blob: d92dff6d3c5928cccc617eb861d796e324c709e2 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070020import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050023import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050025import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060026import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.content.pm.PackageManager;
28import android.content.pm.ResolveInfo;
29import android.content.res.Resources;
30import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080031import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060033import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070034import android.os.Bundle;
35import android.os.IBinder;
36import android.os.Parcel;
37import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000038import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050039import android.os.ResultReceiver;
40import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070041import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010042import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070043import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070046import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070048import android.util.AttributeSet;
49import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080050import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import org.xmlpull.v1.XmlPullParser;
52import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070053import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070054
55import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080056import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070058import java.lang.annotation.Retention;
59import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070060import java.net.URISyntaxException;
61import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080062import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070063import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080064import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070065import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066import java.util.Set;
67
Jason Monk2f68e8a2016-02-23 17:57:28 -050068import static android.content.ContentProvider.maybeAddUserId;
69
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070/**
71 * An intent is an abstract description of an operation to be performed. It
72 * can be used with {@link Context#startActivity(Intent) startActivity} to
73 * launch an {@link android.app.Activity},
74 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
75 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
76 * and {@link android.content.Context#startService} or
77 * {@link android.content.Context#bindService} to communicate with a
78 * background {@link android.app.Service}.
79 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070080 * <p>An Intent provides a facility for performing late runtime binding between the code in
81 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070082 * can be thought of as the glue between activities. It is basically a passive data structure
83 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070084 *
85 * <div class="special reference">
86 * <h3>Developer Guides</h3>
87 * <p>For information about how to create and resolve intents, read the
88 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
89 * developer guide.</p>
90 * </div>
91 *
92 * <a name="IntentStructure"></a>
93 * <h3>Intent Structure</h3>
94 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 *
96 * <ul>
97 * <li> <p><b>action</b> -- The general action to be performed, such as
98 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
99 * etc.</p>
100 * </li>
101 * <li> <p><b>data</b> -- The data to operate on, such as a person record
102 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
103 * </li>
104 * </ul>
105 *
106 *
107 * <p>Some examples of action/data pairs are:</p>
108 *
109 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700110 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700111 * information about the person whose identifier is "1".</p>
112 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * the phone dialer with the person filled in.</p>
115 * </li>
116 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
117 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700118 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700119 * a particular URI.</p>
120 * </li>
121 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
122 * the phone dialer with the given number filled in.</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * information about the person whose identifier is "1".</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * a list of people, which the user can browse through. This example is a
129 * typical top-level entry into the Contacts application, showing you the
130 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700131 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * being used to start an activity to display that person.</p>
133 * </li>
134 * </ul>
135 *
136 * <p>In addition to these primary attributes, there are a number of secondary
137 * attributes that you can also include with an intent:</p>
138 *
139 * <ul>
140 * <li> <p><b>category</b> -- Gives additional information about the action
141 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
142 * appear in the Launcher as a top-level application, while
143 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
144 * of alternative actions the user can perform on a piece of data.</p>
145 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
146 * intent data. Normally the type is inferred from the data itself.
147 * By setting this attribute, you disable that evaluation and force
148 * an explicit type.</p>
149 * <li> <p><b>component</b> -- Specifies an explicit name of a component
150 * class to use for the intent. Normally this is determined by looking
151 * at the other information in the intent (the action, data/type, and
152 * categories) and matching that with a component that can handle it.
153 * If this attribute is set then none of the evaluation is performed,
154 * and this component is used exactly as is. By specifying this attribute,
155 * all of the other Intent attributes become optional.</p>
156 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
157 * This can be used to provide extended information to the component.
158 * For example, if we have a action to send an e-mail message, we could
159 * also include extra pieces of data here to supply a subject, body,
160 * etc.</p>
161 * </ul>
162 *
163 * <p>Here are some examples of other operations you can specify as intents
164 * using these additional parameters:</p>
165 *
166 * <ul>
167 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
168 * Launch the home screen.</p>
169 * </li>
170 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
171 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
172 * vnd.android.cursor.item/phone}</i></b>
173 * -- Display the list of people's phone numbers, allowing the user to
174 * browse through them and pick one and return it to the parent activity.</p>
175 * </li>
176 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
177 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
178 * -- Display all pickers for data that can be opened with
179 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
180 * allowing the user to pick one of them and then some data inside of it
181 * and returning the resulting URI to the caller. This can be used,
182 * for example, in an e-mail application to allow the user to pick some
183 * data to include as an attachment.</p>
184 * </li>
185 * </ul>
186 *
187 * <p>There are a variety of standard Intent action and category constants
188 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700189 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700190 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700191 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700192 *
193 * <p>Put together, the set of actions, data types, categories, and extra data
194 * defines a language for the system allowing for the expression of phrases
195 * such as "call john smith's cell". As applications are added to the system,
196 * they can extend this language by adding new actions, types, and categories, or
197 * they can modify the behavior of existing phrases by supplying their own
198 * activities that handle them.</p>
199 *
200 * <a name="IntentResolution"></a>
201 * <h3>Intent Resolution</h3>
202 *
203 * <p>There are two primary forms of intents you will use.
204 *
205 * <ul>
206 * <li> <p><b>Explicit Intents</b> have specified a component (via
207 * {@link #setComponent} or {@link #setClass}), which provides the exact
208 * class to be run. Often these will not include any other information,
209 * simply being a way for an application to launch various internal
210 * activities it has as the user interacts with the application.
211 *
212 * <li> <p><b>Implicit Intents</b> have not specified a component;
213 * instead, they must include enough information for the system to
214 * determine which of the available components is best to run for that
215 * intent.
216 * </ul>
217 *
218 * <p>When using implicit intents, given such an arbitrary intent we need to
219 * know what to do with it. This is handled by the process of <em>Intent
220 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
221 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
222 * more activities/receivers) that can handle it.</p>
223 *
224 * <p>The intent resolution mechanism basically revolves around matching an
225 * Intent against all of the &lt;intent-filter&gt; descriptions in the
226 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
227 * objects explicitly registered with {@link Context#registerReceiver}.) More
228 * details on this can be found in the documentation on the {@link
229 * IntentFilter} class.</p>
230 *
231 * <p>There are three pieces of information in the Intent that are used for
232 * resolution: the action, type, and category. Using this information, a query
233 * is done on the {@link PackageManager} for a component that can handle the
234 * intent. The appropriate component is determined based on the intent
235 * information supplied in the <code>AndroidManifest.xml</code> file as
236 * follows:</p>
237 *
238 * <ul>
239 * <li> <p>The <b>action</b>, if given, must be listed by the component as
240 * one it handles.</p>
241 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
242 * already supplied in the Intent. Like the action, if a type is
243 * included in the intent (either explicitly or implicitly in its
244 * data), then this must be listed by the component as one it handles.</p>
245 * <li> For data that is not a <code>content:</code> URI and where no explicit
246 * type is included in the Intent, instead the <b>scheme</b> of the
247 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
248 * considered. Again like the action, if we are matching a scheme it
249 * must be listed by the component as one it can handle.
250 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
251 * by the activity as categories it handles. That is, if you include
252 * the categories {@link #CATEGORY_LAUNCHER} and
253 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
254 * with an intent that lists <em>both</em> of those categories.
255 * Activities will very often need to support the
256 * {@link #CATEGORY_DEFAULT} so that they can be found by
257 * {@link Context#startActivity Context.startActivity()}.</p>
258 * </ul>
259 *
260 * <p>For example, consider the Note Pad sample application that
261 * allows user to browse through a list of notes data and view details about
262 * individual items. Text in italics indicate places were you would replace a
263 * name with one specific to your own package.</p>
264 *
265 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
266 * package="<i>com.android.notepad</i>"&gt;
267 * &lt;application android:icon="@drawable/app_notes"
268 * android:label="@string/app_name"&gt;
269 *
270 * &lt;provider class=".NotePadProvider"
271 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
272 *
273 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
274 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700275 * &lt;action android:name="android.intent.action.MAIN" /&gt;
276 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700277 * &lt;/intent-filter&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.VIEW" /&gt;
280 * &lt;action android:name="android.intent.action.EDIT" /&gt;
281 * &lt;action android:name="android.intent.action.PICK" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
287 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
288 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700289 * &lt;/intent-filter&gt;
290 * &lt;/activity&gt;
291 *
292 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
293 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.VIEW" /&gt;
295 * &lt;action android:name="android.intent.action.EDIT" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700298 * &lt;/intent-filter&gt;
299 *
300 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700301 * &lt;action android:name="android.intent.action.INSERT" /&gt;
302 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
303 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700304 * &lt;/intent-filter&gt;
305 *
306 * &lt;/activity&gt;
307 *
308 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
309 * android:theme="@android:style/Theme.Dialog"&gt;
310 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
314 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
315 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700316 * &lt;/intent-filter&gt;
317 * &lt;/activity&gt;
318 *
319 * &lt;/application&gt;
320 * &lt;/manifest&gt;</pre>
321 *
322 * <p>The first activity,
323 * <code>com.android.notepad.NotesList</code>, serves as our main
324 * entry into the app. It can do three things as described by its three intent
325 * templates:
326 * <ol>
327 * <li><pre>
328 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700329 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
330 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700331 * &lt;/intent-filter&gt;</pre>
332 * <p>This provides a top-level entry into the NotePad application: the standard
333 * MAIN action is a main entry point (not requiring any other information in
334 * the Intent), and the LAUNCHER category says that this entry point should be
335 * listed in the application launcher.</p>
336 * <li><pre>
337 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700338 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
339 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
340 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700342 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700343 * &lt;/intent-filter&gt;</pre>
344 * <p>This declares the things that the activity can do on a directory of
345 * notes. The type being supported is given with the &lt;type&gt; tag, where
346 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
347 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
348 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
349 * The activity allows the user to view or edit the directory of data (via
350 * the VIEW and EDIT actions), or to pick a particular note and return it
351 * to the caller (via the PICK action). Note also the DEFAULT category
352 * supplied here: this is <em>required</em> for the
353 * {@link Context#startActivity Context.startActivity} method to resolve your
354 * activity when its component name is not explicitly specified.</p>
355 * <li><pre>
356 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700357 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
358 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
359 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700360 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700361 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * the user without needing to know where it came from. The data type
363 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
364 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
365 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
366 * The GET_CONTENT action is similar to the PICK action, where the activity
367 * will return to its caller a piece of data selected by the user. Here,
368 * however, the caller specifies the type of data they desire instead of
369 * the type of data the user will be picking from.</p>
370 * </ol>
371 *
372 * <p>Given these capabilities, the following intents will resolve to the
373 * NotesList activity:</p>
374 *
375 * <ul>
376 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
377 * activities that can be used as top-level entry points into an
378 * application.</p>
379 * <li> <p><b>{ action=android.app.action.MAIN,
380 * category=android.app.category.LAUNCHER }</b> is the actual intent
381 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700382 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700383 * data=content://com.google.provider.NotePad/notes }</b>
384 * displays a list of all the notes under
385 * "content://com.google.provider.NotePad/notes", which
386 * the user can browse through and see the details on.</p>
387 * <li> <p><b>{ action=android.app.action.PICK
388 * data=content://com.google.provider.NotePad/notes }</b>
389 * provides a list of the notes under
390 * "content://com.google.provider.NotePad/notes", from which
391 * the user can pick a note whose data URL is returned back to the caller.</p>
392 * <li> <p><b>{ action=android.app.action.GET_CONTENT
393 * type=vnd.android.cursor.item/vnd.google.note }</b>
394 * is similar to the pick action, but allows the caller to specify the
395 * kind of data they want back so that the system can find the appropriate
396 * activity to pick something of that data type.</p>
397 * </ul>
398 *
399 * <p>The second activity,
400 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
401 * note entry and allows them to edit it. It can do two things as described
402 * by its two intent templates:
403 * <ol>
404 * <li><pre>
405 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700406 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
407 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
408 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
409 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700410 * &lt;/intent-filter&gt;</pre>
411 * <p>The first, primary, purpose of this activity is to let the user interact
412 * with a single note, as decribed by the MIME type
413 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
414 * either VIEW a note or allow the user to EDIT it. Again we support the
415 * DEFAULT category to allow the activity to be launched without explicitly
416 * specifying its component.</p>
417 * <li><pre>
418 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700419 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
420 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
421 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700422 * &lt;/intent-filter&gt;</pre>
423 * <p>The secondary use of this activity is to insert a new note entry into
424 * an existing directory of notes. This is used when the user creates a new
425 * note: the INSERT action is executed on the directory of notes, causing
426 * this activity to run and have the user create the new note data which
427 * it then adds to the content provider.</p>
428 * </ol>
429 *
430 * <p>Given these capabilities, the following intents will resolve to the
431 * NoteEditor activity:</p>
432 *
433 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700434 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700435 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
436 * shows the user the content of note <var>{ID}</var>.</p>
437 * <li> <p><b>{ action=android.app.action.EDIT
438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * allows the user to edit the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.INSERT
441 * data=content://com.google.provider.NotePad/notes }</b>
442 * creates a new, empty note in the notes list at
443 * "content://com.google.provider.NotePad/notes"
444 * and allows the user to edit it. If they keep their changes, the URI
445 * of the newly created note is returned to the caller.</p>
446 * </ul>
447 *
448 * <p>The last activity,
449 * <code>com.android.notepad.TitleEditor</code>, allows the user to
450 * edit the title of a note. This could be implemented as a class that the
451 * application directly invokes (by explicitly setting its component in
452 * the Intent), but here we show a way you can publish alternative
453 * operations on existing data:</p>
454 *
455 * <pre>
456 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700457 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
459 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
460 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
461 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700462 * &lt;/intent-filter&gt;</pre>
463 *
464 * <p>In the single intent template here, we
465 * have created our own private action called
466 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
467 * edit the title of a note. It must be invoked on a specific note
468 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
469 * view and edit actions, but here displays and edits the title contained
470 * in the note data.
471 *
472 * <p>In addition to supporting the default category as usual, our title editor
473 * also supports two other standard categories: ALTERNATIVE and
474 * SELECTED_ALTERNATIVE. Implementing
475 * these categories allows others to find the special action it provides
476 * without directly knowing about it, through the
477 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
478 * more often to build dynamic menu items with
479 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
480 * template here was also supply an explicit name for the template
481 * (via <code>android:label="@string/resolve_title"</code>) to better control
482 * what the user sees when presented with this activity as an alternative
483 * action to the data they are viewing.
484 *
485 * <p>Given these capabilities, the following intent will resolve to the
486 * TitleEditor activity:</p>
487 *
488 * <ul>
489 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
490 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
491 * displays and allows the user to edit the title associated
492 * with note <var>{ID}</var>.</p>
493 * </ul>
494 *
495 * <h3>Standard Activity Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for launching
498 * activities (usually through {@link Context#startActivity}. The most
499 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
500 * {@link #ACTION_EDIT}.
501 *
502 * <ul>
503 * <li> {@link #ACTION_MAIN}
504 * <li> {@link #ACTION_VIEW}
505 * <li> {@link #ACTION_ATTACH_DATA}
506 * <li> {@link #ACTION_EDIT}
507 * <li> {@link #ACTION_PICK}
508 * <li> {@link #ACTION_CHOOSER}
509 * <li> {@link #ACTION_GET_CONTENT}
510 * <li> {@link #ACTION_DIAL}
511 * <li> {@link #ACTION_CALL}
512 * <li> {@link #ACTION_SEND}
513 * <li> {@link #ACTION_SENDTO}
514 * <li> {@link #ACTION_ANSWER}
515 * <li> {@link #ACTION_INSERT}
516 * <li> {@link #ACTION_DELETE}
517 * <li> {@link #ACTION_RUN}
518 * <li> {@link #ACTION_SYNC}
519 * <li> {@link #ACTION_PICK_ACTIVITY}
520 * <li> {@link #ACTION_SEARCH}
521 * <li> {@link #ACTION_WEB_SEARCH}
522 * <li> {@link #ACTION_FACTORY_TEST}
523 * </ul>
524 *
525 * <h3>Standard Broadcast Actions</h3>
526 *
527 * <p>These are the current standard actions that Intent defines for receiving
528 * broadcasts (usually through {@link Context#registerReceiver} or a
529 * &lt;receiver&gt; tag in a manifest).
530 *
531 * <ul>
532 * <li> {@link #ACTION_TIME_TICK}
533 * <li> {@link #ACTION_TIME_CHANGED}
534 * <li> {@link #ACTION_TIMEZONE_CHANGED}
535 * <li> {@link #ACTION_BOOT_COMPLETED}
536 * <li> {@link #ACTION_PACKAGE_ADDED}
537 * <li> {@link #ACTION_PACKAGE_CHANGED}
538 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 * <li> {@link #ACTION_PACKAGE_RESTARTED}
540 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000541 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
542 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700543 * <li> {@link #ACTION_UID_REMOVED}
544 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700545 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700546 * <li> {@link #ACTION_POWER_DISCONNECTED}
547 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700548 * </ul>
549 *
550 * <h3>Standard Categories</h3>
551 *
552 * <p>These are the current standard categories that can be used to further
553 * clarify an Intent via {@link #addCategory}.
554 *
555 * <ul>
556 * <li> {@link #CATEGORY_DEFAULT}
557 * <li> {@link #CATEGORY_BROWSABLE}
558 * <li> {@link #CATEGORY_TAB}
559 * <li> {@link #CATEGORY_ALTERNATIVE}
560 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
561 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800562 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_HOME}
564 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400566 * <li> {@link #CATEGORY_CAR_DOCK}
567 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500568 * <li> {@link #CATEGORY_LE_DESK_DOCK}
569 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200570 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700571 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800572 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * </ul>
574 *
575 * <h3>Standard Extra Data</h3>
576 *
577 * <p>These are the current standard fields that can be used as extra data via
578 * {@link #putExtra}.
579 *
580 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800581 * <li> {@link #EXTRA_ALARM_COUNT}
582 * <li> {@link #EXTRA_BCC}
583 * <li> {@link #EXTRA_CC}
584 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
585 * <li> {@link #EXTRA_DATA_REMOVED}
586 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500587 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800589 * <li> {@link #EXTRA_DOCK_STATE_CAR}
590 * <li> {@link #EXTRA_DOCK_STATE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
592 * <li> {@link #EXTRA_DONT_KILL_APP}
593 * <li> {@link #EXTRA_EMAIL}
594 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700595 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700597 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700599 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
601 * <li> {@link #EXTRA_REPLACING}
602 * <li> {@link #EXTRA_SHORTCUT_ICON}
603 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
604 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_SHORTCUT_NAME}
607 * <li> {@link #EXTRA_SUBJECT}
608 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_TITLE}
611 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * </ul>
613 *
614 * <h3>Flags</h3>
615 *
616 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800617 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
618 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800620public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700621 private static final String ATTR_ACTION = "action";
622 private static final String TAG_CATEGORIES = "categories";
623 private static final String ATTR_CATEGORY = "category";
624 private static final String TAG_EXTRA = "extra";
625 private static final String ATTR_TYPE = "type";
626 private static final String ATTR_COMPONENT = "component";
627 private static final String ATTR_DATA = "data";
628 private static final String ATTR_FLAGS = "flags";
629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 // ---------------------------------------------------------------------
631 // ---------------------------------------------------------------------
632 // Standard intent activity actions (see action variable).
633
634 /**
635 * Activity Action: Start as a main entry point, does not expect to
636 * receive data.
637 * <p>Input: nothing
638 * <p>Output: nothing
639 */
640 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
641 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 /**
644 * Activity Action: Display the data to the user. This is the most common
645 * action performed on data -- it is the generic action you can use on
646 * a piece of data to get the most reasonable thing to occur. For example,
647 * when used on a contacts entry it will view the entry; when used on a
648 * mailto: URI it will bring up a compose window filled with the information
649 * supplied by the URI; when used with a tel: URI it will invoke the
650 * dialer.
651 * <p>Input: {@link #getData} is URI from which to retrieve data.
652 * <p>Output: nothing.
653 */
654 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
655 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700657 /**
658 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
659 * performed on a piece of data.
660 */
661 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700663 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900664 * Activity Action: Quick view the data. Launches a quick viewer for
665 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900666 * <p>Activities handling this intent action should handle the vast majority of
667 * MIME types rather than only specific ones.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900668 * <p>Input: {@link #getData} is a mandatory content URI of the item to
669 * preview. {@link #getClipData} contains an optional list of content URIs
670 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
671 * optional index of the URI in the clip data to show first.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900672 * <p>By default quick viewers are supposed to be lightweight and focus on
673 * previewing the content only. They should not expose features such as printing,
674 * opening in an external app, deleting, rotating, casting, etc.
675 * However, if {@link #EXTRA_QUICK_VIEW_ADVANCED} is true, then the quick viewer
676 * may show advanced UI which includes convenience actions suitable for the passed
677 * Uris.
Steve McKayc78bcb82015-07-31 14:35:22 -0700678 * <p>Output: nothing.
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +0900679 * @see #EXTRA_QUICK_VIEW_ADVANCED
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900680 * @see #EXTRA_INDEX
Steve McKayc78bcb82015-07-31 14:35:22 -0700681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
684
685 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700686 * Used to indicate that some piece of data should be attached to some other
687 * place. For example, image data could be attached to a contact. It is up
688 * to the recipient to decide where the data should be attached; the intent
689 * does not specify the ultimate destination.
690 * <p>Input: {@link #getData} is URI of data to be attached.
691 * <p>Output: nothing.
692 */
693 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
694 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800695
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700696 /**
697 * Activity Action: Provide explicit editable access to the given data.
698 * <p>Input: {@link #getData} is URI of data to be edited.
699 * <p>Output: nothing.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
706 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
707 * The extras can contain type specific data to pass through to the editing/creating
708 * activity.
709 * <p>Output: The URI of the item that was picked. This must be a content:
710 * URI so that any receiver can access it.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Pick an item from the data, returning what was selected.
717 * <p>Input: {@link #getData} is URI containing a directory of data
718 * (vnd.android.cursor.dir/*) from which to pick an item.
719 * <p>Output: The URI of the item that was picked.
720 */
721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
722 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724 /**
725 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800726 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800727 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
728 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700729 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
730 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800731 * (value: ShortcutIconResource).</p>
732 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800733 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 * @see #EXTRA_SHORTCUT_INTENT
735 * @see #EXTRA_SHORTCUT_NAME
736 * @see #EXTRA_SHORTCUT_ICON
737 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
738 * @see android.content.Intent.ShortcutIconResource
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
742
743 /**
744 * The name of the extra used to define the Intent of a shortcut.
745 *
746 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800749 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
751 /**
752 * The name of the extra used to define the name of a shortcut.
753 *
754 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800755 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700756 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700758 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
759 /**
760 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
761 *
762 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
767 /**
768 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
769 *
770 * @see #ACTION_CREATE_SHORTCUT
771 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
776 "android.intent.extra.shortcut.ICON_RESOURCE";
777
778 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500779 * An activity that provides a user interface for adjusting application preferences.
780 * Optional but recommended settings for all applications which have settings.
781 */
782 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
783 public static final String ACTION_APPLICATION_PREFERENCES
784 = "android.intent.action.APPLICATION_PREFERENCES";
785
786 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700787 * Activity Action: Launch an activity showing the app information.
788 * For applications which install other applications (such as app stores), it is recommended
789 * to handle this action for providing the app information to the user.
790 *
791 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
792 * to be displayed.
793 * <p>Output: Nothing.
794 */
795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
796 public static final String ACTION_SHOW_APP_INFO
797 = "android.intent.action.SHOW_APP_INFO";
798
799 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800800 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700801 *
802 * @see Intent#ACTION_CREATE_SHORTCUT
803 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800804 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
805 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700806 */
807 public static class ShortcutIconResource implements Parcelable {
808 /**
809 * The package name of the application containing the icon.
810 */
811 public String packageName;
812
813 /**
814 * The resource name of the icon, including package, name and type.
815 */
816 public String resourceName;
817
818 /**
819 * Creates a new ShortcutIconResource for the specified context and resource
820 * identifier.
821 *
822 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700823 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700825 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700827 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700828 ShortcutIconResource icon = new ShortcutIconResource();
829 icon.packageName = context.getPackageName();
830 icon.resourceName = context.getResources().getResourceName(resourceId);
831 return icon;
832 }
833
834 /**
835 * Used to read a ShortcutIconResource from a Parcel.
836 */
837 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
838 new Parcelable.Creator<ShortcutIconResource>() {
839
840 public ShortcutIconResource createFromParcel(Parcel source) {
841 ShortcutIconResource icon = new ShortcutIconResource();
842 icon.packageName = source.readString();
843 icon.resourceName = source.readString();
844 return icon;
845 }
846
847 public ShortcutIconResource[] newArray(int size) {
848 return new ShortcutIconResource[size];
849 }
850 };
851
852 /**
853 * No special parcel contents.
854 */
855 public int describeContents() {
856 return 0;
857 }
858
859 public void writeToParcel(Parcel dest, int flags) {
860 dest.writeString(packageName);
861 dest.writeString(resourceName);
862 }
863
864 @Override
865 public String toString() {
866 return resourceName;
867 }
868 }
869
870 /**
871 * Activity Action: Display an activity chooser, allowing the user to pick
872 * what they want to before proceeding. This can be used as an alternative
873 * to the standard activity picker that is displayed by the system when
874 * you try to start an activity with multiple possible matches, with these
875 * differences in behavior:
876 * <ul>
877 * <li>You can specify the title that will appear in the activity chooser.
878 * <li>The user does not have the option to make one of the matching
879 * activities a preferred activity, and all possible activities will
880 * always be shown even if one of them is currently marked as the
881 * preferred activity.
882 * </ul>
883 * <p>
884 * This action should be used when the user will naturally expect to
885 * select an activity in order to proceed. An example if when not to use
886 * it is when the user clicks on a "mailto:" link. They would naturally
887 * expect to go directly to their mail app, so startActivity() should be
888 * called directly: it will
889 * either launch the current preferred app, or put up a dialog allowing the
890 * user to pick an app to use and optionally marking that as preferred.
891 * <p>
892 * In contrast, if the user is selecting a menu item to send a picture
893 * they are viewing to someone else, there are many different things they
894 * may want to do at this point: send it through e-mail, upload it to a
895 * web service, etc. In this case the CHOOSER action should be used, to
896 * always present to the user a list of the things they can do, with a
897 * nice title given by the caller such as "Send this photo with:".
898 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700899 * If you need to grant URI permissions through a chooser, you must specify
900 * the permissions to be granted on the ACTION_CHOOSER Intent
901 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
902 * {@link #setClipData} to specify the URIs to be granted as well as
903 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
904 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
905 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700906 * As a convenience, an Intent of this form can be created with the
907 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700908 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700909 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700910 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
911 * and can optionally have a {@link #EXTRA_TITLE} field containing the
912 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700913 * <p>
914 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915 */
916 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
917 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
918
919 /**
920 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
921 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700922 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
923 * target intent, also optionally supplying a title. If the target
924 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
925 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
926 * set in the returned chooser intent, with its ClipData set appropriately:
927 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500928 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700929 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 * @param target The Intent that the user will be selecting an activity
931 * to perform.
932 * @param title Optional title that will be displayed in the chooser.
933 * @return Return a new Intent object that you can hand to
934 * {@link Context#startActivity(Intent) Context.startActivity()} and
935 * related methods.
936 */
937 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700938 return createChooser(target, title, null);
939 }
940
941 /**
942 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
943 *
944 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
945 * target intent, also optionally supplying a title. If the target
946 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
947 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
948 * set in the returned chooser intent, with its ClipData set appropriately:
949 * either a direct reflection of {@link #getClipData()} if that is non-null,
950 * or a new ClipData built from {@link #getData()}.</p>
951 *
952 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
953 * when the user makes a choice. This can be useful if the calling application wants
954 * to remember the last chosen target and surface it as a more prominent or one-touch
955 * affordance elsewhere in the UI for next time.</p>
956 *
957 * @param target The Intent that the user will be selecting an activity
958 * to perform.
959 * @param title Optional title that will be displayed in the chooser.
960 * @param sender Optional IntentSender to be called when a choice is made.
961 * @return Return a new Intent object that you can hand to
962 * {@link Context#startActivity(Intent) Context.startActivity()} and
963 * related methods.
964 */
965 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 Intent intent = new Intent(ACTION_CHOOSER);
967 intent.putExtra(EXTRA_INTENT, target);
968 if (title != null) {
969 intent.putExtra(EXTRA_TITLE, title);
970 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700971
Adam Powell0b3c1122014-10-09 12:50:14 -0700972 if (sender != null) {
973 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
974 }
975
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700976 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700977 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
978 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
979 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700980 if (permFlags != 0) {
981 ClipData targetClipData = target.getClipData();
982 if (targetClipData == null && target.getData() != null) {
983 ClipData.Item item = new ClipData.Item(target.getData());
984 String[] mimeTypes;
985 if (target.getType() != null) {
986 mimeTypes = new String[] { target.getType() };
987 } else {
988 mimeTypes = new String[] { };
989 }
990 targetClipData = new ClipData(null, mimeTypes, item);
991 }
992 if (targetClipData != null) {
993 intent.setClipData(targetClipData);
994 intent.addFlags(permFlags);
995 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700996 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700997
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700998 return intent;
999 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001000
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 /**
1002 * Activity Action: Allow the user to select a particular kind of data and
1003 * return it. This is different than {@link #ACTION_PICK} in that here we
1004 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001005 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001006 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001007 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * etc.
1009 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001010 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001011 * of data, such as a person contact, you set the MIME type to the kind of
1012 * data you want and launch it with {@link Context#startActivity(Intent)}.
1013 * The system will then launch the best application to select that kind
1014 * of data for you.
1015 * <p>
1016 * You may also be interested in any of a set of types of content the user
1017 * can pick. For example, an e-mail application that wants to allow the
1018 * user to add an attachment to an e-mail message can use this action to
1019 * bring up a list of all of the types of content the user can attach.
1020 * <p>
1021 * In this case, you should wrap the GET_CONTENT intent with a chooser
1022 * (through {@link #createChooser}), which will give the proper interface
1023 * for the user to pick how to send your data and allow you to specify
1024 * a prompt indicating what they are doing. You will usually specify a
1025 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1026 * broad range of content types the user can select from.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * only pick from data that can be represented as a stream. This is
1030 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1031 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001032 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001033 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001034 * is locally available on the device. For example, if this extra is set
1035 * to true then an image picker should not show any pictures that are available
1036 * from a remote server but not already on the local device (thus requiring
1037 * they be downloaded when opened).
1038 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001039 * If the caller can handle multiple returned items (the user performing
1040 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1041 * to indicate this.
1042 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1044 * that no URI is supplied in the intent, as there are no constraints on
1045 * where the returned data originally comes from. You may also include the
1046 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001047 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001048 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1049 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001050 * <p>
1051 * Output: The URI of the item that was picked. This must be a content:
1052 * URI so that any receiver can access it.
1053 */
1054 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1055 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1056 /**
1057 * Activity Action: Dial a number as specified by the data. This shows a
1058 * UI with the number being dialed, allowing the user to explicitly
1059 * initiate the call.
1060 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1061 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1062 * number.
1063 * <p>Output: nothing.
1064 */
1065 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1066 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1067 /**
1068 * Activity Action: Perform a call to someone specified by the data.
1069 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1070 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1071 * number.
1072 * <p>Output: nothing.
1073 *
1074 * <p>Note: there will be restrictions on which applications can initiate a
1075 * call; most applications should use the {@link #ACTION_DIAL}.
1076 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1077 * numbers. Applications can <strong>dial</strong> emergency numbers using
1078 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001079 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001080 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001081 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001082 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001083 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_CALL = "android.intent.action.CALL";
1087 /**
1088 * Activity Action: Perform a call to an emergency number specified by the
1089 * data.
1090 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1091 * tel: URI of an explicit phone number.
1092 * <p>Output: nothing.
1093 * @hide
1094 */
1095 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1096 /**
1097 * Activity action: Perform a call to any number (emergency or not)
1098 * specified by the data.
1099 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1100 * tel: URI of an explicit phone number.
1101 * <p>Output: nothing.
1102 * @hide
1103 */
1104 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1105 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001106 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1107 * sending this intent is a no-op.
1108 * <p>Input: No data should be specified. get*Extra may have an optional
1109 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1110 * send the activation result.
1111 * <p>Output: nothing.
1112 * @hide
1113 */
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1115 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1116 "android.intent.action.SIM_ACTIVATION_REQUEST";
1117 /**
fionaxuadfe7002017-02-17 17:20:46 -08001118 * Activity Action: Main entry point for carrier setup apps.
1119 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1120 * carrier service and typically require
1121 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1122 * fulfill their duties.
1123 */
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1126 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001127 * Activity Action: Send a message to someone specified by the data.
1128 * <p>Input: {@link #getData} is URI describing the target.
1129 * <p>Output: nothing.
1130 */
1131 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1132 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1133 /**
1134 * Activity Action: Deliver some data to someone else. Who the data is
1135 * being delivered to is not specified; it is up to the receiver of this
1136 * action to ask the user where the data should be sent.
1137 * <p>
1138 * When launching a SEND intent, you should usually wrap it in a chooser
1139 * (through {@link #createChooser}), which will give the proper interface
1140 * for the user to pick how to send your data and allow you to specify
1141 * a prompt indicating what they are doing.
1142 * <p>
1143 * Input: {@link #getType} is the MIME type of the data being sent.
1144 * get*Extra can have either a {@link #EXTRA_TEXT}
1145 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1146 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1147 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1148 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001149 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1150 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1151 * your text with HTML formatting.
1152 * <p>
1153 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1154 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1155 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1156 * content: URIs and other advanced features of {@link ClipData}. If
1157 * using this approach, you still must supply the same data through the
1158 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1159 * for compatibility with old applications. If you don't set a ClipData,
1160 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001161 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001162 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1163 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1164 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1165 * be openable only as asset typed files using
1166 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1167 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001168 * Optional standard extras, which may be interpreted by some recipients as
1169 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1170 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1171 * <p>
1172 * Output: nothing.
1173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_SEND = "android.intent.action.SEND";
1176 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001177 * Activity Action: Deliver multiple data to someone else.
1178 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001179 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001180 * <p>
1181 * Input: {@link #getType} is the MIME type of the data being sent.
1182 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001183 * #EXTRA_STREAM} field, containing the data to be sent. If using
1184 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1185 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001186 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001187 * Multiple types are supported, and receivers should handle mixed types
1188 * whenever possible. The right way for the receiver to check them is to
1189 * use the content resolver on each URI. The intent sender should try to
1190 * put the most concrete mime type in the intent type, but it can fall
1191 * back to {@literal <type>/*} or {@literal *}/* as needed.
1192 * <p>
1193 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1194 * be image/jpg, but if you are sending image/jpg and image/png, then the
1195 * intent's type should be image/*.
1196 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001197 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1198 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1199 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1200 * content: URIs and other advanced features of {@link ClipData}. If
1201 * using this approach, you still must supply the same data through the
1202 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1203 * for compatibility with old applications. If you don't set a ClipData,
1204 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1205 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001206 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1207 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1208 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1209 * be openable only as asset typed files using
1210 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1211 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001212 * Optional standard extras, which may be interpreted by some recipients as
1213 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1214 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1215 * <p>
1216 * Output: nothing.
1217 */
1218 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1220 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001221 * Activity Action: Handle an incoming phone call.
1222 * <p>Input: nothing.
1223 * <p>Output: nothing.
1224 */
1225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1226 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1227 /**
1228 * Activity Action: Insert an empty item into the given container.
1229 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1230 * in which to place the data.
1231 * <p>Output: URI of the new data that was created.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1235 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001236 * Activity Action: Create a new item in the given container, initializing it
1237 * from the current contents of the clipboard.
1238 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1239 * in which to place the data.
1240 * <p>Output: URI of the new data that was created.
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1244 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001245 * Activity Action: Delete the given data from its container.
1246 * <p>Input: {@link #getData} is URI of data to be deleted.
1247 * <p>Output: nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1251 /**
1252 * Activity Action: Run the data, whatever that means.
1253 * <p>Input: ? (Note: this is currently specific to the test harness.)
1254 * <p>Output: nothing.
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_RUN = "android.intent.action.RUN";
1258 /**
1259 * Activity Action: Perform a data synchronization.
1260 * <p>Input: ?
1261 * <p>Output: ?
1262 */
1263 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1264 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1265 /**
1266 * Activity Action: Pick an activity given an intent, returning the class
1267 * selected.
1268 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1269 * used with {@link PackageManager#queryIntentActivities} to determine the
1270 * set of activities from which to pick.
1271 * <p>Output: Class name of the activity that was selected.
1272 */
1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1275 /**
1276 * Activity Action: Perform a search.
1277 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1278 * is the text to search for. If empty, simply
1279 * enter your search results Activity with the search UI activated.
1280 * <p>Output: nothing.
1281 */
1282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1283 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1284 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001285 * Activity Action: Start the platform-defined tutorial
1286 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1287 * is the text to search for. If empty, simply
1288 * enter your search results Activity with the search UI activated.
1289 * <p>Output: nothing.
1290 */
1291 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1292 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1293 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001294 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001295 * <p>
1296 * Input: {@link android.app.SearchManager#QUERY
1297 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1298 * a url starts with http or https, the site will be opened. If it is plain
1299 * text, Google search will be applied.
1300 * <p>
1301 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001305
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 /**
Jim Miller07994402012-05-02 14:22:27 -07001307 * Activity Action: Perform assist action.
1308 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001309 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1310 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001311 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1312 * information.
Jim Miller07994402012-05-02 14:22:27 -07001313 * Output: nothing.
1314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001317
1318 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001319 * Activity Action: Perform voice assist action.
1320 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001321 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1322 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001323 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001324 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001325 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1329
1330 /**
Adam Skory7140a252013-09-11 12:04:58 +01001331 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1332 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001333 */
1334 public static final String EXTRA_ASSIST_PACKAGE
1335 = "android.intent.extra.ASSIST_PACKAGE";
1336
1337 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001338 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1339 * application package at the time the assist was invoked.
1340 */
1341 public static final String EXTRA_ASSIST_UID
1342 = "android.intent.extra.ASSIST_UID";
1343
1344 /**
Adam Skory7140a252013-09-11 12:04:58 +01001345 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1346 * information supplied by the current foreground app at the time of the assist request.
1347 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001348 */
1349 public static final String EXTRA_ASSIST_CONTEXT
1350 = "android.intent.extra.ASSIST_CONTEXT";
1351
Jim Miller07994402012-05-02 14:22:27 -07001352 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001353 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1354 * keyboard as the primary input device for assistance.
1355 */
1356 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1357 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1358
1359 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001360 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1361 * that was used to invoke the assist.
1362 */
1363 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1364 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1365
1366 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001367 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001368 * <p>Input: Nothing.
1369 * <p>Output: nothing.
1370 */
1371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1372 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1373 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001374 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001375 * <p>Input: Nothing.
1376 * <p>Output: Nothing.
1377 */
1378 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1379 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1380
1381 /**
1382 * Activity Action: Show activity for reporting a bug.
1383 * <p>Input: Nothing.
1384 * <p>Output: Nothing.
1385 */
1386 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1387 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1388
1389 /**
1390 * Activity Action: Main entry point for factory tests. Only used when
1391 * the device is booting in factory test node. The implementing package
1392 * must be installed in the system image.
1393 * <p>Input: nothing
1394 * <p>Output: nothing
1395 */
1396 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1397
1398 /**
1399 * Activity Action: The user pressed the "call" button to go to the dialer
1400 * or other appropriate UI for placing a call.
1401 * <p>Input: Nothing.
1402 * <p>Output: Nothing.
1403 */
1404 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1405 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1406
1407 /**
1408 * Activity Action: Start Voice Command.
1409 * <p>Input: Nothing.
1410 * <p>Output: Nothing.
1411 */
1412 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1413 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001414
1415 /**
1416 * Activity Action: Start action associated with long pressing on the
1417 * search key.
1418 * <p>Input: Nothing.
1419 * <p>Output: Nothing.
1420 */
1421 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1422 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001423
Jacek Surazski86b6c532009-05-13 14:38:28 +02001424 /**
1425 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1426 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001427 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001428 * <p>Input: No data is specified. The bug report is passed in using
1429 * an {@link #EXTRA_BUG_REPORT} field.
1430 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001431 *
1432 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001433 */
1434 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1435 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001436
1437 /**
1438 * Activity Action: Show power usage information to the user.
1439 * <p>Input: Nothing.
1440 * <p>Output: Nothing.
1441 */
1442 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1443 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001444
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001445 /**
1446 * Activity Action: Setup wizard to launch after a platform update. This
1447 * activity should have a string meta-data field associated with it,
1448 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1449 * the platform for setup. The activity will be launched only if
1450 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1451 * same value.
1452 * <p>Input: Nothing.
1453 * <p>Output: Nothing.
1454 * @hide
1455 */
1456 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1457 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001458
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001459 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001460 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1461 * <p>Input: Nothing.
1462 * <p>Output: Nothing.
1463 * @hide
1464 */
1465 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1466 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1467 "android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1468
1469 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001470 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1471 * <p>Input: Nothing.
1472 * <p>Output: Nothing.
1473 * @hide
1474 */
1475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1476 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1477 "android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1478
1479 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001480 * Activity Action: Show settings for managing network data usage of a
1481 * specific application. Applications should define an activity that offers
1482 * options to control data usage.
1483 */
1484 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1485 public static final String ACTION_MANAGE_NETWORK_USAGE =
1486 "android.intent.action.MANAGE_NETWORK_USAGE";
1487
1488 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001489 * Activity Action: Launch application installer.
1490 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001491 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001492 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1493 * you can also use "package:<package-name>" to install an application for the
1494 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001495 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1496 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1497 * <p>
1498 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1499 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001500 * <p>
1501 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1502 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1503 * in order to launch the application installer.
1504 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001505 *
1506 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1507 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1508 * @see #EXTRA_RETURN_RESULT
1509 */
1510 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1511 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1512
1513 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001514 * Activity Action: Launch ephemeral installer.
1515 * <p>
1516 * Input: The data must be a http: URI that the ephemeral application is registered
1517 * to handle.
1518 * <p class="note">
1519 * This is a protected intent that can only be sent by the system.
1520 * </p>
1521 *
1522 * @hide
1523 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001524 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1525 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1526 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1527
1528 /**
1529 * Service Action: Resolve ephemeral application.
1530 * <p>
1531 * The system will have a persistent connection to this service.
1532 * This is a protected intent that can only be sent by the system.
1533 * </p>
1534 *
1535 * @hide
1536 */
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001537 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1538 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1539 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1540
1541 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001542 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1543 * package. Specifies the installer package name; this package will receive the
1544 * {@link #ACTION_APP_ERROR} intent.
1545 */
1546 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1547 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1548
1549 /**
1550 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1551 * package. Specifies that the application being installed should not be
1552 * treated as coming from an unknown source, but as coming from the app
1553 * invoking the Intent. For this to work you must start the installer with
1554 * startActivityForResult().
1555 */
1556 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1557 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1558
1559 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001560 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1561 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001562 * data field originated from.
1563 */
rich cannings706e8ba2012-08-20 13:20:14 -07001564 public static final String EXTRA_ORIGINATING_URI
1565 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001566
1567 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001568 * This extra can be used with any Intent used to launch an activity, supplying information
1569 * about who is launching that activity. This field contains a {@link android.net.Uri}
1570 * object, typically an http: or https: URI of the web site that the referral came from;
1571 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1572 * a native application that it came from.
1573 *
1574 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1575 * instead of directly retrieving the extra. It is also valid for applications to
1576 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1577 * a string, not a Uri; the field here, if supplied, will always take precedence,
1578 * however.</p>
1579 *
1580 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001581 */
1582 public static final String EXTRA_REFERRER
1583 = "android.intent.extra.REFERRER";
1584
1585 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001586 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1587 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1588 * not be created, in particular when Intent extras are supplied through the
1589 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1590 * schemes.
1591 *
1592 * @see #EXTRA_REFERRER
1593 */
1594 public static final String EXTRA_REFERRER_NAME
1595 = "android.intent.extra.REFERRER_NAME";
1596
1597 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001598 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001599 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Ben Gruver37d83a32012-09-27 13:02:06 -07001600 * @hide
1601 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001602 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001603 public static final String EXTRA_ORIGINATING_UID
1604 = "android.intent.extra.ORIGINATING_UID";
1605
1606 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001607 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1608 * package. Tells the installer UI to skip the confirmation with the user
1609 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001610 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1611 * will no longer show an interstitial message about updating existing
1612 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001613 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001614 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001615 public static final String EXTRA_ALLOW_REPLACE
1616 = "android.intent.extra.ALLOW_REPLACE";
1617
1618 /**
1619 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1620 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1621 * return to the application the result code of the install/uninstall. The returned result
1622 * code will be {@link android.app.Activity#RESULT_OK} on success or
1623 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1624 */
1625 public static final String EXTRA_RETURN_RESULT
1626 = "android.intent.extra.RETURN_RESULT";
1627
1628 /**
1629 * Package manager install result code. @hide because result codes are not
1630 * yet ready to be exposed.
1631 */
1632 public static final String EXTRA_INSTALL_RESULT
1633 = "android.intent.extra.INSTALL_RESULT";
1634
1635 /**
1636 * Activity Action: Launch application uninstaller.
1637 * <p>
1638 * Input: The data must be a package: URI whose scheme specific part is
1639 * the package name of the current installed package to be uninstalled.
1640 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1641 * <p>
1642 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1643 * succeeded.
1644 */
1645 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1646 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1647
1648 /**
msnider3c191b82017-01-23 14:23:16 -08001649 * Activity Action: Launch application uninstaller.
1650 * <p>
1651 * Input: The data must be a package: URI whose scheme specific part is
1652 * the package name of the current installed package to be uninstalled.
1653 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1654 * <p>
1655 * Output: Nothing.
1656 * </p>
1657 */
1658 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1659 public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1660
1661 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001662 * Specify whether the package should be uninstalled for all users.
1663 * @hide because these should not be part of normal application flow.
1664 */
1665 public static final String EXTRA_UNINSTALL_ALL_USERS
1666 = "android.intent.extra.UNINSTALL_ALL_USERS";
1667
1668 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001669 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1670 * describing the last run version of the platform that was setup.
1671 * @hide
1672 */
1673 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1674
Svet Ganov3695b8a2015-03-24 16:30:25 -07001675 /**
1676 * Activity action: Launch UI to manage the permissions of an app.
1677 * <p>
1678 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1679 * will be managed by the launched UI.
1680 * </p>
1681 * <p>
1682 * Output: Nothing.
1683 * </p>
1684 *
1685 * @see #EXTRA_PACKAGE_NAME
1686 *
1687 * @hide
1688 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001689 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001690 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1691 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1692 "android.intent.action.MANAGE_APP_PERMISSIONS";
1693
1694 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001695 * Activity action: Launch UI to manage permissions.
1696 * <p>
1697 * Input: Nothing.
1698 * </p>
1699 * <p>
1700 * Output: Nothing.
1701 * </p>
1702 *
1703 * @hide
1704 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001705 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001706 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1707 public static final String ACTION_MANAGE_PERMISSIONS =
1708 "android.intent.action.MANAGE_PERMISSIONS";
1709
1710 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001711 * Activity action: Launch UI to review permissions for an app.
1712 * The system uses this intent if permission review for apps not
1713 * supporting the new runtime permissions model is enabled. In
1714 * this mode a permission review is required before any of the
1715 * app components can run.
1716 * <p>
1717 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1718 * permissions will be reviewed (mandatory).
1719 * </p>
1720 * <p>
1721 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1722 * be fired after the permission review (optional).
1723 * </p>
1724 * <p>
1725 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1726 * be invoked after the permission review (optional).
1727 * </p>
1728 * <p>
1729 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1730 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1731 * </p>
1732 * <p>
1733 * Output: Nothing.
1734 * </p>
1735 *
1736 * @see #EXTRA_PACKAGE_NAME
1737 * @see #EXTRA_INTENT
1738 * @see #EXTRA_REMOTE_CALLBACK
1739 * @see #EXTRA_RESULT_NEEDED
1740 *
1741 * @hide
1742 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001743 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001744 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1745 public static final String ACTION_REVIEW_PERMISSIONS =
1746 "android.intent.action.REVIEW_PERMISSIONS";
1747
1748 /**
1749 * Intent extra: A callback for reporting remote result as a bundle.
1750 * <p>
1751 * Type: IRemoteCallback
1752 * </p>
1753 *
1754 * @hide
1755 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001756 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001757 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1758
1759 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001760 * Intent extra: An app package name.
1761 * <p>
1762 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001763 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001764 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001765 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001766 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1767
1768 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001769 * Intent extra: An app split name.
1770 * <p>
1771 * Type: String
1772 * </p>
1773 * @hide
1774 */
1775 @SystemApi
1776 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1777
1778 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001779 * Intent extra: An extra for specifying whether a result is needed.
1780 * <p>
1781 * Type: boolean
1782 * </p>
1783 *
1784 * @hide
1785 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001786 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001787 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1788
1789 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001790 * Activity action: Launch UI to manage which apps have a given permission.
1791 * <p>
1792 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1793 * to which will be managed by the launched UI.
1794 * </p>
1795 * <p>
1796 * Output: Nothing.
1797 * </p>
1798 *
1799 * @see #EXTRA_PERMISSION_NAME
1800 *
1801 * @hide
1802 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001803 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805 public static final String ACTION_MANAGE_PERMISSION_APPS =
1806 "android.intent.action.MANAGE_PERMISSION_APPS";
1807
1808 /**
1809 * Intent extra: The name of a permission.
1810 * <p>
1811 * Type: String
1812 * </p>
1813 *
1814 * @hide
1815 */
1816 @SystemApi
1817 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001819 // ---------------------------------------------------------------------
1820 // ---------------------------------------------------------------------
1821 // Standard intent broadcast actions (see action variable).
1822
1823 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001824 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1825 * <p>
1826 * For historical reasons, the name of this broadcast action refers to the power
1827 * state of the screen but it is actually sent in response to changes in the
1828 * overall interactive state of the device.
1829 * </p><p>
1830 * This broadcast is sent when the device becomes non-interactive which may have
1831 * nothing to do with the screen turning off. To determine the
1832 * actual state of the screen, use {@link android.view.Display#getState}.
1833 * </p><p>
1834 * See {@link android.os.PowerManager#isInteractive} for details.
1835 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001836 * You <em>cannot</em> receive this through components declared in
1837 * manifests, only by explicitly registering for it with
1838 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1839 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001840 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001841 * <p class="note">This is a protected intent that can only be sent
1842 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001843 */
1844 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1845 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001846
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001847 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001848 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1849 * <p>
1850 * For historical reasons, the name of this broadcast action refers to the power
1851 * state of the screen but it is actually sent in response to changes in the
1852 * overall interactive state of the device.
1853 * </p><p>
1854 * This broadcast is sent when the device becomes interactive which may have
1855 * nothing to do with the screen turning on. To determine the
1856 * actual state of the screen, use {@link android.view.Display#getState}.
1857 * </p><p>
1858 * See {@link android.os.PowerManager#isInteractive} for details.
1859 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001860 * You <em>cannot</em> receive this through components declared in
1861 * manifests, only by explicitly registering for it with
1862 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1863 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001864 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001870
1871 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001872 * Broadcast Action: Sent after the system stops dreaming.
1873 *
1874 * <p class="note">This is a protected intent that can only be sent by the system.
1875 * It is only sent to registered receivers.</p>
1876 */
1877 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1878 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1879
1880 /**
1881 * Broadcast Action: Sent after the system starts dreaming.
1882 *
1883 * <p class="note">This is a protected intent that can only be sent by the system.
1884 * It is only sent to registered receivers.</p>
1885 */
1886 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1887 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1888
1889 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001890 * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001891 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001892 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001893 * <p class="note">This is a protected intent that can only be sent
1894 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001895 */
1896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001897 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001898
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 /**
1900 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001901 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001902 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001903 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1904 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001905 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001906 * <p class="note">This is a protected intent that can only be sent
1907 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001908 */
1909 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1910 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1911 /**
1912 * Broadcast Action: The time was set.
1913 */
1914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1916 /**
1917 * Broadcast Action: The date has changed.
1918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1921 /**
1922 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1923 * <ul>
1924 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1925 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001926 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001927 * <p class="note">This is a protected intent that can only be sent
1928 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001929 */
1930 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1931 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1932 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001933 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1934 * DNS entries should be tossed.
1935 * @hide
1936 */
1937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1938 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1939 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001940 * Alarm Changed Action: This is broadcast when the AlarmClock
1941 * application's alarm is set or unset. It is used by the
1942 * AlarmClock application and the StatusBar service.
1943 * @hide
1944 */
1945 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1946 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001947
1948 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001949 * Broadcast Action: This is broadcast once, after the user has finished
1950 * booting, but while still in the "locked" state. It can be used to perform
1951 * application-specific initialization, such as installing alarms. You must
1952 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1953 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001954 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001955 * This broadcast is sent immediately at boot by all devices (regardless of
1956 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1957 * higher. Upon receipt of this broadcast, the user is still locked and only
1958 * device-protected storage can be accessed safely. If you want to access
1959 * credential-protected storage, you need to wait for the user to be
1960 * unlocked (typically by entering their lock pattern or PIN for the first
1961 * time), after which the {@link #ACTION_USER_UNLOCKED} and
1962 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1963 * <p>
1964 * To receive this broadcast, your receiver component must be marked as
1965 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001966 * <p class="note">
1967 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001968 *
1969 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1973
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001974 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06001975 * Broadcast Action: This is broadcast once, after the user has finished
1976 * booting. It can be used to perform application-specific initialization,
1977 * such as installing alarms. You must hold the
1978 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1979 * order to receive this broadcast.
1980 * <p>
1981 * This broadcast is sent at boot by all devices (both with and without
1982 * direct boot support). Upon receipt of this broadcast, the user is
1983 * unlocked and both device-protected and credential-protected storage can
1984 * accessed safely.
1985 * <p>
1986 * If you need to run while the user is still locked (before they've entered
1987 * their lock pattern or PIN for the first time), you can listen for the
1988 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
1989 * <p class="note">
1990 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 */
1992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1993 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001994
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001995 /**
1996 * Broadcast Action: This is broadcast when a user action should request a
1997 * temporary system dialog to dismiss. Some examples of temporary system
1998 * dialogs are the notification window-shade and the recent tasks dialog.
1999 */
2000 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2001 /**
2002 * Broadcast Action: Trigger the download and eventual installation
2003 * of a package.
2004 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002005 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002006 * <p class="note">This is a protected intent that can only be sent
2007 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002008 *
2009 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002010 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002011 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002012 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2013 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2014 /**
2015 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002016 * device. The data contains the name of the package. Note that the
2017 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002018 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002019 * <ul>
2020 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2021 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2022 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2023 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002024 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002025 * <p class="note">This is a protected intent that can only be sent
2026 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002027 */
2028 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2029 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2030 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002031 * Broadcast Action: A new version of an application package has been
2032 * installed, replacing an existing version that was previously installed.
2033 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002034 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002035 * <ul>
2036 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2037 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002038 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002039 * <p class="note">This is a protected intent that can only be sent
2040 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002041 */
2042 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2043 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2044 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002045 * Broadcast Action: A new version of your application has been installed
2046 * over an existing one. This is only sent to the application that was
2047 * replaced. It does not contain any additional data; to receive it, just
2048 * use an intent filter for this action.
2049 *
2050 * <p class="note">This is a protected intent that can only be sent
2051 * by the system.
2052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2054 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2055 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002056 * Broadcast Action: An existing application package has been removed from
2057 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002058 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002059 * <ul>
2060 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2061 * to the package.
2062 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2063 * application -- data and code -- is being removed.
2064 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2065 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2066 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002067 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002068 * <p class="note">This is a protected intent that can only be sent
2069 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002070 */
2071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2072 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2073 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002074 * Broadcast Action: An existing application package has been completely
2075 * removed from the device. The data contains the name of the package.
2076 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2077 * {@link #EXTRA_DATA_REMOVED} is true and
2078 * {@link #EXTRA_REPLACING} is false of that broadcast.
2079 *
2080 * <ul>
2081 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2082 * to the package.
2083 * </ul>
2084 *
2085 * <p class="note">This is a protected intent that can only be sent
2086 * by the system.
2087 */
2088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2089 public static final String ACTION_PACKAGE_FULLY_REMOVED
2090 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2091 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002092 * Broadcast Action: An existing application package has been changed (for
2093 * example, a component has been enabled or disabled). The data contains
2094 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002095 * <ul>
2096 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002097 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002098 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002099 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2100 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002101 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002102 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002103 * <p class="note">This is a protected intent that can only be sent
2104 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002105 */
2106 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2107 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2108 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002109 * @hide
2110 * Broadcast Action: Ask system services if there is any reason to
2111 * restart the given package. The data contains the name of the
2112 * package.
2113 * <ul>
2114 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2115 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2116 * </ul>
2117 *
2118 * <p class="note">This is a protected intent that can only be sent
2119 * by the system.
2120 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002121 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002122 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2123 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2124 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002125 * Broadcast Action: The user has restarted a package, and all of its
2126 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002127 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002128 * be removed. Note that the restarted package does <em>not</em>
2129 * receive this broadcast.
2130 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002131 * <ul>
2132 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2133 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002134 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2140 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002141 * Broadcast Action: The user has cleared the data of a package. This should
2142 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002143 * its persistent data is erased and this broadcast sent.
2144 * Note that the cleared package does <em>not</em>
2145 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002146 * <ul>
2147 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2148 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2155 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002156 * Broadcast Action: Packages have been suspended.
2157 * <p>Includes the following extras:
2158 * <ul>
2159 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2160 * </ul>
2161 *
2162 * <p class="note">This is a protected intent that can only be sent
2163 * by the system. It is only sent to registered receivers.
2164 */
2165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2166 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2167 /**
2168 * Broadcast Action: Packages have been unsuspended.
2169 * <p>Includes the following extras:
2170 * <ul>
2171 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2172 * </ul>
2173 *
2174 * <p class="note">This is a protected intent that can only be sent
2175 * by the system. It is only sent to registered receivers.
2176 */
2177 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2178 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2179 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002180 * Broadcast Action: A user ID has been removed from the system. The user
2181 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002182 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002183 * <p class="note">This is a protected intent that can only be sent
2184 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002185 */
2186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002188
2189 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002190 * Broadcast Action: Sent to the installer package of an application when
2191 * that application is first launched (that is the first time it is moved
2192 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002193 *
2194 * <p class="note">This is a protected intent that can only be sent
2195 * by the system.
2196 */
2197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2198 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2199
2200 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002201 * Broadcast Action: Sent to the system package verifier when a package
2202 * needs to be verified. The data contains the package URI.
2203 * <p class="note">
2204 * This is a protected intent that can only be sent by the system.
2205 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002206 */
2207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2208 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2209
2210 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002211 * Broadcast Action: Sent to the system package verifier when a package is
2212 * verified. The data contains the package URI.
2213 * <p class="note">
2214 * This is a protected intent that can only be sent by the system.
2215 */
2216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2217 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2218
2219 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002220 * Broadcast Action: Sent to the system intent filter verifier when an
2221 * intent filter needs to be verified. The data contains the filter data
2222 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002223 * <p class="note">
2224 * This is a protected intent that can only be sent by the system.
2225 * </p>
2226 *
2227 * @hide
2228 */
2229 @SystemApi
2230 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2231 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2232
2233 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002234 * Broadcast Action: Resources for a set of packages (which were
2235 * previously unavailable) are currently
2236 * available since the media on which they exist is available.
2237 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2238 * list of packages whose availability changed.
2239 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2240 * list of uids of packages whose availability changed.
2241 * Note that the
2242 * packages in this list do <em>not</em> receive this broadcast.
2243 * The specified set of packages are now available on the system.
2244 * <p>Includes the following extras:
2245 * <ul>
2246 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2247 * whose resources(were previously unavailable) are currently available.
2248 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2249 * packages whose resources(were previously unavailable)
2250 * are currently available.
2251 * </ul>
2252 *
2253 * <p class="note">This is a protected intent that can only be sent
2254 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002255 */
2256 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002257 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2258 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002259
2260 /**
2261 * Broadcast Action: Resources for a set of packages are currently
2262 * unavailable since the media on which they exist is unavailable.
2263 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2264 * list of packages whose availability changed.
2265 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2266 * list of uids of packages whose availability changed.
2267 * The specified set of packages can no longer be
2268 * launched and are practically unavailable on the system.
2269 * <p>Inclues the following extras:
2270 * <ul>
2271 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2272 * whose resources are no longer available.
2273 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2274 * whose resources are no longer available.
2275 * </ul>
2276 *
2277 * <p class="note">This is a protected intent that can only be sent
2278 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002279 */
2280 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002281 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002282 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002284 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002285 * Broadcast Action: preferred activities have changed *explicitly*.
2286 *
2287 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2288 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2289 * be sent.
2290 *
2291 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2292 *
2293 * @hide
2294 */
2295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2296 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2297 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2298
2299
2300 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002301 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002302 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002303 * This should <em>only</em> be used to determine when the wallpaper
2304 * has changed to show the new wallpaper to the user. You should certainly
2305 * never, in response to this, change the wallpaper or other attributes of
2306 * it such as the suggested size. That would be crazy, right? You'd cause
2307 * all kinds of loops, especially if other apps are doing similar things,
2308 * right? Of course. So please don't do this.
2309 *
2310 * @deprecated Modern applications should use
2311 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2312 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2313 * shown behind their UI, rather than watching for this broadcast and
2314 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002315 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002316 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2318 /**
2319 * Broadcast Action: The current device {@link android.content.res.Configuration}
2320 * (orientation, locale, etc) has changed. When such a change happens, the
2321 * UIs (view hierarchy) will need to be rebuilt based on this new
2322 * information; for the most part, applications don't need to worry about
2323 * this, because the system will take care of stopping and restarting the
2324 * application to make sure it sees the new changes. Some system code that
2325 * can not be restarted will need to watch for this action and handle it
2326 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002327 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002328 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002329 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002330 * in manifests, only by explicitly registering for it with
2331 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2332 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002333 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002334 * <p class="note">This is a protected intent that can only be sent
2335 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002336 *
2337 * @see android.content.res.Configuration
2338 */
2339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2340 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2341 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002342 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002343 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002344 * <p class="note">This is a protected intent that can only be sent
2345 * by the system.
2346 */
2347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2348 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2349 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002350 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2351 * charging state, level, and other information about the battery.
2352 * See {@link android.os.BatteryManager} for documentation on the
2353 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002354 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002355 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002356 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002357 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002358 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002359 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2360 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2361 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2362 * broadcasts that are sent and can be received through manifest
2363 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002364 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002365 * <p class="note">This is a protected intent that can only be sent
2366 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002367 */
2368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2369 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2370 /**
2371 * Broadcast Action: Indicates low battery condition on the device.
2372 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002373 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002374 * <p class="note">This is a protected intent that can only be sent
2375 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002376 */
2377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2378 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2379 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002380 * Broadcast Action: Indicates the battery is now okay after being low.
2381 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2382 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002383 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002384 * <p class="note">This is a protected intent that can only be sent
2385 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002386 */
2387 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2388 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2389 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002390 * Broadcast Action: External power has been connected to the device.
2391 * This is intended for applications that wish to register specifically to this notification.
2392 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2393 * stay active to receive this notification. This action can be used to implement actions
2394 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002395 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002396 * <p class="note">This is a protected intent that can only be sent
2397 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002398 */
2399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002400 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002401 /**
2402 * Broadcast Action: External power has been removed from the device.
2403 * This is intended for applications that wish to register specifically to this notification.
2404 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2405 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002406 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002407 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002408 * <p class="note">This is a protected intent that can only be sent
2409 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002410 */
2411 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002412 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002413 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002414 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002415 * Broadcast Action: Device is shutting down.
2416 * This is broadcast when the device is being shut down (completely turned
2417 * off, not sleeping). Once the broadcast is complete, the final shutdown
2418 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002419 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002420 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002421 * <p class="note">This is a protected intent that can only be sent
2422 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002423 * <p>May include the following extras:
2424 * <ul>
2425 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2426 * shutdown is only for userspace processes. If not set, assumed to be false.
2427 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002428 */
2429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002430 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002431 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002432 * Activity Action: Start this activity to request system shutdown.
2433 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002434 * to request confirmation from the user before shutting down. The optional boolean
2435 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2436 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002437 *
2438 * <p class="note">This is a protected intent that can only be sent
2439 * by the system.
2440 *
2441 * {@hide}
2442 */
2443 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2444 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002445 * Broadcast Action: A sticky broadcast that indicates low memory
2446 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002447 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002448 * <p class="note">This is a protected intent that can only be sent
2449 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 */
2451 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2452 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2453 /**
2454 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002455 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002456 * <p class="note">This is a protected intent that can only be sent
2457 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002458 */
2459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2460 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2461 /**
Jake Hambybb371632010-08-23 18:16:48 -07002462 * Broadcast Action: A sticky broadcast that indicates a memory full
2463 * condition on the device. This is intended for activities that want
2464 * to be able to fill the data partition completely, leaving only
2465 * enough free space to prevent system-wide SQLite failures.
2466 *
2467 * <p class="note">This is a protected intent that can only be sent
2468 * by the system.
2469 *
2470 * {@hide}
2471 */
2472 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2473 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2474 /**
2475 * Broadcast Action: Indicates memory full condition on the device
2476 * no longer exists.
2477 *
2478 * <p class="note">This is a protected intent that can only be sent
2479 * by the system.
2480 *
2481 * {@hide}
2482 */
2483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2484 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2485 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002486 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2487 * and package management should be started.
2488 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2489 * notification.
2490 */
2491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2492 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2493 /**
2494 * Broadcast Action: The device has entered USB Mass Storage mode.
2495 * This is used mainly for the USB Settings panel.
2496 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2497 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002498 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002499 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002500 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002501 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2502
2503 /**
2504 * Broadcast Action: The device has exited USB Mass Storage mode.
2505 * This is used mainly for the USB Settings panel.
2506 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2507 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002508 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002509 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002510 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002511 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2512
2513 /**
2514 * Broadcast Action: External media has been removed.
2515 * The path to the mount point for the removed media is contained in the Intent.mData field.
2516 */
2517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2518 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2519
2520 /**
2521 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002522 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002523 */
2524 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2525 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2526
2527 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002528 * Broadcast Action: External media is present, and being disk-checked
2529 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002530 */
2531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2532 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2533
2534 /**
2535 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2536 * The path to the mount point for the checking media is contained in the Intent.mData field.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002537 */
2538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2539 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2540
2541 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002542 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002543 * The path to the mount point for the mounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002544 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2545 * media was mounted read only.
2546 */
2547 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2548 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2549
2550 /**
2551 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002552 * The path to the mount point for the shared media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002553 */
2554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2556
2557 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002558 * Broadcast Action: External media is no longer being shared via USB mass storage.
2559 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2560 *
2561 * @hide
2562 */
2563 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2564
2565 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002566 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2567 * The path to the mount point for the removed media is contained in the Intent.mData field.
2568 */
2569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2570 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2571
2572 /**
2573 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002574 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002575 */
2576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2577 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2578
2579 /**
2580 * Broadcast Action: User has expressed the desire to remove the external storage media.
2581 * Applications should close all files they have open within the mount point when they receive this intent.
2582 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2583 */
2584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2585 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2586
2587 /**
2588 * Broadcast Action: The media scanner has started scanning a directory.
2589 * The path to the directory being scanned is contained in the Intent.mData field.
2590 */
2591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2592 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2593
2594 /**
2595 * Broadcast Action: The media scanner has finished scanning a directory.
2596 * The path to the scanned directory is contained in the Intent.mData field.
2597 */
2598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2600
2601 /**
2602 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2603 * The path to the file is contained in the Intent.mData field.
2604 */
2605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2607
2608 /**
2609 * Broadcast Action: The "Media Button" was pressed. Includes a single
2610 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2611 * caused the broadcast.
2612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2615
2616 /**
2617 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2618 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2619 * caused the broadcast.
2620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2623
2624 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2625 // location; they are not general-purpose actions.
2626
2627 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002628 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002629 */
2630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2631 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2632 "android.intent.action.GTALK_CONNECTED";
2633
2634 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002635 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002636 */
2637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2638 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2639 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002640
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002641 /**
2642 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_INPUT_METHOD_CHANGED =
2646 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002647
2648 /**
2649 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2650 * more radios have been turned off or on. The intent will have the following extra value:</p>
2651 * <ul>
2652 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2653 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2654 * turned off</li>
2655 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002656 *
Peng Xua35b5532016-01-20 00:05:45 -08002657 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 */
2659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2660 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2661
2662 /**
2663 * Broadcast Action: Some content providers have parts of their namespace
2664 * where they publish new events or items that the user may be especially
2665 * interested in. For these things, they may broadcast this action when the
2666 * set of interesting items change.
2667 *
2668 * For example, GmailProvider sends this notification when the set of unread
2669 * mail in the inbox changes.
2670 *
2671 * <p>The data of the intent identifies which part of which provider
2672 * changed. When queried through the content resolver, the data URI will
2673 * return the data set in question.
2674 *
2675 * <p>The intent will have the following extra values:
2676 * <ul>
2677 * <li><em>count</em> - The number of items in the data set. This is the
2678 * same as the number of items in the cursor returned by querying the
2679 * data URI. </li>
2680 * </ul>
2681 *
2682 * This intent will be sent at boot (if the count is non-zero) and when the
2683 * data set changes. It is possible for the data set to change without the
2684 * count changing (for example, if a new unread message arrives in the same
2685 * sync operation in which a message is archived). The phone should still
2686 * ring/vibrate/etc as normal in this case.
2687 */
2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2689 public static final String ACTION_PROVIDER_CHANGED =
2690 "android.intent.action.PROVIDER_CHANGED";
2691
2692 /**
2693 * Broadcast Action: Wired Headset plugged in or unplugged.
2694 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002695 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2696 * and documentation.
2697 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002698 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002699 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002700 */
2701 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002702 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002703
2704 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002705 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2706 * <ul>
2707 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2708 * </ul>
2709 *
2710 * <p class="note">This is a protected intent that can only be sent
2711 * by the system.
2712 *
2713 * @hide
2714 */
2715 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2716 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2717 = "android.intent.action.ADVANCED_SETTINGS";
2718
2719 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002720 * Broadcast Action: Sent after application restrictions are changed.
2721 *
2722 * <p class="note">This is a protected intent that can only be sent
2723 * by the system.</p>
2724 */
2725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2726 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2727 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2728
2729 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002730 * Broadcast Action: An outgoing call is about to be placed.
2731 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002732 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002734 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002735 * the phone number originally intended to be dialed.</li>
2736 * </ul>
2737 * <p>Once the broadcast is finished, the resultData is used as the actual
2738 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002739 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002740 * outgoing call in turn: for example, a parental control application
2741 * might verify that the user is authorized to place the call at that
2742 * time, then a number-rewriting application might add an area code if
2743 * one was not specified.</p>
2744 * <p>For consistency, any receiver whose purpose is to prohibit phone
2745 * calls should have a priority of 0, to ensure it will see the final
2746 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002747 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002748 * should have a positive priority.
2749 * Negative priorities are reserved for the system for this broadcast;
2750 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002751 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2752 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002753 * <p>Emergency calls cannot be intercepted using this mechanism, and
2754 * other calls cannot be modified to call emergency numbers using this
2755 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002756 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2757 * call to use their own service instead. Those apps should first prevent
2758 * the call from being placed by setting resultData to <code>null</code>
2759 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002760 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002761 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2762 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002763 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002764 * <p class="note">This is a protected intent that can only be sent
2765 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002766 */
2767 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2768 public static final String ACTION_NEW_OUTGOING_CALL =
2769 "android.intent.action.NEW_OUTGOING_CALL";
2770
2771 /**
2772 * Broadcast Action: Have the device reboot. This is only for use by
2773 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002774 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002775 * <p class="note">This is a protected intent that can only be sent
2776 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002777 */
2778 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2779 public static final String ACTION_REBOOT =
2780 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002781
Wei Huang97ecc9c2009-05-11 17:44:20 -07002782 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002783 * Broadcast Action: A sticky broadcast for changes in the physical
2784 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002785 *
2786 * <p>The intent will have the following extra values:
2787 * <ul>
2788 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002789 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002790 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002791 * <p>This is intended for monitoring the current physical dock state.
2792 * See {@link android.app.UiModeManager} for the normal API dealing with
2793 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002794 */
2795 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2796 public static final String ACTION_DOCK_EVENT =
2797 "android.intent.action.DOCK_EVENT";
2798
2799 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002800 * Broadcast Action: A broadcast when idle maintenance can be started.
2801 * This means that the user is not interacting with the device and is
2802 * not expected to do so soon. Typical use of the idle maintenance is
2803 * to perform somehow expensive tasks that can be postponed at a moment
2804 * when they will not degrade user experience.
2805 * <p>
2806 * <p class="note">In order to keep the device responsive in case of an
2807 * unexpected user interaction, implementations of a maintenance task
2808 * should be interruptible. In such a scenario a broadcast with action
2809 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2810 * should not do the maintenance work in
2811 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2812 * maintenance service by {@link Context#startService(Intent)}. Also
2813 * you should hold a wake lock while your maintenance service is running
2814 * to prevent the device going to sleep.
2815 * </p>
2816 * <p>
2817 * <p class="note">This is a protected intent that can only be sent by
2818 * the system.
2819 * </p>
2820 *
2821 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002822 *
2823 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002824 */
2825 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2826 public static final String ACTION_IDLE_MAINTENANCE_START =
2827 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2828
2829 /**
2830 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2831 * This means that the user was not interacting with the device as a result
2832 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2833 * was sent and now the user started interacting with the device. Typical
2834 * use of the idle maintenance is to perform somehow expensive tasks that
2835 * can be postponed at a moment when they will not degrade user experience.
2836 * <p>
2837 * <p class="note">In order to keep the device responsive in case of an
2838 * unexpected user interaction, implementations of a maintenance task
2839 * should be interruptible. Hence, on receiving a broadcast with this
2840 * action, the maintenance task should be interrupted as soon as possible.
2841 * In other words, you should not do the maintenance work in
2842 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2843 * maintenance service that was started on receiving of
2844 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2845 * lock you acquired when your maintenance service started.
2846 * </p>
2847 * <p class="note">This is a protected intent that can only be sent
2848 * by the system.
2849 *
2850 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002851 *
2852 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002853 */
2854 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2855 public static final String ACTION_IDLE_MAINTENANCE_END =
2856 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2857
2858 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002859 * Broadcast Action: a remote intent is to be broadcasted.
2860 *
2861 * A remote intent is used for remote RPC between devices. The remote intent
2862 * is serialized and sent from one device to another device. The receiving
2863 * device parses the remote intent and broadcasts it. Note that anyone can
2864 * broadcast a remote intent. However, if the intent receiver of the remote intent
2865 * does not trust intent broadcasts from arbitrary intent senders, it should require
2866 * the sender to hold certain permissions so only trusted sender's broadcast will be
2867 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002868 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002869 */
2870 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002871 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002872
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002873 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06002874 * Broadcast Action: This is broadcast once when the user is booting after a
2875 * system update. It can be used to perform cleanup or upgrades after a
2876 * system update.
2877 * <p>
2878 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2879 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2880 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2881 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002882 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002883 * @hide
2884 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08002885 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002886 public static final String ACTION_PRE_BOOT_COMPLETED =
2887 "android.intent.action.PRE_BOOT_COMPLETED";
2888
Amith Yamasani13593602012-03-22 16:16:17 -07002889 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002890 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002891 * on restricted users. The broadcast intent contains an extra
2892 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2893 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2894 * String[] depending on the restriction type.<p/>
2895 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002896 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2897 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2898 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002899 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2900 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002901 * @see RestrictionEntry
2902 */
2903 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2904 "android.intent.action.GET_RESTRICTION_ENTRIES";
2905
2906 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002907 * Sent the first time a user is starting, to allow system apps to
2908 * perform one time initialization. (This will not be seen by third
2909 * party applications because a newly initialized user does not have any
2910 * third party applications installed for it.) This is sent early in
2911 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002912 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2913 * broadcast, since it is part of a visible user interaction; be as quick
2914 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002915 */
2916 public static final String ACTION_USER_INITIALIZE =
2917 "android.intent.action.USER_INITIALIZE";
2918
2919 /**
2920 * Sent when a user switch is happening, causing the process's user to be
2921 * brought to the foreground. This is only sent to receivers registered
2922 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2923 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002924 * foreground. This is sent as a foreground
2925 * broadcast, since it is part of a visible user interaction; be as quick
2926 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002927 */
2928 public static final String ACTION_USER_FOREGROUND =
2929 "android.intent.action.USER_FOREGROUND";
2930
2931 /**
2932 * Sent when a user switch is happening, causing the process's user to be
2933 * sent to the background. This is only sent to receivers registered
2934 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2935 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002936 * background. This is sent as a foreground
2937 * broadcast, since it is part of a visible user interaction; be as quick
2938 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002939 */
2940 public static final String ACTION_USER_BACKGROUND =
2941 "android.intent.action.USER_BACKGROUND";
2942
2943 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002944 * Broadcast sent to the system when a user is added. Carries an extra
2945 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2946 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002947 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002948 * @hide
2949 */
2950 public static final String ACTION_USER_ADDED =
2951 "android.intent.action.USER_ADDED";
2952
2953 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002954 * Broadcast sent by the system when a user is started. Carries an extra
2955 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002956 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002957 * that has been started. This is sent as a foreground
2958 * broadcast, since it is part of a visible user interaction; be as quick
2959 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002960 * @hide
2961 */
2962 public static final String ACTION_USER_STARTED =
2963 "android.intent.action.USER_STARTED";
2964
2965 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002966 * Broadcast sent when a user is in the process of starting. Carries an extra
2967 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2968 * sent to registered receivers, not manifest receivers. It is sent to all
2969 * users (including the one that is being started). You must hold
2970 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2971 * this broadcast. This is sent as a background broadcast, since
2972 * its result is not part of the primary UX flow; to safely keep track of
2973 * started/stopped state of a user you can use this in conjunction with
2974 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2975 * other user state broadcasts since those are foreground broadcasts so can
2976 * execute in a different order.
2977 * @hide
2978 */
2979 public static final String ACTION_USER_STARTING =
2980 "android.intent.action.USER_STARTING";
2981
2982 /**
2983 * Broadcast sent when a user is going to be stopped. Carries an extra
2984 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2985 * sent to registered receivers, not manifest receivers. It is sent to all
2986 * users (including the one that is being stopped). You must hold
2987 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2988 * this broadcast. The user will not stop until all receivers have
2989 * handled the broadcast. This is sent as a background broadcast, since
2990 * its result is not part of the primary UX flow; to safely keep track of
2991 * started/stopped state of a user you can use this in conjunction with
2992 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2993 * other user state broadcasts since those are foreground broadcasts so can
2994 * execute in a different order.
2995 * @hide
2996 */
2997 public static final String ACTION_USER_STOPPING =
2998 "android.intent.action.USER_STOPPING";
2999
3000 /**
3001 * Broadcast sent to the system when a user is stopped. Carries an extra
3002 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3003 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3004 * specific package. This is only sent to registered receivers, not manifest
3005 * receivers. It is sent to all running users <em>except</em> the one that
3006 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003007 * @hide
3008 */
3009 public static final String ACTION_USER_STOPPED =
3010 "android.intent.action.USER_STOPPED";
3011
3012 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003013 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003014 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003015 * one that has been removed. The user will not be completely removed until all receivers have
3016 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003017 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003018 * @hide
3019 */
3020 public static final String ACTION_USER_REMOVED =
3021 "android.intent.action.USER_REMOVED";
3022
3023 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003024 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003025 * the userHandle of the user to become the current one. This is only sent to
3026 * registered receivers, not manifest receivers. It is sent to all running users.
3027 * You must hold
3028 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003029 * @hide
3030 */
3031 public static final String ACTION_USER_SWITCHED =
3032 "android.intent.action.USER_SWITCHED";
3033
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003034 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003035 * Broadcast Action: Sent when the credential-encrypted private storage has
3036 * become unlocked for the target user. This is only sent to registered
3037 * receivers, not manifest receivers.
3038 */
3039 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3040 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3041
3042 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003043 * Broadcast sent to the system when a user's information changes. Carries an extra
3044 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003045 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003046 * @hide
3047 */
3048 public static final String ACTION_USER_INFO_CHANGED =
3049 "android.intent.action.USER_INFO_CHANGED";
3050
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003051 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003052 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3053 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003054 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3055 * that need to display merged content across both primary and managed profiles need to
3056 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003057 * not manifest receivers.
3058 */
3059 public static final String ACTION_MANAGED_PROFILE_ADDED =
3060 "android.intent.action.MANAGED_PROFILE_ADDED";
3061
3062 /**
3063 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003064 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3065 * Only applications (for example Launchers) that need to display merged content across both
3066 * primary and managed profiles need to worry about this broadcast. This is only sent to
3067 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003068 */
3069 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3070 "android.intent.action.MANAGED_PROFILE_REMOVED";
3071
3072 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003073 * Broadcast sent to the primary user when the credential-encrypted private storage for
3074 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3075 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3076 * Launchers) that need to display merged content across both primary and managed profiles
3077 * need to worry about this broadcast. This is only sent to registered receivers,
3078 * not manifest receivers.
3079 */
3080 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3081 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3082
3083 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003084 * Broadcast sent to the primary user when an associated managed profile has become available.
3085 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003086 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3087 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3088 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003089 */
Rubin Xue95057a2016-04-01 16:49:25 +01003090 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3091 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3092
3093 /**
3094 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3095 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3096 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3097 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3098 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3099 */
3100 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3101 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003102
3103 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003104 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3105 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3106 * the device was locked or unlocked.
3107 *
3108 * This is only sent to registered receivers.
3109 *
3110 * @hide
3111 */
3112 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3113 "android.intent.action.DEVICE_LOCKED_CHANGED";
3114
3115 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003116 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3117 */
3118 public static final String ACTION_QUICK_CLOCK =
3119 "android.intent.action.QUICK_CLOCK";
3120
Michael Wright0087a142013-02-05 16:29:39 -08003121 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003122 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003123 * @hide
3124 */
3125 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3126 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3127
Justin Kohd378ad72013-04-01 12:18:26 -07003128 /**
3129 * Broadcast Action: A global button was pressed. Includes a single
3130 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3131 * caused the broadcast.
3132 * @hide
3133 */
3134 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3135
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003136 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003137 * Broadcast Action: Sent when media resource is granted.
3138 * <p>
3139 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3140 * granted.
3141 * </p>
3142 * <p class="note">
3143 * This is a protected intent that can only be sent by the system.
3144 * </p>
3145 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003146 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003147 * </p>
3148 *
3149 * @hide
3150 */
3151 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3152 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3153
3154 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003155 * Broadcast Action: An overlay package has been installed. The data
3156 * contains the name of the added overlay package.
3157 * @hide
3158 */
3159 public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3160
3161 /**
3162 * Broadcast Action: An overlay package has changed. The data contains the
3163 * name of the overlay package which has changed. This is broadcast on all
3164 * changes to the OverlayInfo returned by {@link
3165 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3166 * most common change is a state change that will change whether the
3167 * overlay is enabled or not.
3168 * @hide
3169 */
3170 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3171
3172 /**
3173 * Broadcast Action: An overlay package has been removed. The data contains
3174 * the name of the overlay package which has been removed.
3175 * @hide
3176 */
3177 public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3178
3179 /**
3180 * Broadcast Action: The order of a package's list of overlay packages has
3181 * changed. The data contains the package name of the overlay package that
3182 * had its position in the list adjusted.
3183 * @hide
3184 */
3185 public static final String
3186 ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3187
3188 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003189 * Activity Action: Allow the user to select and return one or more existing
3190 * documents. When invoked, the system will display the various
3191 * {@link DocumentsProvider} instances installed on the device, letting the
3192 * user interactively navigate through them. These documents include local
3193 * media, such as photos and video, and documents provided by installed
3194 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003195 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003196 * Each document is represented as a {@code content://} URI backed by a
3197 * {@link DocumentsProvider}, which can be opened as a stream with
3198 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3199 * {@link android.provider.DocumentsContract.Document} metadata.
3200 * <p>
3201 * All selected documents are returned to the calling application with
3202 * persistable read and write permission grants. If you want to maintain
3203 * access to the documents across device reboots, you need to explicitly
3204 * take the persistable permissions using
3205 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3206 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003207 * Callers must indicate the acceptable document MIME types through
3208 * {@link #setType(String)}. For example, to select photos, use
3209 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3210 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3211 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003212 * <p>
3213 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003214 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3215 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003216 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003217 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3218 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003219 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003220 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003221 * Callers can set a document URI through
3222 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3223 * location of documents navigator. System will do its best to launch the
3224 * navigator in the specified document if it's a folder, or the folder that
3225 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003226 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003227 * Output: The URI of the item that was picked, returned in
3228 * {@link #getData()}. This must be a {@code content://} URI so that any
3229 * receiver can access it. If multiple documents were selected, they are
3230 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003231 *
3232 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003233 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003234 * @see #ACTION_CREATE_DOCUMENT
3235 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003236 */
3237 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3238 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3239
3240 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003241 * Activity Action: Allow the user to create a new document. When invoked,
3242 * the system will display the various {@link DocumentsProvider} instances
3243 * installed on the device, letting the user navigate through them. The
3244 * returned document may be a newly created document with no content, or it
3245 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003246 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003247 * Each document is represented as a {@code content://} URI backed by a
3248 * {@link DocumentsProvider}, which can be opened as a stream with
3249 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3250 * {@link android.provider.DocumentsContract.Document} metadata.
3251 * <p>
3252 * Callers must indicate the concrete MIME type of the document being
3253 * created by setting {@link #setType(String)}. This MIME type cannot be
3254 * changed after the document is created.
3255 * <p>
3256 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3257 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003258 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003259 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3260 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003261 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003262 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003263 * Callers can set a document URI through
3264 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3265 * location of documents navigator. System will do its best to launch the
3266 * navigator in the specified document if it's a folder, or the folder that
3267 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003268 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003269 * Output: The URI of the item that was created. This must be a
3270 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003271 *
3272 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003273 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003274 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003275 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003276 */
3277 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3278 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3279
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003280 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003281 * Activity Action: Allow the user to pick a directory subtree. When
3282 * invoked, the system will display the various {@link DocumentsProvider}
3283 * instances installed on the device, letting the user navigate through
3284 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003285 * <p>
3286 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003287 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3288 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3289 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003290 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003291 * Callers can set a document URI through
3292 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3293 * location of documents navigator. System will do its best to launch the
3294 * navigator in the specified document if it's a folder, or the folder that
3295 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003296 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003297 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003298 *
3299 * @see DocumentsContract
3300 */
3301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003302 public static final String
3303 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003304
Felipe Lemec7b1f892016-01-15 15:02:31 -08003305 /**
Peng Xua35b5532016-01-20 00:05:45 -08003306 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3307 * exisiting sensor being disconnected.
3308 *
3309 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3310 *
3311 * {@hide}
3312 */
3313 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3314 public static final String
3315 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3316
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003317 /**
3318 * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3319 *
3320 * {@hide}
3321 */
3322 @Deprecated
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003323 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3324
Christopher Tate6597e342015-02-17 12:15:25 -08003325 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003326 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3327 * is about to be performed.
3328 * @hide
3329 */
3330 @SystemApi
3331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3332 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3333 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3334
3335 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003336 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3337 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3338 *
3339 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3340 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003341 * @hide
3342 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003343 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003344 public static final String EXTRA_FORCE_MASTER_CLEAR =
3345 "android.intent.extra.FORCE_MASTER_CLEAR";
3346
3347 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003348 * A broadcast action to trigger a factory reset.
3349 *
3350 * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3351 *
3352 * <p>Not for use by third-party applications.
3353 *
3354 * @see #EXTRA_FORCE_MASTER_CLEAR
3355 *
3356 * {@hide}
3357 */
3358 @SystemApi
3359 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3360 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3361
3362 /**
3363 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3364 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3365 *
3366 * <p>Not for use by third-party applications.
3367 *
3368 * @hide
3369 */
3370 @SystemApi
3371 public static final String EXTRA_FORCE_FACTORY_RESET =
3372 "android.intent.extra.FORCE_FACTORY_RESET";
3373
3374 /**
Christopher Tate6597e342015-02-17 12:15:25 -08003375 * Broadcast action: report that a settings element is being restored from backup. The intent
3376 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3377 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3378 * is the value of that settings entry prior to the restore operation. All of these values are
3379 * represented as strings.
3380 *
3381 * <p>This broadcast is sent only for settings provider entries known to require special handling
3382 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3383 * the provider's backup agent implementation.
3384 *
3385 * @see #EXTRA_SETTING_NAME
3386 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3387 * @see #EXTRA_SETTING_NEW_VALUE
3388 * {@hide}
3389 */
3390 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3391
3392 /** {@hide} */
3393 public static final String EXTRA_SETTING_NAME = "setting_name";
3394 /** {@hide} */
3395 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3396 /** {@hide} */
3397 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3398
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003399 /**
3400 * Activity Action: Process a piece of text.
3401 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3402 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3403 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3404 */
3405 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3406 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003407
3408 /**
3409 * Broadcast Action: The sim card state has changed.
3410 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3411 * because TelephonyIntents is an internal class.
3412 * @hide
3413 */
3414 @SystemApi
3415 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3416 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3417
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003418 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003419 * The name of the extra used to define the text to be processed, as a
3420 * CharSequence. Note that this may be a styled CharSequence, so you must use
3421 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003422 */
3423 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3424 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003425 * The name of the boolean extra used to define if the processed text will be used as read-only.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003426 */
3427 public static final String EXTRA_PROCESS_TEXT_READONLY =
3428 "android.intent.extra.PROCESS_TEXT_READONLY";
3429
Bryce Leebc58f592015-09-25 16:43:01 -07003430 /**
3431 * Broadcast action: reports when a new thermal event has been reached. When the device
3432 * is reaching its maximum temperatue, the thermal level reported
3433 * {@hide}
3434 */
3435 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3436 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3437
3438 /** {@hide} */
3439 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3440
3441 /**
3442 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003443 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003444 * {@hide}
3445 */
3446 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3447
3448 /**
3449 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003450 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003451 * {@hide}
3452 */
3453 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3454
3455 /**
3456 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003457 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003458 * {@hide}
3459 */
3460 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3461
3462
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003463 // ---------------------------------------------------------------------
3464 // ---------------------------------------------------------------------
3465 // Standard intent categories (see addCategory()).
3466
3467 /**
3468 * Set if the activity should be an option for the default action
3469 * (center press) to perform on a piece of data. Setting this will
3470 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003471 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003472 * Intent when initiating an action -- it is for use in intent filters
3473 * specified in packages.
3474 */
3475 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3476 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3477 /**
3478 * Activities that can be safely invoked from a browser must support this
3479 * category. For example, if the user is viewing a web page or an e-mail
3480 * and clicks on a link in the text, the Intent generated execute that
3481 * link will require the BROWSABLE category, so that only activities
3482 * supporting this category will be considered as possible actions. By
3483 * supporting this category, you are promising that there is nothing
3484 * damaging (without user intervention) that can happen by invoking any
3485 * matching Intent.
3486 */
3487 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3488 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3489 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003490 * Categories for activities that can participate in voice interaction.
3491 * An activity that supports this category must be prepared to run with
3492 * no UI shown at all (though in some case it may have a UI shown), and
3493 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3494 */
3495 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3496 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3497 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003498 * Set if the activity should be considered as an alternative action to
3499 * the data the user is currently viewing. See also
3500 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3501 * applies to the selection in a list of items.
3502 *
3503 * <p>Supporting this category means that you would like your activity to be
3504 * displayed in the set of alternative things the user can do, usually as
3505 * part of the current activity's options menu. You will usually want to
3506 * include a specific label in the &lt;intent-filter&gt; of this action
3507 * describing to the user what it does.
3508 *
3509 * <p>The action of IntentFilter with this category is important in that it
3510 * describes the specific action the target will perform. This generally
3511 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3512 * a specific name such as "com.android.camera.action.CROP. Only one
3513 * alternative of any particular action will be shown to the user, so using
3514 * a specific action like this makes sure that your alternative will be
3515 * displayed while also allowing other applications to provide their own
3516 * overrides of that particular action.
3517 */
3518 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3519 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3520 /**
3521 * Set if the activity should be considered as an alternative selection
3522 * action to the data the user has currently selected. This is like
3523 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3524 * of items from which the user can select, giving them alternatives to the
3525 * default action that will be performed on it.
3526 */
3527 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3528 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3529 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003530 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003531 */
3532 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3533 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3534 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003535 * Should be displayed in the top-level launcher.
3536 */
3537 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3538 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3539 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003540 * Indicates an activity optimized for Leanback mode, and that should
3541 * be displayed in the Leanback launcher.
3542 */
3543 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3544 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3545 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003546 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3547 * @hide
3548 */
3549 @SystemApi
3550 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3551 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003552 * Provides information about the package it is in; typically used if
3553 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3554 * a front-door to the user without having to be shown in the all apps list.
3555 */
3556 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3557 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3558 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003559 * This is the home activity, that is the first activity that is displayed
3560 * when the device boots.
3561 */
3562 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3563 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3564 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003565 * This is the home activity that is displayed when the device is finished setting up and ready
3566 * for use.
3567 * @hide
3568 */
3569 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3570 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3571 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003572 * This is the setup wizard activity, that is the first activity that is displayed
3573 * when the user sets up the device for the first time.
3574 * @hide
3575 */
3576 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3577 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3578 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003579 * This activity is a preference panel.
3580 */
3581 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3582 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3583 /**
3584 * This activity is a development preference panel.
3585 */
3586 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3587 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3588 /**
3589 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003590 */
3591 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3592 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3593 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003594 * This activity allows the user to browse and download new applications.
3595 */
3596 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3597 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3598 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003599 * This activity may be exercised by the monkey or other automated test tools.
3600 */
3601 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3602 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3603 /**
3604 * To be used as a test (not part of the normal user experience).
3605 */
3606 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3607 /**
3608 * To be used as a unit test (run through the Test Harness).
3609 */
3610 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3611 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003612 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003613 * experience).
3614 */
3615 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003616
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003617 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003618 * Used to indicate that an intent only wants URIs that can be opened with
3619 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3620 * must support at least the columns defined in {@link OpenableColumns} when
3621 * queried.
3622 *
3623 * @see #ACTION_GET_CONTENT
3624 * @see #ACTION_OPEN_DOCUMENT
3625 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003626 */
3627 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3628 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3629
3630 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09003631 * Used to indicate that an intent filter can accept files which are not necessarily
3632 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3633 * at least streamable via
3634 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3635 * using one of the stream types exposed via
3636 * {@link ContentResolver#getStreamTypes(Uri, String)}.
3637 *
3638 * @see #ACTION_SEND
3639 * @see #ACTION_SEND_MULTIPLE
3640 */
3641 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3642 public static final String CATEGORY_TYPED_OPENABLE =
3643 "android.intent.category.TYPED_OPENABLE";
3644
3645 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003646 * To be used as code under test for framework instrumentation tests.
3647 */
3648 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3649 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003650 /**
3651 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003652 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3653 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003654 */
3655 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3656 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3657 /**
3658 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003659 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3660 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003661 */
3662 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3663 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003664 /**
3665 * An activity to run when device is inserted into a analog (low end) dock.
3666 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3667 * information, see {@link android.app.UiModeManager}.
3668 */
3669 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3670 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3671
3672 /**
3673 * An activity to run when device is inserted into a digital (high end) dock.
3674 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3675 * information, see {@link android.app.UiModeManager}.
3676 */
3677 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3678 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003679
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003680 /**
3681 * Used to indicate that the activity can be used in a car environment.
3682 */
3683 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3684 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3685
Zak Cohendb6ca492017-01-26 14:09:00 -08003686 /**
3687 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3688 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3689 * information, see {@link android.app.UiModeManager}.
3690 */
3691 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3692 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003693 // ---------------------------------------------------------------------
3694 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003695 // Application launch intent categories (see addCategory()).
3696
3697 /**
3698 * Used with {@link #ACTION_MAIN} to launch the browser application.
3699 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003700 * <p>NOTE: This should not be used as the primary key of an Intent,
3701 * since it will not result in the app launching with the correct
3702 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003703 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003704 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003705 */
3706 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3707 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3708
3709 /**
3710 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3711 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003712 * <p>NOTE: This should not be used as the primary key of an Intent,
3713 * since it will not result in the app launching with the correct
3714 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003715 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003716 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003717 */
3718 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3719 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3720
3721 /**
3722 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3723 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003724 * <p>NOTE: This should not be used as the primary key of an Intent,
3725 * since it will not result in the app launching with the correct
3726 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003727 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003728 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003729 */
3730 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3731 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3732
3733 /**
3734 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3735 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003736 * <p>NOTE: This should not be used as the primary key of an Intent,
3737 * since it will not result in the app launching with the correct
3738 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003739 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003740 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003741 */
3742 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3743 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3744
3745 /**
3746 * Used with {@link #ACTION_MAIN} to launch the email application.
3747 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003748 * <p>NOTE: This should not be used as the primary key of an Intent,
3749 * since it will not result in the app launching with the correct
3750 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003751 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003752 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003753 */
3754 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3755 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3756
3757 /**
3758 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3759 * The activity should be able to view and manipulate image and video files
3760 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003761 * <p>NOTE: This should not be used as the primary key of an Intent,
3762 * since it will not result in the app launching with the correct
3763 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003764 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003765 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003766 */
3767 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3768 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3769
3770 /**
3771 * Used with {@link #ACTION_MAIN} to launch the maps application.
3772 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003773 * <p>NOTE: This should not be used as the primary key of an Intent,
3774 * since it will not result in the app launching with the correct
3775 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003776 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003777 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003778 */
3779 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3780 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3781
3782 /**
3783 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3784 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003785 * <p>NOTE: This should not be used as the primary key of an Intent,
3786 * since it will not result in the app launching with the correct
3787 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003788 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003789 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003790 */
3791 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3792 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3793
3794 /**
3795 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003796 * The activity should be able to play, browse, or manipulate music files
3797 * stored on the device.
3798 * <p>NOTE: This should not be used as the primary key of an Intent,
3799 * since it will not result in the app launching with the correct
3800 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003801 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003802 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003803 */
3804 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3805 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3806
3807 // ---------------------------------------------------------------------
3808 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003809 // Standard extra data keys.
3810
3811 /**
3812 * The initial data to place in a newly created record. Use with
3813 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3814 * fields as would be given to the underlying ContentProvider.insert()
3815 * call.
3816 */
3817 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3818
3819 /**
3820 * A constant CharSequence that is associated with the Intent, used with
3821 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3822 * this may be a styled CharSequence, so you must use
3823 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3824 * retrieve it.
3825 */
3826 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3827
3828 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003829 * A constant String that is associated with the Intent, used with
3830 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3831 * as HTML formatted text. Note that you <em>must</em> also supply
3832 * {@link #EXTRA_TEXT}.
3833 */
3834 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3835
3836 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003837 * A content: URI holding a stream of data associated with the Intent,
3838 * used with {@link #ACTION_SEND} to supply the data being sent.
3839 */
3840 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3841
3842 /**
3843 * A String[] holding e-mail addresses that should be delivered to.
3844 */
3845 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3846
3847 /**
3848 * A String[] holding e-mail addresses that should be carbon copied.
3849 */
3850 public static final String EXTRA_CC = "android.intent.extra.CC";
3851
3852 /**
3853 * A String[] holding e-mail addresses that should be blind carbon copied.
3854 */
3855 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3856
3857 /**
3858 * A constant string holding the desired subject line of a message.
3859 */
3860 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3861
3862 /**
3863 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003864 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003865 */
3866 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3867
3868 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003869 * An int representing the user id to be used.
3870 *
3871 * @hide
3872 */
3873 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3874
3875 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003876 * An int representing the task id to be retrieved. This is used when a launch from recents is
3877 * intercepted by another action such as credentials confirmation to remember which task should
3878 * be resumed when complete.
3879 *
3880 * @hide
3881 */
3882 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3883
3884 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003885 * An Intent[] describing additional, alternate choices you would like shown with
3886 * {@link #ACTION_CHOOSER}.
3887 *
3888 * <p>An app may be capable of providing several different payload types to complete a
3889 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3890 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3891 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3892 * photo data or a hosted link where the photos can be viewed.</p>
3893 *
3894 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3895 * first/primary/preferred intent in the set. Additional intents specified in
3896 * this extra are ordered; by default intents that appear earlier in the array will be
3897 * preferred over intents that appear later in the array as matches for the same
3898 * target component. To alter this preference, a calling app may also supply
3899 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3900 */
3901 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3902
3903 /**
Adam Powell52c39212016-04-07 15:14:18 -07003904 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3905 * and omitted from a list of components presented to the user.
3906 *
3907 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3908 * in this array if it otherwise would have shown them. Useful for omitting specific targets
3909 * from your own package or other apps from your organization if the idea of sending to those
3910 * targets would be redundant with other app functionality. Filtered components will not
3911 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3912 */
3913 public static final String EXTRA_EXCLUDE_COMPONENTS
3914 = "android.intent.extra.EXCLUDE_COMPONENTS";
3915
3916 /**
3917 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3918 * describing additional high-priority deep-link targets for the chooser to present to the user.
3919 *
3920 * <p>Targets provided in this way will be presented inline with all other targets provided
3921 * by services from other apps. They will be prioritized before other service targets, but
3922 * after those targets provided by sources that the user has manually pinned to the front.</p>
3923 *
3924 * @see #ACTION_CHOOSER
3925 */
3926 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
3927
3928 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003929 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3930 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3931 *
3932 * <p>An app preparing an action for another app to complete may wish to allow the user to
3933 * disambiguate between several options for completing the action based on the chosen target
3934 * or otherwise refine the action before it is invoked.
3935 * </p>
3936 *
3937 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3938 * <ul>
3939 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3940 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3941 * chosen target beyond the first</li>
3942 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3943 * should fill in and send once the disambiguation is complete</li>
3944 * </ul>
3945 */
3946 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3947 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3948
3949 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08003950 * An {@code ArrayList} of {@code String} annotations describing content for
3951 * {@link #ACTION_CHOOSER}.
3952 *
3953 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
3954 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
3955 *
3956 * <p>Annotations should describe the major components or topics of the content. It is up to
3957 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
3958 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
3959 * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
3960 * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
3961 * use the following annotations when applicable:</p>
3962 * <ul>
3963 * <li>"product": represents that the topic of the content is mainly about products, e.g.,
3964 * health & beauty, and office supplies.</li>
3965 * <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
3966 * happy, and sad.</li>
3967 * <li>"person": represents that the topic of the content is mainly about persons, e.g.,
3968 * face, finger, standing, and walking.</li>
3969 * <li>"child": represents that the topic of the content is mainly about children, e.g.,
3970 * child, and baby.</li>
3971 * <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
3972 * <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
3973 * <li>"party": represents that the topic of the content is mainly about parties.</li>
3974 * <li>"animal": represent that the topic of the content is mainly about animals.</li>
3975 * <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
3976 * flowers.</li>
3977 * <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
3978 * <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
3979 * sunglasses, jewelry, handbags and clothing.</li>
3980 * <li>"material": represents that the topic of the content is mainly about materials, e.g.,
3981 * paper, and silk.</li>
3982 * <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
3983 * cars, and boats.</li>
3984 * <li>"document": represents that the topic of the content is mainly about documents, e.g.
3985 * posters.</li>
3986 * <li>"design": represents that the topic of the content is mainly about design, e.g. arts
3987 * and designs of houses.</li>
3988 * <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
3989 * Christmas and Thanksgiving.</li>
3990 * </ul>
3991 */
3992 public static final String EXTRA_CONTENT_ANNOTATIONS
3993 = "android.intent.extra.CONTENT_ANNOTATIONS";
3994
3995 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003996 * A {@link ResultReceiver} used to return data back to the sender.
3997 *
3998 * <p>Used to complete an app-specific
3999 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4000 *
4001 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4002 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4003 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4004 * when the user selects a target component from the chooser. It is up to the recipient
4005 * to send a result to this ResultReceiver to signal that disambiguation is complete
4006 * and that the chooser should invoke the user's choice.</p>
4007 *
4008 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4009 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4010 * to match and fill in the final Intent or ChooserTarget before starting it.
4011 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4012 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4013 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4014 *
4015 * <p>The result code passed to the ResultReceiver should be
4016 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4017 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4018 * the chooser should finish without starting a target.</p>
4019 */
4020 public static final String EXTRA_RESULT_RECEIVER
4021 = "android.intent.extra.RESULT_RECEIVER";
4022
4023 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004024 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004025 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004026 */
4027 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4028
4029 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004030 * A Parcelable[] of {@link Intent} or
4031 * {@link android.content.pm.LabeledIntent} objects as set with
4032 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4033 * a the front of the list of choices, when shown to the user with a
4034 * {@link #ACTION_CHOOSER}.
4035 */
4036 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4037
4038 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004039 * A {@link IntentSender} to start after ephemeral installation success.
4040 * @hide
4041 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004042 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4043
4044 /**
4045 * A {@link IntentSender} to start after ephemeral installation failure.
4046 * @hide
4047 */
Todd Kennedy7440f172015-12-09 14:31:22 -08004048 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4049
4050 /**
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004051 * The host name that triggered an ephemeral resolution.
4052 * @hide
4053 */
4054 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4055
4056 /**
4057 * An opaque token to track ephemeral resolution.
4058 * @hide
4059 */
4060 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4061
4062 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004063 * The version code of the app to install components from.
4064 * @hide
4065 */
4066 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4067
4068 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004069 * A Bundle forming a mapping of potential target package names to different extras Bundles
4070 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4071 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4072 * be currently installed on the device.
4073 *
4074 * <p>An application may choose to provide alternate extras for the case where a user
4075 * selects an activity from a predetermined set of target packages. If the activity
4076 * the user selects from the chooser belongs to a package with its package name as
4077 * a key in this bundle, the corresponding extras for that package will be merged with
4078 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4079 * extra has the same key as an extra already present in the intent it will overwrite
4080 * the extra from the intent.</p>
4081 *
4082 * <p><em>Examples:</em>
4083 * <ul>
4084 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4085 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4086 * parameters for that target.</li>
4087 * <li>An application may offer additional metadata for known targets of a given intent
4088 * to pass along information only relevant to that target such as account or content
4089 * identifiers already known to that application.</li>
4090 * </ul></p>
4091 */
4092 public static final String EXTRA_REPLACEMENT_EXTRAS =
4093 "android.intent.extra.REPLACEMENT_EXTRAS";
4094
4095 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004096 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4097 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4098 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4099 * {@link ComponentName} of the chosen component.
4100 *
4101 * <p>In some situations this callback may never come, for example if the user abandons
4102 * the chooser, switches to another task or any number of other reasons. Apps should not
4103 * be written assuming that this callback will always occur.</p>
4104 */
4105 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4106 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4107
4108 /**
4109 * The {@link ComponentName} chosen by the user to complete an action.
4110 *
4111 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4112 */
4113 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4114
4115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004116 * A {@link android.view.KeyEvent} object containing the event that
4117 * triggered the creation of the Intent it is in.
4118 */
4119 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4120
4121 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004122 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4123 * before shutting down.
4124 *
4125 * {@hide}
4126 */
4127 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4128
4129 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004130 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4131 * requested by the user.
4132 *
4133 * {@hide}
4134 */
4135 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4136 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4137
4138 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004139 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004140 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4141 * of restarting the application.
4142 */
4143 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4144
4145 /**
4146 * A String holding the phone number originally entered in
4147 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4148 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4149 */
4150 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004151
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004152 /**
4153 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4154 * intents to supply the uid the package had been assigned. Also an optional
4155 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4156 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4157 * purpose.
4158 */
4159 public static final String EXTRA_UID = "android.intent.extra.UID";
4160
4161 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004162 * @hide String array of package names.
4163 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004164 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004165 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4166
4167 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004168 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4169 * intents to indicate whether this represents a full uninstall (removing
4170 * both the code and its data) or a partial uninstall (leaving its data,
4171 * implying that this is an update).
4172 */
4173 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004174
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004175 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004176 * @hide
4177 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4178 * intents to indicate that at this point the package has been removed for
4179 * all users on the device.
4180 */
4181 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4182 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4183
4184 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004185 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4186 * intents to indicate that this is a replacement of the package, so this
4187 * broadcast will immediately be followed by an add broadcast for a
4188 * different version of the same package.
4189 */
4190 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004191
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004192 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004193 * Used as an int extra field in {@link android.app.AlarmManager} intents
4194 * to tell the application being invoked how many pending alarms are being
4195 * delievered with the intent. For one-shot alarms this will always be 1.
4196 * For recurring alarms, this might be greater than 1 if the device was
4197 * asleep or powered off at the time an earlier alarm would have been
4198 * delivered.
4199 */
4200 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004201
Jacek Surazski86b6c532009-05-13 14:38:28 +02004202 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004203 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4204 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004205 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4206 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004207 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4208 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4209 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004210 */
4211 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4212
4213 /**
4214 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4215 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004216 */
4217 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4218
4219 /**
4220 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4221 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004222 */
4223 public static final int EXTRA_DOCK_STATE_DESK = 1;
4224
4225 /**
4226 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4227 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004228 */
4229 public static final int EXTRA_DOCK_STATE_CAR = 2;
4230
4231 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004232 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4233 * to represent that the phone is in a analog (low end) dock.
4234 */
4235 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4236
4237 /**
4238 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4239 * to represent that the phone is in a digital (high end) dock.
4240 */
4241 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4242
4243 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004244 * Boolean that can be supplied as meta-data with a dock activity, to
4245 * indicate that the dock should take over the home key when it is active.
4246 */
4247 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004248
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004249 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004250 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4251 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004252 */
4253 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4254
4255 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004256 * Used in the extra field in the remote intent. It's astring token passed with the
4257 * remote intent.
4258 */
4259 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4260 "android.intent.extra.remote_intent_token";
4261
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004262 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004263 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004264 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004265 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004266 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004267 "android.intent.extra.changed_component_name";
4268
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004269 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004270 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004271 * and contains a string array of all of the components that have changed. If
4272 * the state of the overall package has changed, then it will contain an entry
4273 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004274 */
4275 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4276 "android.intent.extra.changed_component_name_list";
4277
4278 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004279 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004280 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004281 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4282 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4283 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004284 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004285 */
4286 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4287 "android.intent.extra.changed_package_list";
4288
4289 /**
4290 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004291 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4292 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004293 * and contains an integer array of uids of all of the components
4294 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004295 */
4296 public static final String EXTRA_CHANGED_UID_LIST =
4297 "android.intent.extra.changed_uid_list";
4298
4299 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004300 * @hide
4301 * Magic extra system code can use when binding, to give a label for
4302 * who it is that has bound to a service. This is an integer giving
4303 * a framework string resource that can be displayed to the user.
4304 */
4305 public static final String EXTRA_CLIENT_LABEL =
4306 "android.intent.extra.client_label";
4307
4308 /**
4309 * @hide
4310 * Magic extra system code can use when binding, to give a PendingIntent object
4311 * that can be launched for the user to disable the system's use of this
4312 * service.
4313 */
4314 public static final String EXTRA_CLIENT_INTENT =
4315 "android.intent.extra.client_intent";
4316
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004317 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004318 * Extra used to indicate that an intent should only return data that is on
4319 * the local device. This is a boolean extra; the default is false. If true,
4320 * an implementation should only allow the user to select data that is
4321 * already on the device, not requiring it be downloaded from a remote
4322 * service when opened.
4323 *
4324 * @see #ACTION_GET_CONTENT
4325 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004326 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004327 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004328 */
4329 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004330 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004331
Amith Yamasani13593602012-03-22 16:16:17 -07004332 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004333 * Extra used to indicate that an intent can allow the user to select and
4334 * return multiple items. This is a boolean extra; the default is false. If
4335 * true, an implementation is allowed to present the user with a UI where
4336 * they can pick multiple items that are all returned to the caller. When
4337 * this happens, they should be returned as the {@link #getClipData()} part
4338 * of the result Intent.
4339 *
4340 * @see #ACTION_GET_CONTENT
4341 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004342 */
4343 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004344 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004345
4346 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004347 * The integer userHandle carried with broadcast intents related to addition, removal and
4348 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4349 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4350 *
Amith Yamasani13593602012-03-22 16:16:17 -07004351 * @hide
4352 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004353 public static final String EXTRA_USER_HANDLE =
4354 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004355
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004356 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004357 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4358 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4359 */
4360 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004361 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004362
4363 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004364 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004365 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4366 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004367 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004368 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4369
4370 /**
4371 * Extra sent in the intent to the BroadcastReceiver that handles
4372 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4373 * the restrictions as key/value pairs.
4374 */
4375 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4376 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004377
Amith Yamasani86118ba2013-03-28 14:33:16 -07004378 /**
4379 * Extra used in the response from a BroadcastReceiver that handles
4380 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4381 */
4382 public static final String EXTRA_RESTRICTIONS_INTENT =
4383 "android.intent.extra.restrictions_intent";
4384
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004385 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004386 * Extra used to communicate a set of acceptable MIME types. The type of the
4387 * extra is {@code String[]}. Values may be a combination of concrete MIME
4388 * types (such as "image/png") and/or partial MIME types (such as
4389 * "audio/*").
4390 *
4391 * @see #ACTION_GET_CONTENT
4392 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004393 */
4394 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4395
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004396 /**
4397 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4398 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004399 * When this is true, hardware devices can use this information to determine that
4400 * they shouldn't do a complete shutdown of their device since this is not a
4401 * complete shutdown down to the kernel, but only user space restarting.
4402 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004403 */
4404 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4405 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4406
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004407 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00004408 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4409 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4410 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4411 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004412 *
4413 * @hide for internal use only.
4414 */
4415 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4416 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00004417 /** @hide */
4418 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4419 /** @hide */
4420 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4421 /** @hide */
4422 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004423
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004424 /** {@hide} */
4425 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4426
Rubin Xue8490f12015-06-25 12:17:48 +01004427 /** {@hide} */
4428 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4429
Santos Cordon15a13782015-03-31 18:32:31 -07004430 /**
4431 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4432 * activation request.
4433 * TODO: Add information about the structure and response data used with the pending intent.
4434 * @hide
4435 */
4436 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4437 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4438
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004439 /**
4440 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09004441 *
4442 * <p>The value must be an integer greater or equal to 0.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004443 * @see ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004444 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004445 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4446
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004447 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004448 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4449 * such as opening in other apps, sharing, opening, editing, printing, deleting,
4450 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004451 *
4452 * <p>The value is boolean. By default false.
4453 * @see ACTION_QUICK_VIEW
4454 */
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09004455 public static final String EXTRA_QUICK_VIEW_ADVANCED =
4456 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09004457
4458 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004459 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01004460 * When a profile goes into quiet mode, all apps in the profile are killed and the
4461 * profile user is stopped. Widgets originating from the profile are masked, and app
4462 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004463 */
4464 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004465
4466 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004467 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004468 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004469 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4470 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004471 *
4472 * @hide
4473 */
4474 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4475 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4476
4477 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07004478 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4479 * whether to show the chooser or not when there is only one application available
4480 * to choose from.
4481 *
4482 * @hide
4483 */
4484 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4485 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4486
4487 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004488 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004489 * to represent that a video codec is allowed to use.
4490 *
4491 * @hide
4492 */
4493 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4494
4495 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004496 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004497 * to represent that a audio codec is allowed to use.
4498 *
4499 * @hide
4500 */
4501 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4502
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004503 // ---------------------------------------------------------------------
4504 // ---------------------------------------------------------------------
4505 // Intent flags (see mFlags variable).
4506
Tor Norbyed9273d62013-05-30 15:59:53 -07004507 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004508 @IntDef(flag = true, value = {
4509 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4510 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004511 @Retention(RetentionPolicy.SOURCE)
4512 public @interface GrantUriMode {}
4513
Jeff Sharkey846318a2014-04-04 12:12:41 -07004514 /** @hide */
4515 @IntDef(flag = true, value = {
4516 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4517 @Retention(RetentionPolicy.SOURCE)
4518 public @interface AccessUriMode {}
4519
4520 /**
4521 * Test if given mode flags specify an access mode, which must be at least
4522 * read and/or write.
4523 *
4524 * @hide
4525 */
4526 public static boolean isAccessUriMode(int modeFlags) {
4527 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4528 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4529 }
4530
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004531 /**
4532 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004533 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004534 * specified in its ClipData. When applying to an Intent's ClipData,
4535 * all URIs as well as recursive traversals through data or other ClipData
4536 * in Intent items will be granted; only the grant flags of the top-level
4537 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004538 */
4539 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4540 /**
4541 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004542 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004543 * specified in its ClipData. When applying to an Intent's ClipData,
4544 * all URIs as well as recursive traversals through data or other ClipData
4545 * in Intent items will be granted; only the grant flags of the top-level
4546 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004547 */
4548 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4549 /**
4550 * Can be set by the caller to indicate that this Intent is coming from
4551 * a background operation, not from direct user interaction.
4552 */
4553 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4554 /**
4555 * A flag you can enable for debugging: when set, log messages will be
4556 * printed during the resolution of this intent to show you what has
4557 * been found to create the final resolved list.
4558 */
4559 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004560 /**
4561 * If set, this intent will not match any components in packages that
4562 * are currently stopped. If this is not set, then the default behavior
4563 * is to include such applications in the result.
4564 */
4565 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4566 /**
4567 * If set, this intent will always match any components in packages that
4568 * are currently stopped. This is the default behavior when
4569 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4570 * flags are set, this one wins (it allows overriding of exclude for
4571 * places where the framework may automatically set the exclude flag).
4572 */
4573 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004574
4575 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004576 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004577 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004578 * persisted across device reboots until explicitly revoked with
4579 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4580 * grant for possible persisting; the receiving application must call
4581 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4582 * actually persist.
4583 *
4584 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4585 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4586 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004587 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004588 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004589 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004590
4591 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004592 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4593 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4594 * applies to any URI that is a prefix match against the original granted
4595 * URI. (Without this flag, the URI must match exactly for access to be
4596 * granted.) Another URI is considered a prefix match only when scheme,
4597 * authority, and all path segments defined by the prefix are an exact
4598 * match.
4599 */
4600 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4601
4602 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004603 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004604 * homework and verified that they correctly handle packages and components
4605 * that come and go over time. In particular:
4606 * <ul>
4607 * <li>Apps installed on external storage, which will appear to be
4608 * uninstalled while the the device is ejected.
4609 * <li>Apps with encryption unaware components, which will appear to not
4610 * exist while the device is locked.
4611 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004612 *
4613 * @hide
4614 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004615 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004616
4617 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07004618 * Internal flag used to indicate ephemeral applications should not be
4619 * considered when resolving the intent.
4620 *
4621 * @hide
4622 */
4623 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4624
4625 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004626 * If set, the new activity is not kept in the history stack. As soon as
4627 * the user navigates away from it, the activity is finished. This may also
4628 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4629 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004630 *
4631 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4632 * is never invoked when the current activity starts a new activity which
4633 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004634 */
4635 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4636 /**
4637 * If set, the activity will not be launched if it is already running
4638 * at the top of the history stack.
4639 */
4640 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4641 /**
4642 * If set, this activity will become the start of a new task on this
4643 * history stack. A task (from the activity that started it to the
4644 * next task activity) defines an atomic group of activities that the
4645 * user can move to. Tasks can be moved to the foreground and background;
4646 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004647 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004648 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4649 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004650 *
4651 * <p>This flag is generally used by activities that want
4652 * to present a "launcher" style behavior: they give the user a list of
4653 * separate things that can be done, which otherwise run completely
4654 * independently of the activity launching them.
4655 *
4656 * <p>When using this flag, if a task is already running for the activity
4657 * you are now starting, then a new activity will not be started; instead,
4658 * the current task will simply be brought to the front of the screen with
4659 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4660 * to disable this behavior.
4661 *
4662 * <p>This flag can not be used when the caller is requesting a result from
4663 * the activity being launched.
4664 */
4665 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4666 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004667 * This flag is used to create a new task and launch an activity into it.
4668 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4669 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4670 * search through existing tasks for ones matching this Intent. Only if no such
4671 * task is found would a new task be created. When paired with
4672 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4673 * the search for a matching task and unconditionally start a new task.
4674 *
4675 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4676 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004677 * top-level application launcher.</strong> Used in conjunction with
4678 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4679 * behavior of bringing an existing task to the foreground. When set,
4680 * a new task is <em>always</em> started to host the Activity for the
4681 * Intent, regardless of whether there is already an existing task running
4682 * the same thing.
4683 *
4684 * <p><strong>Because the default system does not include graphical task management,
4685 * you should not use this flag unless you provide some way for a user to
4686 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004687 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004688 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4689 * creating new document tasks.
4690 *
4691 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004692 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004693 *
Scott Main7aee61f2011-02-08 11:25:01 -08004694 * <p>See
4695 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4696 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004697 *
4698 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4699 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004700 */
4701 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4702 /**
4703 * If set, and the activity being launched is already running in the
4704 * current task, then instead of launching a new instance of that activity,
4705 * all of the other activities on top of it will be closed and this Intent
4706 * will be delivered to the (now on top) old activity as a new Intent.
4707 *
4708 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4709 * If D calls startActivity() with an Intent that resolves to the component
4710 * of activity B, then C and D will be finished and B receive the given
4711 * Intent, resulting in the stack now being: A, B.
4712 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004713 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004714 * either receive the new intent you are starting here in its
4715 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004716 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004717 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4718 * the same intent, then it will be finished and re-created; for all other
4719 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4720 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004721 *
4722 * <p>This launch mode can also be used to good effect in conjunction with
4723 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4724 * of a task, it will bring any currently running instance of that task
4725 * to the foreground, and then clear it to its root state. This is
4726 * especially useful, for example, when launching an activity from the
4727 * notification manager.
4728 *
Scott Main7aee61f2011-02-08 11:25:01 -08004729 * <p>See
4730 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4731 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004732 */
4733 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4734 /**
4735 * If set and this intent is being used to launch a new activity from an
4736 * existing one, then the reply target of the existing activity will be
4737 * transfered to the new activity. This way the new activity can call
4738 * {@link android.app.Activity#setResult} and have that result sent back to
4739 * the reply target of the original activity.
4740 */
4741 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4742 /**
4743 * If set and this intent is being used to launch a new activity from an
4744 * existing one, the current activity will not be counted as the top
4745 * activity for deciding whether the new intent should be delivered to
4746 * the top instead of starting a new one. The previous activity will
4747 * be used as the top, with the assumption being that the current activity
4748 * will finish itself immediately.
4749 */
4750 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4751 /**
4752 * If set, the new activity is not kept in the list of recently launched
4753 * activities.
4754 */
4755 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4756 /**
4757 * This flag is not normally set by application code, but set for you by
4758 * the system as described in the
4759 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4760 * launchMode} documentation for the singleTask mode.
4761 */
4762 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4763 /**
4764 * If set, and this activity is either being started in a new task or
4765 * bringing to the top an existing task, then it will be launched as
4766 * the front door of the task. This will result in the application of
4767 * any affinities needed to have that task in the proper state (either
4768 * moving activities to or from it), or simply resetting that task to
4769 * its initial state if needed.
4770 */
4771 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4772 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004773 * This flag is not normally set by application code, but set for you by
4774 * the system if this activity is being launched from history
4775 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004776 */
4777 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004778 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004779 * @deprecated As of API 21 this performs identically to
4780 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004781 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07004782 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004783 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004784 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004785 * This flag is used to open a document into a new task rooted at the activity launched
4786 * by this Intent. Through the use of this flag, or its equivalent attribute,
4787 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004788 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004789 *
Craig Mautner026596b2014-05-21 15:35:44 -07004790 * <p>The use of the activity attribute form of this,
4791 * {@link android.R.attr#documentLaunchMode}, is
4792 * preferred over the Intent flag described here. The attribute form allows the
4793 * Activity to specify multiple document behavior for all launchers of the Activity
4794 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004795 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004796 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4797 * it is kept after the activity is finished is different than the use of
4798 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4799 * this flag is being used to create a new recents entry, then by default that entry
4800 * will be removed once the activity is finished. You can modify this behavior with
4801 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4802 *
Craig Mautner026596b2014-05-21 15:35:44 -07004803 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4804 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4805 * equivalent of the Activity manifest specifying {@link
4806 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4807 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4808 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004809 *
Craig Mautner026596b2014-05-21 15:35:44 -07004810 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004811 *
Craig Mautner026596b2014-05-21 15:35:44 -07004812 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004813 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4814 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004815 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004816 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004817 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004818 * callback from occurring on the current frontmost activity before it is
4819 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004820 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004821 * <p>Typically, an activity can rely on that callback to indicate that an
4822 * explicit user action has caused their activity to be moved out of the
4823 * foreground. The callback marks an appropriate point in the activity's
4824 * lifecycle for it to dismiss any notifications that it intends to display
4825 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004826 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004827 * <p>If an activity is ever started via any non-user-driven events such as
4828 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4829 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004830 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004831 */
4832 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004833 /**
4834 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4835 * this flag will cause the launched activity to be brought to the front of its
4836 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004837 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004838 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4839 * If D calls startActivity() with an Intent that resolves to the component
4840 * of activity B, then B will be brought to the front of the history stack,
4841 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004842 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004843 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004844 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004845 */
4846 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004847 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004848 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4849 * this flag will prevent the system from applying an activity transition
4850 * animation to go to the next activity state. This doesn't mean an
4851 * animation will never run -- if another activity change happens that doesn't
4852 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004853 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004854 * when you are going to do a series of activity operations but the
4855 * animation seen by the user shouldn't be driven by the first activity
4856 * change but rather a later one.
4857 */
4858 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4859 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004860 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4861 * this flag will cause any existing task that would be associated with the
4862 * activity to be cleared before the activity is started. That is, the activity
4863 * becomes the new root of an otherwise empty task, and any old activities
4864 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4865 */
4866 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4867 /**
4868 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4869 * this flag will cause a newly launching task to be placed on top of the current
4870 * home activity task (if there is one). That is, pressing back from the task
4871 * will always return the user to home even if that was not the last activity they
4872 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4873 */
4874 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4875 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004876 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4877 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004878 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004879 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004880 * this flag. When set and the task's activity is finished, the recents
4881 * entry will remain in the interface for the user to re-launch it, like a
4882 * recents entry for a top-level application.
4883 * <p>
4884 * The receiving activity can override this request with
4885 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4886 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004887 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004888 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004889 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004890
4891 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004892 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4893 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004894 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4895 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004896 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004897 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004898
4899 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004900 * If set, when sending a broadcast only registered receivers will be
4901 * called -- no BroadcastReceiver components will be launched.
4902 */
4903 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004904 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004905 * If set, when sending a broadcast the new broadcast will replace
4906 * any existing pending broadcast that matches it. Matching is defined
4907 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4908 * true for the intents of the two broadcasts. When a match is found,
4909 * the new broadcast (and receivers associated with it) will replace the
4910 * existing one in the pending broadcast list, remaining at the same
4911 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004912 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004913 * <p>This flag is most typically used with sticky broadcasts, which
4914 * only care about delivering the most recent values of the broadcast
4915 * to their receivers.
4916 */
4917 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4918 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004919 * If set, when sending a broadcast the recipient is allowed to run at
4920 * foreground priority, with a shorter timeout interval. During normal
4921 * broadcasts the receivers are not automatically hoisted out of the
4922 * background priority class.
4923 */
4924 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4925 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004926 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4927 * They can still propagate results through to later receivers, but they can not prevent
4928 * later receivers from seeing the broadcast.
4929 */
4930 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4931 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004932 * If set, when sending a broadcast <i>before boot has completed</i> only
4933 * registered receivers will be called -- no BroadcastReceiver components
4934 * will be launched. Sticky intent state will be recorded properly even
4935 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4936 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004937 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004938 * <p>This flag is only for use by system sevices as a convenience to
4939 * avoid having to implement a more complex mechanism around detection
4940 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004941 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004942 * @hide
4943 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004944 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004945 /**
4946 * Set when this broadcast is for a boot upgrade, a special mode that
4947 * allows the broadcast to be sent before the system is ready and launches
4948 * the app process with no providers running in it.
4949 * @hide
4950 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004951 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004952 /**
4953 * If set, the broadcast will always go to manifest receivers in background (cached
4954 * or not running) apps, regardless of whether that would be done by default. By
4955 * default they will only receive broadcasts if the broadcast has specified an
4956 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08004957 *
4958 * NOTE: dumpstate uses this flag numerically, so when its value is changed
4959 * the broadcast code there must also be changed to match.
4960 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004961 * @hide
4962 */
4963 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4964 /**
4965 * If set, the broadcast will never go to manifest receivers in background (cached
4966 * or not running) apps, regardless of whether that would be done by default. By
4967 * default they will receive broadcasts if the broadcast has specified an
4968 * explicit component or package name.
4969 * @hide
4970 */
4971 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07004972 /**
4973 * If set, this broadcast is being sent from the shell.
4974 * @hide
4975 */
4976 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004977
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004978 /**
4979 * @hide Flags that can't be changed with PendingIntent.
4980 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004981 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4982 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4983 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004984
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004985 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004986 // ---------------------------------------------------------------------
4987 // toUri() and parseUri() options.
4988
4989 /**
4990 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4991 * always has the "intent:" scheme. This syntax can be used when you want
4992 * to later disambiguate between URIs that are intended to describe an
4993 * Intent vs. all others that should be treated as raw URIs. When used
4994 * with {@link #parseUri}, any other scheme will result in a generic
4995 * VIEW action for that raw URI.
4996 */
4997 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004998
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004999 /**
5000 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5001 * always has the "android-app:" scheme. This is a variation of
5002 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5003 * http/https URI being delivered to a specific package name. The format
5004 * is:
5005 *
5006 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005007 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005008 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005009 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5010 * you must also include a scheme; including a path also requires both a host and a scheme.
5011 * The final #Intent; fragment can be used without a scheme, host, or path.
5012 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005013 * used with intents that have a {@link #setSelector}, since the base intent
5014 * will always have an explicit package name.</p>
5015 *
5016 * <p>Some examples of how this scheme maps to Intent objects:</p>
5017 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5018 * <colgroup align="left" />
5019 * <colgroup align="left" />
5020 * <thead>
5021 * <tr><th>URI</th> <th>Intent</th></tr>
5022 * </thead>
5023 *
5024 * <tbody>
5025 * <tr><td><code>android-app://com.example.app</code></td>
5026 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5027 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5028 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5029 * </table></td>
5030 * </tr>
5031 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5032 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5033 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5034 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5035 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5036 * </table></td>
5037 * </tr>
5038 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5039 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5040 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5041 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5042 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5043 * </table></td>
5044 * </tr>
5045 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5046 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5047 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5048 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5049 * </table></td>
5050 * </tr>
5051 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5052 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5053 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5054 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5055 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5056 * </table></td>
5057 * </tr>
5058 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
5059 * <td><table border="" style="margin:0" >
5060 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5061 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5062 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5063 * </table></td>
5064 * </tr>
5065 * </tbody>
5066 * </table>
5067 */
5068 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5069
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005070 /**
5071 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5072 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5073 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5074 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5075 * generated Intent can not cause unexpected data access to happen.
5076 *
5077 * <p>If you do not trust the source of the URI being parsed, you should still do further
5078 * processing to protect yourself from it. In particular, when using it to start an
5079 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5080 * that can handle it.</p>
5081 */
5082 public static final int URI_ALLOW_UNSAFE = 1<<2;
5083
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005084 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005085
5086 private String mAction;
5087 private Uri mData;
5088 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005089 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005090 private ComponentName mComponent;
5091 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005092 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005093 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005094 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005095 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005096 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005097 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005098
5099 // ---------------------------------------------------------------------
5100
5101 /**
5102 * Create an empty intent.
5103 */
5104 public Intent() {
5105 }
5106
5107 /**
5108 * Copy constructor.
5109 */
5110 public Intent(Intent o) {
5111 this.mAction = o.mAction;
5112 this.mData = o.mData;
5113 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005114 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005115 this.mComponent = o.mComponent;
5116 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005117 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005118 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005119 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005120 }
5121 if (o.mExtras != null) {
5122 this.mExtras = new Bundle(o.mExtras);
5123 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005124 if (o.mSourceBounds != null) {
5125 this.mSourceBounds = new Rect(o.mSourceBounds);
5126 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005127 if (o.mSelector != null) {
5128 this.mSelector = new Intent(o.mSelector);
5129 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005130 if (o.mClipData != null) {
5131 this.mClipData = new ClipData(o.mClipData);
5132 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005133 }
5134
5135 @Override
5136 public Object clone() {
5137 return new Intent(this);
5138 }
5139
5140 private Intent(Intent o, boolean all) {
5141 this.mAction = o.mAction;
5142 this.mData = o.mData;
5143 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005144 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005145 this.mComponent = o.mComponent;
5146 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005147 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005148 }
5149 }
5150
5151 /**
5152 * Make a clone of only the parts of the Intent that are relevant for
5153 * filter matching: the action, data, type, component, and categories.
5154 */
5155 public Intent cloneFilter() {
5156 return new Intent(this, false);
5157 }
5158
5159 /**
5160 * Create an intent with a given action. All other fields (data, type,
5161 * class) are null. Note that the action <em>must</em> be in a
5162 * namespace because Intents are used globally in the system -- for
5163 * example the system VIEW action is android.intent.action.VIEW; an
5164 * application's custom action would be something like
5165 * com.google.app.myapp.CUSTOM_ACTION.
5166 *
5167 * @param action The Intent action, such as ACTION_VIEW.
5168 */
5169 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005170 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005171 }
5172
5173 /**
5174 * Create an intent with a given action and for a given data url. Note
5175 * that the action <em>must</em> be in a namespace because Intents are
5176 * used globally in the system -- for example the system VIEW action is
5177 * android.intent.action.VIEW; an application's custom action would be
5178 * something like com.google.app.myapp.CUSTOM_ACTION.
5179 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005180 * <p><em>Note: scheme and host name matching in the Android framework is
5181 * case-sensitive, unlike the formal RFC. As a result,
5182 * you should always ensure that you write your Uri with these elements
5183 * using lower case letters, and normalize any Uris you receive from
5184 * outside of Android to ensure the scheme and host is lower case.</em></p>
5185 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005186 * @param action The Intent action, such as ACTION_VIEW.
5187 * @param uri The Intent data URI.
5188 */
5189 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005190 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005191 mData = uri;
5192 }
5193
5194 /**
5195 * Create an intent for a specific component. All other fields (action, data,
5196 * type, class) are null, though they can be modified later with explicit
5197 * calls. This provides a convenient way to create an intent that is
5198 * intended to execute a hard-coded class name, rather than relying on the
5199 * system to find an appropriate class for you; see {@link #setComponent}
5200 * for more information on the repercussions of this.
5201 *
5202 * @param packageContext A Context of the application package implementing
5203 * this class.
5204 * @param cls The component class that is to be used for the intent.
5205 *
5206 * @see #setClass
5207 * @see #setComponent
5208 * @see #Intent(String, android.net.Uri , Context, Class)
5209 */
5210 public Intent(Context packageContext, Class<?> cls) {
5211 mComponent = new ComponentName(packageContext, cls);
5212 }
5213
5214 /**
5215 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07005216 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005217 * construct the Intent and then calling {@link #setClass} to set its
5218 * class.
5219 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005220 * <p><em>Note: scheme and host name matching in the Android framework is
5221 * case-sensitive, unlike the formal RFC. As a result,
5222 * you should always ensure that you write your Uri with these elements
5223 * using lower case letters, and normalize any Uris you receive from
5224 * outside of Android to ensure the scheme and host is lower case.</em></p>
5225 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005226 * @param action The Intent action, such as ACTION_VIEW.
5227 * @param uri The Intent data URI.
5228 * @param packageContext A Context of the application package implementing
5229 * this class.
5230 * @param cls The component class that is to be used for the intent.
5231 *
5232 * @see #Intent(String, android.net.Uri)
5233 * @see #Intent(Context, Class)
5234 * @see #setClass
5235 * @see #setComponent
5236 */
5237 public Intent(String action, Uri uri,
5238 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005239 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005240 mData = uri;
5241 mComponent = new ComponentName(packageContext, cls);
5242 }
5243
5244 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005245 * Create an intent to launch the main (root) activity of a task. This
5246 * is the Intent that is started when the application's is launched from
5247 * Home. For anything else that wants to launch an application in the
5248 * same way, it is important that they use an Intent structured the same
5249 * way, and can use this function to ensure this is the case.
5250 *
5251 * <p>The returned Intent has the given Activity component as its explicit
5252 * component, {@link #ACTION_MAIN} as its action, and includes the
5253 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5254 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5255 * to do that through {@link #addFlags(int)} on the returned Intent.
5256 *
5257 * @param mainActivity The main activity component that this Intent will
5258 * launch.
5259 * @return Returns a newly created Intent that can be used to launch the
5260 * activity as a main application entry.
5261 *
5262 * @see #setClass
5263 * @see #setComponent
5264 */
5265 public static Intent makeMainActivity(ComponentName mainActivity) {
5266 Intent intent = new Intent(ACTION_MAIN);
5267 intent.setComponent(mainActivity);
5268 intent.addCategory(CATEGORY_LAUNCHER);
5269 return intent;
5270 }
5271
5272 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005273 * Make an Intent for the main activity of an application, without
5274 * specifying a specific activity to run but giving a selector to find
5275 * the activity. This results in a final Intent that is structured
5276 * the same as when the application is launched from
5277 * Home. For anything else that wants to launch an application in the
5278 * same way, it is important that they use an Intent structured the same
5279 * way, and can use this function to ensure this is the case.
5280 *
5281 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5282 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
5283 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5284 * to do that through {@link #addFlags(int)} on the returned Intent.
5285 *
5286 * @param selectorAction The action name of the Intent's selector.
5287 * @param selectorCategory The name of a category to add to the Intent's
5288 * selector.
5289 * @return Returns a newly created Intent that can be used to launch the
5290 * activity as a main application entry.
5291 *
5292 * @see #setSelector(Intent)
5293 */
5294 public static Intent makeMainSelectorActivity(String selectorAction,
5295 String selectorCategory) {
5296 Intent intent = new Intent(ACTION_MAIN);
5297 intent.addCategory(CATEGORY_LAUNCHER);
5298 Intent selector = new Intent();
5299 selector.setAction(selectorAction);
5300 selector.addCategory(selectorCategory);
5301 intent.setSelector(selector);
5302 return intent;
5303 }
5304
5305 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08005306 * Make an Intent that can be used to re-launch an application's task
5307 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
5308 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5309 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5310 *
5311 * @param mainActivity The activity component that is the root of the
5312 * task; this is the activity that has been published in the application's
5313 * manifest as the main launcher icon.
5314 *
5315 * @return Returns a newly created Intent that can be used to relaunch the
5316 * activity's task in its root state.
5317 */
5318 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5319 Intent intent = makeMainActivity(mainActivity);
5320 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5321 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5322 return intent;
5323 }
5324
5325 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005326 * Call {@link #parseUri} with 0 flags.
5327 * @deprecated Use {@link #parseUri} instead.
5328 */
5329 @Deprecated
5330 public static Intent getIntent(String uri) throws URISyntaxException {
5331 return parseUri(uri, 0);
5332 }
Tom Taylord4a47292009-12-21 13:59:18 -08005333
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005334 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005335 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005336 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07005337 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005338 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005339 *
5340 * <p>The URI given here must not be relative -- that is, it must include
5341 * the scheme and full path.
5342 *
5343 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005344 * @param flags Additional processing flags. Either 0,
5345 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005346 *
5347 * @return Intent The newly created Intent object.
5348 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005349 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5350 * it bad (as parsed by the Uri class) or the Intent data within the
5351 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005352 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005353 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005354 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005355 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005356 int i = 0;
5357 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005358 final boolean androidApp = uri.startsWith("android-app:");
5359
5360 // Validate intent scheme if requested.
5361 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5362 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005363 Intent intent = new Intent(ACTION_VIEW);
5364 try {
5365 intent.setData(Uri.parse(uri));
5366 } catch (IllegalArgumentException e) {
5367 throw new URISyntaxException(uri, e.getMessage());
5368 }
5369 return intent;
5370 }
5371 }
Tom Taylord4a47292009-12-21 13:59:18 -08005372
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005373 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005374 // simple case
5375 if (i == -1) {
5376 if (!androidApp) {
5377 return new Intent(ACTION_VIEW, Uri.parse(uri));
5378 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005379
5380 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005381 } else if (!uri.startsWith("#Intent;", i)) {
5382 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005383 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005384 } else {
5385 i = -1;
5386 }
5387 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005388
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005389 // new format
5390 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005391 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005392 boolean explicitAction = false;
5393 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005394
5395 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005396 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005397 String data;
5398 if (i >= 0) {
5399 data = uri.substring(0, i);
5400 i += 8; // length of "#Intent;"
5401 } else {
5402 data = uri;
5403 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005404
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005405 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005406 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005407 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005408 if (eq < 0) eq = i-1;
5409 int semi = uri.indexOf(';', i);
5410 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005411
5412 // action
5413 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005414 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005415 if (!inSelector) {
5416 explicitAction = true;
5417 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005418 }
5419
5420 // categories
5421 else if (uri.startsWith("category=", i)) {
5422 intent.addCategory(value);
5423 }
5424
5425 // type
5426 else if (uri.startsWith("type=", i)) {
5427 intent.mType = value;
5428 }
5429
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005430 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005431 else if (uri.startsWith("launchFlags=", i)) {
5432 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005433 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5434 intent.mFlags &= ~IMMUTABLE_FLAGS;
5435 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005436 }
5437
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005438 // package
5439 else if (uri.startsWith("package=", i)) {
5440 intent.mPackage = value;
5441 }
5442
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005443 // component
5444 else if (uri.startsWith("component=", i)) {
5445 intent.mComponent = ComponentName.unflattenFromString(value);
5446 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005447
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005448 // scheme
5449 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005450 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005451 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005452 } else {
5453 scheme = value;
5454 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005455 }
5456
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005457 // source bounds
5458 else if (uri.startsWith("sourceBounds=", i)) {
5459 intent.mSourceBounds = Rect.unflattenFromString(value);
5460 }
5461
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005462 // selector
5463 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5464 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005465 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005466 }
5467
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005468 // extra
5469 else {
5470 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005471 // create Bundle if it doesn't already exist
5472 if (intent.mExtras == null) intent.mExtras = new Bundle();
5473 Bundle b = intent.mExtras;
5474 // add EXTRA
5475 if (uri.startsWith("S.", i)) b.putString(key, value);
5476 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5477 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5478 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5479 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5480 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5481 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5482 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5483 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5484 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5485 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005486
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005487 // move to the next item
5488 i = semi + 1;
5489 }
5490
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005491 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005492 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005493 if (baseIntent.mPackage == null) {
5494 baseIntent.setSelector(intent);
5495 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005496 intent = baseIntent;
5497 }
5498
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005499 if (data != null) {
5500 if (data.startsWith("intent:")) {
5501 data = data.substring(7);
5502 if (scheme != null) {
5503 data = scheme + ':' + data;
5504 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005505 } else if (data.startsWith("android-app:")) {
5506 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5507 // Correctly formed android-app, first part is package name.
5508 int end = data.indexOf('/', 14);
5509 if (end < 0) {
5510 // All we have is a package name.
5511 intent.mPackage = data.substring(14);
5512 if (!explicitAction) {
5513 intent.setAction(ACTION_MAIN);
5514 }
5515 data = "";
5516 } else {
5517 // Target the Intent at the given package name always.
5518 String authority = null;
5519 intent.mPackage = data.substring(14, end);
5520 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005521 if ((end+1) < data.length()) {
5522 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5523 // Found a scheme, remember it.
5524 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005525 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005526 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5527 // Found a authority, remember it.
5528 authority = data.substring(end+1, newEnd);
5529 end = newEnd;
5530 }
5531 } else {
5532 // All we have is a scheme.
5533 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005534 }
5535 }
5536 if (scheme == null) {
5537 // If there was no scheme, then this just targets the package.
5538 if (!explicitAction) {
5539 intent.setAction(ACTION_MAIN);
5540 }
5541 data = "";
5542 } else if (authority == null) {
5543 data = scheme + ":";
5544 } else {
5545 data = scheme + "://" + authority + data.substring(end);
5546 }
5547 }
5548 } else {
5549 data = "";
5550 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005551 }
Tom Taylord4a47292009-12-21 13:59:18 -08005552
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005553 if (data.length() > 0) {
5554 try {
5555 intent.mData = Uri.parse(data);
5556 } catch (IllegalArgumentException e) {
5557 throw new URISyntaxException(uri, e.getMessage());
5558 }
5559 }
5560 }
Tom Taylord4a47292009-12-21 13:59:18 -08005561
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005562 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005563
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005564 } catch (IndexOutOfBoundsException e) {
5565 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5566 }
5567 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005568
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005569 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005570 return getIntentOld(uri, 0);
5571 }
5572
5573 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005574 Intent intent;
5575
5576 int i = uri.lastIndexOf('#');
5577 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005578 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005579 final int intentFragmentStart = i;
5580 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005581
5582 i++;
5583
5584 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005585 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005586 i += 7;
5587 int j = uri.indexOf(')', i);
5588 action = uri.substring(i, j);
5589 i = j + 1;
5590 }
5591
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005592 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005593
5594 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005595 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005596 i += 11;
5597 int j = uri.indexOf(')', i);
5598 while (i < j) {
5599 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005600 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005601 if (i < sep) {
5602 intent.addCategory(uri.substring(i, sep));
5603 }
5604 i = sep + 1;
5605 }
5606 i = j + 1;
5607 }
5608
5609 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005610 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005611 i += 5;
5612 int j = uri.indexOf(')', i);
5613 intent.mType = uri.substring(i, j);
5614 i = j + 1;
5615 }
5616
5617 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005618 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005619 i += 12;
5620 int j = uri.indexOf(')', i);
5621 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005622 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5623 intent.mFlags &= ~IMMUTABLE_FLAGS;
5624 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005625 i = j + 1;
5626 }
5627
5628 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005629 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005630 i += 10;
5631 int j = uri.indexOf(')', i);
5632 int sep = uri.indexOf('!', i);
5633 if (sep >= 0 && sep < j) {
5634 String pkg = uri.substring(i, sep);
5635 String cls = uri.substring(sep + 1, j);
5636 intent.mComponent = new ComponentName(pkg, cls);
5637 }
5638 i = j + 1;
5639 }
5640
5641 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005642 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005643 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005645 final int closeParen = uri.indexOf(')', i);
5646 if (closeParen == -1) throw new URISyntaxException(uri,
5647 "EXTRA missing trailing ')'", i);
5648
5649 while (i < closeParen) {
5650 // fetch the key value
5651 int j = uri.indexOf('=', i);
5652 if (j <= i + 1 || i >= closeParen) {
5653 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5654 }
5655 char type = uri.charAt(i);
5656 i++;
5657 String key = uri.substring(i, j);
5658 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005660 // get type-value
5661 j = uri.indexOf('!', i);
5662 if (j == -1 || j >= closeParen) j = closeParen;
5663 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5664 String value = uri.substring(i, j);
5665 i = j;
5666
5667 // create Bundle if it doesn't already exist
5668 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005669
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005670 // add item to bundle
5671 try {
5672 switch (type) {
5673 case 'S':
5674 intent.mExtras.putString(key, Uri.decode(value));
5675 break;
5676 case 'B':
5677 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5678 break;
5679 case 'b':
5680 intent.mExtras.putByte(key, Byte.parseByte(value));
5681 break;
5682 case 'c':
5683 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5684 break;
5685 case 'd':
5686 intent.mExtras.putDouble(key, Double.parseDouble(value));
5687 break;
5688 case 'f':
5689 intent.mExtras.putFloat(key, Float.parseFloat(value));
5690 break;
5691 case 'i':
5692 intent.mExtras.putInt(key, Integer.parseInt(value));
5693 break;
5694 case 'l':
5695 intent.mExtras.putLong(key, Long.parseLong(value));
5696 break;
5697 case 's':
5698 intent.mExtras.putShort(key, Short.parseShort(value));
5699 break;
5700 default:
5701 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5702 }
5703 } catch (NumberFormatException e) {
5704 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5705 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005706
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005707 char ch = uri.charAt(i);
5708 if (ch == ')') break;
5709 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5710 i++;
5711 }
5712 }
5713
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005714 if (isIntentFragment) {
5715 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5716 } else {
5717 intent.mData = Uri.parse(uri);
5718 }
Tom Taylord4a47292009-12-21 13:59:18 -08005719
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005720 if (intent.mAction == null) {
5721 // By default, if no action is specified, then use VIEW.
5722 intent.mAction = ACTION_VIEW;
5723 }
5724
5725 } else {
5726 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5727 }
5728
5729 return intent;
5730 }
5731
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005732 /** @hide */
5733 public interface CommandOptionHandler {
5734 boolean handleOption(String opt, ShellCommand cmd);
5735 }
5736
5737 /** @hide */
5738 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5739 throws URISyntaxException {
5740 Intent intent = new Intent();
5741 Intent baseIntent = intent;
5742 boolean hasIntentInfo = false;
5743
5744 Uri data = null;
5745 String type = null;
5746
5747 String opt;
5748 while ((opt=cmd.getNextOption()) != null) {
5749 switch (opt) {
5750 case "-a":
5751 intent.setAction(cmd.getNextArgRequired());
5752 if (intent == baseIntent) {
5753 hasIntentInfo = true;
5754 }
5755 break;
5756 case "-d":
5757 data = Uri.parse(cmd.getNextArgRequired());
5758 if (intent == baseIntent) {
5759 hasIntentInfo = true;
5760 }
5761 break;
5762 case "-t":
5763 type = cmd.getNextArgRequired();
5764 if (intent == baseIntent) {
5765 hasIntentInfo = true;
5766 }
5767 break;
5768 case "-c":
5769 intent.addCategory(cmd.getNextArgRequired());
5770 if (intent == baseIntent) {
5771 hasIntentInfo = true;
5772 }
5773 break;
5774 case "-e":
5775 case "--es": {
5776 String key = cmd.getNextArgRequired();
5777 String value = cmd.getNextArgRequired();
5778 intent.putExtra(key, value);
5779 }
5780 break;
5781 case "--esn": {
5782 String key = cmd.getNextArgRequired();
5783 intent.putExtra(key, (String) null);
5784 }
5785 break;
5786 case "--ei": {
5787 String key = cmd.getNextArgRequired();
5788 String value = cmd.getNextArgRequired();
5789 intent.putExtra(key, Integer.decode(value));
5790 }
5791 break;
5792 case "--eu": {
5793 String key = cmd.getNextArgRequired();
5794 String value = cmd.getNextArgRequired();
5795 intent.putExtra(key, Uri.parse(value));
5796 }
5797 break;
5798 case "--ecn": {
5799 String key = cmd.getNextArgRequired();
5800 String value = cmd.getNextArgRequired();
5801 ComponentName cn = ComponentName.unflattenFromString(value);
5802 if (cn == null)
5803 throw new IllegalArgumentException("Bad component name: " + value);
5804 intent.putExtra(key, cn);
5805 }
5806 break;
5807 case "--eia": {
5808 String key = cmd.getNextArgRequired();
5809 String value = cmd.getNextArgRequired();
5810 String[] strings = value.split(",");
5811 int[] list = new int[strings.length];
5812 for (int i = 0; i < strings.length; i++) {
5813 list[i] = Integer.decode(strings[i]);
5814 }
5815 intent.putExtra(key, list);
5816 }
5817 break;
5818 case "--eial": {
5819 String key = cmd.getNextArgRequired();
5820 String value = cmd.getNextArgRequired();
5821 String[] strings = value.split(",");
5822 ArrayList<Integer> list = new ArrayList<>(strings.length);
5823 for (int i = 0; i < strings.length; i++) {
5824 list.add(Integer.decode(strings[i]));
5825 }
5826 intent.putExtra(key, list);
5827 }
5828 break;
5829 case "--el": {
5830 String key = cmd.getNextArgRequired();
5831 String value = cmd.getNextArgRequired();
5832 intent.putExtra(key, Long.valueOf(value));
5833 }
5834 break;
5835 case "--ela": {
5836 String key = cmd.getNextArgRequired();
5837 String value = cmd.getNextArgRequired();
5838 String[] strings = value.split(",");
5839 long[] list = new long[strings.length];
5840 for (int i = 0; i < strings.length; i++) {
5841 list[i] = Long.valueOf(strings[i]);
5842 }
5843 intent.putExtra(key, list);
5844 hasIntentInfo = true;
5845 }
5846 break;
5847 case "--elal": {
5848 String key = cmd.getNextArgRequired();
5849 String value = cmd.getNextArgRequired();
5850 String[] strings = value.split(",");
5851 ArrayList<Long> list = new ArrayList<>(strings.length);
5852 for (int i = 0; i < strings.length; i++) {
5853 list.add(Long.valueOf(strings[i]));
5854 }
5855 intent.putExtra(key, list);
5856 hasIntentInfo = true;
5857 }
5858 break;
5859 case "--ef": {
5860 String key = cmd.getNextArgRequired();
5861 String value = cmd.getNextArgRequired();
5862 intent.putExtra(key, Float.valueOf(value));
5863 hasIntentInfo = true;
5864 }
5865 break;
5866 case "--efa": {
5867 String key = cmd.getNextArgRequired();
5868 String value = cmd.getNextArgRequired();
5869 String[] strings = value.split(",");
5870 float[] list = new float[strings.length];
5871 for (int i = 0; i < strings.length; i++) {
5872 list[i] = Float.valueOf(strings[i]);
5873 }
5874 intent.putExtra(key, list);
5875 hasIntentInfo = true;
5876 }
5877 break;
5878 case "--efal": {
5879 String key = cmd.getNextArgRequired();
5880 String value = cmd.getNextArgRequired();
5881 String[] strings = value.split(",");
5882 ArrayList<Float> list = new ArrayList<>(strings.length);
5883 for (int i = 0; i < strings.length; i++) {
5884 list.add(Float.valueOf(strings[i]));
5885 }
5886 intent.putExtra(key, list);
5887 hasIntentInfo = true;
5888 }
5889 break;
5890 case "--esa": {
5891 String key = cmd.getNextArgRequired();
5892 String value = cmd.getNextArgRequired();
5893 // Split on commas unless they are preceeded by an escape.
5894 // The escape character must be escaped for the string and
5895 // again for the regex, thus four escape characters become one.
5896 String[] strings = value.split("(?<!\\\\),");
5897 intent.putExtra(key, strings);
5898 hasIntentInfo = true;
5899 }
5900 break;
5901 case "--esal": {
5902 String key = cmd.getNextArgRequired();
5903 String value = cmd.getNextArgRequired();
5904 // Split on commas unless they are preceeded by an escape.
5905 // The escape character must be escaped for the string and
5906 // again for the regex, thus four escape characters become one.
5907 String[] strings = value.split("(?<!\\\\),");
5908 ArrayList<String> list = new ArrayList<>(strings.length);
5909 for (int i = 0; i < strings.length; i++) {
5910 list.add(strings[i]);
5911 }
5912 intent.putExtra(key, list);
5913 hasIntentInfo = true;
5914 }
5915 break;
5916 case "--ez": {
5917 String key = cmd.getNextArgRequired();
5918 String value = cmd.getNextArgRequired().toLowerCase();
5919 // Boolean.valueOf() results in false for anything that is not "true", which is
5920 // error-prone in shell commands
5921 boolean arg;
5922 if ("true".equals(value) || "t".equals(value)) {
5923 arg = true;
5924 } else if ("false".equals(value) || "f".equals(value)) {
5925 arg = false;
5926 } else {
5927 try {
5928 arg = Integer.decode(value) != 0;
5929 } catch (NumberFormatException ex) {
5930 throw new IllegalArgumentException("Invalid boolean value: " + value);
5931 }
5932 }
5933
5934 intent.putExtra(key, arg);
5935 }
5936 break;
5937 case "-n": {
5938 String str = cmd.getNextArgRequired();
5939 ComponentName cn = ComponentName.unflattenFromString(str);
5940 if (cn == null)
5941 throw new IllegalArgumentException("Bad component name: " + str);
5942 intent.setComponent(cn);
5943 if (intent == baseIntent) {
5944 hasIntentInfo = true;
5945 }
5946 }
5947 break;
5948 case "-p": {
5949 String str = cmd.getNextArgRequired();
5950 intent.setPackage(str);
5951 if (intent == baseIntent) {
5952 hasIntentInfo = true;
5953 }
5954 }
5955 break;
5956 case "-f":
5957 String str = cmd.getNextArgRequired();
5958 intent.setFlags(Integer.decode(str).intValue());
5959 break;
5960 case "--grant-read-uri-permission":
5961 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5962 break;
5963 case "--grant-write-uri-permission":
5964 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5965 break;
5966 case "--grant-persistable-uri-permission":
5967 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5968 break;
5969 case "--grant-prefix-uri-permission":
5970 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5971 break;
5972 case "--exclude-stopped-packages":
5973 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5974 break;
5975 case "--include-stopped-packages":
5976 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5977 break;
5978 case "--debug-log-resolution":
5979 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5980 break;
5981 case "--activity-brought-to-front":
5982 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5983 break;
5984 case "--activity-clear-top":
5985 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5986 break;
5987 case "--activity-clear-when-task-reset":
5988 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5989 break;
5990 case "--activity-exclude-from-recents":
5991 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5992 break;
5993 case "--activity-launched-from-history":
5994 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5995 break;
5996 case "--activity-multiple-task":
5997 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5998 break;
5999 case "--activity-no-animation":
6000 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6001 break;
6002 case "--activity-no-history":
6003 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6004 break;
6005 case "--activity-no-user-action":
6006 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6007 break;
6008 case "--activity-previous-is-top":
6009 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6010 break;
6011 case "--activity-reorder-to-front":
6012 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6013 break;
6014 case "--activity-reset-task-if-needed":
6015 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6016 break;
6017 case "--activity-single-top":
6018 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6019 break;
6020 case "--activity-clear-task":
6021 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6022 break;
6023 case "--activity-task-on-home":
6024 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6025 break;
6026 case "--receiver-registered-only":
6027 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6028 break;
6029 case "--receiver-replace-pending":
6030 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6031 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006032 case "--receiver-foreground":
6033 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6034 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006035 case "--receiver-no-abort":
6036 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6037 break;
6038 case "--receiver-include-background":
6039 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6040 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006041 case "--selector":
6042 intent.setDataAndType(data, type);
6043 intent = new Intent();
6044 break;
6045 default:
6046 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6047 // Okay, caller handled this option.
6048 } else {
6049 throw new IllegalArgumentException("Unknown option: " + opt);
6050 }
6051 break;
6052 }
6053 }
6054 intent.setDataAndType(data, type);
6055
6056 final boolean hasSelector = intent != baseIntent;
6057 if (hasSelector) {
6058 // A selector was specified; fix up.
6059 baseIntent.setSelector(intent);
6060 intent = baseIntent;
6061 }
6062
6063 String arg = cmd.getNextArg();
6064 baseIntent = null;
6065 if (arg == null) {
6066 if (hasSelector) {
6067 // If a selector has been specified, and no arguments
6068 // have been supplied for the main Intent, then we can
6069 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6070 // need to have a component name specified yet, the
6071 // selector will take care of that.
6072 baseIntent = new Intent(Intent.ACTION_MAIN);
6073 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6074 }
6075 } else if (arg.indexOf(':') >= 0) {
6076 // The argument is a URI. Fully parse it, and use that result
6077 // to fill in any data not specified so far.
6078 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6079 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6080 } else if (arg.indexOf('/') >= 0) {
6081 // The argument is a component name. Build an Intent to launch
6082 // it.
6083 baseIntent = new Intent(Intent.ACTION_MAIN);
6084 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6085 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6086 } else {
6087 // Assume the argument is a package name.
6088 baseIntent = new Intent(Intent.ACTION_MAIN);
6089 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6090 baseIntent.setPackage(arg);
6091 }
6092 if (baseIntent != null) {
6093 Bundle extras = intent.getExtras();
6094 intent.replaceExtras((Bundle)null);
6095 Bundle uriExtras = baseIntent.getExtras();
6096 baseIntent.replaceExtras((Bundle)null);
6097 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6098 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6099 for (String c : cats) {
6100 baseIntent.removeCategory(c);
6101 }
6102 }
6103 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6104 if (extras == null) {
6105 extras = uriExtras;
6106 } else if (uriExtras != null) {
6107 uriExtras.putAll(extras);
6108 extras = uriExtras;
6109 }
6110 intent.replaceExtras(extras);
6111 hasIntentInfo = true;
6112 }
6113
6114 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6115 return intent;
6116 }
6117
6118 /** @hide */
6119 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6120 final String[] lines = new String[] {
6121 "<INTENT> specifications include these flags and arguments:",
6122 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6123 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6124 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6125 " [--esn <EXTRA_KEY> ...]",
6126 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6127 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6128 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6129 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6130 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6131 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6132 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6133 " (mutiple extras passed as Integer[])",
6134 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6135 " (mutiple extras passed as List<Integer>)",
6136 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6137 " (mutiple extras passed as Long[])",
6138 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6139 " (mutiple extras passed as List<Long>)",
6140 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6141 " (mutiple extras passed as Float[])",
6142 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6143 " (mutiple extras passed as List<Float>)",
6144 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6145 " (mutiple extras passed as String[]; to embed a comma into a string,",
6146 " escape it using \"\\,\")",
6147 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6148 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6149 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006150 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006151 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6152 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6153 " [--debug-log-resolution] [--exclude-stopped-packages]",
6154 " [--include-stopped-packages]",
6155 " [--activity-brought-to-front] [--activity-clear-top]",
6156 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6157 " [--activity-launched-from-history] [--activity-multiple-task]",
6158 " [--activity-no-animation] [--activity-no-history]",
6159 " [--activity-no-user-action] [--activity-previous-is-top]",
6160 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6161 " [--activity-single-top] [--activity-clear-task]",
6162 " [--activity-task-on-home]",
6163 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006164 " [--receiver-foreground] [--receiver-no-abort]",
6165 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006166 " [--selector]",
6167 " [<URI> | <PACKAGE> | <COMPONENT>]"
6168 };
6169 for (String line : lines) {
6170 pw.print(prefix);
6171 pw.println(line);
6172 }
6173 }
6174
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006175 /**
6176 * Retrieve the general action to be performed, such as
6177 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6178 * the information in the intent should be interpreted -- most importantly,
6179 * what to do with the data returned by {@link #getData}.
6180 *
6181 * @return The action of this intent or null if none is specified.
6182 *
6183 * @see #setAction
6184 */
6185 public String getAction() {
6186 return mAction;
6187 }
6188
6189 /**
6190 * Retrieve data this intent is operating on. This URI specifies the name
6191 * of the data; often it uses the content: scheme, specifying data in a
6192 * content provider. Other schemes may be handled by specific activities,
6193 * such as http: by the web browser.
6194 *
6195 * @return The URI of the data this intent is targeting or null.
6196 *
6197 * @see #getScheme
6198 * @see #setData
6199 */
6200 public Uri getData() {
6201 return mData;
6202 }
6203
6204 /**
6205 * The same as {@link #getData()}, but returns the URI as an encoded
6206 * String.
6207 */
6208 public String getDataString() {
6209 return mData != null ? mData.toString() : null;
6210 }
6211
6212 /**
6213 * Return the scheme portion of the intent's data. If the data is null or
6214 * does not include a scheme, null is returned. Otherwise, the scheme
6215 * prefix without the final ':' is returned, i.e. "http".
6216 *
6217 * <p>This is the same as calling getData().getScheme() (and checking for
6218 * null data).
6219 *
6220 * @return The scheme of this intent.
6221 *
6222 * @see #getData
6223 */
6224 public String getScheme() {
6225 return mData != null ? mData.getScheme() : null;
6226 }
6227
6228 /**
6229 * Retrieve any explicit MIME type included in the intent. This is usually
6230 * null, as the type is determined by the intent data.
6231 *
6232 * @return If a type was manually set, it is returned; else null is
6233 * returned.
6234 *
6235 * @see #resolveType(ContentResolver)
6236 * @see #setType
6237 */
6238 public String getType() {
6239 return mType;
6240 }
6241
6242 /**
6243 * Return the MIME data type of this intent. If the type field is
6244 * explicitly set, that is simply returned. Otherwise, if the data is set,
6245 * the type of that data is returned. If neither fields are set, a null is
6246 * returned.
6247 *
6248 * @return The MIME type of this intent.
6249 *
6250 * @see #getType
6251 * @see #resolveType(ContentResolver)
6252 */
6253 public String resolveType(Context context) {
6254 return resolveType(context.getContentResolver());
6255 }
6256
6257 /**
6258 * Return the MIME data type of this intent. If the type field is
6259 * explicitly set, that is simply returned. Otherwise, if the data is set,
6260 * the type of that data is returned. If neither fields are set, a null is
6261 * returned.
6262 *
6263 * @param resolver A ContentResolver that can be used to determine the MIME
6264 * type of the intent's data.
6265 *
6266 * @return The MIME type of this intent.
6267 *
6268 * @see #getType
6269 * @see #resolveType(Context)
6270 */
6271 public String resolveType(ContentResolver resolver) {
6272 if (mType != null) {
6273 return mType;
6274 }
6275 if (mData != null) {
6276 if ("content".equals(mData.getScheme())) {
6277 return resolver.getType(mData);
6278 }
6279 }
6280 return null;
6281 }
6282
6283 /**
6284 * Return the MIME data type of this intent, only if it will be needed for
6285 * intent resolution. This is not generally useful for application code;
6286 * it is used by the frameworks for communicating with back-end system
6287 * services.
6288 *
6289 * @param resolver A ContentResolver that can be used to determine the MIME
6290 * type of the intent's data.
6291 *
6292 * @return The MIME type of this intent, or null if it is unknown or not
6293 * needed.
6294 */
6295 public String resolveTypeIfNeeded(ContentResolver resolver) {
6296 if (mComponent != null) {
6297 return mType;
6298 }
6299 return resolveType(resolver);
6300 }
6301
6302 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006303 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006304 *
6305 * @param category The category to check.
6306 *
6307 * @return boolean True if the intent contains the category, else false.
6308 *
6309 * @see #getCategories
6310 * @see #addCategory
6311 */
6312 public boolean hasCategory(String category) {
6313 return mCategories != null && mCategories.contains(category);
6314 }
6315
6316 /**
6317 * Return the set of all categories in the intent. If there are no categories,
6318 * returns NULL.
6319 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006320 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006321 *
6322 * @see #hasCategory
6323 * @see #addCategory
6324 */
6325 public Set<String> getCategories() {
6326 return mCategories;
6327 }
6328
6329 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006330 * Return the specific selector associated with this Intent. If there is
6331 * none, returns null. See {@link #setSelector} for more information.
6332 *
6333 * @see #setSelector
6334 */
6335 public Intent getSelector() {
6336 return mSelector;
6337 }
6338
6339 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006340 * Return the {@link ClipData} associated with this Intent. If there is
6341 * none, returns null. See {@link #setClipData} for more information.
6342 *
John Spurlock125d1332013-11-25 11:58:37 -05006343 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006344 */
6345 public ClipData getClipData() {
6346 return mClipData;
6347 }
6348
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006349 /** @hide */
6350 public int getContentUserHint() {
6351 return mContentUserHint;
6352 }
6353
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006354 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006355 * Sets the ClassLoader that will be used when unmarshalling
6356 * any Parcelable values from the extras of this Intent.
6357 *
6358 * @param loader a ClassLoader, or null to use the default loader
6359 * at the time of unmarshalling.
6360 */
6361 public void setExtrasClassLoader(ClassLoader loader) {
6362 if (mExtras != null) {
6363 mExtras.setClassLoader(loader);
6364 }
6365 }
6366
6367 /**
6368 * Returns true if an extra value is associated with the given name.
6369 * @param name the extra's name
6370 * @return true if the given extra is present.
6371 */
6372 public boolean hasExtra(String name) {
6373 return mExtras != null && mExtras.containsKey(name);
6374 }
6375
6376 /**
6377 * Returns true if the Intent's extras contain a parcelled file descriptor.
6378 * @return true if the Intent contains a parcelled file descriptor.
6379 */
6380 public boolean hasFileDescriptors() {
6381 return mExtras != null && mExtras.hasFileDescriptors();
6382 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006383
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006384 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006385 public void setAllowFds(boolean allowFds) {
6386 if (mExtras != null) {
6387 mExtras.setAllowFds(allowFds);
6388 }
6389 }
6390
Jeff Sharkeyd136e512016-03-09 22:30:56 -07006391 /** {@hide} */
6392 public void setDefusable(boolean defusable) {
6393 if (mExtras != null) {
6394 mExtras.setDefusable(defusable);
6395 }
6396 }
6397
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006398 /**
6399 * Retrieve extended data from the intent.
6400 *
6401 * @param name The name of the desired item.
6402 *
6403 * @return the value of an item that previously added with putExtra()
6404 * or null if none was found.
6405 *
6406 * @deprecated
6407 * @hide
6408 */
6409 @Deprecated
6410 public Object getExtra(String name) {
6411 return getExtra(name, null);
6412 }
6413
6414 /**
6415 * Retrieve extended data from the intent.
6416 *
6417 * @param name The name of the desired item.
6418 * @param defaultValue the value to be returned if no value of the desired
6419 * type is stored with the given name.
6420 *
6421 * @return the value of an item that previously added with putExtra()
6422 * or the default value if none was found.
6423 *
6424 * @see #putExtra(String, boolean)
6425 */
6426 public boolean getBooleanExtra(String name, boolean defaultValue) {
6427 return mExtras == null ? defaultValue :
6428 mExtras.getBoolean(name, defaultValue);
6429 }
6430
6431 /**
6432 * Retrieve extended data from the intent.
6433 *
6434 * @param name The name of the desired item.
6435 * @param defaultValue the value to be returned if no value of the desired
6436 * type is stored with the given name.
6437 *
6438 * @return the value of an item that previously added with putExtra()
6439 * or the default value if none was found.
6440 *
6441 * @see #putExtra(String, byte)
6442 */
6443 public byte getByteExtra(String name, byte defaultValue) {
6444 return mExtras == null ? defaultValue :
6445 mExtras.getByte(name, defaultValue);
6446 }
6447
6448 /**
6449 * Retrieve extended data from the intent.
6450 *
6451 * @param name The name of the desired item.
6452 * @param defaultValue the value to be returned if no value of the desired
6453 * type is stored with the given name.
6454 *
6455 * @return the value of an item that previously added with putExtra()
6456 * or the default value if none was found.
6457 *
6458 * @see #putExtra(String, short)
6459 */
6460 public short getShortExtra(String name, short defaultValue) {
6461 return mExtras == null ? defaultValue :
6462 mExtras.getShort(name, defaultValue);
6463 }
6464
6465 /**
6466 * Retrieve extended data from the intent.
6467 *
6468 * @param name The name of the desired item.
6469 * @param defaultValue the value to be returned if no value of the desired
6470 * type is stored with the given name.
6471 *
6472 * @return the value of an item that previously added with putExtra()
6473 * or the default value if none was found.
6474 *
6475 * @see #putExtra(String, char)
6476 */
6477 public char getCharExtra(String name, char defaultValue) {
6478 return mExtras == null ? defaultValue :
6479 mExtras.getChar(name, defaultValue);
6480 }
6481
6482 /**
6483 * Retrieve extended data from the intent.
6484 *
6485 * @param name The name of the desired item.
6486 * @param defaultValue the value to be returned if no value of the desired
6487 * type is stored with the given name.
6488 *
6489 * @return the value of an item that previously added with putExtra()
6490 * or the default value if none was found.
6491 *
6492 * @see #putExtra(String, int)
6493 */
6494 public int getIntExtra(String name, int defaultValue) {
6495 return mExtras == null ? defaultValue :
6496 mExtras.getInt(name, defaultValue);
6497 }
6498
6499 /**
6500 * Retrieve extended data from the intent.
6501 *
6502 * @param name The name of the desired item.
6503 * @param defaultValue the value to be returned if no value of the desired
6504 * type is stored with the given name.
6505 *
6506 * @return the value of an item that previously added with putExtra()
6507 * or the default value if none was found.
6508 *
6509 * @see #putExtra(String, long)
6510 */
6511 public long getLongExtra(String name, long defaultValue) {
6512 return mExtras == null ? defaultValue :
6513 mExtras.getLong(name, defaultValue);
6514 }
6515
6516 /**
6517 * Retrieve extended data from the intent.
6518 *
6519 * @param name The name of the desired item.
6520 * @param defaultValue the value to be returned if no value of the desired
6521 * type is stored with the given name.
6522 *
6523 * @return the value of an item that previously added with putExtra(),
6524 * or the default value if no such item is present
6525 *
6526 * @see #putExtra(String, float)
6527 */
6528 public float getFloatExtra(String name, float defaultValue) {
6529 return mExtras == null ? defaultValue :
6530 mExtras.getFloat(name, defaultValue);
6531 }
6532
6533 /**
6534 * Retrieve extended data from the intent.
6535 *
6536 * @param name The name of the desired item.
6537 * @param defaultValue the value to be returned if no value of the desired
6538 * type is stored with the given name.
6539 *
6540 * @return the value of an item that previously added with putExtra()
6541 * or the default value if none was found.
6542 *
6543 * @see #putExtra(String, double)
6544 */
6545 public double getDoubleExtra(String name, double defaultValue) {
6546 return mExtras == null ? defaultValue :
6547 mExtras.getDouble(name, defaultValue);
6548 }
6549
6550 /**
6551 * Retrieve extended data from the intent.
6552 *
6553 * @param name The name of the desired item.
6554 *
6555 * @return the value of an item that previously added with putExtra()
6556 * or null if no String value was found.
6557 *
6558 * @see #putExtra(String, String)
6559 */
6560 public String getStringExtra(String name) {
6561 return mExtras == null ? null : mExtras.getString(name);
6562 }
6563
6564 /**
6565 * Retrieve extended data from the intent.
6566 *
6567 * @param name The name of the desired item.
6568 *
6569 * @return the value of an item that previously added with putExtra()
6570 * or null if no CharSequence value was found.
6571 *
6572 * @see #putExtra(String, CharSequence)
6573 */
6574 public CharSequence getCharSequenceExtra(String name) {
6575 return mExtras == null ? null : mExtras.getCharSequence(name);
6576 }
6577
6578 /**
6579 * Retrieve extended data from the intent.
6580 *
6581 * @param name The name of the desired item.
6582 *
6583 * @return the value of an item that previously added with putExtra()
6584 * or null if no Parcelable value was found.
6585 *
6586 * @see #putExtra(String, Parcelable)
6587 */
6588 public <T extends Parcelable> T getParcelableExtra(String name) {
6589 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6590 }
6591
6592 /**
6593 * Retrieve extended data from the intent.
6594 *
6595 * @param name The name of the desired item.
6596 *
6597 * @return the value of an item that previously added with putExtra()
6598 * or null if no Parcelable[] value was found.
6599 *
6600 * @see #putExtra(String, Parcelable[])
6601 */
6602 public Parcelable[] getParcelableArrayExtra(String name) {
6603 return mExtras == null ? null : mExtras.getParcelableArray(name);
6604 }
6605
6606 /**
6607 * Retrieve extended data from the intent.
6608 *
6609 * @param name The name of the desired item.
6610 *
6611 * @return the value of an item that previously added with putExtra()
6612 * or null if no ArrayList<Parcelable> value was found.
6613 *
6614 * @see #putParcelableArrayListExtra(String, ArrayList)
6615 */
6616 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6617 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6618 }
6619
6620 /**
6621 * Retrieve extended data from the intent.
6622 *
6623 * @param name The name of the desired item.
6624 *
6625 * @return the value of an item that previously added with putExtra()
6626 * or null if no Serializable value was found.
6627 *
6628 * @see #putExtra(String, Serializable)
6629 */
6630 public Serializable getSerializableExtra(String name) {
6631 return mExtras == null ? null : mExtras.getSerializable(name);
6632 }
6633
6634 /**
6635 * Retrieve extended data from the intent.
6636 *
6637 * @param name The name of the desired item.
6638 *
6639 * @return the value of an item that previously added with putExtra()
6640 * or null if no ArrayList<Integer> value was found.
6641 *
6642 * @see #putIntegerArrayListExtra(String, ArrayList)
6643 */
6644 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6645 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6646 }
6647
6648 /**
6649 * Retrieve extended data from the intent.
6650 *
6651 * @param name The name of the desired item.
6652 *
6653 * @return the value of an item that previously added with putExtra()
6654 * or null if no ArrayList<String> value was found.
6655 *
6656 * @see #putStringArrayListExtra(String, ArrayList)
6657 */
6658 public ArrayList<String> getStringArrayListExtra(String name) {
6659 return mExtras == null ? null : mExtras.getStringArrayList(name);
6660 }
6661
6662 /**
6663 * Retrieve extended data from the intent.
6664 *
6665 * @param name The name of the desired item.
6666 *
6667 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006668 * or null if no ArrayList<CharSequence> value was found.
6669 *
6670 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6671 */
6672 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6673 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6674 }
6675
6676 /**
6677 * Retrieve extended data from the intent.
6678 *
6679 * @param name The name of the desired item.
6680 *
6681 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006682 * or null if no boolean array value was found.
6683 *
6684 * @see #putExtra(String, boolean[])
6685 */
6686 public boolean[] getBooleanArrayExtra(String name) {
6687 return mExtras == null ? null : mExtras.getBooleanArray(name);
6688 }
6689
6690 /**
6691 * Retrieve extended data from the intent.
6692 *
6693 * @param name The name of the desired item.
6694 *
6695 * @return the value of an item that previously added with putExtra()
6696 * or null if no byte array value was found.
6697 *
6698 * @see #putExtra(String, byte[])
6699 */
6700 public byte[] getByteArrayExtra(String name) {
6701 return mExtras == null ? null : mExtras.getByteArray(name);
6702 }
6703
6704 /**
6705 * Retrieve extended data from the intent.
6706 *
6707 * @param name The name of the desired item.
6708 *
6709 * @return the value of an item that previously added with putExtra()
6710 * or null if no short array value was found.
6711 *
6712 * @see #putExtra(String, short[])
6713 */
6714 public short[] getShortArrayExtra(String name) {
6715 return mExtras == null ? null : mExtras.getShortArray(name);
6716 }
6717
6718 /**
6719 * Retrieve extended data from the intent.
6720 *
6721 * @param name The name of the desired item.
6722 *
6723 * @return the value of an item that previously added with putExtra()
6724 * or null if no char array value was found.
6725 *
6726 * @see #putExtra(String, char[])
6727 */
6728 public char[] getCharArrayExtra(String name) {
6729 return mExtras == null ? null : mExtras.getCharArray(name);
6730 }
6731
6732 /**
6733 * Retrieve extended data from the intent.
6734 *
6735 * @param name The name of the desired item.
6736 *
6737 * @return the value of an item that previously added with putExtra()
6738 * or null if no int array value was found.
6739 *
6740 * @see #putExtra(String, int[])
6741 */
6742 public int[] getIntArrayExtra(String name) {
6743 return mExtras == null ? null : mExtras.getIntArray(name);
6744 }
6745
6746 /**
6747 * Retrieve extended data from the intent.
6748 *
6749 * @param name The name of the desired item.
6750 *
6751 * @return the value of an item that previously added with putExtra()
6752 * or null if no long array value was found.
6753 *
6754 * @see #putExtra(String, long[])
6755 */
6756 public long[] getLongArrayExtra(String name) {
6757 return mExtras == null ? null : mExtras.getLongArray(name);
6758 }
6759
6760 /**
6761 * Retrieve extended data from the intent.
6762 *
6763 * @param name The name of the desired item.
6764 *
6765 * @return the value of an item that previously added with putExtra()
6766 * or null if no float array value was found.
6767 *
6768 * @see #putExtra(String, float[])
6769 */
6770 public float[] getFloatArrayExtra(String name) {
6771 return mExtras == null ? null : mExtras.getFloatArray(name);
6772 }
6773
6774 /**
6775 * Retrieve extended data from the intent.
6776 *
6777 * @param name The name of the desired item.
6778 *
6779 * @return the value of an item that previously added with putExtra()
6780 * or null if no double array value was found.
6781 *
6782 * @see #putExtra(String, double[])
6783 */
6784 public double[] getDoubleArrayExtra(String name) {
6785 return mExtras == null ? null : mExtras.getDoubleArray(name);
6786 }
6787
6788 /**
6789 * Retrieve extended data from the intent.
6790 *
6791 * @param name The name of the desired item.
6792 *
6793 * @return the value of an item that previously added with putExtra()
6794 * or null if no String array value was found.
6795 *
6796 * @see #putExtra(String, String[])
6797 */
6798 public String[] getStringArrayExtra(String name) {
6799 return mExtras == null ? null : mExtras.getStringArray(name);
6800 }
6801
6802 /**
6803 * Retrieve extended data from the intent.
6804 *
6805 * @param name The name of the desired item.
6806 *
6807 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006808 * or null if no CharSequence array value was found.
6809 *
6810 * @see #putExtra(String, CharSequence[])
6811 */
6812 public CharSequence[] getCharSequenceArrayExtra(String name) {
6813 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6814 }
6815
6816 /**
6817 * Retrieve extended data from the intent.
6818 *
6819 * @param name The name of the desired item.
6820 *
6821 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006822 * or null if no Bundle value was found.
6823 *
6824 * @see #putExtra(String, Bundle)
6825 */
6826 public Bundle getBundleExtra(String name) {
6827 return mExtras == null ? null : mExtras.getBundle(name);
6828 }
6829
6830 /**
6831 * Retrieve extended data from the intent.
6832 *
6833 * @param name The name of the desired item.
6834 *
6835 * @return the value of an item that previously added with putExtra()
6836 * or null if no IBinder value was found.
6837 *
6838 * @see #putExtra(String, IBinder)
6839 *
6840 * @deprecated
6841 * @hide
6842 */
6843 @Deprecated
6844 public IBinder getIBinderExtra(String name) {
6845 return mExtras == null ? null : mExtras.getIBinder(name);
6846 }
6847
6848 /**
6849 * Retrieve extended data from the intent.
6850 *
6851 * @param name The name of the desired item.
6852 * @param defaultValue The default value to return in case no item is
6853 * associated with the key 'name'
6854 *
6855 * @return the value of an item that previously added with putExtra()
6856 * or defaultValue if none was found.
6857 *
6858 * @see #putExtra
6859 *
6860 * @deprecated
6861 * @hide
6862 */
6863 @Deprecated
6864 public Object getExtra(String name, Object defaultValue) {
6865 Object result = defaultValue;
6866 if (mExtras != null) {
6867 Object result2 = mExtras.get(name);
6868 if (result2 != null) {
6869 result = result2;
6870 }
6871 }
6872
6873 return result;
6874 }
6875
6876 /**
6877 * Retrieves a map of extended data from the intent.
6878 *
6879 * @return the map of all extras previously added with putExtra(),
6880 * or null if none have been added.
6881 */
6882 public Bundle getExtras() {
6883 return (mExtras != null)
6884 ? new Bundle(mExtras)
6885 : null;
6886 }
6887
6888 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006889 * Filter extras to only basic types.
6890 * @hide
6891 */
6892 public void removeUnsafeExtras() {
6893 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07006894 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006895 }
6896 }
6897
6898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006899 * Retrieve any special flags associated with this intent. You will
6900 * normally just set them with {@link #setFlags} and let the system
6901 * take the appropriate action with them.
6902 *
6903 * @return int The currently set flags.
6904 *
6905 * @see #setFlags
6906 */
6907 public int getFlags() {
6908 return mFlags;
6909 }
6910
Dianne Hackborne7f97212011-02-24 14:40:20 -08006911 /** @hide */
6912 public boolean isExcludingStopped() {
6913 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6914 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6915 }
6916
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006917 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006918 * Retrieve the application package name this Intent is limited to. When
6919 * resolving an Intent, if non-null this limits the resolution to only
6920 * components in the given application package.
6921 *
6922 * @return The name of the application package for the Intent.
6923 *
6924 * @see #resolveActivity
6925 * @see #setPackage
6926 */
6927 public String getPackage() {
6928 return mPackage;
6929 }
6930
6931 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006932 * Retrieve the concrete component associated with the intent. When receiving
6933 * an intent, this is the component that was found to best handle it (that is,
6934 * yourself) and will always be non-null; in all other cases it will be
6935 * null unless explicitly set.
6936 *
6937 * @return The name of the application component to handle the intent.
6938 *
6939 * @see #resolveActivity
6940 * @see #setComponent
6941 */
6942 public ComponentName getComponent() {
6943 return mComponent;
6944 }
6945
6946 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006947 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6948 * used as a hint to the receiver for animations and the like. Null means that there
6949 * is no source bounds.
6950 */
6951 public Rect getSourceBounds() {
6952 return mSourceBounds;
6953 }
6954
6955 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006956 * Return the Activity component that should be used to handle this intent.
6957 * The appropriate component is determined based on the information in the
6958 * intent, evaluated as follows:
6959 *
6960 * <p>If {@link #getComponent} returns an explicit class, that is returned
6961 * without any further consideration.
6962 *
6963 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6964 * category to be considered.
6965 *
6966 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6967 * action.
6968 *
6969 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6970 * this type.
6971 *
6972 * <p>If {@link #addCategory} has added any categories, the activity must
6973 * handle ALL of the categories specified.
6974 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006975 * <p>If {@link #getPackage} is non-NULL, only activity components in
6976 * that application package will be considered.
6977 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006978 * <p>If there are no activities that satisfy all of these conditions, a
6979 * null string is returned.
6980 *
6981 * <p>If multiple activities are found to satisfy the intent, the one with
6982 * the highest priority will be used. If there are multiple activities
6983 * with the same priority, the system will either pick the best activity
6984 * based on user preference, or resolve to a system class that will allow
6985 * the user to pick an activity and forward from there.
6986 *
6987 * <p>This method is implemented simply by calling
6988 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6989 * true.</p>
6990 * <p> This API is called for you as part of starting an activity from an
6991 * intent. You do not normally need to call it yourself.</p>
6992 *
6993 * @param pm The package manager with which to resolve the Intent.
6994 *
6995 * @return Name of the component implementing an activity that can
6996 * display the intent.
6997 *
6998 * @see #setComponent
6999 * @see #getComponent
7000 * @see #resolveActivityInfo
7001 */
7002 public ComponentName resolveActivity(PackageManager pm) {
7003 if (mComponent != null) {
7004 return mComponent;
7005 }
7006
7007 ResolveInfo info = pm.resolveActivity(
7008 this, PackageManager.MATCH_DEFAULT_ONLY);
7009 if (info != null) {
7010 return new ComponentName(
7011 info.activityInfo.applicationInfo.packageName,
7012 info.activityInfo.name);
7013 }
7014
7015 return null;
7016 }
7017
7018 /**
7019 * Resolve the Intent into an {@link ActivityInfo}
7020 * describing the activity that should execute the intent. Resolution
7021 * follows the same rules as described for {@link #resolveActivity}, but
7022 * you get back the completely information about the resolved activity
7023 * instead of just its class name.
7024 *
7025 * @param pm The package manager with which to resolve the Intent.
7026 * @param flags Addition information to retrieve as per
7027 * {@link PackageManager#getActivityInfo(ComponentName, int)
7028 * PackageManager.getActivityInfo()}.
7029 *
7030 * @return PackageManager.ActivityInfo
7031 *
7032 * @see #resolveActivity
7033 */
7034 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7035 ActivityInfo ai = null;
7036 if (mComponent != null) {
7037 try {
7038 ai = pm.getActivityInfo(mComponent, flags);
7039 } catch (PackageManager.NameNotFoundException e) {
7040 // ignore
7041 }
7042 } else {
7043 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007044 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007045 if (info != null) {
7046 ai = info.activityInfo;
7047 }
7048 }
7049
7050 return ai;
7051 }
7052
7053 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007054 * Special function for use by the system to resolve service
7055 * intents to system apps. Throws an exception if there are
7056 * multiple potential matches to the Intent. Returns null if
7057 * there are no matches.
7058 * @hide
7059 */
7060 public ComponentName resolveSystemService(PackageManager pm, int flags) {
7061 if (mComponent != null) {
7062 return mComponent;
7063 }
7064
7065 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7066 if (results == null) {
7067 return null;
7068 }
7069 ComponentName comp = null;
7070 for (int i=0; i<results.size(); i++) {
7071 ResolveInfo ri = results.get(i);
7072 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7073 continue;
7074 }
7075 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7076 ri.serviceInfo.name);
7077 if (comp != null) {
7078 throw new IllegalStateException("Multiple system services handle " + this
7079 + ": " + comp + ", " + foundComp);
7080 }
7081 comp = foundComp;
7082 }
7083 return comp;
7084 }
7085
7086 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007087 * Set the general action to be performed.
7088 *
7089 * @param action An action name, such as ACTION_VIEW. Application-specific
7090 * actions should be prefixed with the vendor's package name.
7091 *
7092 * @return Returns the same Intent object, for chaining multiple calls
7093 * into a single statement.
7094 *
7095 * @see #getAction
7096 */
7097 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007098 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007099 return this;
7100 }
7101
7102 /**
7103 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007104 * clears any type that was previously set by {@link #setType} or
7105 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007106 *
Nick Pellyccae4122012-01-09 14:12:58 -08007107 * <p><em>Note: scheme matching in the Android framework is
7108 * case-sensitive, unlike the formal RFC. As a result,
7109 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007110 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007111 * {@link #setDataAndNormalize}
7112 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007113 *
Nick Pellyccae4122012-01-09 14:12:58 -08007114 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007115 *
7116 * @return Returns the same Intent object, for chaining multiple calls
7117 * into a single statement.
7118 *
7119 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007120 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007121 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007122 */
7123 public Intent setData(Uri data) {
7124 mData = data;
7125 mType = null;
7126 return this;
7127 }
7128
7129 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007130 * Normalize and set the data this intent is operating on.
7131 *
7132 * <p>This method automatically clears any type that was
7133 * previously set (for example, by {@link #setType}).
7134 *
7135 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007136 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007137 * so really this is just a convenience method for
7138 * <pre>
7139 * setData(data.normalize())
7140 * </pre>
7141 *
7142 * @param data The Uri of the data this intent is now targeting.
7143 *
7144 * @return Returns the same Intent object, for chaining multiple calls
7145 * into a single statement.
7146 *
7147 * @see #getData
7148 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007149 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007150 */
7151 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007152 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007153 }
7154
7155 /**
7156 * Set an explicit MIME data type.
7157 *
7158 * <p>This is used to create intents that only specify a type and not data,
7159 * for example to indicate the type of data to return.
7160 *
7161 * <p>This method automatically clears any data that was
7162 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07007163 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007164 * <p><em>Note: MIME type matching in the Android framework is
7165 * case-sensitive, unlike formal RFC MIME types. As a result,
7166 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08007167 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7168 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007169 *
7170 * @param type The MIME type of the data being handled by this intent.
7171 *
7172 * @return Returns the same Intent object, for chaining multiple calls
7173 * into a single statement.
7174 *
7175 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08007176 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007177 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08007178 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007179 */
7180 public Intent setType(String type) {
7181 mData = null;
7182 mType = type;
7183 return this;
7184 }
7185
7186 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007187 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007188 *
Nick Pellyccae4122012-01-09 14:12:58 -08007189 * <p>This is used to create intents that only specify a type and not data,
7190 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007191 *
Nick Pellyccae4122012-01-09 14:12:58 -08007192 * <p>This method automatically clears any data that was
7193 * previously set (for example by {@link #setData}).
7194 *
7195 * <p>The MIME type is normalized using
7196 * {@link #normalizeMimeType} before it is set,
7197 * so really this is just a convenience method for
7198 * <pre>
7199 * setType(Intent.normalizeMimeType(type))
7200 * </pre>
7201 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007202 * @param type The MIME type of the data being handled by this intent.
7203 *
7204 * @return Returns the same Intent object, for chaining multiple calls
7205 * into a single statement.
7206 *
Nick Pellyccae4122012-01-09 14:12:58 -08007207 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007208 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08007209 * @see #normalizeMimeType
7210 */
7211 public Intent setTypeAndNormalize(String type) {
7212 return setType(normalizeMimeType(type));
7213 }
7214
7215 /**
7216 * (Usually optional) Set the data for the intent along with an explicit
7217 * MIME data type. This method should very rarely be used -- it allows you
7218 * to override the MIME type that would ordinarily be inferred from the
7219 * data with your own type given here.
7220 *
7221 * <p><em>Note: MIME type and Uri scheme matching in the
7222 * Android framework is case-sensitive, unlike the formal RFC definitions.
7223 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007224 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007225 * {@link #setDataAndTypeAndNormalize}
7226 * to ensure that they are converted to lower case.</em>
7227 *
7228 * @param data The Uri of the data this intent is now targeting.
7229 * @param type The MIME type of the data being handled by this intent.
7230 *
7231 * @return Returns the same Intent object, for chaining multiple calls
7232 * into a single statement.
7233 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007234 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08007235 * @see #setData
7236 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007237 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007238 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007239 */
7240 public Intent setDataAndType(Uri data, String type) {
7241 mData = data;
7242 mType = type;
7243 return this;
7244 }
7245
7246 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007247 * (Usually optional) Normalize and set both the data Uri and an explicit
7248 * MIME data type. This method should very rarely be used -- it allows you
7249 * to override the MIME type that would ordinarily be inferred from the
7250 * data with your own type given here.
7251 *
7252 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007253 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08007254 * before they are set, so really this is just a convenience method for
7255 * <pre>
7256 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7257 * </pre>
7258 *
7259 * @param data The Uri of the data this intent is now targeting.
7260 * @param type The MIME type of the data being handled by this intent.
7261 *
7262 * @return Returns the same Intent object, for chaining multiple calls
7263 * into a single statement.
7264 *
7265 * @see #setType
7266 * @see #setData
7267 * @see #setDataAndType
7268 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007269 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007270 */
7271 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007272 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08007273 }
7274
7275 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007276 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007277 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007278 * activities that provide <em>all</em> of the requested categories will be
7279 * used.
7280 *
7281 * @param category The desired category. This can be either one of the
7282 * predefined Intent categories, or a custom category in your own
7283 * namespace.
7284 *
7285 * @return Returns the same Intent object, for chaining multiple calls
7286 * into a single statement.
7287 *
7288 * @see #hasCategory
7289 * @see #removeCategory
7290 */
7291 public Intent addCategory(String category) {
7292 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007293 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007294 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08007295 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007296 return this;
7297 }
7298
7299 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007300 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 *
7302 * @param category The category to remove.
7303 *
7304 * @see #addCategory
7305 */
7306 public void removeCategory(String category) {
7307 if (mCategories != null) {
7308 mCategories.remove(category);
7309 if (mCategories.size() == 0) {
7310 mCategories = null;
7311 }
7312 }
7313 }
7314
7315 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007316 * Set a selector for this Intent. This is a modification to the kinds of
7317 * things the Intent will match. If the selector is set, it will be used
7318 * when trying to find entities that can handle the Intent, instead of the
7319 * main contents of the Intent. This allows you build an Intent containing
7320 * a generic protocol while targeting it more specifically.
7321 *
7322 * <p>An example of where this may be used is with things like
7323 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
7324 * Intent that will launch the Browser application. However, the correct
7325 * main entry point of an application is actually {@link #ACTION_MAIN}
7326 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7327 * used to specify the actual Activity to launch. If you launch the browser
7328 * with something different, undesired behavior may happen if the user has
7329 * previously or later launches it the normal way, since they do not match.
7330 * Instead, you can build an Intent with the MAIN action (but no ComponentName
7331 * yet specified) and set a selector with {@link #ACTION_MAIN} and
7332 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7333 *
7334 * <p>Setting a selector does not impact the behavior of
7335 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
7336 * desired behavior of a selector -- it does not impact the base meaning
7337 * of the Intent, just what kinds of things will be matched against it
7338 * when determining who can handle it.</p>
7339 *
7340 * <p>You can not use both a selector and {@link #setPackage(String)} on
7341 * the same base Intent.</p>
7342 *
7343 * @param selector The desired selector Intent; set to null to not use
7344 * a special selector.
7345 */
7346 public void setSelector(Intent selector) {
7347 if (selector == this) {
7348 throw new IllegalArgumentException(
7349 "Intent being set as a selector of itself");
7350 }
7351 if (selector != null && mPackage != null) {
7352 throw new IllegalArgumentException(
7353 "Can't set selector when package name is already set");
7354 }
7355 mSelector = selector;
7356 }
7357
7358 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007359 * Set a {@link ClipData} associated with this Intent. This replaces any
7360 * previously set ClipData.
7361 *
7362 * <p>The ClipData in an intent is not used for Intent matching or other
7363 * such operations. Semantically it is like extras, used to transmit
7364 * additional data with the Intent. The main feature of using this over
7365 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7366 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7367 * items included in the clip data. This is useful, in particular, if
7368 * you want to transmit an Intent containing multiple <code>content:</code>
7369 * URIs for which the recipient may not have global permission to access the
7370 * content provider.
7371 *
7372 * <p>If the ClipData contains items that are themselves Intents, any
7373 * grant flags in those Intents will be ignored. Only the top-level flags
7374 * of the main Intent are respected, and will be applied to all Uri or
7375 * Intent items in the clip (or sub-items of the clip).
7376 *
7377 * <p>The MIME type, label, and icon in the ClipData object are not
7378 * directly used by Intent. Applications should generally rely on the
7379 * MIME type of the Intent itself, not what it may find in the ClipData.
7380 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007381 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007382 *
7383 * @param clip The new clip to set. May be null to clear the current clip.
7384 */
7385 public void setClipData(ClipData clip) {
7386 mClipData = clip;
7387 }
7388
7389 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007390 * This is NOT a secure mechanism to identify the user who sent the intent.
7391 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7392 * who sent the intent.
7393 * @hide
7394 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007395 public void prepareToLeaveUser(int userId) {
7396 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7397 // We want mContentUserHint to refer to the original user, so don't do anything.
7398 if (mContentUserHint == UserHandle.USER_CURRENT) {
7399 mContentUserHint = userId;
7400 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007401 }
7402
7403 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007404 * Add extended data to the intent. The name must include a package
7405 * prefix, for example the app com.android.contacts would use names
7406 * like "com.android.contacts.ShowAll".
7407 *
7408 * @param name The name of the extra data, with package prefix.
7409 * @param value The boolean data value.
7410 *
7411 * @return Returns the same Intent object, for chaining multiple calls
7412 * into a single statement.
7413 *
7414 * @see #putExtras
7415 * @see #removeExtra
7416 * @see #getBooleanExtra(String, boolean)
7417 */
7418 public Intent putExtra(String name, boolean value) {
7419 if (mExtras == null) {
7420 mExtras = new Bundle();
7421 }
7422 mExtras.putBoolean(name, value);
7423 return this;
7424 }
7425
7426 /**
7427 * Add extended data to the intent. The name must include a package
7428 * prefix, for example the app com.android.contacts would use names
7429 * like "com.android.contacts.ShowAll".
7430 *
7431 * @param name The name of the extra data, with package prefix.
7432 * @param value The byte data value.
7433 *
7434 * @return Returns the same Intent object, for chaining multiple calls
7435 * into a single statement.
7436 *
7437 * @see #putExtras
7438 * @see #removeExtra
7439 * @see #getByteExtra(String, byte)
7440 */
7441 public Intent putExtra(String name, byte value) {
7442 if (mExtras == null) {
7443 mExtras = new Bundle();
7444 }
7445 mExtras.putByte(name, value);
7446 return this;
7447 }
7448
7449 /**
7450 * Add extended data to the intent. The name must include a package
7451 * prefix, for example the app com.android.contacts would use names
7452 * like "com.android.contacts.ShowAll".
7453 *
7454 * @param name The name of the extra data, with package prefix.
7455 * @param value The char data value.
7456 *
7457 * @return Returns the same Intent object, for chaining multiple calls
7458 * into a single statement.
7459 *
7460 * @see #putExtras
7461 * @see #removeExtra
7462 * @see #getCharExtra(String, char)
7463 */
7464 public Intent putExtra(String name, char value) {
7465 if (mExtras == null) {
7466 mExtras = new Bundle();
7467 }
7468 mExtras.putChar(name, value);
7469 return this;
7470 }
7471
7472 /**
7473 * Add extended data to the intent. The name must include a package
7474 * prefix, for example the app com.android.contacts would use names
7475 * like "com.android.contacts.ShowAll".
7476 *
7477 * @param name The name of the extra data, with package prefix.
7478 * @param value The short data value.
7479 *
7480 * @return Returns the same Intent object, for chaining multiple calls
7481 * into a single statement.
7482 *
7483 * @see #putExtras
7484 * @see #removeExtra
7485 * @see #getShortExtra(String, short)
7486 */
7487 public Intent putExtra(String name, short value) {
7488 if (mExtras == null) {
7489 mExtras = new Bundle();
7490 }
7491 mExtras.putShort(name, value);
7492 return this;
7493 }
7494
7495 /**
7496 * Add extended data to the intent. The name must include a package
7497 * prefix, for example the app com.android.contacts would use names
7498 * like "com.android.contacts.ShowAll".
7499 *
7500 * @param name The name of the extra data, with package prefix.
7501 * @param value The integer data value.
7502 *
7503 * @return Returns the same Intent object, for chaining multiple calls
7504 * into a single statement.
7505 *
7506 * @see #putExtras
7507 * @see #removeExtra
7508 * @see #getIntExtra(String, int)
7509 */
7510 public Intent putExtra(String name, int value) {
7511 if (mExtras == null) {
7512 mExtras = new Bundle();
7513 }
7514 mExtras.putInt(name, value);
7515 return this;
7516 }
7517
7518 /**
7519 * Add extended data to the intent. The name must include a package
7520 * prefix, for example the app com.android.contacts would use names
7521 * like "com.android.contacts.ShowAll".
7522 *
7523 * @param name The name of the extra data, with package prefix.
7524 * @param value The long data value.
7525 *
7526 * @return Returns the same Intent object, for chaining multiple calls
7527 * into a single statement.
7528 *
7529 * @see #putExtras
7530 * @see #removeExtra
7531 * @see #getLongExtra(String, long)
7532 */
7533 public Intent putExtra(String name, long value) {
7534 if (mExtras == null) {
7535 mExtras = new Bundle();
7536 }
7537 mExtras.putLong(name, value);
7538 return this;
7539 }
7540
7541 /**
7542 * Add extended data to the intent. The name must include a package
7543 * prefix, for example the app com.android.contacts would use names
7544 * like "com.android.contacts.ShowAll".
7545 *
7546 * @param name The name of the extra data, with package prefix.
7547 * @param value The float data value.
7548 *
7549 * @return Returns the same Intent object, for chaining multiple calls
7550 * into a single statement.
7551 *
7552 * @see #putExtras
7553 * @see #removeExtra
7554 * @see #getFloatExtra(String, float)
7555 */
7556 public Intent putExtra(String name, float value) {
7557 if (mExtras == null) {
7558 mExtras = new Bundle();
7559 }
7560 mExtras.putFloat(name, value);
7561 return this;
7562 }
7563
7564 /**
7565 * Add extended data to the intent. The name must include a package
7566 * prefix, for example the app com.android.contacts would use names
7567 * like "com.android.contacts.ShowAll".
7568 *
7569 * @param name The name of the extra data, with package prefix.
7570 * @param value The double data value.
7571 *
7572 * @return Returns the same Intent object, for chaining multiple calls
7573 * into a single statement.
7574 *
7575 * @see #putExtras
7576 * @see #removeExtra
7577 * @see #getDoubleExtra(String, double)
7578 */
7579 public Intent putExtra(String name, double value) {
7580 if (mExtras == null) {
7581 mExtras = new Bundle();
7582 }
7583 mExtras.putDouble(name, value);
7584 return this;
7585 }
7586
7587 /**
7588 * Add extended data to the intent. The name must include a package
7589 * prefix, for example the app com.android.contacts would use names
7590 * like "com.android.contacts.ShowAll".
7591 *
7592 * @param name The name of the extra data, with package prefix.
7593 * @param value The String data value.
7594 *
7595 * @return Returns the same Intent object, for chaining multiple calls
7596 * into a single statement.
7597 *
7598 * @see #putExtras
7599 * @see #removeExtra
7600 * @see #getStringExtra(String)
7601 */
7602 public Intent putExtra(String name, String value) {
7603 if (mExtras == null) {
7604 mExtras = new Bundle();
7605 }
7606 mExtras.putString(name, value);
7607 return this;
7608 }
7609
7610 /**
7611 * Add extended data to the intent. The name must include a package
7612 * prefix, for example the app com.android.contacts would use names
7613 * like "com.android.contacts.ShowAll".
7614 *
7615 * @param name The name of the extra data, with package prefix.
7616 * @param value The CharSequence data value.
7617 *
7618 * @return Returns the same Intent object, for chaining multiple calls
7619 * into a single statement.
7620 *
7621 * @see #putExtras
7622 * @see #removeExtra
7623 * @see #getCharSequenceExtra(String)
7624 */
7625 public Intent putExtra(String name, CharSequence value) {
7626 if (mExtras == null) {
7627 mExtras = new Bundle();
7628 }
7629 mExtras.putCharSequence(name, value);
7630 return this;
7631 }
7632
7633 /**
7634 * Add extended data to the intent. The name must include a package
7635 * prefix, for example the app com.android.contacts would use names
7636 * like "com.android.contacts.ShowAll".
7637 *
7638 * @param name The name of the extra data, with package prefix.
7639 * @param value The Parcelable data value.
7640 *
7641 * @return Returns the same Intent object, for chaining multiple calls
7642 * into a single statement.
7643 *
7644 * @see #putExtras
7645 * @see #removeExtra
7646 * @see #getParcelableExtra(String)
7647 */
7648 public Intent putExtra(String name, Parcelable value) {
7649 if (mExtras == null) {
7650 mExtras = new Bundle();
7651 }
7652 mExtras.putParcelable(name, value);
7653 return this;
7654 }
7655
7656 /**
7657 * Add extended data to the intent. The name must include a package
7658 * prefix, for example the app com.android.contacts would use names
7659 * like "com.android.contacts.ShowAll".
7660 *
7661 * @param name The name of the extra data, with package prefix.
7662 * @param value The Parcelable[] data value.
7663 *
7664 * @return Returns the same Intent object, for chaining multiple calls
7665 * into a single statement.
7666 *
7667 * @see #putExtras
7668 * @see #removeExtra
7669 * @see #getParcelableArrayExtra(String)
7670 */
7671 public Intent putExtra(String name, Parcelable[] value) {
7672 if (mExtras == null) {
7673 mExtras = new Bundle();
7674 }
7675 mExtras.putParcelableArray(name, value);
7676 return this;
7677 }
7678
7679 /**
7680 * Add extended data to the intent. The name must include a package
7681 * prefix, for example the app com.android.contacts would use names
7682 * like "com.android.contacts.ShowAll".
7683 *
7684 * @param name The name of the extra data, with package prefix.
7685 * @param value The ArrayList<Parcelable> data value.
7686 *
7687 * @return Returns the same Intent object, for chaining multiple calls
7688 * into a single statement.
7689 *
7690 * @see #putExtras
7691 * @see #removeExtra
7692 * @see #getParcelableArrayListExtra(String)
7693 */
7694 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7695 if (mExtras == null) {
7696 mExtras = new Bundle();
7697 }
7698 mExtras.putParcelableArrayList(name, value);
7699 return this;
7700 }
7701
7702 /**
7703 * Add extended data to the intent. The name must include a package
7704 * prefix, for example the app com.android.contacts would use names
7705 * like "com.android.contacts.ShowAll".
7706 *
7707 * @param name The name of the extra data, with package prefix.
7708 * @param value The ArrayList<Integer> data value.
7709 *
7710 * @return Returns the same Intent object, for chaining multiple calls
7711 * into a single statement.
7712 *
7713 * @see #putExtras
7714 * @see #removeExtra
7715 * @see #getIntegerArrayListExtra(String)
7716 */
7717 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7718 if (mExtras == null) {
7719 mExtras = new Bundle();
7720 }
7721 mExtras.putIntegerArrayList(name, value);
7722 return this;
7723 }
7724
7725 /**
7726 * Add extended data to the intent. The name must include a package
7727 * prefix, for example the app com.android.contacts would use names
7728 * like "com.android.contacts.ShowAll".
7729 *
7730 * @param name The name of the extra data, with package prefix.
7731 * @param value The ArrayList<String> data value.
7732 *
7733 * @return Returns the same Intent object, for chaining multiple calls
7734 * into a single statement.
7735 *
7736 * @see #putExtras
7737 * @see #removeExtra
7738 * @see #getStringArrayListExtra(String)
7739 */
7740 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7741 if (mExtras == null) {
7742 mExtras = new Bundle();
7743 }
7744 mExtras.putStringArrayList(name, value);
7745 return this;
7746 }
7747
7748 /**
7749 * Add extended data to the intent. The name must include a package
7750 * prefix, for example the app com.android.contacts would use names
7751 * like "com.android.contacts.ShowAll".
7752 *
7753 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007754 * @param value The ArrayList<CharSequence> data value.
7755 *
7756 * @return Returns the same Intent object, for chaining multiple calls
7757 * into a single statement.
7758 *
7759 * @see #putExtras
7760 * @see #removeExtra
7761 * @see #getCharSequenceArrayListExtra(String)
7762 */
7763 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7764 if (mExtras == null) {
7765 mExtras = new Bundle();
7766 }
7767 mExtras.putCharSequenceArrayList(name, value);
7768 return this;
7769 }
7770
7771 /**
7772 * Add extended data to the intent. The name must include a package
7773 * prefix, for example the app com.android.contacts would use names
7774 * like "com.android.contacts.ShowAll".
7775 *
7776 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007777 * @param value The Serializable data value.
7778 *
7779 * @return Returns the same Intent object, for chaining multiple calls
7780 * into a single statement.
7781 *
7782 * @see #putExtras
7783 * @see #removeExtra
7784 * @see #getSerializableExtra(String)
7785 */
7786 public Intent putExtra(String name, Serializable value) {
7787 if (mExtras == null) {
7788 mExtras = new Bundle();
7789 }
7790 mExtras.putSerializable(name, value);
7791 return this;
7792 }
7793
7794 /**
7795 * Add extended data to the intent. The name must include a package
7796 * prefix, for example the app com.android.contacts would use names
7797 * like "com.android.contacts.ShowAll".
7798 *
7799 * @param name The name of the extra data, with package prefix.
7800 * @param value The boolean array data value.
7801 *
7802 * @return Returns the same Intent object, for chaining multiple calls
7803 * into a single statement.
7804 *
7805 * @see #putExtras
7806 * @see #removeExtra
7807 * @see #getBooleanArrayExtra(String)
7808 */
7809 public Intent putExtra(String name, boolean[] value) {
7810 if (mExtras == null) {
7811 mExtras = new Bundle();
7812 }
7813 mExtras.putBooleanArray(name, value);
7814 return this;
7815 }
7816
7817 /**
7818 * Add extended data to the intent. The name must include a package
7819 * prefix, for example the app com.android.contacts would use names
7820 * like "com.android.contacts.ShowAll".
7821 *
7822 * @param name The name of the extra data, with package prefix.
7823 * @param value The byte array data value.
7824 *
7825 * @return Returns the same Intent object, for chaining multiple calls
7826 * into a single statement.
7827 *
7828 * @see #putExtras
7829 * @see #removeExtra
7830 * @see #getByteArrayExtra(String)
7831 */
7832 public Intent putExtra(String name, byte[] value) {
7833 if (mExtras == null) {
7834 mExtras = new Bundle();
7835 }
7836 mExtras.putByteArray(name, value);
7837 return this;
7838 }
7839
7840 /**
7841 * Add extended data to the intent. The name must include a package
7842 * prefix, for example the app com.android.contacts would use names
7843 * like "com.android.contacts.ShowAll".
7844 *
7845 * @param name The name of the extra data, with package prefix.
7846 * @param value The short array data value.
7847 *
7848 * @return Returns the same Intent object, for chaining multiple calls
7849 * into a single statement.
7850 *
7851 * @see #putExtras
7852 * @see #removeExtra
7853 * @see #getShortArrayExtra(String)
7854 */
7855 public Intent putExtra(String name, short[] value) {
7856 if (mExtras == null) {
7857 mExtras = new Bundle();
7858 }
7859 mExtras.putShortArray(name, value);
7860 return this;
7861 }
7862
7863 /**
7864 * Add extended data to the intent. The name must include a package
7865 * prefix, for example the app com.android.contacts would use names
7866 * like "com.android.contacts.ShowAll".
7867 *
7868 * @param name The name of the extra data, with package prefix.
7869 * @param value The char array data value.
7870 *
7871 * @return Returns the same Intent object, for chaining multiple calls
7872 * into a single statement.
7873 *
7874 * @see #putExtras
7875 * @see #removeExtra
7876 * @see #getCharArrayExtra(String)
7877 */
7878 public Intent putExtra(String name, char[] value) {
7879 if (mExtras == null) {
7880 mExtras = new Bundle();
7881 }
7882 mExtras.putCharArray(name, value);
7883 return this;
7884 }
7885
7886 /**
7887 * Add extended data to the intent. The name must include a package
7888 * prefix, for example the app com.android.contacts would use names
7889 * like "com.android.contacts.ShowAll".
7890 *
7891 * @param name The name of the extra data, with package prefix.
7892 * @param value The int array data value.
7893 *
7894 * @return Returns the same Intent object, for chaining multiple calls
7895 * into a single statement.
7896 *
7897 * @see #putExtras
7898 * @see #removeExtra
7899 * @see #getIntArrayExtra(String)
7900 */
7901 public Intent putExtra(String name, int[] value) {
7902 if (mExtras == null) {
7903 mExtras = new Bundle();
7904 }
7905 mExtras.putIntArray(name, value);
7906 return this;
7907 }
7908
7909 /**
7910 * Add extended data to the intent. The name must include a package
7911 * prefix, for example the app com.android.contacts would use names
7912 * like "com.android.contacts.ShowAll".
7913 *
7914 * @param name The name of the extra data, with package prefix.
7915 * @param value The byte array data value.
7916 *
7917 * @return Returns the same Intent object, for chaining multiple calls
7918 * into a single statement.
7919 *
7920 * @see #putExtras
7921 * @see #removeExtra
7922 * @see #getLongArrayExtra(String)
7923 */
7924 public Intent putExtra(String name, long[] value) {
7925 if (mExtras == null) {
7926 mExtras = new Bundle();
7927 }
7928 mExtras.putLongArray(name, value);
7929 return this;
7930 }
7931
7932 /**
7933 * Add extended data to the intent. The name must include a package
7934 * prefix, for example the app com.android.contacts would use names
7935 * like "com.android.contacts.ShowAll".
7936 *
7937 * @param name The name of the extra data, with package prefix.
7938 * @param value The float array data value.
7939 *
7940 * @return Returns the same Intent object, for chaining multiple calls
7941 * into a single statement.
7942 *
7943 * @see #putExtras
7944 * @see #removeExtra
7945 * @see #getFloatArrayExtra(String)
7946 */
7947 public Intent putExtra(String name, float[] value) {
7948 if (mExtras == null) {
7949 mExtras = new Bundle();
7950 }
7951 mExtras.putFloatArray(name, value);
7952 return this;
7953 }
7954
7955 /**
7956 * Add extended data to the intent. The name must include a package
7957 * prefix, for example the app com.android.contacts would use names
7958 * like "com.android.contacts.ShowAll".
7959 *
7960 * @param name The name of the extra data, with package prefix.
7961 * @param value The double array data value.
7962 *
7963 * @return Returns the same Intent object, for chaining multiple calls
7964 * into a single statement.
7965 *
7966 * @see #putExtras
7967 * @see #removeExtra
7968 * @see #getDoubleArrayExtra(String)
7969 */
7970 public Intent putExtra(String name, double[] value) {
7971 if (mExtras == null) {
7972 mExtras = new Bundle();
7973 }
7974 mExtras.putDoubleArray(name, value);
7975 return this;
7976 }
7977
7978 /**
7979 * Add extended data to the intent. The name must include a package
7980 * prefix, for example the app com.android.contacts would use names
7981 * like "com.android.contacts.ShowAll".
7982 *
7983 * @param name The name of the extra data, with package prefix.
7984 * @param value The String array data value.
7985 *
7986 * @return Returns the same Intent object, for chaining multiple calls
7987 * into a single statement.
7988 *
7989 * @see #putExtras
7990 * @see #removeExtra
7991 * @see #getStringArrayExtra(String)
7992 */
7993 public Intent putExtra(String name, String[] value) {
7994 if (mExtras == null) {
7995 mExtras = new Bundle();
7996 }
7997 mExtras.putStringArray(name, value);
7998 return this;
7999 }
8000
8001 /**
8002 * Add extended data to the intent. The name must include a package
8003 * prefix, for example the app com.android.contacts would use names
8004 * like "com.android.contacts.ShowAll".
8005 *
8006 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008007 * @param value The CharSequence array data value.
8008 *
8009 * @return Returns the same Intent object, for chaining multiple calls
8010 * into a single statement.
8011 *
8012 * @see #putExtras
8013 * @see #removeExtra
8014 * @see #getCharSequenceArrayExtra(String)
8015 */
8016 public Intent putExtra(String name, CharSequence[] value) {
8017 if (mExtras == null) {
8018 mExtras = new Bundle();
8019 }
8020 mExtras.putCharSequenceArray(name, value);
8021 return this;
8022 }
8023
8024 /**
8025 * Add extended data to the intent. The name must include a package
8026 * prefix, for example the app com.android.contacts would use names
8027 * like "com.android.contacts.ShowAll".
8028 *
8029 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008030 * @param value The Bundle data value.
8031 *
8032 * @return Returns the same Intent object, for chaining multiple calls
8033 * into a single statement.
8034 *
8035 * @see #putExtras
8036 * @see #removeExtra
8037 * @see #getBundleExtra(String)
8038 */
8039 public Intent putExtra(String name, Bundle value) {
8040 if (mExtras == null) {
8041 mExtras = new Bundle();
8042 }
8043 mExtras.putBundle(name, value);
8044 return this;
8045 }
8046
8047 /**
8048 * Add extended data to the intent. The name must include a package
8049 * prefix, for example the app com.android.contacts would use names
8050 * like "com.android.contacts.ShowAll".
8051 *
8052 * @param name The name of the extra data, with package prefix.
8053 * @param value The IBinder data value.
8054 *
8055 * @return Returns the same Intent object, for chaining multiple calls
8056 * into a single statement.
8057 *
8058 * @see #putExtras
8059 * @see #removeExtra
8060 * @see #getIBinderExtra(String)
8061 *
8062 * @deprecated
8063 * @hide
8064 */
8065 @Deprecated
8066 public Intent putExtra(String name, IBinder value) {
8067 if (mExtras == null) {
8068 mExtras = new Bundle();
8069 }
8070 mExtras.putIBinder(name, value);
8071 return this;
8072 }
8073
8074 /**
8075 * Copy all extras in 'src' in to this intent.
8076 *
8077 * @param src Contains the extras to copy.
8078 *
8079 * @see #putExtra
8080 */
8081 public Intent putExtras(Intent src) {
8082 if (src.mExtras != null) {
8083 if (mExtras == null) {
8084 mExtras = new Bundle(src.mExtras);
8085 } else {
8086 mExtras.putAll(src.mExtras);
8087 }
8088 }
8089 return this;
8090 }
8091
8092 /**
8093 * Add a set of extended data to the intent. The keys must include a package
8094 * prefix, for example the app com.android.contacts would use names
8095 * like "com.android.contacts.ShowAll".
8096 *
8097 * @param extras The Bundle of extras to add to this intent.
8098 *
8099 * @see #putExtra
8100 * @see #removeExtra
8101 */
8102 public Intent putExtras(Bundle extras) {
8103 if (mExtras == null) {
8104 mExtras = new Bundle();
8105 }
8106 mExtras.putAll(extras);
8107 return this;
8108 }
8109
8110 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008111 * Completely replace the extras in the Intent with the extras in the
8112 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008113 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008114 * @param src The exact extras contained in this Intent are copied
8115 * into the target intent, replacing any that were previously there.
8116 */
8117 public Intent replaceExtras(Intent src) {
8118 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8119 return this;
8120 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008121
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008122 /**
8123 * Completely replace the extras in the Intent with the given Bundle of
8124 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008125 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008126 * @param extras The new set of extras in the Intent, or null to erase
8127 * all extras.
8128 */
8129 public Intent replaceExtras(Bundle extras) {
8130 mExtras = extras != null ? new Bundle(extras) : null;
8131 return this;
8132 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008133
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008134 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008135 * Remove extended data from the intent.
8136 *
8137 * @see #putExtra
8138 */
8139 public void removeExtra(String name) {
8140 if (mExtras != null) {
8141 mExtras.remove(name);
8142 if (mExtras.size() == 0) {
8143 mExtras = null;
8144 }
8145 }
8146 }
8147
8148 /**
8149 * Set special flags controlling how this intent is handled. Most values
8150 * here depend on the type of component being executed by the Intent,
8151 * specifically the FLAG_ACTIVITY_* flags are all for use with
8152 * {@link Context#startActivity Context.startActivity()} and the
8153 * FLAG_RECEIVER_* flags are all for use with
8154 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8155 *
Scott Main7aee61f2011-02-08 11:25:01 -08008156 * <p>See the
8157 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8158 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159 * the behavior of your application.
8160 *
8161 * @param flags The desired flags.
8162 *
8163 * @return Returns the same Intent object, for chaining multiple calls
8164 * into a single statement.
8165 *
8166 * @see #getFlags
8167 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008168 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008169 *
8170 * @see #FLAG_GRANT_READ_URI_PERMISSION
8171 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07008172 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8173 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008174 * @see #FLAG_DEBUG_LOG_RESOLUTION
8175 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008176 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008177 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008178 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008179 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008180 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8181 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008182 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07008184 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008185 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008186 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008187 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08008188 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008189 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8190 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008191 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008192 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08008193 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008194 * @see #FLAG_RECEIVER_REGISTERED_ONLY
8195 */
8196 public Intent setFlags(int flags) {
8197 mFlags = flags;
8198 return this;
8199 }
8200
8201 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008202 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008203 *
8204 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008205 * @return Returns the same Intent object, for chaining multiple calls into
8206 * a single statement.
8207 * @see #setFlags(int)
8208 * @see #removeFlags(int)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008209 */
8210 public Intent addFlags(int flags) {
8211 mFlags |= flags;
8212 return this;
8213 }
8214
8215 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07008216 * Remove these flags from the intent.
8217 *
8218 * @param flags The flags to remove.
8219 * @see #setFlags(int)
8220 * @see #addFlags(int)
8221 */
8222 public void removeFlags(int flags) {
8223 mFlags &= ~flags;
8224 }
8225
8226 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008227 * (Usually optional) Set an explicit application package name that limits
8228 * the components this Intent will resolve to. If left to the default
8229 * value of null, all components in all applications will considered.
8230 * If non-null, the Intent can only match the components in the given
8231 * application package.
8232 *
8233 * @param packageName The name of the application package to handle the
8234 * intent, or null to allow any application package.
8235 *
8236 * @return Returns the same Intent object, for chaining multiple calls
8237 * into a single statement.
8238 *
8239 * @see #getPackage
8240 * @see #resolveActivity
8241 */
8242 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008243 if (packageName != null && mSelector != null) {
8244 throw new IllegalArgumentException(
8245 "Can't set package name when selector is already set");
8246 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008247 mPackage = packageName;
8248 return this;
8249 }
8250
8251 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008252 * (Usually optional) Explicitly set the component to handle the intent.
8253 * If left with the default value of null, the system will determine the
8254 * appropriate class to use based on the other fields (action, data,
8255 * type, categories) in the Intent. If this class is defined, the
8256 * specified class will always be used regardless of the other fields. You
8257 * should only set this value when you know you absolutely want a specific
8258 * class to be used; otherwise it is better to let the system find the
8259 * appropriate class so that you will respect the installed applications
8260 * and user preferences.
8261 *
8262 * @param component The name of the application component to handle the
8263 * intent, or null to let the system find one for you.
8264 *
8265 * @return Returns the same Intent object, for chaining multiple calls
8266 * into a single statement.
8267 *
8268 * @see #setClass
8269 * @see #setClassName(Context, String)
8270 * @see #setClassName(String, String)
8271 * @see #getComponent
8272 * @see #resolveActivity
8273 */
8274 public Intent setComponent(ComponentName component) {
8275 mComponent = component;
8276 return this;
8277 }
8278
8279 /**
8280 * Convenience for calling {@link #setComponent} with an
8281 * explicit class name.
8282 *
8283 * @param packageContext A Context of the application package implementing
8284 * this class.
8285 * @param className The name of a class inside of the application package
8286 * that will be used as the component for this Intent.
8287 *
8288 * @return Returns the same Intent object, for chaining multiple calls
8289 * into a single statement.
8290 *
8291 * @see #setComponent
8292 * @see #setClass
8293 */
8294 public Intent setClassName(Context packageContext, String className) {
8295 mComponent = new ComponentName(packageContext, className);
8296 return this;
8297 }
8298
8299 /**
8300 * Convenience for calling {@link #setComponent} with an
8301 * explicit application package name and class name.
8302 *
8303 * @param packageName The name of the package implementing the desired
8304 * component.
8305 * @param className The name of a class inside of the application package
8306 * that will be used as the component for this Intent.
8307 *
8308 * @return Returns the same Intent object, for chaining multiple calls
8309 * into a single statement.
8310 *
8311 * @see #setComponent
8312 * @see #setClass
8313 */
8314 public Intent setClassName(String packageName, String className) {
8315 mComponent = new ComponentName(packageName, className);
8316 return this;
8317 }
8318
8319 /**
8320 * Convenience for calling {@link #setComponent(ComponentName)} with the
8321 * name returned by a {@link Class} object.
8322 *
8323 * @param packageContext A Context of the application package implementing
8324 * this class.
8325 * @param cls The class name to set, equivalent to
8326 * <code>setClassName(context, cls.getName())</code>.
8327 *
8328 * @return Returns the same Intent object, for chaining multiple calls
8329 * into a single statement.
8330 *
8331 * @see #setComponent
8332 */
8333 public Intent setClass(Context packageContext, Class<?> cls) {
8334 mComponent = new ComponentName(packageContext, cls);
8335 return this;
8336 }
8337
8338 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008339 * Set the bounds of the sender of this intent, in screen coordinates. This can be
8340 * used as a hint to the receiver for animations and the like. Null means that there
8341 * is no source bounds.
8342 */
8343 public void setSourceBounds(Rect r) {
8344 if (r != null) {
8345 mSourceBounds = new Rect(r);
8346 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07008347 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008348 }
8349 }
8350
Tor Norbyed9273d62013-05-30 15:59:53 -07008351 /** @hide */
8352 @IntDef(flag = true,
8353 value = {
8354 FILL_IN_ACTION,
8355 FILL_IN_DATA,
8356 FILL_IN_CATEGORIES,
8357 FILL_IN_COMPONENT,
8358 FILL_IN_PACKAGE,
8359 FILL_IN_SOURCE_BOUNDS,
8360 FILL_IN_SELECTOR,
8361 FILL_IN_CLIP_DATA
8362 })
8363 @Retention(RetentionPolicy.SOURCE)
8364 public @interface FillInFlags {}
8365
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008366 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008367 * Use with {@link #fillIn} to allow the current action value to be
8368 * overwritten, even if it is already set.
8369 */
8370 public static final int FILL_IN_ACTION = 1<<0;
8371
8372 /**
8373 * Use with {@link #fillIn} to allow the current data or type value
8374 * overwritten, even if it is already set.
8375 */
8376 public static final int FILL_IN_DATA = 1<<1;
8377
8378 /**
8379 * Use with {@link #fillIn} to allow the current categories to be
8380 * overwritten, even if they are already set.
8381 */
8382 public static final int FILL_IN_CATEGORIES = 1<<2;
8383
8384 /**
8385 * Use with {@link #fillIn} to allow the current component value to be
8386 * overwritten, even if it is already set.
8387 */
8388 public static final int FILL_IN_COMPONENT = 1<<3;
8389
8390 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008391 * Use with {@link #fillIn} to allow the current package value to be
8392 * overwritten, even if it is already set.
8393 */
8394 public static final int FILL_IN_PACKAGE = 1<<4;
8395
8396 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008397 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008398 * overwritten, even if it is already set.
8399 */
8400 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8401
8402 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008403 * Use with {@link #fillIn} to allow the current selector to be
8404 * overwritten, even if it is already set.
8405 */
8406 public static final int FILL_IN_SELECTOR = 1<<6;
8407
8408 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008409 * Use with {@link #fillIn} to allow the current ClipData to be
8410 * overwritten, even if it is already set.
8411 */
8412 public static final int FILL_IN_CLIP_DATA = 1<<7;
8413
8414 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008415 * Copy the contents of <var>other</var> in to this object, but only
8416 * where fields are not defined by this object. For purposes of a field
8417 * being defined, the following pieces of data in the Intent are
8418 * considered to be separate fields:
8419 *
8420 * <ul>
8421 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008422 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008423 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8424 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008425 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008426 * <li> component, as set by {@link #setComponent(ComponentName)} or
8427 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008428 * <li> source bounds, as set by {@link #setSourceBounds}.
8429 * <li> selector, as set by {@link #setSelector(Intent)}.
8430 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008431 * <li> each top-level name in the associated extras.
8432 * </ul>
8433 *
8434 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008435 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008436 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8437 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8438 * the restriction where the corresponding field will not be replaced if
8439 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008440 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008441 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8442 * is explicitly specified. The selector will only be copied if
8443 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008444 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008445 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8446 * and Intent B with {action="gotit", data-type="some/thing",
8447 * categories="one","two"}.
8448 *
8449 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8450 * containing: {action="gotit", data-type="some/thing",
8451 * categories="bar"}.
8452 *
8453 * @param other Another Intent whose values are to be used to fill in
8454 * the current one.
8455 * @param flags Options to control which fields can be filled in.
8456 *
8457 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008458 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008459 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08008460 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07008461 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008462 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008463 @FillInFlags
8464 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008465 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008466 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008467 if (other.mAction != null
8468 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008469 mAction = other.mAction;
8470 changes |= FILL_IN_ACTION;
8471 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008472 if ((other.mData != null || other.mType != null)
8473 && ((mData == null && mType == null)
8474 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008475 mData = other.mData;
8476 mType = other.mType;
8477 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008478 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008479 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008480 if (other.mCategories != null
8481 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008482 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008483 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008484 }
8485 changes |= FILL_IN_CATEGORIES;
8486 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008487 if (other.mPackage != null
8488 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008489 // Only do this if mSelector is not set.
8490 if (mSelector == null) {
8491 mPackage = other.mPackage;
8492 changes |= FILL_IN_PACKAGE;
8493 }
8494 }
8495 // Selector is special: it can only be set if explicitly allowed,
8496 // for the same reason as the component name.
8497 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8498 if (mPackage == null) {
8499 mSelector = new Intent(other.mSelector);
8500 mPackage = null;
8501 changes |= FILL_IN_SELECTOR;
8502 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008503 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008504 if (other.mClipData != null
8505 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8506 mClipData = other.mClipData;
8507 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008508 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008509 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008510 // Component is special: it can -only- be set if explicitly allowed,
8511 // since otherwise the sender could force the intent somewhere the
8512 // originator didn't intend.
8513 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008514 mComponent = other.mComponent;
8515 changes |= FILL_IN_COMPONENT;
8516 }
8517 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008518 if (other.mSourceBounds != null
8519 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8520 mSourceBounds = new Rect(other.mSourceBounds);
8521 changes |= FILL_IN_SOURCE_BOUNDS;
8522 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008523 if (mExtras == null) {
8524 if (other.mExtras != null) {
8525 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008526 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008527 }
8528 } else if (other.mExtras != null) {
8529 try {
8530 Bundle newb = new Bundle(other.mExtras);
8531 newb.putAll(mExtras);
8532 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008533 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008534 } catch (RuntimeException e) {
8535 // Modifying the extras can cause us to unparcel the contents
8536 // of the bundle, and if we do this in the system process that
8537 // may fail. We really should handle this (i.e., the Bundle
8538 // impl shouldn't be on top of a plain map), but for now just
8539 // ignore it and keep the original contents. :(
8540 Log.w("Intent", "Failure filling in extras", e);
8541 }
8542 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008543 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8544 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8545 mContentUserHint = other.mContentUserHint;
8546 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008547 return changes;
8548 }
8549
8550 /**
8551 * Wrapper class holding an Intent and implementing comparisons on it for
8552 * the purpose of filtering. The class implements its
8553 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8554 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8555 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8556 * on the wrapped Intent.
8557 */
8558 public static final class FilterComparison {
8559 private final Intent mIntent;
8560 private final int mHashCode;
8561
8562 public FilterComparison(Intent intent) {
8563 mIntent = intent;
8564 mHashCode = intent.filterHashCode();
8565 }
8566
8567 /**
8568 * Return the Intent that this FilterComparison represents.
8569 * @return Returns the Intent held by the FilterComparison. Do
8570 * not modify!
8571 */
8572 public Intent getIntent() {
8573 return mIntent;
8574 }
8575
8576 @Override
8577 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008578 if (obj instanceof FilterComparison) {
8579 Intent other = ((FilterComparison)obj).mIntent;
8580 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008582 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 }
8584
8585 @Override
8586 public int hashCode() {
8587 return mHashCode;
8588 }
8589 }
8590
8591 /**
8592 * Determine if two intents are the same for the purposes of intent
8593 * resolution (filtering). That is, if their action, data, type,
8594 * class, and categories are the same. This does <em>not</em> compare
8595 * any extra data included in the intents.
8596 *
8597 * @param other The other Intent to compare against.
8598 *
8599 * @return Returns true if action, data, type, class, and categories
8600 * are the same.
8601 */
8602 public boolean filterEquals(Intent other) {
8603 if (other == null) {
8604 return false;
8605 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008606 if (!Objects.equals(this.mAction, other.mAction)) return false;
8607 if (!Objects.equals(this.mData, other.mData)) return false;
8608 if (!Objects.equals(this.mType, other.mType)) return false;
8609 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8610 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8611 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008612
8613 return true;
8614 }
8615
8616 /**
8617 * Generate hash code that matches semantics of filterEquals().
8618 *
8619 * @return Returns the hash value of the action, data, type, class, and
8620 * categories.
8621 *
8622 * @see #filterEquals
8623 */
8624 public int filterHashCode() {
8625 int code = 0;
8626 if (mAction != null) {
8627 code += mAction.hashCode();
8628 }
8629 if (mData != null) {
8630 code += mData.hashCode();
8631 }
8632 if (mType != null) {
8633 code += mType.hashCode();
8634 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008635 if (mPackage != null) {
8636 code += mPackage.hashCode();
8637 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008638 if (mComponent != null) {
8639 code += mComponent.hashCode();
8640 }
8641 if (mCategories != null) {
8642 code += mCategories.hashCode();
8643 }
8644 return code;
8645 }
8646
8647 @Override
8648 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008649 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008650
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008651 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008652 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008653 b.append(" }");
8654
8655 return b.toString();
8656 }
8657
8658 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008659 public String toInsecureString() {
8660 StringBuilder b = new StringBuilder(128);
8661
8662 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008663 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008664 b.append(" }");
8665
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008666 return b.toString();
8667 }
Romain Guy4969af72009-06-17 10:53:19 -07008668
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008669 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008670 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008671 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008672
8673 b.append("Intent { ");
8674 toShortString(b, false, true, true, true);
8675 b.append(" }");
8676
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008677 return b.toString();
8678 }
8679
8680 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008681 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8682 StringBuilder b = new StringBuilder(128);
8683 toShortString(b, secure, comp, extras, clip);
8684 return b.toString();
8685 }
8686
8687 /** @hide */
8688 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8689 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008690 boolean first = true;
8691 if (mAction != null) {
8692 b.append("act=").append(mAction);
8693 first = false;
8694 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008695 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008696 if (!first) {
8697 b.append(' ');
8698 }
8699 first = false;
8700 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008701 for (int i=0; i<mCategories.size(); i++) {
8702 if (i > 0) b.append(',');
8703 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008704 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008705 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008706 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008707 if (mData != null) {
8708 if (!first) {
8709 b.append(' ');
8710 }
8711 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008712 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008713 if (secure) {
8714 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008715 } else {
8716 b.append(mData);
8717 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008718 }
8719 if (mType != null) {
8720 if (!first) {
8721 b.append(' ');
8722 }
8723 first = false;
8724 b.append("typ=").append(mType);
8725 }
8726 if (mFlags != 0) {
8727 if (!first) {
8728 b.append(' ');
8729 }
8730 first = false;
8731 b.append("flg=0x").append(Integer.toHexString(mFlags));
8732 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008733 if (mPackage != null) {
8734 if (!first) {
8735 b.append(' ');
8736 }
8737 first = false;
8738 b.append("pkg=").append(mPackage);
8739 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008740 if (comp && mComponent != null) {
8741 if (!first) {
8742 b.append(' ');
8743 }
8744 first = false;
8745 b.append("cmp=").append(mComponent.flattenToShortString());
8746 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008747 if (mSourceBounds != null) {
8748 if (!first) {
8749 b.append(' ');
8750 }
8751 first = false;
8752 b.append("bnds=").append(mSourceBounds.toShortString());
8753 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008754 if (mClipData != null) {
8755 if (!first) {
8756 b.append(' ');
8757 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008758 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008759 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008760 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008761 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008762 if (mClipData.getDescription() != null) {
8763 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8764 } else {
8765 first = true;
8766 }
8767 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008768 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008769 first = false;
8770 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008771 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008772 if (extras && mExtras != null) {
8773 if (!first) {
8774 b.append(' ');
8775 }
8776 first = false;
8777 b.append("(has extras)");
8778 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008779 if (mContentUserHint != UserHandle.USER_CURRENT) {
8780 if (!first) {
8781 b.append(' ');
8782 }
8783 first = false;
8784 b.append("u=").append(mContentUserHint);
8785 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008786 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008787 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008788 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008789 b.append("}");
8790 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008791 }
8792
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008793 /**
8794 * Call {@link #toUri} with 0 flags.
8795 * @deprecated Use {@link #toUri} instead.
8796 */
8797 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008798 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008799 return toUri(0);
8800 }
8801
8802 /**
8803 * Convert this Intent into a String holding a URI representation of it.
8804 * The returned URI string has been properly URI encoded, so it can be
8805 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8806 * Intent's data as the base URI, with an additional fragment describing
8807 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008808 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008809 * <p>You can convert the returned string back to an Intent with
8810 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008811 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008812 * @param flags Additional operating flags. Either 0,
8813 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008814 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008815 * @return Returns a URI encoding URI string describing the entire contents
8816 * of the Intent.
8817 */
8818 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008819 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008820 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8821 if (mPackage == null) {
8822 throw new IllegalArgumentException(
8823 "Intent must include an explicit package name to build an android-app: "
8824 + this);
8825 }
8826 uri.append("android-app://");
8827 uri.append(mPackage);
8828 String scheme = null;
8829 if (mData != null) {
8830 scheme = mData.getScheme();
8831 if (scheme != null) {
8832 uri.append('/');
8833 uri.append(scheme);
8834 String authority = mData.getEncodedAuthority();
8835 if (authority != null) {
8836 uri.append('/');
8837 uri.append(authority);
8838 String path = mData.getEncodedPath();
8839 if (path != null) {
8840 uri.append(path);
8841 }
8842 String queryParams = mData.getEncodedQuery();
8843 if (queryParams != null) {
8844 uri.append('?');
8845 uri.append(queryParams);
8846 }
8847 String fragment = mData.getEncodedFragment();
8848 if (fragment != null) {
8849 uri.append('#');
8850 uri.append(fragment);
8851 }
8852 }
8853 }
8854 }
8855 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8856 mPackage, flags);
8857 return uri.toString();
8858 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008859 String scheme = null;
8860 if (mData != null) {
8861 String data = mData.toString();
8862 if ((flags&URI_INTENT_SCHEME) != 0) {
8863 final int N = data.length();
8864 for (int i=0; i<N; i++) {
8865 char c = data.charAt(i);
8866 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8867 || c == '.' || c == '-') {
8868 continue;
8869 }
8870 if (c == ':' && i > 0) {
8871 // Valid scheme.
8872 scheme = data.substring(0, i);
8873 uri.append("intent:");
8874 data = data.substring(i+1);
8875 break;
8876 }
Tom Taylord4a47292009-12-21 13:59:18 -08008877
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008878 // No scheme.
8879 break;
8880 }
8881 }
8882 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008883
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008884 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8885 uri.append("intent:");
8886 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008887
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008888 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008889
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008890 return uri.toString();
8891 }
8892
8893 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8894 String defPackage, int flags) {
8895 StringBuilder frag = new StringBuilder(128);
8896
8897 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008898 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008899 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008900 // Note that for now we are not going to try to handle the
8901 // data part; not clear how to represent this as a URI, and
8902 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008903 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8904 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008905 }
8906
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008907 if (frag.length() > 0) {
8908 uri.append("#Intent;");
8909 uri.append(frag);
8910 uri.append("end");
8911 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008912 }
8913
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008914 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8915 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008916 if (scheme != null) {
8917 uri.append("scheme=").append(scheme).append(';');
8918 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008919 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008920 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008921 }
8922 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008923 for (int i=0; i<mCategories.size(); i++) {
8924 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008925 }
8926 }
8927 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008928 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008929 }
8930 if (mFlags != 0) {
8931 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8932 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008933 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008934 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8935 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008936 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008937 uri.append("component=").append(Uri.encode(
8938 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008939 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008940 if (mSourceBounds != null) {
8941 uri.append("sourceBounds=")
8942 .append(Uri.encode(mSourceBounds.flattenToString()))
8943 .append(';');
8944 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 if (mExtras != null) {
8946 for (String key : mExtras.keySet()) {
8947 final Object value = mExtras.get(key);
8948 char entryType =
8949 value instanceof String ? 'S' :
8950 value instanceof Boolean ? 'B' :
8951 value instanceof Byte ? 'b' :
8952 value instanceof Character ? 'c' :
8953 value instanceof Double ? 'd' :
8954 value instanceof Float ? 'f' :
8955 value instanceof Integer ? 'i' :
8956 value instanceof Long ? 'l' :
8957 value instanceof Short ? 's' :
8958 '\0';
8959
8960 if (entryType != '\0') {
8961 uri.append(entryType);
8962 uri.append('.');
8963 uri.append(Uri.encode(key));
8964 uri.append('=');
8965 uri.append(Uri.encode(value.toString()));
8966 uri.append(';');
8967 }
8968 }
8969 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008970 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008971
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008972 public int describeContents() {
8973 return (mExtras != null) ? mExtras.describeContents() : 0;
8974 }
8975
8976 public void writeToParcel(Parcel out, int flags) {
8977 out.writeString(mAction);
8978 Uri.writeToParcel(out, mData);
8979 out.writeString(mType);
8980 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008981 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008982 ComponentName.writeToParcel(mComponent, out);
8983
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008984 if (mSourceBounds != null) {
8985 out.writeInt(1);
8986 mSourceBounds.writeToParcel(out, flags);
8987 } else {
8988 out.writeInt(0);
8989 }
8990
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008991 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008992 final int N = mCategories.size();
8993 out.writeInt(N);
8994 for (int i=0; i<N; i++) {
8995 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008996 }
8997 } else {
8998 out.writeInt(0);
8999 }
9000
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009001 if (mSelector != null) {
9002 out.writeInt(1);
9003 mSelector.writeToParcel(out, flags);
9004 } else {
9005 out.writeInt(0);
9006 }
9007
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009008 if (mClipData != null) {
9009 out.writeInt(1);
9010 mClipData.writeToParcel(out, flags);
9011 } else {
9012 out.writeInt(0);
9013 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009014 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009015 out.writeBundle(mExtras);
9016 }
9017
9018 public static final Parcelable.Creator<Intent> CREATOR
9019 = new Parcelable.Creator<Intent>() {
9020 public Intent createFromParcel(Parcel in) {
9021 return new Intent(in);
9022 }
9023 public Intent[] newArray(int size) {
9024 return new Intent[size];
9025 }
9026 };
9027
Dianne Hackborneb034652009-09-07 00:49:58 -07009028 /** @hide */
9029 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009030 readFromParcel(in);
9031 }
9032
9033 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009034 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009035 mData = Uri.CREATOR.createFromParcel(in);
9036 mType = in.readString();
9037 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009038 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009039 mComponent = ComponentName.readFromParcel(in);
9040
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009041 if (in.readInt() != 0) {
9042 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9043 }
9044
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009045 int N = in.readInt();
9046 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009047 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009048 int i;
9049 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009050 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009051 }
9052 } else {
9053 mCategories = null;
9054 }
9055
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009056 if (in.readInt() != 0) {
9057 mSelector = new Intent(in);
9058 }
9059
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009060 if (in.readInt() != 0) {
9061 mClipData = new ClipData(in);
9062 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009063 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009064 mExtras = in.readBundle();
9065 }
9066
9067 /**
9068 * Parses the "intent" element (and its children) from XML and instantiates
9069 * an Intent object. The given XML parser should be located at the tag
9070 * where parsing should start (often named "intent"), from which the
9071 * basic action, data, type, and package and class name will be
9072 * retrieved. The function will then parse in to any child elements,
9073 * looking for <category android:name="xxx"> tags to add categories and
9074 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9075 * to the intent.
9076 *
9077 * @param resources The Resources to use when inflating resources.
9078 * @param parser The XML parser pointing at an "intent" tag.
9079 * @param attrs The AttributeSet interface for retrieving extended
9080 * attribute data at the current <var>parser</var> location.
9081 * @return An Intent object matching the XML data.
9082 * @throws XmlPullParserException If there was an XML parsing error.
9083 * @throws IOException If there was an I/O error.
9084 */
9085 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9086 throws XmlPullParserException, IOException {
9087 Intent intent = new Intent();
9088
9089 TypedArray sa = resources.obtainAttributes(attrs,
9090 com.android.internal.R.styleable.Intent);
9091
9092 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9093
9094 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9095 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9096 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9097
9098 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9099 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9100 if (packageName != null && className != null) {
9101 intent.setComponent(new ComponentName(packageName, className));
9102 }
9103
9104 sa.recycle();
9105
9106 int outerDepth = parser.getDepth();
9107 int type;
9108 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9109 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9110 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9111 continue;
9112 }
9113
9114 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009115 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 sa = resources.obtainAttributes(attrs,
9117 com.android.internal.R.styleable.IntentCategory);
9118 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9119 sa.recycle();
9120
9121 if (cat != null) {
9122 intent.addCategory(cat);
9123 }
9124 XmlUtils.skipCurrentTag(parser);
9125
Craig Mautner21d24a22014-04-23 11:45:37 -07009126 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009127 if (intent.mExtras == null) {
9128 intent.mExtras = new Bundle();
9129 }
Craig Mautner21d24a22014-04-23 11:45:37 -07009130 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009131 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132
9133 } else {
9134 XmlUtils.skipCurrentTag(parser);
9135 }
9136 }
9137
9138 return intent;
9139 }
Nick Pellyccae4122012-01-09 14:12:58 -08009140
Craig Mautner21d24a22014-04-23 11:45:37 -07009141 /** @hide */
9142 public void saveToXml(XmlSerializer out) throws IOException {
9143 if (mAction != null) {
9144 out.attribute(null, ATTR_ACTION, mAction);
9145 }
9146 if (mData != null) {
9147 out.attribute(null, ATTR_DATA, mData.toString());
9148 }
9149 if (mType != null) {
9150 out.attribute(null, ATTR_TYPE, mType);
9151 }
9152 if (mComponent != null) {
9153 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9154 }
9155 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9156
9157 if (mCategories != null) {
9158 out.startTag(null, TAG_CATEGORIES);
9159 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9160 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9161 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07009162 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07009163 }
9164 }
9165
9166 /** @hide */
9167 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9168 XmlPullParserException {
9169 Intent intent = new Intent();
9170 final int outerDepth = in.getDepth();
9171
9172 int attrCount = in.getAttributeCount();
9173 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9174 final String attrName = in.getAttributeName(attrNdx);
9175 final String attrValue = in.getAttributeValue(attrNdx);
9176 if (ATTR_ACTION.equals(attrName)) {
9177 intent.setAction(attrValue);
9178 } else if (ATTR_DATA.equals(attrName)) {
9179 intent.setData(Uri.parse(attrValue));
9180 } else if (ATTR_TYPE.equals(attrName)) {
9181 intent.setType(attrValue);
9182 } else if (ATTR_COMPONENT.equals(attrName)) {
9183 intent.setComponent(ComponentName.unflattenFromString(attrValue));
9184 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +01009185 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -07009186 } else {
9187 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9188 }
9189 }
9190
9191 int event;
9192 String name;
9193 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9194 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9195 if (event == XmlPullParser.START_TAG) {
9196 name = in.getName();
9197 if (TAG_CATEGORIES.equals(name)) {
9198 attrCount = in.getAttributeCount();
9199 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9200 intent.addCategory(in.getAttributeValue(attrNdx));
9201 }
9202 } else {
9203 Log.w("Intent", "restoreFromXml: unknown name=" + name);
9204 XmlUtils.skipCurrentTag(in);
9205 }
9206 }
9207 }
9208
9209 return intent;
9210 }
9211
Nick Pellyccae4122012-01-09 14:12:58 -08009212 /**
9213 * Normalize a MIME data type.
9214 *
9215 * <p>A normalized MIME type has white-space trimmed,
9216 * content-type parameters removed, and is lower-case.
9217 * This aligns the type with Android best practices for
9218 * intent filtering.
9219 *
9220 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9221 * "text/x-vCard" becomes "text/x-vcard".
9222 *
9223 * <p>All MIME types received from outside Android (such as user input,
9224 * or external sources like Bluetooth, NFC, or the Internet) should
9225 * be normalized before they are used to create an Intent.
9226 *
9227 * @param type MIME data type to normalize
9228 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05009229 * @see #setType
9230 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08009231 */
9232 public static String normalizeMimeType(String type) {
9233 if (type == null) {
9234 return null;
9235 }
9236
Elliott Hughescb64d432013-08-02 10:00:44 -07009237 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08009238
9239 final int semicolonIndex = type.indexOf(';');
9240 if (semicolonIndex != -1) {
9241 type = type.substring(0, semicolonIndex);
9242 }
9243 return type;
9244 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009245
9246 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009247 * Prepare this {@link Intent} to leave an app process.
9248 *
9249 * @hide
9250 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07009251 public void prepareToLeaveProcess(Context context) {
9252 final boolean leavingPackage = (mComponent == null)
9253 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9254 prepareToLeaveProcess(leavingPackage);
9255 }
9256
9257 /**
9258 * Prepare this {@link Intent} to leave an app process.
9259 *
9260 * @hide
9261 */
9262 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009263 setAllowFds(false);
9264
9265 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009266 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009267 }
9268 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009269 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009270 }
9271
Jeff Sharkeya8b42782016-01-30 17:58:09 -07009272 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9273 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07009274 switch (mAction) {
9275 case ACTION_MEDIA_REMOVED:
9276 case ACTION_MEDIA_UNMOUNTED:
9277 case ACTION_MEDIA_CHECKING:
9278 case ACTION_MEDIA_NOFS:
9279 case ACTION_MEDIA_MOUNTED:
9280 case ACTION_MEDIA_SHARED:
9281 case ACTION_MEDIA_UNSHARED:
9282 case ACTION_MEDIA_BAD_REMOVAL:
9283 case ACTION_MEDIA_UNMOUNTABLE:
9284 case ACTION_MEDIA_EJECT:
9285 case ACTION_MEDIA_SCANNER_STARTED:
9286 case ACTION_MEDIA_SCANNER_FINISHED:
9287 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07009288 case ACTION_PACKAGE_NEEDS_VERIFICATION:
9289 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07009290 // Ignore legacy actions
9291 break;
9292 default:
9293 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009294 }
9295 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -07009296
9297 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9298 && leavingPackage) {
9299 switch (mAction) {
9300 case ACTION_PROVIDER_CHANGED:
9301 // Ignore actions that don't need to grant
9302 break;
9303 default:
9304 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9305 }
9306 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -07009307 }
9308
9309 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009310 * @hide
9311 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009312 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -07009313 // We just entered destination process, so we should be able to read all
9314 // parcelables inside.
9315 setDefusable(true);
9316
9317 if (mSelector != null) {
9318 mSelector.prepareToEnterProcess();
9319 }
9320 if (mClipData != null) {
9321 mClipData.prepareToEnterProcess();
9322 }
9323
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009324 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00009325 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9326 fixUris(mContentUserHint);
9327 mContentUserHint = UserHandle.USER_CURRENT;
9328 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009329 }
9330 }
9331
9332 /**
9333 * @hide
9334 */
9335 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009336 Uri data = getData();
9337 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009338 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009339 }
9340 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009341 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009342 }
9343 String action = getAction();
9344 if (ACTION_SEND.equals(action)) {
9345 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9346 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009347 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009348 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009349 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009350 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9351 if (streams != null) {
9352 ArrayList<Uri> newStreams = new ArrayList<Uri>();
9353 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009354 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009355 }
9356 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9357 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009358 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9359 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9360 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9361 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9362 if (output != null) {
9363 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9364 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009365 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009366 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01009367
9368 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009369 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009370 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9371 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009372 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009373 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009374 * @hide
9375 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009376 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009377 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009378 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009379
9380 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009381 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009382
9383 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009384 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009385 // Inspect contained intents to see if we need to migrate extras. We
9386 // don't promote ClipData to the parent, since ChooserActivity will
9387 // already start the picked item as the caller, and we can't combine
9388 // the flags in a safe way.
9389
9390 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009391 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009392 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9393 if (intent != null) {
9394 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009395 }
9396 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009397 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009398 try {
9399 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9400 if (intents != null) {
9401 for (int i = 0; i < intents.length; i++) {
9402 final Intent intent = (Intent) intents[i];
9403 if (intent != null) {
9404 migrated |= intent.migrateExtraStreamToClipData();
9405 }
9406 }
9407 }
9408 } catch (ClassCastException e) {
9409 }
9410 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009411
9412 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009413 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009414 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9415 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9416 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9417 if (stream != null || text != null || htmlText != null) {
9418 final ClipData clipData = new ClipData(
9419 null, new String[] { getType() },
9420 new ClipData.Item(text, htmlText, null, stream));
9421 setClipData(clipData);
9422 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009423 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009424 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009425 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009426 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009427
9428 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009429 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009430 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9431 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9432 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9433 int num = -1;
9434 if (streams != null) {
9435 num = streams.size();
9436 }
9437 if (texts != null) {
9438 if (num >= 0 && num != texts.size()) {
9439 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009440 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009441 }
9442 num = texts.size();
9443 }
9444 if (htmlTexts != null) {
9445 if (num >= 0 && num != htmlTexts.size()) {
9446 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009447 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009448 }
9449 num = htmlTexts.size();
9450 }
9451 if (num > 0) {
9452 final ClipData clipData = new ClipData(
9453 null, new String[] { getType() },
9454 makeClipItem(streams, texts, htmlTexts, 0));
9455
9456 for (int i = 1; i < num; i++) {
9457 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9458 }
9459
9460 setClipData(clipData);
9461 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009462 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009463 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009464 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009465 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009466 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9467 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9468 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9469 final Uri output;
9470 try {
9471 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9472 } catch (ClassCastException e) {
9473 return false;
9474 }
9475 if (output != null) {
9476 setClipData(ClipData.newRawUri("", output));
9477 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9478 return true;
9479 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009480 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009481
9482 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009483 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009484
9485 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9486 ArrayList<String> htmlTexts, int which) {
9487 Uri uri = streams != null ? streams.get(which) : null;
9488 CharSequence text = texts != null ? texts.get(which) : null;
9489 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9490 return new ClipData.Item(text, htmlText, null, uri);
9491 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009492
9493 /** @hide */
9494 public boolean isDocument() {
9495 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9496 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009497}