Intent.java revision 010358f60df3b084893f1d020f1d4fffc7346ae0
1/*
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
19import android.annotation.AnyRes;
20import android.annotation.BroadcastBehavior;
21import android.annotation.IntDef;
22import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
24import android.annotation.SystemApi;
25import android.content.pm.ActivityInfo;
26import android.content.pm.ApplicationInfo;
27import android.content.pm.ComponentInfo;
28import android.content.pm.PackageManager;
29import android.content.pm.ResolveInfo;
30import android.content.res.Resources;
31import android.content.res.TypedArray;
32import android.graphics.Rect;
33import android.net.Uri;
34import android.os.Build;
35import android.os.Bundle;
36import android.os.IBinder;
37import android.os.Parcel;
38import android.os.Parcelable;
39import android.os.Process;
40import android.os.ResultReceiver;
41import android.os.ShellCommand;
42import android.os.StrictMode;
43import android.os.UserHandle;
44import android.os.storage.StorageManager;
45import android.provider.DocumentsContract;
46import android.provider.DocumentsProvider;
47import android.provider.MediaStore;
48import android.provider.OpenableColumns;
49import android.util.ArraySet;
50import android.util.AttributeSet;
51import android.util.Log;
52import com.android.internal.util.XmlUtils;
53import org.xmlpull.v1.XmlPullParser;
54import org.xmlpull.v1.XmlPullParserException;
55import org.xmlpull.v1.XmlSerializer;
56
57import java.io.IOException;
58import java.io.PrintWriter;
59import java.io.Serializable;
60import java.lang.annotation.Retention;
61import java.lang.annotation.RetentionPolicy;
62import java.net.URISyntaxException;
63import java.util.ArrayList;
64import java.util.HashSet;
65import java.util.List;
66import java.util.Locale;
67import java.util.Objects;
68import java.util.Set;
69
70import static android.content.ContentProvider.maybeAddUserId;
71
72/**
73 * An intent is an abstract description of an operation to be performed.  It
74 * can be used with {@link Context#startActivity(Intent) startActivity} to
75 * launch an {@link android.app.Activity},
76 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
77 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
78 * and {@link android.content.Context#startService} or
79 * {@link android.content.Context#bindService} to communicate with a
80 * background {@link android.app.Service}.
81 *
82 * <p>An Intent provides a facility for performing late runtime binding between the code in
83 * different applications. Its most significant use is in the launching of activities, where it
84 * can be thought of as the glue between activities. It is basically a passive data structure
85 * holding an abstract description of an action to be performed.</p>
86 *
87 * <div class="special reference">
88 * <h3>Developer Guides</h3>
89 * <p>For information about how to create and resolve intents, read the
90 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
91 * developer guide.</p>
92 * </div>
93 *
94 * <a name="IntentStructure"></a>
95 * <h3>Intent Structure</h3>
96 * <p>The primary pieces of information in an intent are:</p>
97 *
98 * <ul>
99 *   <li> <p><b>action</b> -- The general action to be performed, such as
100 *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
101 *     etc.</p>
102 *   </li>
103 *   <li> <p><b>data</b> -- The data to operate on, such as a person record
104 *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
105 *   </li>
106 * </ul>
107 *
108 *
109 * <p>Some examples of action/data pairs are:</p>
110 *
111 * <ul>
112 *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
113 *     information about the person whose identifier is "1".</p>
114 *   </li>
115 *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
116 *     the phone dialer with the person filled in.</p>
117 *   </li>
118 *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
119 *     the phone dialer with the given number filled in.  Note how the
120 *     VIEW action does what is considered the most reasonable thing for
121 *     a particular URI.</p>
122 *   </li>
123 *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
124 *     the phone dialer with the given number filled in.</p>
125 *   </li>
126 *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
127 *     information about the person whose identifier is "1".</p>
128 *   </li>
129 *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
130 *     a list of people, which the user can browse through.  This example is a
131 *     typical top-level entry into the Contacts application, showing you the
132 *     list of people. Selecting a particular person to view would result in a
133 *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
134 *     being used to start an activity to display that person.</p>
135 *   </li>
136 * </ul>
137 *
138 * <p>In addition to these primary attributes, there are a number of secondary
139 * attributes that you can also include with an intent:</p>
140 *
141 * <ul>
142 *     <li> <p><b>category</b> -- Gives additional information about the action
143 *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
144 *         appear in the Launcher as a top-level application, while
145 *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
146 *         of alternative actions the user can perform on a piece of data.</p>
147 *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
148 *         intent data.  Normally the type is inferred from the data itself.
149 *         By setting this attribute, you disable that evaluation and force
150 *         an explicit type.</p>
151 *     <li> <p><b>component</b> -- Specifies an explicit name of a component
152 *         class to use for the intent.  Normally this is determined by looking
153 *         at the other information in the intent (the action, data/type, and
154 *         categories) and matching that with a component that can handle it.
155 *         If this attribute is set then none of the evaluation is performed,
156 *         and this component is used exactly as is.  By specifying this attribute,
157 *         all of the other Intent attributes become optional.</p>
158 *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
159 *         This can be used to provide extended information to the component.
160 *         For example, if we have a action to send an e-mail message, we could
161 *         also include extra pieces of data here to supply a subject, body,
162 *         etc.</p>
163 * </ul>
164 *
165 * <p>Here are some examples of other operations you can specify as intents
166 * using these additional parameters:</p>
167 *
168 * <ul>
169 *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
170 *     Launch the home screen.</p>
171 *   </li>
172 *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
173 *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
174 *     vnd.android.cursor.item/phone}</i></b>
175 *     -- Display the list of people's phone numbers, allowing the user to
176 *     browse through them and pick one and return it to the parent activity.</p>
177 *   </li>
178 *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
179 *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
180 *     -- Display all pickers for data that can be opened with
181 *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
182 *     allowing the user to pick one of them and then some data inside of it
183 *     and returning the resulting URI to the caller.  This can be used,
184 *     for example, in an e-mail application to allow the user to pick some
185 *     data to include as an attachment.</p>
186 *   </li>
187 * </ul>
188 *
189 * <p>There are a variety of standard Intent action and category constants
190 * defined in the Intent class, but applications can also define their own.
191 * These strings use Java-style scoping, to ensure they are unique -- for
192 * example, the standard {@link #ACTION_VIEW} is called
193 * "android.intent.action.VIEW".</p>
194 *
195 * <p>Put together, the set of actions, data types, categories, and extra data
196 * defines a language for the system allowing for the expression of phrases
197 * such as "call john smith's cell".  As applications are added to the system,
198 * they can extend this language by adding new actions, types, and categories, or
199 * they can modify the behavior of existing phrases by supplying their own
200 * activities that handle them.</p>
201 *
202 * <a name="IntentResolution"></a>
203 * <h3>Intent Resolution</h3>
204 *
205 * <p>There are two primary forms of intents you will use.
206 *
207 * <ul>
208 *     <li> <p><b>Explicit Intents</b> have specified a component (via
209 *     {@link #setComponent} or {@link #setClass}), which provides the exact
210 *     class to be run.  Often these will not include any other information,
211 *     simply being a way for an application to launch various internal
212 *     activities it has as the user interacts with the application.
213 *
214 *     <li> <p><b>Implicit Intents</b> have not specified a component;
215 *     instead, they must include enough information for the system to
216 *     determine which of the available components is best to run for that
217 *     intent.
218 * </ul>
219 *
220 * <p>When using implicit intents, given such an arbitrary intent we need to
221 * know what to do with it. This is handled by the process of <em>Intent
222 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
223 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
224 * more activities/receivers) that can handle it.</p>
225 *
226 * <p>The intent resolution mechanism basically revolves around matching an
227 * Intent against all of the &lt;intent-filter&gt; descriptions in the
228 * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
229 * objects explicitly registered with {@link Context#registerReceiver}.)  More
230 * details on this can be found in the documentation on the {@link
231 * IntentFilter} class.</p>
232 *
233 * <p>There are three pieces of information in the Intent that are used for
234 * resolution: the action, type, and category.  Using this information, a query
235 * is done on the {@link PackageManager} for a component that can handle the
236 * intent. The appropriate component is determined based on the intent
237 * information supplied in the <code>AndroidManifest.xml</code> file as
238 * follows:</p>
239 *
240 * <ul>
241 *     <li> <p>The <b>action</b>, if given, must be listed by the component as
242 *         one it handles.</p>
243 *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
244 *         already supplied in the Intent.  Like the action, if a type is
245 *         included in the intent (either explicitly or implicitly in its
246 *         data), then this must be listed by the component as one it handles.</p>
247 *     <li> For data that is not a <code>content:</code> URI and where no explicit
248 *         type is included in the Intent, instead the <b>scheme</b> of the
249 *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
250 *         considered. Again like the action, if we are matching a scheme it
251 *         must be listed by the component as one it can handle.
252 *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
253 *         by the activity as categories it handles.  That is, if you include
254 *         the categories {@link #CATEGORY_LAUNCHER} and
255 *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
256 *         with an intent that lists <em>both</em> of those categories.
257 *         Activities will very often need to support the
258 *         {@link #CATEGORY_DEFAULT} so that they can be found by
259 *         {@link Context#startActivity Context.startActivity()}.</p>
260 * </ul>
261 *
262 * <p>For example, consider the Note Pad sample application that
263 * allows user to browse through a list of notes data and view details about
264 * individual items.  Text in italics indicate places were you would replace a
265 * name with one specific to your own package.</p>
266 *
267 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
268 *       package="<i>com.android.notepad</i>"&gt;
269 *     &lt;application android:icon="@drawable/app_notes"
270 *             android:label="@string/app_name"&gt;
271 *
272 *         &lt;provider class=".NotePadProvider"
273 *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
274 *
275 *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
276 *             &lt;intent-filter&gt;
277 *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
278 *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
279 *             &lt;/intent-filter&gt;
280 *             &lt;intent-filter&gt;
281 *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
282 *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
283 *                 &lt;action android:name="android.intent.action.PICK" /&gt;
284 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
285 *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
286 *             &lt;/intent-filter&gt;
287 *             &lt;intent-filter&gt;
288 *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
289 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
291 *             &lt;/intent-filter&gt;
292 *         &lt;/activity&gt;
293 *
294 *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
295 *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
296 *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
297 *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
298 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
300 *             &lt;/intent-filter&gt;
301 *
302 *             &lt;intent-filter&gt;
303 *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
304 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305 *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
306 *             &lt;/intent-filter&gt;
307 *
308 *         &lt;/activity&gt;
309 *
310 *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
311 *                 android:theme="@android:style/Theme.Dialog"&gt;
312 *             &lt;intent-filter android:label="@string/resolve_title"&gt;
313 *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
314 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
316 *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
317 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
318 *             &lt;/intent-filter&gt;
319 *         &lt;/activity&gt;
320 *
321 *     &lt;/application&gt;
322 * &lt;/manifest&gt;</pre>
323 *
324 * <p>The first activity,
325 * <code>com.android.notepad.NotesList</code>, serves as our main
326 * entry into the app.  It can do three things as described by its three intent
327 * templates:
328 * <ol>
329 * <li><pre>
330 * &lt;intent-filter&gt;
331 *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
332 *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
333 * &lt;/intent-filter&gt;</pre>
334 * <p>This provides a top-level entry into the NotePad application: the standard
335 * MAIN action is a main entry point (not requiring any other information in
336 * the Intent), and the LAUNCHER category says that this entry point should be
337 * listed in the application launcher.</p>
338 * <li><pre>
339 * &lt;intent-filter&gt;
340 *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
341 *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
342 *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
343 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
344 *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
345 * &lt;/intent-filter&gt;</pre>
346 * <p>This declares the things that the activity can do on a directory of
347 * notes.  The type being supported is given with the &lt;type&gt; tag, where
348 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
349 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
350 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
351 * The activity allows the user to view or edit the directory of data (via
352 * the VIEW and EDIT actions), or to pick a particular note and return it
353 * to the caller (via the PICK action).  Note also the DEFAULT category
354 * supplied here: this is <em>required</em> for the
355 * {@link Context#startActivity Context.startActivity} method to resolve your
356 * activity when its component name is not explicitly specified.</p>
357 * <li><pre>
358 * &lt;intent-filter&gt;
359 *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
360 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
362 * &lt;/intent-filter&gt;</pre>
363 * <p>This filter describes the ability to return to the caller a note selected by
364 * the user without needing to know where it came from.  The data type
365 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
366 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
367 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
368 * The GET_CONTENT action is similar to the PICK action, where the activity
369 * will return to its caller a piece of data selected by the user.  Here,
370 * however, the caller specifies the type of data they desire instead of
371 * the type of data the user will be picking from.</p>
372 * </ol>
373 *
374 * <p>Given these capabilities, the following intents will resolve to the
375 * NotesList activity:</p>
376 *
377 * <ul>
378 *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
379 *         activities that can be used as top-level entry points into an
380 *         application.</p>
381 *     <li> <p><b>{ action=android.app.action.MAIN,
382 *         category=android.app.category.LAUNCHER }</b> is the actual intent
383 *         used by the Launcher to populate its top-level list.</p>
384 *     <li> <p><b>{ action=android.intent.action.VIEW
385 *          data=content://com.google.provider.NotePad/notes }</b>
386 *         displays a list of all the notes under
387 *         "content://com.google.provider.NotePad/notes", which
388 *         the user can browse through and see the details on.</p>
389 *     <li> <p><b>{ action=android.app.action.PICK
390 *          data=content://com.google.provider.NotePad/notes }</b>
391 *         provides a list of the notes under
392 *         "content://com.google.provider.NotePad/notes", from which
393 *         the user can pick a note whose data URL is returned back to the caller.</p>
394 *     <li> <p><b>{ action=android.app.action.GET_CONTENT
395 *          type=vnd.android.cursor.item/vnd.google.note }</b>
396 *         is similar to the pick action, but allows the caller to specify the
397 *         kind of data they want back so that the system can find the appropriate
398 *         activity to pick something of that data type.</p>
399 * </ul>
400 *
401 * <p>The second activity,
402 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
403 * note entry and allows them to edit it.  It can do two things as described
404 * by its two intent templates:
405 * <ol>
406 * <li><pre>
407 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
408 *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
409 *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
410 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
411 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
412 * &lt;/intent-filter&gt;</pre>
413 * <p>The first, primary, purpose of this activity is to let the user interact
414 * with a single note, as decribed by the MIME type
415 * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
416 * either VIEW a note or allow the user to EDIT it.  Again we support the
417 * DEFAULT category to allow the activity to be launched without explicitly
418 * specifying its component.</p>
419 * <li><pre>
420 * &lt;intent-filter&gt;
421 *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
422 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
423 *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
424 * &lt;/intent-filter&gt;</pre>
425 * <p>The secondary use of this activity is to insert a new note entry into
426 * an existing directory of notes.  This is used when the user creates a new
427 * note: the INSERT action is executed on the directory of notes, causing
428 * this activity to run and have the user create the new note data which
429 * it then adds to the content provider.</p>
430 * </ol>
431 *
432 * <p>Given these capabilities, the following intents will resolve to the
433 * NoteEditor activity:</p>
434 *
435 * <ul>
436 *     <li> <p><b>{ action=android.intent.action.VIEW
437 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
438 *         shows the user the content of note <var>{ID}</var>.</p>
439 *     <li> <p><b>{ action=android.app.action.EDIT
440 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
441 *         allows the user to edit the content of note <var>{ID}</var>.</p>
442 *     <li> <p><b>{ action=android.app.action.INSERT
443 *          data=content://com.google.provider.NotePad/notes }</b>
444 *         creates a new, empty note in the notes list at
445 *         "content://com.google.provider.NotePad/notes"
446 *         and allows the user to edit it.  If they keep their changes, the URI
447 *         of the newly created note is returned to the caller.</p>
448 * </ul>
449 *
450 * <p>The last activity,
451 * <code>com.android.notepad.TitleEditor</code>, allows the user to
452 * edit the title of a note.  This could be implemented as a class that the
453 * application directly invokes (by explicitly setting its component in
454 * the Intent), but here we show a way you can publish alternative
455 * operations on existing data:</p>
456 *
457 * <pre>
458 * &lt;intent-filter android:label="@string/resolve_title"&gt;
459 *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
460 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
461 *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
462 *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
463 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
464 * &lt;/intent-filter&gt;</pre>
465 *
466 * <p>In the single intent template here, we
467 * have created our own private action called
468 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
469 * edit the title of a note.  It must be invoked on a specific note
470 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
471 * view and edit actions, but here displays and edits the title contained
472 * in the note data.
473 *
474 * <p>In addition to supporting the default category as usual, our title editor
475 * also supports two other standard categories: ALTERNATIVE and
476 * SELECTED_ALTERNATIVE.  Implementing
477 * these categories allows others to find the special action it provides
478 * without directly knowing about it, through the
479 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
480 * more often to build dynamic menu items with
481 * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
482 * template here was also supply an explicit name for the template
483 * (via <code>android:label="@string/resolve_title"</code>) to better control
484 * what the user sees when presented with this activity as an alternative
485 * action to the data they are viewing.
486 *
487 * <p>Given these capabilities, the following intent will resolve to the
488 * TitleEditor activity:</p>
489 *
490 * <ul>
491 *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
492 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
493 *         displays and allows the user to edit the title associated
494 *         with note <var>{ID}</var>.</p>
495 * </ul>
496 *
497 * <h3>Standard Activity Actions</h3>
498 *
499 * <p>These are the current standard actions that Intent defines for launching
500 * activities (usually through {@link Context#startActivity}.  The most
501 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
502 * {@link #ACTION_EDIT}.
503 *
504 * <ul>
505 *     <li> {@link #ACTION_MAIN}
506 *     <li> {@link #ACTION_VIEW}
507 *     <li> {@link #ACTION_ATTACH_DATA}
508 *     <li> {@link #ACTION_EDIT}
509 *     <li> {@link #ACTION_PICK}
510 *     <li> {@link #ACTION_CHOOSER}
511 *     <li> {@link #ACTION_GET_CONTENT}
512 *     <li> {@link #ACTION_DIAL}
513 *     <li> {@link #ACTION_CALL}
514 *     <li> {@link #ACTION_SEND}
515 *     <li> {@link #ACTION_SENDTO}
516 *     <li> {@link #ACTION_ANSWER}
517 *     <li> {@link #ACTION_INSERT}
518 *     <li> {@link #ACTION_DELETE}
519 *     <li> {@link #ACTION_RUN}
520 *     <li> {@link #ACTION_SYNC}
521 *     <li> {@link #ACTION_PICK_ACTIVITY}
522 *     <li> {@link #ACTION_SEARCH}
523 *     <li> {@link #ACTION_WEB_SEARCH}
524 *     <li> {@link #ACTION_FACTORY_TEST}
525 * </ul>
526 *
527 * <h3>Standard Broadcast Actions</h3>
528 *
529 * <p>These are the current standard actions that Intent defines for receiving
530 * broadcasts (usually through {@link Context#registerReceiver} or a
531 * &lt;receiver&gt; tag in a manifest).
532 *
533 * <ul>
534 *     <li> {@link #ACTION_TIME_TICK}
535 *     <li> {@link #ACTION_TIME_CHANGED}
536 *     <li> {@link #ACTION_TIMEZONE_CHANGED}
537 *     <li> {@link #ACTION_BOOT_COMPLETED}
538 *     <li> {@link #ACTION_PACKAGE_ADDED}
539 *     <li> {@link #ACTION_PACKAGE_CHANGED}
540 *     <li> {@link #ACTION_PACKAGE_REMOVED}
541 *     <li> {@link #ACTION_PACKAGE_RESTARTED}
542 *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
543 *     <li> {@link #ACTION_PACKAGES_SUSPENDED}
544 *     <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
545 *     <li> {@link #ACTION_UID_REMOVED}
546 *     <li> {@link #ACTION_BATTERY_CHANGED}
547 *     <li> {@link #ACTION_POWER_CONNECTED}
548 *     <li> {@link #ACTION_POWER_DISCONNECTED}
549 *     <li> {@link #ACTION_SHUTDOWN}
550 * </ul>
551 *
552 * <h3>Standard Categories</h3>
553 *
554 * <p>These are the current standard categories that can be used to further
555 * clarify an Intent via {@link #addCategory}.
556 *
557 * <ul>
558 *     <li> {@link #CATEGORY_DEFAULT}
559 *     <li> {@link #CATEGORY_BROWSABLE}
560 *     <li> {@link #CATEGORY_TAB}
561 *     <li> {@link #CATEGORY_ALTERNATIVE}
562 *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
563 *     <li> {@link #CATEGORY_LAUNCHER}
564 *     <li> {@link #CATEGORY_INFO}
565 *     <li> {@link #CATEGORY_HOME}
566 *     <li> {@link #CATEGORY_PREFERENCE}
567 *     <li> {@link #CATEGORY_TEST}
568 *     <li> {@link #CATEGORY_CAR_DOCK}
569 *     <li> {@link #CATEGORY_DESK_DOCK}
570 *     <li> {@link #CATEGORY_LE_DESK_DOCK}
571 *     <li> {@link #CATEGORY_HE_DESK_DOCK}
572 *     <li> {@link #CATEGORY_CAR_MODE}
573 *     <li> {@link #CATEGORY_APP_MARKET}
574 *     <li> {@link #CATEGORY_VR_HOME}
575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
583 *     <li> {@link #EXTRA_ALARM_COUNT}
584 *     <li> {@link #EXTRA_BCC}
585 *     <li> {@link #EXTRA_CC}
586 *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 *     <li> {@link #EXTRA_DATA_REMOVED}
588 *     <li> {@link #EXTRA_DOCK_STATE}
589 *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
591 *     <li> {@link #EXTRA_DOCK_STATE_CAR}
592 *     <li> {@link #EXTRA_DOCK_STATE_DESK}
593 *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 *     <li> {@link #EXTRA_DONT_KILL_APP}
595 *     <li> {@link #EXTRA_EMAIL}
596 *     <li> {@link #EXTRA_INITIAL_INTENTS}
597 *     <li> {@link #EXTRA_INTENT}
598 *     <li> {@link #EXTRA_KEY_EVENT}
599 *     <li> {@link #EXTRA_ORIGINATING_URI}
600 *     <li> {@link #EXTRA_PHONE_NUMBER}
601 *     <li> {@link #EXTRA_REFERRER}
602 *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 *     <li> {@link #EXTRA_REPLACING}
604 *     <li> {@link #EXTRA_SHORTCUT_ICON}
605 *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 *     <li> {@link #EXTRA_SHORTCUT_INTENT}
607 *     <li> {@link #EXTRA_STREAM}
608 *     <li> {@link #EXTRA_SHORTCUT_NAME}
609 *     <li> {@link #EXTRA_SUBJECT}
610 *     <li> {@link #EXTRA_TEMPLATE}
611 *     <li> {@link #EXTRA_TEXT}
612 *     <li> {@link #EXTRA_TITLE}
613 *     <li> {@link #EXTRA_UID}
614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
619 * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
620 * of all possible flags.
621 */
622public class Intent implements Parcelable, Cloneable {
623    private static final String ATTR_ACTION = "action";
624    private static final String TAG_CATEGORIES = "categories";
625    private static final String ATTR_CATEGORY = "category";
626    private static final String TAG_EXTRA = "extra";
627    private static final String ATTR_TYPE = "type";
628    private static final String ATTR_COMPONENT = "component";
629    private static final String ATTR_DATA = "data";
630    private static final String ATTR_FLAGS = "flags";
631
632    // ---------------------------------------------------------------------
633    // ---------------------------------------------------------------------
634    // Standard intent activity actions (see action variable).
635
636    /**
637     *  Activity Action: Start as a main entry point, does not expect to
638     *  receive data.
639     *  <p>Input: nothing
640     *  <p>Output: nothing
641     */
642    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643    public static final String ACTION_MAIN = "android.intent.action.MAIN";
644
645    /**
646     * Activity Action: Display the data to the user.  This is the most common
647     * action performed on data -- it is the generic action you can use on
648     * a piece of data to get the most reasonable thing to occur.  For example,
649     * when used on a contacts entry it will view the entry; when used on a
650     * mailto: URI it will bring up a compose window filled with the information
651     * supplied by the URI; when used with a tel: URI it will invoke the
652     * dialer.
653     * <p>Input: {@link #getData} is URI from which to retrieve data.
654     * <p>Output: nothing.
655     */
656    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657    public static final String ACTION_VIEW = "android.intent.action.VIEW";
658
659    /**
660     * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661     * performed on a piece of data.
662     */
663    public static final String ACTION_DEFAULT = ACTION_VIEW;
664
665    /**
666     * Activity Action: Quick view the data. Launches a quick viewer for
667     * a URI or a list of URIs.
668     * <p>Activities handling this intent action should handle the vast majority of
669     * MIME types rather than only specific ones.
670     * <p>Quick viewers must render the quick view image locally, and must not send
671     * file content outside current device.
672     * <p>Input: {@link #getData} is a mandatory content URI of the item to
673     * preview. {@link #getClipData} contains an optional list of content URIs
674     * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
675     * optional index of the URI in the clip data to show first.
676     * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
677     * that can be shown in the quick view UI.
678     * <p>Output: nothing.
679     * @see #EXTRA_INDEX
680     * @see #EXTRA_QUICK_VIEW_FEATURES
681     */
682    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683    public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
684
685    /**
686     * 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";
695
696    /**
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";
703
704    /**
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";
714
715    /**
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";
723
724    /**
725     * Activity Action: Creates a shortcut.
726     * <p>Input: Nothing.</p>
727     * <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
729     * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
730     * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
731     * (value: ShortcutIconResource).</p>
732     *
733     * @see android.content.pm.ShortcutManager#createShortcutResultIntent
734     * @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
747     * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
748     */
749    @Deprecated
750    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
755     * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
756     */
757    @Deprecated
758    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
763     * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
764     */
765    @Deprecated
766    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
772     * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
773     */
774    @Deprecated
775    public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
776            "android.intent.extra.shortcut.ICON_RESOURCE";
777
778    /**
779     * 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    /**
787     * 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    /**
800     * Represents a shortcut/live folder icon resource.
801     *
802     * @see Intent#ACTION_CREATE_SHORTCUT
803     * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
804     * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
805     * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
806     */
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.
823         * @param resourceId The resource identifier for the icon.
824         * @return A new ShortcutIconResource with the specified's context package name
825         *         and icon resource identifier.``
826         */
827        public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
828            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>
899     * 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>
906     * As a convenience, an Intent of this form can be created with the
907     * {@link #createChooser} function.
908     * <p>
909     * Input: No data should be specified.  get*Extra must have
910     * 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.
913     * <p>
914     * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
915     */
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     *
922     * <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,
928     * or a new ClipData built from {@link #getData()}.
929     *
930     * @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) {
938        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) {
966        Intent intent = new Intent(ACTION_CHOOSER);
967        intent.putExtra(EXTRA_INTENT, target);
968        if (title != null) {
969            intent.putExtra(EXTRA_TITLE, title);
970        }
971
972        if (sender != null) {
973            intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
974        }
975
976        // Migrate any clip data and flags from target.
977        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);
980        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            }
996        }
997
998        return intent;
999    }
1000
1001    /**
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
1005     * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
1006     * create the data as it runs (for example taking a picture or recording a
1007     * sound), let them browse over the web and download the desired data,
1008     * etc.
1009     * <p>
1010     * There are two main ways to use this action: if you want a specific kind
1011     * 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>
1028     * When using such a broad GET_CONTENT action, it is often desirable to
1029     * 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>
1032     * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1033     * the launched content chooser only returns results representing data that
1034     * 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>
1039     * 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>
1043     * 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
1047     * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1048     * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1049     * allow the user to select multiple items.
1050     * <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.
1079     *
1080     * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1081     * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1082     * permission which is not granted, then attempting to use this action will
1083     * result in a {@link java.lang.SecurityException}.
1084     */
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    @SystemApi
1096    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1097    public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1098    /**
1099     * Activity action: Perform a call to any number (emergency or not)
1100     * specified by the data.
1101     * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1102     * tel: URI of an explicit phone number.
1103     * <p>Output: nothing.
1104     * @hide
1105     */
1106    @SystemApi
1107    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1108    public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1109
1110    /**
1111     * Activity Action: Main entry point for carrier setup apps.
1112     * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1113     * carrier service and typically require
1114     * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1115     * fulfill their duties.
1116     */
1117    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118    public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1119    /**
1120     * Activity Action: Send a message to someone specified by the data.
1121     * <p>Input: {@link #getData} is URI describing the target.
1122     * <p>Output: nothing.
1123     */
1124    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125    public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1126    /**
1127     * Activity Action: Deliver some data to someone else.  Who the data is
1128     * being delivered to is not specified; it is up to the receiver of this
1129     * action to ask the user where the data should be sent.
1130     * <p>
1131     * When launching a SEND intent, you should usually wrap it in a chooser
1132     * (through {@link #createChooser}), which will give the proper interface
1133     * for the user to pick how to send your data and allow you to specify
1134     * a prompt indicating what they are doing.
1135     * <p>
1136     * Input: {@link #getType} is the MIME type of the data being sent.
1137     * get*Extra can have either a {@link #EXTRA_TEXT}
1138     * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
1139     * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1140     * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
1141     * if the MIME type is unknown (this will only allow senders that can
1142     * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
1143     * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1144     * your text with HTML formatting.
1145     * <p>
1146     * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1147     * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1148     * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1149     * content: URIs and other advanced features of {@link ClipData}.  If
1150     * using this approach, you still must supply the same data through the
1151     * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1152     * for compatibility with old applications.  If you don't set a ClipData,
1153     * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1154     * <p>
1155     * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1156     * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1157     * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1158     * be openable only as asset typed files using
1159     * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1160     * <p>
1161     * Optional standard extras, which may be interpreted by some recipients as
1162     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1163     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1164     * <p>
1165     * Output: nothing.
1166     */
1167    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1168    public static final String ACTION_SEND = "android.intent.action.SEND";
1169    /**
1170     * Activity Action: Deliver multiple data to someone else.
1171     * <p>
1172     * Like {@link #ACTION_SEND}, except the data is multiple.
1173     * <p>
1174     * Input: {@link #getType} is the MIME type of the data being sent.
1175     * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1176     * #EXTRA_STREAM} field, containing the data to be sent.  If using
1177     * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1178     * for clients to retrieve your text with HTML formatting.
1179     * <p>
1180     * Multiple types are supported, and receivers should handle mixed types
1181     * whenever possible. The right way for the receiver to check them is to
1182     * use the content resolver on each URI. The intent sender should try to
1183     * put the most concrete mime type in the intent type, but it can fall
1184     * back to {@literal <type>/*} or {@literal *}/* as needed.
1185     * <p>
1186     * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1187     * be image/jpg, but if you are sending image/jpg and image/png, then the
1188     * intent's type should be image/*.
1189     * <p>
1190     * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1191     * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1192     * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1193     * content: URIs and other advanced features of {@link ClipData}.  If
1194     * using this approach, you still must supply the same data through the
1195     * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1196     * for compatibility with old applications.  If you don't set a ClipData,
1197     * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1198     * <p>
1199     * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1200     * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1201     * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1202     * be openable only as asset typed files using
1203     * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1204     * <p>
1205     * Optional standard extras, which may be interpreted by some recipients as
1206     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1207     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1208     * <p>
1209     * Output: nothing.
1210     */
1211    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1212    public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1213    /**
1214     * Activity Action: Handle an incoming phone call.
1215     * <p>Input: nothing.
1216     * <p>Output: nothing.
1217     */
1218    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1219    public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1220    /**
1221     * Activity Action: Insert an empty item into the given container.
1222     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1223     * in which to place the data.
1224     * <p>Output: URI of the new data that was created.
1225     */
1226    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227    public static final String ACTION_INSERT = "android.intent.action.INSERT";
1228    /**
1229     * Activity Action: Create a new item in the given container, initializing it
1230     * from the current contents of the clipboard.
1231     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1232     * in which to place the data.
1233     * <p>Output: URI of the new data that was created.
1234     */
1235    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236    public static final String ACTION_PASTE = "android.intent.action.PASTE";
1237    /**
1238     * Activity Action: Delete the given data from its container.
1239     * <p>Input: {@link #getData} is URI of data to be deleted.
1240     * <p>Output: nothing.
1241     */
1242    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243    public static final String ACTION_DELETE = "android.intent.action.DELETE";
1244    /**
1245     * Activity Action: Run the data, whatever that means.
1246     * <p>Input: ?  (Note: this is currently specific to the test harness.)
1247     * <p>Output: nothing.
1248     */
1249    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250    public static final String ACTION_RUN = "android.intent.action.RUN";
1251    /**
1252     * Activity Action: Perform a data synchronization.
1253     * <p>Input: ?
1254     * <p>Output: ?
1255     */
1256    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257    public static final String ACTION_SYNC = "android.intent.action.SYNC";
1258    /**
1259     * Activity Action: Pick an activity given an intent, returning the class
1260     * selected.
1261     * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1262     * used with {@link PackageManager#queryIntentActivities} to determine the
1263     * set of activities from which to pick.
1264     * <p>Output: Class name of the activity that was selected.
1265     */
1266    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267    public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1268    /**
1269     * Activity Action: Perform a search.
1270     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1271     * is the text to search for.  If empty, simply
1272     * enter your search results Activity with the search UI activated.
1273     * <p>Output: nothing.
1274     */
1275    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276    public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1277    /**
1278     * Activity Action: Start the platform-defined tutorial
1279     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1280     * is the text to search for.  If empty, simply
1281     * enter your search results Activity with the search UI activated.
1282     * <p>Output: nothing.
1283     */
1284    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1285    public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1286    /**
1287     * Activity Action: Perform a web search.
1288     * <p>
1289     * Input: {@link android.app.SearchManager#QUERY
1290     * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1291     * a url starts with http or https, the site will be opened. If it is plain
1292     * text, Google search will be applied.
1293     * <p>
1294     * Output: nothing.
1295     */
1296    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1297    public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1298
1299    /**
1300     * Activity Action: Perform assist action.
1301     * <p>
1302     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1303     * additional optional contextual information about where the user was when they
1304     * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1305     * information.
1306     * Output: nothing.
1307     */
1308    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309    public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1310
1311    /**
1312     * Activity Action: Perform voice assist action.
1313     * <p>
1314     * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1315     * additional optional contextual information about where the user was when they
1316     * requested the voice assist.
1317     * Output: nothing.
1318     * @hide
1319     */
1320    @SystemApi
1321    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322    public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1323
1324    /**
1325     * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1326     * application package at the time the assist was invoked.
1327     */
1328    public static final String EXTRA_ASSIST_PACKAGE
1329            = "android.intent.extra.ASSIST_PACKAGE";
1330
1331    /**
1332     * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1333     * application package at the time the assist was invoked.
1334     */
1335    public static final String EXTRA_ASSIST_UID
1336            = "android.intent.extra.ASSIST_UID";
1337
1338    /**
1339     * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1340     * information supplied by the current foreground app at the time of the assist request.
1341     * This is a {@link Bundle} of additional data.
1342     */
1343    public static final String EXTRA_ASSIST_CONTEXT
1344            = "android.intent.extra.ASSIST_CONTEXT";
1345
1346    /**
1347     * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1348     * keyboard as the primary input device for assistance.
1349     */
1350    public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1351            "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1352
1353    /**
1354     * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1355     * that was used to invoke the assist.
1356     */
1357    public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1358            "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1359
1360    /**
1361     * Activity Action: List all available applications.
1362     * <p>Input: Nothing.
1363     * <p>Output: nothing.
1364     */
1365    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366    public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1367    /**
1368     * Activity Action: Show settings for choosing wallpaper.
1369     * <p>Input: Nothing.
1370     * <p>Output: Nothing.
1371     */
1372    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1373    public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1374
1375    /**
1376     * Activity Action: Show activity for reporting a bug.
1377     * <p>Input: Nothing.
1378     * <p>Output: Nothing.
1379     */
1380    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1381    public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1382
1383    /**
1384     *  Activity Action: Main entry point for factory tests.  Only used when
1385     *  the device is booting in factory test node.  The implementing package
1386     *  must be installed in the system image.
1387     *  <p>Input: nothing
1388     *  <p>Output: nothing
1389     */
1390    public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1391
1392    /**
1393     * Activity Action: The user pressed the "call" button to go to the dialer
1394     * or other appropriate UI for placing a call.
1395     * <p>Input: Nothing.
1396     * <p>Output: Nothing.
1397     */
1398    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1399    public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1400
1401    /**
1402     * Activity Action: Start Voice Command.
1403     * <p>Input: Nothing.
1404     * <p>Output: Nothing.
1405     */
1406    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1407    public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1408
1409    /**
1410     * Activity Action: Start action associated with long pressing on the
1411     * search key.
1412     * <p>Input: Nothing.
1413     * <p>Output: Nothing.
1414     */
1415    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1416    public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1417
1418    /**
1419     * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1420     * This intent is delivered to the package which installed the application, usually
1421     * Google Play.
1422     * <p>Input: No data is specified. The bug report is passed in using
1423     * an {@link #EXTRA_BUG_REPORT} field.
1424     * <p>Output: Nothing.
1425     *
1426     * @see #EXTRA_BUG_REPORT
1427     */
1428    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429    public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1430
1431    /**
1432     * Activity Action: Show power usage information to the user.
1433     * <p>Input: Nothing.
1434     * <p>Output: Nothing.
1435     */
1436    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1437    public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1438
1439    /**
1440     * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1441     * to run.
1442     * <p>Input: Nothing.
1443     * <p>Output: Nothing.
1444     * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1445     * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1446     * @hide
1447     */
1448    @Deprecated
1449    @SystemApi
1450    public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1451            "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1452
1453    /**
1454     * Activity Action: Setup wizard to launch after a platform update.  This
1455     * activity should have a string meta-data field associated with it,
1456     * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1457     * the platform for setup.  The activity will be launched only if
1458     * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1459     * same value.
1460     * <p>Input: Nothing.
1461     * <p>Output: Nothing.
1462     * @hide
1463     */
1464    @SystemApi
1465    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1466    public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1467
1468    /**
1469     * Activity Action: Start the Keyboard Shortcuts Helper screen.
1470     * <p>Input: Nothing.
1471     * <p>Output: Nothing.
1472     * @hide
1473     */
1474    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1475    public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1476            "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1477
1478    /**
1479     * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1480     * <p>Input: Nothing.
1481     * <p>Output: Nothing.
1482     * @hide
1483     */
1484    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1485    public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1486            "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1487
1488    /**
1489     * Activity Action: Show settings for managing network data usage of a
1490     * specific application. Applications should define an activity that offers
1491     * options to control data usage.
1492     */
1493    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1494    public static final String ACTION_MANAGE_NETWORK_USAGE =
1495            "android.intent.action.MANAGE_NETWORK_USAGE";
1496
1497    /**
1498     * Activity Action: Launch application installer.
1499     * <p>
1500     * Input: The data must be a content: URI at which the application
1501     * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1502     * you can also use "package:<package-name>" to install an application for the
1503     * current user that is already installed for another user. You can optionally supply
1504     * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1505     * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1506     * <p>
1507     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1508     * succeeded.
1509     * <p>
1510     * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1511     * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1512     * in order to launch the application installer.
1513     * </p>
1514     *
1515     * @see #EXTRA_INSTALLER_PACKAGE_NAME
1516     * @see #EXTRA_NOT_UNKNOWN_SOURCE
1517     * @see #EXTRA_RETURN_RESULT
1518     */
1519    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1520    public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1521
1522    /**
1523     * Activity Action: Launch ephemeral installer.
1524     * <p>
1525     * Input: The data must be a http: URI that the ephemeral application is registered
1526     * to handle.
1527     * <p class="note">
1528     * This is a protected intent that can only be sent by the system.
1529     * </p>
1530     *
1531     * @hide
1532     */
1533    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1534    public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1535            = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1536
1537    /**
1538     * Service Action: Resolve ephemeral application.
1539     * <p>
1540     * The system will have a persistent connection to this service.
1541     * This is a protected intent that can only be sent by the system.
1542     * </p>
1543     *
1544     * @hide
1545     */
1546    @SdkConstant(SdkConstantType.SERVICE_ACTION)
1547    public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1548            = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1549
1550    /**
1551     * Activity Action: Launch ephemeral settings.
1552     *
1553     * <p class="note">
1554     * This is a protected intent that can only be sent by the system.
1555     * </p>
1556     *
1557     * @hide
1558     */
1559    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1560    public static final String ACTION_EPHEMERAL_RESOLVER_SETTINGS
1561            = "android.intent.action.EPHEMERAL_RESOLVER_SETTINGS";
1562
1563    /**
1564     * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1565     * package.  Specifies the installer package name; this package will receive the
1566     * {@link #ACTION_APP_ERROR} intent.
1567     */
1568    public static final String EXTRA_INSTALLER_PACKAGE_NAME
1569            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1570
1571    /**
1572     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1573     * package.  Specifies that the application being installed should not be
1574     * treated as coming from an unknown source, but as coming from the app
1575     * invoking the Intent.  For this to work you must start the installer with
1576     * startActivityForResult().
1577     */
1578    public static final String EXTRA_NOT_UNKNOWN_SOURCE
1579            = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1580
1581    /**
1582     * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1583     * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1584     * data field originated from.
1585     */
1586    public static final String EXTRA_ORIGINATING_URI
1587            = "android.intent.extra.ORIGINATING_URI";
1588
1589    /**
1590     * This extra can be used with any Intent used to launch an activity, supplying information
1591     * about who is launching that activity.  This field contains a {@link android.net.Uri}
1592     * object, typically an http: or https: URI of the web site that the referral came from;
1593     * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1594     * a native application that it came from.
1595     *
1596     * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1597     * instead of directly retrieving the extra.  It is also valid for applications to
1598     * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1599     * a string, not a Uri; the field here, if supplied, will always take precedence,
1600     * however.</p>
1601     *
1602     * @see #EXTRA_REFERRER_NAME
1603     */
1604    public static final String EXTRA_REFERRER
1605            = "android.intent.extra.REFERRER";
1606
1607    /**
1608     * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1609     * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
1610     * not be created, in particular when Intent extras are supplied through the
1611     * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1612     * schemes.
1613     *
1614     * @see #EXTRA_REFERRER
1615     */
1616    public static final String EXTRA_REFERRER_NAME
1617            = "android.intent.extra.REFERRER_NAME";
1618
1619    /**
1620     * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1621     * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1622     * @hide
1623     */
1624    @SystemApi
1625    public static final String EXTRA_ORIGINATING_UID
1626            = "android.intent.extra.ORIGINATING_UID";
1627
1628    /**
1629     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1630     * package.  Tells the installer UI to skip the confirmation with the user
1631     * if the .apk is replacing an existing one.
1632     * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1633     * will no longer show an interstitial message about updating existing
1634     * applications so this is no longer needed.
1635     */
1636    @Deprecated
1637    public static final String EXTRA_ALLOW_REPLACE
1638            = "android.intent.extra.ALLOW_REPLACE";
1639
1640    /**
1641     * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1642     * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
1643     * return to the application the result code of the install/uninstall.  The returned result
1644     * code will be {@link android.app.Activity#RESULT_OK} on success or
1645     * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1646     */
1647    public static final String EXTRA_RETURN_RESULT
1648            = "android.intent.extra.RETURN_RESULT";
1649
1650    /**
1651     * Package manager install result code.  @hide because result codes are not
1652     * yet ready to be exposed.
1653     */
1654    public static final String EXTRA_INSTALL_RESULT
1655            = "android.intent.extra.INSTALL_RESULT";
1656
1657    /**
1658     * Activity Action: Launch application uninstaller.
1659     * <p>
1660     * Input: The data must be a package: URI whose scheme specific part is
1661     * the package name of the current installed package to be uninstalled.
1662     * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1663     * <p>
1664     * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1665     * succeeded.
1666     */
1667    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1668    public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1669
1670    /**
1671     * Activity Action: Launch application uninstaller.
1672     * <p>
1673     * Input: The data must be a package: URI whose scheme specific part is
1674     * the package name of the current installed package to be uninstalled.
1675     * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1676     * <p>
1677     * Output: Nothing.
1678     * </p>
1679     */
1680    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1681    public static final String ACTION_CLEAR_PACKAGE = "android.intent.action.CLEAR_PACKAGE";
1682
1683    /**
1684     * Specify whether the package should be uninstalled for all users.
1685     * @hide because these should not be part of normal application flow.
1686     */
1687    public static final String EXTRA_UNINSTALL_ALL_USERS
1688            = "android.intent.extra.UNINSTALL_ALL_USERS";
1689
1690    /**
1691     * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1692     * describing the last run version of the platform that was setup.
1693     * @hide
1694     */
1695    public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1696
1697    /**
1698     * Activity action: Launch UI to manage the permissions of an app.
1699     * <p>
1700     * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1701     * will be managed by the launched UI.
1702     * </p>
1703     * <p>
1704     * Output: Nothing.
1705     * </p>
1706     *
1707     * @see #EXTRA_PACKAGE_NAME
1708     *
1709     * @hide
1710     */
1711    @SystemApi
1712    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1713    public static final String ACTION_MANAGE_APP_PERMISSIONS =
1714            "android.intent.action.MANAGE_APP_PERMISSIONS";
1715
1716    /**
1717     * Activity action: Launch UI to manage permissions.
1718     * <p>
1719     * Input: Nothing.
1720     * </p>
1721     * <p>
1722     * Output: Nothing.
1723     * </p>
1724     *
1725     * @hide
1726     */
1727    @SystemApi
1728    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1729    public static final String ACTION_MANAGE_PERMISSIONS =
1730            "android.intent.action.MANAGE_PERMISSIONS";
1731
1732    /**
1733     * Activity action: Launch UI to review permissions for an app.
1734     * The system uses this intent if permission review for apps not
1735     * supporting the new runtime permissions model is enabled. In
1736     * this mode a permission review is required before any of the
1737     * app components can run.
1738     * <p>
1739     * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1740     * permissions will be reviewed (mandatory).
1741     * </p>
1742     * <p>
1743     * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1744     * be fired after the permission review (optional).
1745     * </p>
1746     * <p>
1747     * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1748     * be invoked after the permission review (optional).
1749     * </p>
1750     * <p>
1751     * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1752     * passed via {@link #EXTRA_INTENT} needs a result (optional).
1753     * </p>
1754     * <p>
1755     * Output: Nothing.
1756     * </p>
1757     *
1758     * @see #EXTRA_PACKAGE_NAME
1759     * @see #EXTRA_INTENT
1760     * @see #EXTRA_REMOTE_CALLBACK
1761     * @see #EXTRA_RESULT_NEEDED
1762     *
1763     * @hide
1764     */
1765    @SystemApi
1766    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1767    public static final String ACTION_REVIEW_PERMISSIONS =
1768            "android.intent.action.REVIEW_PERMISSIONS";
1769
1770    /**
1771     * Intent extra: A callback for reporting remote result as a bundle.
1772     * <p>
1773     * Type: IRemoteCallback
1774     * </p>
1775     *
1776     * @hide
1777     */
1778    @SystemApi
1779    public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1780
1781    /**
1782     * Intent extra: An app package name.
1783     * <p>
1784     * Type: String
1785     * </p>
1786     *
1787     */
1788    public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1789
1790    /**
1791     * Intent extra: An app split name.
1792     * <p>
1793     * Type: String
1794     * </p>
1795     * @hide
1796     */
1797    @SystemApi
1798    public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1799
1800    /**
1801     * Intent extra: An extra for specifying whether a result is needed.
1802     * <p>
1803     * Type: boolean
1804     * </p>
1805     *
1806     * @hide
1807     */
1808    @SystemApi
1809    public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1810
1811    /**
1812     * Activity action: Launch UI to manage which apps have a given permission.
1813     * <p>
1814     * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1815     * to which will be managed by the launched UI.
1816     * </p>
1817     * <p>
1818     * Output: Nothing.
1819     * </p>
1820     *
1821     * @see #EXTRA_PERMISSION_NAME
1822     *
1823     * @hide
1824     */
1825    @SystemApi
1826    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1827    public static final String ACTION_MANAGE_PERMISSION_APPS =
1828            "android.intent.action.MANAGE_PERMISSION_APPS";
1829
1830    /**
1831     * Intent extra: The name of a permission.
1832     * <p>
1833     * Type: String
1834     * </p>
1835     *
1836     * @hide
1837     */
1838    @SystemApi
1839    public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1840
1841    // ---------------------------------------------------------------------
1842    // ---------------------------------------------------------------------
1843    // Standard intent broadcast actions (see action variable).
1844
1845    /**
1846     * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1847     * <p>
1848     * For historical reasons, the name of this broadcast action refers to the power
1849     * state of the screen but it is actually sent in response to changes in the
1850     * overall interactive state of the device.
1851     * </p><p>
1852     * This broadcast is sent when the device becomes non-interactive which may have
1853     * nothing to do with the screen turning off.  To determine the
1854     * actual state of the screen, use {@link android.view.Display#getState}.
1855     * </p><p>
1856     * See {@link android.os.PowerManager#isInteractive} for details.
1857     * </p>
1858     * You <em>cannot</em> receive this through components declared in
1859     * manifests, only by explicitly registering for it with
1860     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1861     * Context.registerReceiver()}.
1862     *
1863     * <p class="note">This is a protected intent that can only be sent
1864     * by the system.
1865     */
1866    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1867    public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1868
1869    /**
1870     * Broadcast Action: Sent when the device wakes up and becomes interactive.
1871     * <p>
1872     * For historical reasons, the name of this broadcast action refers to the power
1873     * state of the screen but it is actually sent in response to changes in the
1874     * overall interactive state of the device.
1875     * </p><p>
1876     * This broadcast is sent when the device becomes interactive which may have
1877     * nothing to do with the screen turning on.  To determine the
1878     * actual state of the screen, use {@link android.view.Display#getState}.
1879     * </p><p>
1880     * See {@link android.os.PowerManager#isInteractive} for details.
1881     * </p>
1882     * You <em>cannot</em> receive this through components declared in
1883     * manifests, only by explicitly registering for it with
1884     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1885     * Context.registerReceiver()}.
1886     *
1887     * <p class="note">This is a protected intent that can only be sent
1888     * by the system.
1889     */
1890    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1891    public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
1892
1893    /**
1894     * Broadcast Action: Sent after the system stops dreaming.
1895     *
1896     * <p class="note">This is a protected intent that can only be sent by the system.
1897     * It is only sent to registered receivers.</p>
1898     */
1899    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1900    public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1901
1902    /**
1903     * Broadcast Action: Sent after the system starts dreaming.
1904     *
1905     * <p class="note">This is a protected intent that can only be sent by the system.
1906     * It is only sent to registered receivers.</p>
1907     */
1908    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1909    public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1910
1911    /**
1912     * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
1913     * keyguard is gone).
1914     *
1915     * <p class="note">This is a protected intent that can only be sent
1916     * by the system.
1917     */
1918    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1919    public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
1920
1921    /**
1922     * Broadcast Action: The current time has changed.  Sent every
1923     * minute.  You <em>cannot</em> receive this through components declared
1924     * in manifests, only by explicitly registering for it with
1925     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1926     * Context.registerReceiver()}.
1927     *
1928     * <p class="note">This is a protected intent that can only be sent
1929     * by the system.
1930     */
1931    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932    public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1933    /**
1934     * Broadcast Action: The time was set.
1935     */
1936    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937    public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1938    /**
1939     * Broadcast Action: The date has changed.
1940     */
1941    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1942    public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1943    /**
1944     * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1945     * <ul>
1946     *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1947     * </ul>
1948     *
1949     * <p class="note">This is a protected intent that can only be sent
1950     * by the system.
1951     */
1952    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953    public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1954    /**
1955     * Clear DNS Cache Action: This is broadcast when networks have changed and old
1956     * DNS entries should be tossed.
1957     * @hide
1958     */
1959    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1960    public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1961    /**
1962     * Alarm Changed Action: This is broadcast when the AlarmClock
1963     * application's alarm is set or unset.  It is used by the
1964     * AlarmClock application and the StatusBar service.
1965     * @hide
1966     */
1967    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1968    public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1969
1970    /**
1971     * Broadcast Action: This is broadcast once, after the user has finished
1972     * booting, but while still in the "locked" state. It can be used to perform
1973     * application-specific initialization, such as installing alarms. You must
1974     * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
1975     * permission in order to receive this broadcast.
1976     * <p>
1977     * This broadcast is sent immediately at boot by all devices (regardless of
1978     * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
1979     * higher. Upon receipt of this broadcast, the user is still locked and only
1980     * device-protected storage can be accessed safely. If you want to access
1981     * credential-protected storage, you need to wait for the user to be
1982     * unlocked (typically by entering their lock pattern or PIN for the first
1983     * time), after which the {@link #ACTION_USER_UNLOCKED} and
1984     * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
1985     * <p>
1986     * To receive this broadcast, your receiver component must be marked as
1987     * being {@link ComponentInfo#directBootAware}.
1988     * <p class="note">
1989     * This is a protected intent that can only be sent by the system.
1990     *
1991     * @see Context#createDeviceProtectedStorageContext()
1992     */
1993    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994    public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1995
1996    /**
1997     * Broadcast Action: This is broadcast once, after the user has finished
1998     * booting. It can be used to perform application-specific initialization,
1999     * such as installing alarms. You must hold the
2000     * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2001     * order to receive this broadcast.
2002     * <p>
2003     * This broadcast is sent at boot by all devices (both with and without
2004     * direct boot support). Upon receipt of this broadcast, the user is
2005     * unlocked and both device-protected and credential-protected storage can
2006     * accessed safely.
2007     * <p>
2008     * If you need to run while the user is still locked (before they've entered
2009     * their lock pattern or PIN for the first time), you can listen for the
2010     * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2011     * <p class="note">
2012     * This is a protected intent that can only be sent by the system.
2013     */
2014    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2015    @BroadcastBehavior(includeBackground = true)
2016    public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2017
2018    /**
2019     * Broadcast Action: This is broadcast when a user action should request a
2020     * temporary system dialog to dismiss.  Some examples of temporary system
2021     * dialogs are the notification window-shade and the recent tasks dialog.
2022     */
2023    public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2024    /**
2025     * Broadcast Action: Trigger the download and eventual installation
2026     * of a package.
2027     * <p>Input: {@link #getData} is the URI of the package file to download.
2028     *
2029     * <p class="note">This is a protected intent that can only be sent
2030     * by the system.
2031     *
2032     * @deprecated This constant has never been used.
2033     */
2034    @Deprecated
2035    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2036    public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2037    /**
2038     * Broadcast Action: A new application package has been installed on the
2039     * device. The data contains the name of the package.  Note that the
2040     * newly installed package does <em>not</em> receive this broadcast.
2041     * <p>May include the following extras:
2042     * <ul>
2043     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2044     * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2045     * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2046     * </ul>
2047     *
2048     * <p class="note">This is a protected intent that can only be sent
2049     * by the system.
2050     */
2051    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2052    public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2053    /**
2054     * Broadcast Action: A new version of an application package has been
2055     * installed, replacing an existing version that was previously installed.
2056     * The data contains the name of the package.
2057     * <p>May include the following extras:
2058     * <ul>
2059     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2060     * </ul>
2061     *
2062     * <p class="note">This is a protected intent that can only be sent
2063     * by the system.
2064     */
2065    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2066    public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2067    /**
2068     * Broadcast Action: A new version of your application has been installed
2069     * over an existing one.  This is only sent to the application that was
2070     * replaced.  It does not contain any additional data; to receive it, just
2071     * use an intent filter for this action.
2072     *
2073     * <p class="note">This is a protected intent that can only be sent
2074     * by the system.
2075     */
2076    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2077    public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2078    /**
2079     * Broadcast Action: An existing application package has been removed from
2080     * the device.  The data contains the name of the package.  The package
2081     * that is being removed does <em>not</em> receive this Intent.
2082     * <ul>
2083     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2084     * to the package.
2085     * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2086     * application -- data and code -- is being removed.
2087     * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2088     * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2089     * </ul>
2090     *
2091     * <p class="note">This is a protected intent that can only be sent
2092     * by the system.
2093     */
2094    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2095    public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2096    /**
2097     * Broadcast Action: An existing application package has been completely
2098     * removed from the device.  The data contains the name of the package.
2099     * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2100     * {@link #EXTRA_DATA_REMOVED} is true and
2101     * {@link #EXTRA_REPLACING} is false of that broadcast.
2102     *
2103     * <ul>
2104     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2105     * to the package.
2106     * </ul>
2107     *
2108     * <p class="note">This is a protected intent that can only be sent
2109     * by the system.
2110     */
2111    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2112    public static final String ACTION_PACKAGE_FULLY_REMOVED
2113            = "android.intent.action.PACKAGE_FULLY_REMOVED";
2114    /**
2115     * Broadcast Action: An existing application package has been changed (for
2116     * example, a component has been enabled or disabled).  The data contains
2117     * the name of the package.
2118     * <ul>
2119     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2120     * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2121     * of the changed components (or the package name itself).
2122     * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2123     * default action of restarting the application.
2124     * </ul>
2125     *
2126     * <p class="note">This is a protected intent that can only be sent
2127     * by the system.
2128     */
2129    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2130    public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2131    /**
2132     * @hide
2133     * Broadcast Action: Ask system services if there is any reason to
2134     * restart the given package.  The data contains the name of the
2135     * package.
2136     * <ul>
2137     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2138     * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2139     * </ul>
2140     *
2141     * <p class="note">This is a protected intent that can only be sent
2142     * by the system.
2143     */
2144    @SystemApi
2145    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2146    public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2147    /**
2148     * Broadcast Action: The user has restarted a package, and all of its
2149     * processes have been killed.  All runtime state
2150     * associated with it (processes, alarms, notifications, etc) should
2151     * be removed.  Note that the restarted package does <em>not</em>
2152     * receive this broadcast.
2153     * The data contains the name of the package.
2154     * <ul>
2155     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2156     * </ul>
2157     *
2158     * <p class="note">This is a protected intent that can only be sent
2159     * by the system.
2160     */
2161    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2162    public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2163    /**
2164     * Broadcast Action: The user has cleared the data of a package.  This should
2165     * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2166     * its persistent data is erased and this broadcast sent.
2167     * Note that the cleared package does <em>not</em>
2168     * receive this broadcast. The data contains the name of the package.
2169     * <ul>
2170     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2171     * </ul>
2172     *
2173     * <p class="note">This is a protected intent that can only be sent
2174     * by the system.
2175     */
2176    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2177    public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2178    /**
2179     * Broadcast Action: Packages have been suspended.
2180     * <p>Includes the following extras:
2181     * <ul>
2182     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2183     * </ul>
2184     *
2185     * <p class="note">This is a protected intent that can only be sent
2186     * by the system. It is only sent to registered receivers.
2187     */
2188    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189    public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2190    /**
2191     * Broadcast Action: Packages have been unsuspended.
2192     * <p>Includes the following extras:
2193     * <ul>
2194     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2195     * </ul>
2196     *
2197     * <p class="note">This is a protected intent that can only be sent
2198     * by the system. It is only sent to registered receivers.
2199     */
2200    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2201    public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2202    /**
2203     * Broadcast Action: A user ID has been removed from the system.  The user
2204     * ID number is stored in the extra data under {@link #EXTRA_UID}.
2205     *
2206     * <p class="note">This is a protected intent that can only be sent
2207     * by the system.
2208     */
2209    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2210    public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
2211
2212    /**
2213     * Broadcast Action: Sent to the installer package of an application when
2214     * that application is first launched (that is the first time it is moved
2215     * out of the stopped state).  The data contains the name of the package.
2216     *
2217     * <p class="note">This is a protected intent that can only be sent
2218     * by the system.
2219     */
2220    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2221    public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2222
2223    /**
2224     * Broadcast Action: Sent to the system package verifier when a package
2225     * needs to be verified. The data contains the package URI.
2226     * <p class="note">
2227     * This is a protected intent that can only be sent by the system.
2228     * </p>
2229     */
2230    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2231    public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2232
2233    /**
2234     * Broadcast Action: Sent to the system package verifier when a package is
2235     * verified. The data contains the package URI.
2236     * <p class="note">
2237     * This is a protected intent that can only be sent by the system.
2238     */
2239    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240    public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2241
2242    /**
2243     * Broadcast Action: Sent to the system intent filter verifier when an
2244     * intent filter needs to be verified. The data contains the filter data
2245     * hosts to be verified against.
2246     * <p class="note">
2247     * This is a protected intent that can only be sent by the system.
2248     * </p>
2249     *
2250     * @hide
2251     */
2252    @SystemApi
2253    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2254    public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2255
2256    /**
2257     * Broadcast Action: Resources for a set of packages (which were
2258     * previously unavailable) are currently
2259     * available since the media on which they exist is available.
2260     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2261     * list of packages whose availability changed.
2262     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2263     * list of uids of packages whose availability changed.
2264     * Note that the
2265     * packages in this list do <em>not</em> receive this broadcast.
2266     * The specified set of packages are now available on the system.
2267     * <p>Includes the following extras:
2268     * <ul>
2269     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2270     * whose resources(were previously unavailable) are currently available.
2271     * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2272     * packages whose resources(were previously unavailable)
2273     * are  currently available.
2274     * </ul>
2275     *
2276     * <p class="note">This is a protected intent that can only be sent
2277     * by the system.
2278     */
2279    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2280    public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2281        "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
2282
2283    /**
2284     * Broadcast Action: Resources for a set of packages are currently
2285     * unavailable since the media on which they exist is unavailable.
2286     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2287     * list of packages whose availability changed.
2288     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2289     * list of uids of packages whose availability changed.
2290     * The specified set of packages can no longer be
2291     * launched and are practically unavailable on the system.
2292     * <p>Inclues the following extras:
2293     * <ul>
2294     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2295     * whose resources are no longer available.
2296     * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2297     * whose resources are no longer available.
2298     * </ul>
2299     *
2300     * <p class="note">This is a protected intent that can only be sent
2301     * by the system.
2302     */
2303    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304    public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
2305        "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
2306
2307    /**
2308     * Broadcast Action: preferred activities have changed *explicitly*.
2309     *
2310     * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2311     * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2312     * be sent.
2313     *
2314     * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2315     *
2316     * @hide
2317     */
2318    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319    public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2320            "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2321
2322
2323    /**
2324     * Broadcast Action:  The current system wallpaper has changed.  See
2325     * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
2326     * This should <em>only</em> be used to determine when the wallpaper
2327     * has changed to show the new wallpaper to the user.  You should certainly
2328     * never, in response to this, change the wallpaper or other attributes of
2329     * it such as the suggested size.  That would be crazy, right?  You'd cause
2330     * all kinds of loops, especially if other apps are doing similar things,
2331     * right?  Of course.  So please don't do this.
2332     *
2333     * @deprecated Modern applications should use
2334     * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2335     * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2336     * shown behind their UI, rather than watching for this broadcast and
2337     * rendering the wallpaper on their own.
2338     */
2339    @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2340    public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2341    /**
2342     * Broadcast Action: The current device {@link android.content.res.Configuration}
2343     * (orientation, locale, etc) has changed.  When such a change happens, the
2344     * UIs (view hierarchy) will need to be rebuilt based on this new
2345     * information; for the most part, applications don't need to worry about
2346     * this, because the system will take care of stopping and restarting the
2347     * application to make sure it sees the new changes.  Some system code that
2348     * can not be restarted will need to watch for this action and handle it
2349     * appropriately.
2350     *
2351     * <p class="note">
2352     * You <em>cannot</em> receive this through components declared
2353     * in manifests, only by explicitly registering for it with
2354     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2355     * Context.registerReceiver()}.
2356     *
2357     * <p class="note">This is a protected intent that can only be sent
2358     * by the system.
2359     *
2360     * @see android.content.res.Configuration
2361     */
2362    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2363    public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2364    /**
2365     * Broadcast Action: The current device's locale has changed.
2366     *
2367     * <p class="note">This is a protected intent that can only be sent
2368     * by the system.
2369     */
2370    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2371    public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2372    /**
2373     * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
2374     * charging state, level, and other information about the battery.
2375     * See {@link android.os.BatteryManager} for documentation on the
2376     * contents of the Intent.
2377     *
2378     * <p class="note">
2379     * You <em>cannot</em> receive this through components declared
2380     * in manifests, only by explicitly registering for it with
2381     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2382     * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
2383     * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2384     * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2385     * broadcasts that are sent and can be received through manifest
2386     * receivers.
2387     *
2388     * <p class="note">This is a protected intent that can only be sent
2389     * by the system.
2390     */
2391    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2392    public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2393    /**
2394     * Broadcast Action:  Indicates low battery condition on the device.
2395     * This broadcast corresponds to the "Low battery warning" system dialog.
2396     *
2397     * <p class="note">This is a protected intent that can only be sent
2398     * by the system.
2399     */
2400    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401    public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2402    /**
2403     * Broadcast Action:  Indicates the battery is now okay after being low.
2404     * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2405     * gone back up to an okay state.
2406     *
2407     * <p class="note">This is a protected intent that can only be sent
2408     * by the system.
2409     */
2410    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2411    public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2412    /**
2413     * Broadcast Action:  External power has been connected to the device.
2414     * This is intended for applications that wish to register specifically to this notification.
2415     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2416     * stay active to receive this notification.  This action can be used to implement actions
2417     * that wait until power is available to trigger.
2418     *
2419     * <p class="note">This is a protected intent that can only be sent
2420     * by the system.
2421     */
2422    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2423    public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
2424    /**
2425     * Broadcast Action:  External power has been removed from the device.
2426     * This is intended for applications that wish to register specifically to this notification.
2427     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2428     * stay active to receive this notification.  This action can be used to implement actions
2429     * that wait until power is available to trigger.
2430     *
2431     * <p class="note">This is a protected intent that can only be sent
2432     * by the system.
2433     */
2434    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2435    public static final String ACTION_POWER_DISCONNECTED =
2436            "android.intent.action.ACTION_POWER_DISCONNECTED";
2437    /**
2438     * Broadcast Action:  Device is shutting down.
2439     * This is broadcast when the device is being shut down (completely turned
2440     * off, not sleeping).  Once the broadcast is complete, the final shutdown
2441     * will proceed and all unsaved data lost.  Apps will not normally need
2442     * to handle this, since the foreground activity will be paused as well.
2443     *
2444     * <p class="note">This is a protected intent that can only be sent
2445     * by the system.
2446     * <p>May include the following extras:
2447     * <ul>
2448     * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2449     * shutdown is only for userspace processes.  If not set, assumed to be false.
2450     * </ul>
2451     */
2452    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2453    public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
2454    /**
2455     * Activity Action:  Start this activity to request system shutdown.
2456     * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2457     * to request confirmation from the user before shutting down. The optional boolean
2458     * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2459     * indicate that the shutdown is requested by the user.
2460     *
2461     * <p class="note">This is a protected intent that can only be sent
2462     * by the system.
2463     *
2464     * {@hide}
2465     */
2466    public static final String ACTION_REQUEST_SHUTDOWN
2467            = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
2468    /**
2469     * Broadcast Action: A sticky broadcast that indicates low storage space
2470     * condition on the device
2471     * <p class="note">
2472     * This is a protected intent that can only be sent by the system.
2473     *
2474     * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2475     *             or above, this broadcast will no longer be delivered to any
2476     *             {@link BroadcastReceiver} defined in your manifest. Instead,
2477     *             apps are strongly encouraged to use the improved
2478     *             {@link Context#getCacheDir()} behavior so the system can
2479     *             automatically free up storage when needed.
2480     */
2481    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2482    @Deprecated
2483    public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2484    /**
2485     * Broadcast Action: Indicates low storage space condition on the device no
2486     * longer exists
2487     * <p class="note">
2488     * This is a protected intent that can only be sent by the system.
2489     *
2490     * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2491     *             or above, this broadcast will no longer be delivered to any
2492     *             {@link BroadcastReceiver} defined in your manifest. Instead,
2493     *             apps are strongly encouraged to use the improved
2494     *             {@link Context#getCacheDir()} behavior so the system can
2495     *             automatically free up storage when needed.
2496     */
2497    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498    @Deprecated
2499    public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2500    /**
2501     * Broadcast Action: A sticky broadcast that indicates a storage space full
2502     * condition on the device. This is intended for activities that want to be
2503     * able to fill the data partition completely, leaving only enough free
2504     * space to prevent system-wide SQLite failures.
2505     * <p class="note">
2506     * This is a protected intent that can only be sent by the system.
2507     *
2508     * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2509     *             or above, this broadcast will no longer be delivered to any
2510     *             {@link BroadcastReceiver} defined in your manifest. Instead,
2511     *             apps are strongly encouraged to use the improved
2512     *             {@link Context#getCacheDir()} behavior so the system can
2513     *             automatically free up storage when needed.
2514     * @hide
2515     */
2516    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2517    @Deprecated
2518    public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2519    /**
2520     * Broadcast Action: Indicates storage space full condition on the device no
2521     * longer exists.
2522     * <p class="note">
2523     * This is a protected intent that can only be sent by the system.
2524     *
2525     * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2526     *             or above, this broadcast will no longer be delivered to any
2527     *             {@link BroadcastReceiver} defined in your manifest. Instead,
2528     *             apps are strongly encouraged to use the improved
2529     *             {@link Context#getCacheDir()} behavior so the system can
2530     *             automatically free up storage when needed.
2531     * @hide
2532     */
2533    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2534    @Deprecated
2535    public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2536    /**
2537     * Broadcast Action:  Indicates low memory condition notification acknowledged by user
2538     * and package management should be started.
2539     * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2540     * notification.
2541     */
2542    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2543    public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2544    /**
2545     * Broadcast Action:  The device has entered USB Mass Storage mode.
2546     * This is used mainly for the USB Settings panel.
2547     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2548     * when the SD card file system is mounted or unmounted
2549     * @deprecated replaced by android.os.storage.StorageEventListener
2550     */
2551    @Deprecated
2552    public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2553
2554    /**
2555     * Broadcast Action:  The device has exited USB Mass Storage mode.
2556     * This is used mainly for the USB Settings panel.
2557     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2558     * when the SD card file system is mounted or unmounted
2559     * @deprecated replaced by android.os.storage.StorageEventListener
2560     */
2561    @Deprecated
2562    public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2563
2564    /**
2565     * Broadcast Action:  External media has been removed.
2566     * The path to the mount point for the removed media is contained in the Intent.mData field.
2567     */
2568    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2569    public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2570
2571    /**
2572     * Broadcast Action:  External media is present, but not mounted at its mount point.
2573     * The path to the mount point for the unmounted media is contained in the Intent.mData field.
2574     */
2575    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576    public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2577
2578    /**
2579     * Broadcast Action:  External media is present, and being disk-checked
2580     * The path to the mount point for the checking media is contained in the Intent.mData field.
2581     */
2582    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2583    public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2584
2585    /**
2586     * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
2587     * The path to the mount point for the checking media is contained in the Intent.mData field.
2588     */
2589    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2590    public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2591
2592    /**
2593     * Broadcast Action:  External media is present and mounted at its mount point.
2594     * The path to the mount point for the mounted media is contained in the Intent.mData field.
2595     * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2596     * media was mounted read only.
2597     */
2598    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599    public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2600
2601    /**
2602     * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
2603     * The path to the mount point for the shared media is contained in the Intent.mData field.
2604     */
2605    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2606    public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2607
2608    /**
2609     * Broadcast Action:  External media is no longer being shared via USB mass storage.
2610     * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2611     *
2612     * @hide
2613     */
2614    public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2615
2616    /**
2617     * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
2618     * The path to the mount point for the removed media is contained in the Intent.mData field.
2619     */
2620    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621    public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2622
2623    /**
2624     * Broadcast Action:  External media is present but cannot be mounted.
2625     * The path to the mount point for the unmountable media is contained in the Intent.mData field.
2626     */
2627    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628    public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2629
2630   /**
2631     * Broadcast Action:  User has expressed the desire to remove the external storage media.
2632     * Applications should close all files they have open within the mount point when they receive this intent.
2633     * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2634     */
2635    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2636    public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2637
2638    /**
2639     * Broadcast Action:  The media scanner has started scanning a directory.
2640     * The path to the directory being scanned is contained in the Intent.mData field.
2641     */
2642    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643    public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2644
2645   /**
2646     * Broadcast Action:  The media scanner has finished scanning a directory.
2647     * The path to the scanned directory is contained in the Intent.mData field.
2648     */
2649    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650    public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2651
2652   /**
2653     * Broadcast Action:  Request the media scanner to scan a file and add it to the media database.
2654     * The path to the file is contained in the Intent.mData field.
2655     */
2656    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2657    public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2658
2659   /**
2660     * Broadcast Action:  The "Media Button" was pressed.  Includes a single
2661     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2662     * caused the broadcast.
2663     */
2664    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2665    public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2666
2667    /**
2668     * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
2669     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2670     * caused the broadcast.
2671     */
2672    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2673    public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2674
2675    // *** NOTE: @todo(*) The following really should go into a more domain-specific
2676    // location; they are not general-purpose actions.
2677
2678    /**
2679     * Broadcast Action: A GTalk connection has been established.
2680     */
2681    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2682    public static final String ACTION_GTALK_SERVICE_CONNECTED =
2683            "android.intent.action.GTALK_CONNECTED";
2684
2685    /**
2686     * Broadcast Action: A GTalk connection has been disconnected.
2687     */
2688    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2689    public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2690            "android.intent.action.GTALK_DISCONNECTED";
2691
2692    /**
2693     * Broadcast Action: An input method has been changed.
2694     */
2695    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2696    public static final String ACTION_INPUT_METHOD_CHANGED =
2697            "android.intent.action.INPUT_METHOD_CHANGED";
2698
2699    /**
2700     * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2701     * more radios have been turned off or on. The intent will have the following extra value:</p>
2702     * <ul>
2703     *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2704     *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2705     *   turned off</li>
2706     * </ul>
2707     *
2708     * <p class="note">This is a protected intent that can only be sent by the system.</p>
2709     */
2710    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2711    public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2712
2713    /**
2714     * Broadcast Action: Some content providers have parts of their namespace
2715     * where they publish new events or items that the user may be especially
2716     * interested in. For these things, they may broadcast this action when the
2717     * set of interesting items change.
2718     *
2719     * For example, GmailProvider sends this notification when the set of unread
2720     * mail in the inbox changes.
2721     *
2722     * <p>The data of the intent identifies which part of which provider
2723     * changed. When queried through the content resolver, the data URI will
2724     * return the data set in question.
2725     *
2726     * <p>The intent will have the following extra values:
2727     * <ul>
2728     *   <li><em>count</em> - The number of items in the data set. This is the
2729     *       same as the number of items in the cursor returned by querying the
2730     *       data URI. </li>
2731     * </ul>
2732     *
2733     * This intent will be sent at boot (if the count is non-zero) and when the
2734     * data set changes. It is possible for the data set to change without the
2735     * count changing (for example, if a new unread message arrives in the same
2736     * sync operation in which a message is archived). The phone should still
2737     * ring/vibrate/etc as normal in this case.
2738     */
2739    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740    public static final String ACTION_PROVIDER_CHANGED =
2741            "android.intent.action.PROVIDER_CHANGED";
2742
2743    /**
2744     * Broadcast Action: Wired Headset plugged in or unplugged.
2745     *
2746     * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2747     *   and documentation.
2748     * <p>If the minimum SDK version of your application is
2749     * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
2750     * to the <code>AudioManager</code> constant in your receiver registration code instead.
2751     */
2752    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2753    public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
2754
2755    /**
2756     * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2757     * <ul>
2758     *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2759     * </ul>
2760     *
2761     * <p class="note">This is a protected intent that can only be sent
2762     * by the system.
2763     *
2764     * @hide
2765     */
2766    //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2767    public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2768            = "android.intent.action.ADVANCED_SETTINGS";
2769
2770    /**
2771     *  Broadcast Action: Sent after application restrictions are changed.
2772     *
2773     * <p class="note">This is a protected intent that can only be sent
2774     * by the system.</p>
2775     */
2776    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2777    public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2778            "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2779
2780    /**
2781     * Broadcast Action: An outgoing call is about to be placed.
2782     *
2783     * <p>The Intent will have the following extra value:</p>
2784     * <ul>
2785     *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
2786     *       the phone number originally intended to be dialed.</li>
2787     * </ul>
2788     * <p>Once the broadcast is finished, the resultData is used as the actual
2789     * number to call.  If  <code>null</code>, no call will be placed.</p>
2790     * <p>It is perfectly acceptable for multiple receivers to process the
2791     * outgoing call in turn: for example, a parental control application
2792     * might verify that the user is authorized to place the call at that
2793     * time, then a number-rewriting application might add an area code if
2794     * one was not specified.</p>
2795     * <p>For consistency, any receiver whose purpose is to prohibit phone
2796     * calls should have a priority of 0, to ensure it will see the final
2797     * phone number to be dialed.
2798     * Any receiver whose purpose is to rewrite phone numbers to be called
2799     * should have a positive priority.
2800     * Negative priorities are reserved for the system for this broadcast;
2801     * using them may cause problems.</p>
2802     * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2803     * abort the broadcast.</p>
2804     * <p>Emergency calls cannot be intercepted using this mechanism, and
2805     * other calls cannot be modified to call emergency numbers using this
2806     * mechanism.
2807     * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2808     * call to use their own service instead. Those apps should first prevent
2809     * the call from being placed by setting resultData to <code>null</code>
2810     * and then start their own app to make the call.
2811     * <p>You must hold the
2812     * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2813     * permission to receive this Intent.</p>
2814     *
2815     * <p class="note">This is a protected intent that can only be sent
2816     * by the system.
2817     */
2818    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2819    public static final String ACTION_NEW_OUTGOING_CALL =
2820            "android.intent.action.NEW_OUTGOING_CALL";
2821
2822    /**
2823     * Broadcast Action: Have the device reboot.  This is only for use by
2824     * system code.
2825     *
2826     * <p class="note">This is a protected intent that can only be sent
2827     * by the system.
2828     */
2829    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2830    public static final String ACTION_REBOOT =
2831            "android.intent.action.REBOOT";
2832
2833    /**
2834     * Broadcast Action:  A sticky broadcast for changes in the physical
2835     * docking state of the device.
2836     *
2837     * <p>The intent will have the following extra values:
2838     * <ul>
2839     *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
2840     *       state, indicating which dock the device is physically in.</li>
2841     * </ul>
2842     * <p>This is intended for monitoring the current physical dock state.
2843     * See {@link android.app.UiModeManager} for the normal API dealing with
2844     * dock mode changes.
2845     */
2846    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2847    public static final String ACTION_DOCK_EVENT =
2848            "android.intent.action.DOCK_EVENT";
2849
2850    /**
2851     * Broadcast Action: A broadcast when idle maintenance can be started.
2852     * This means that the user is not interacting with the device and is
2853     * not expected to do so soon. Typical use of the idle maintenance is
2854     * to perform somehow expensive tasks that can be postponed at a moment
2855     * when they will not degrade user experience.
2856     * <p>
2857     * <p class="note">In order to keep the device responsive in case of an
2858     * unexpected user interaction, implementations of a maintenance task
2859     * should be interruptible. In such a scenario a broadcast with action
2860     * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2861     * should not do the maintenance work in
2862     * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2863     * maintenance service by {@link Context#startService(Intent)}. Also
2864     * you should hold a wake lock while your maintenance service is running
2865     * to prevent the device going to sleep.
2866     * </p>
2867     * <p>
2868     * <p class="note">This is a protected intent that can only be sent by
2869     * the system.
2870     * </p>
2871     *
2872     * @see #ACTION_IDLE_MAINTENANCE_END
2873     *
2874     * @hide
2875     */
2876    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2877    public static final String ACTION_IDLE_MAINTENANCE_START =
2878            "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2879
2880    /**
2881     * Broadcast Action:  A broadcast when idle maintenance should be stopped.
2882     * This means that the user was not interacting with the device as a result
2883     * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2884     * was sent and now the user started interacting with the device. Typical
2885     * use of the idle maintenance is to perform somehow expensive tasks that
2886     * can be postponed at a moment when they will not degrade user experience.
2887     * <p>
2888     * <p class="note">In order to keep the device responsive in case of an
2889     * unexpected user interaction, implementations of a maintenance task
2890     * should be interruptible. Hence, on receiving a broadcast with this
2891     * action, the maintenance task should be interrupted as soon as possible.
2892     * In other words, you should not do the maintenance work in
2893     * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2894     * maintenance service that was started on receiving of
2895     * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2896     * lock you acquired when your maintenance service started.
2897     * </p>
2898     * <p class="note">This is a protected intent that can only be sent
2899     * by the system.
2900     *
2901     * @see #ACTION_IDLE_MAINTENANCE_START
2902     *
2903     * @hide
2904     */
2905    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2906    public static final String ACTION_IDLE_MAINTENANCE_END =
2907            "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2908
2909    /**
2910     * Broadcast Action: a remote intent is to be broadcasted.
2911     *
2912     * A remote intent is used for remote RPC between devices. The remote intent
2913     * is serialized and sent from one device to another device. The receiving
2914     * device parses the remote intent and broadcasts it. Note that anyone can
2915     * broadcast a remote intent. However, if the intent receiver of the remote intent
2916     * does not trust intent broadcasts from arbitrary intent senders, it should require
2917     * the sender to hold certain permissions so only trusted sender's broadcast will be
2918     * let through.
2919     * @hide
2920     */
2921    public static final String ACTION_REMOTE_INTENT =
2922            "com.google.android.c2dm.intent.RECEIVE";
2923
2924    /**
2925     * Broadcast Action: This is broadcast once when the user is booting after a
2926     * system update. It can be used to perform cleanup or upgrades after a
2927     * system update.
2928     * <p>
2929     * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
2930     * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
2931     * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
2932     * sent to receivers in the system image.
2933     *
2934     * @hide
2935     */
2936    @SystemApi
2937    public static final String ACTION_PRE_BOOT_COMPLETED =
2938            "android.intent.action.PRE_BOOT_COMPLETED";
2939
2940    /**
2941     * Broadcast to a specific application to query any supported restrictions to impose
2942     * on restricted users. The broadcast intent contains an extra
2943     * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2944     * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2945     * String[] depending on the restriction type.<p/>
2946     * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
2947     * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2948     * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2949     * The activity specified by that intent will be launched for a result which must contain
2950     * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2951     * The keys and values of the returned restrictions will be persisted.
2952     * @see RestrictionEntry
2953     */
2954    public static final String ACTION_GET_RESTRICTION_ENTRIES =
2955            "android.intent.action.GET_RESTRICTION_ENTRIES";
2956
2957    /**
2958     * Sent the first time a user is starting, to allow system apps to
2959     * perform one time initialization.  (This will not be seen by third
2960     * party applications because a newly initialized user does not have any
2961     * third party applications installed for it.)  This is sent early in
2962     * starting the user, around the time the home app is started, before
2963     * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
2964     * broadcast, since it is part of a visible user interaction; be as quick
2965     * as possible when handling it.
2966     */
2967    public static final String ACTION_USER_INITIALIZE =
2968            "android.intent.action.USER_INITIALIZE";
2969
2970    /**
2971     * Sent when a user switch is happening, causing the process's user to be
2972     * brought to the foreground.  This is only sent to receivers registered
2973     * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2974     * Context.registerReceiver}.  It is sent to the user that is going to the
2975     * foreground.  This is sent as a foreground
2976     * broadcast, since it is part of a visible user interaction; be as quick
2977     * as possible when handling it.
2978     */
2979    public static final String ACTION_USER_FOREGROUND =
2980            "android.intent.action.USER_FOREGROUND";
2981
2982    /**
2983     * Sent when a user switch is happening, causing the process's user to be
2984     * sent to the background.  This is only sent to receivers registered
2985     * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2986     * Context.registerReceiver}.  It is sent to the user that is going to the
2987     * background.  This is sent as a foreground
2988     * broadcast, since it is part of a visible user interaction; be as quick
2989     * as possible when handling it.
2990     */
2991    public static final String ACTION_USER_BACKGROUND =
2992            "android.intent.action.USER_BACKGROUND";
2993
2994    /**
2995     * Broadcast sent to the system when a user is added. Carries an extra
2996     * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
2997     * all running users.  You must hold
2998     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
2999     * @hide
3000     */
3001    public static final String ACTION_USER_ADDED =
3002            "android.intent.action.USER_ADDED";
3003
3004    /**
3005     * Broadcast sent by the system when a user is started. Carries an extra
3006     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only sent to
3007     * registered receivers, not manifest receivers.  It is sent to the user
3008     * that has been started.  This is sent as a foreground
3009     * broadcast, since it is part of a visible user interaction; be as quick
3010     * as possible when handling it.
3011     * @hide
3012     */
3013    public static final String ACTION_USER_STARTED =
3014            "android.intent.action.USER_STARTED";
3015
3016    /**
3017     * Broadcast sent when a user is in the process of starting.  Carries an extra
3018     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3019     * sent to registered receivers, not manifest receivers.  It is sent to all
3020     * users (including the one that is being started).  You must hold
3021     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3022     * this broadcast.  This is sent as a background broadcast, since
3023     * its result is not part of the primary UX flow; to safely keep track of
3024     * started/stopped state of a user you can use this in conjunction with
3025     * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
3026     * other user state broadcasts since those are foreground broadcasts so can
3027     * execute in a different order.
3028     * @hide
3029     */
3030    public static final String ACTION_USER_STARTING =
3031            "android.intent.action.USER_STARTING";
3032
3033    /**
3034     * Broadcast sent when a user is going to be stopped.  Carries an extra
3035     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3036     * sent to registered receivers, not manifest receivers.  It is sent to all
3037     * users (including the one that is being stopped).  You must hold
3038     * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3039     * this broadcast.  The user will not stop until all receivers have
3040     * handled the broadcast.  This is sent as a background broadcast, since
3041     * its result is not part of the primary UX flow; to safely keep track of
3042     * started/stopped state of a user you can use this in conjunction with
3043     * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
3044     * other user state broadcasts since those are foreground broadcasts so can
3045     * execute in a different order.
3046     * @hide
3047     */
3048    public static final String ACTION_USER_STOPPING =
3049            "android.intent.action.USER_STOPPING";
3050
3051    /**
3052     * Broadcast sent to the system when a user is stopped. Carries an extra
3053     * EXTRA_USER_HANDLE that has the userHandle of the user.  This is similar to
3054     * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3055     * specific package.  This is only sent to registered receivers, not manifest
3056     * receivers.  It is sent to all running users <em>except</em> the one that
3057     * has just been stopped (which is no longer running).
3058     * @hide
3059     */
3060    public static final String ACTION_USER_STOPPED =
3061            "android.intent.action.USER_STOPPED";
3062
3063    /**
3064     * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
3065     * the userHandle of the user.  It is sent to all running users except the
3066     * one that has been removed. The user will not be completely removed until all receivers have
3067     * handled the broadcast. You must hold
3068     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3069     * @hide
3070     */
3071    @SystemApi
3072    public static final String ACTION_USER_REMOVED =
3073            "android.intent.action.USER_REMOVED";
3074
3075    /**
3076     * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
3077     * the userHandle of the user to become the current one. This is only sent to
3078     * registered receivers, not manifest receivers.  It is sent to all running users.
3079     * You must hold
3080     * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3081     * @hide
3082     */
3083    public static final String ACTION_USER_SWITCHED =
3084            "android.intent.action.USER_SWITCHED";
3085
3086    /**
3087     * Broadcast Action: Sent when the credential-encrypted private storage has
3088     * become unlocked for the target user. This is only sent to registered
3089     * receivers, not manifest receivers.
3090     */
3091    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3092    public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3093
3094    /**
3095     * Broadcast sent to the system when a user's information changes. Carries an extra
3096     * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
3097     * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
3098     * @hide
3099     */
3100    public static final String ACTION_USER_INFO_CHANGED =
3101            "android.intent.action.USER_INFO_CHANGED";
3102
3103    /**
3104     * Broadcast sent to the primary user when an associated managed profile is added (the profile
3105     * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
3106     * the UserHandle of the profile that was added. Only applications (for example Launchers)
3107     * that need to display merged content across both primary and managed profiles need to
3108     * worry about this broadcast. This is only sent to registered receivers,
3109     * not manifest receivers.
3110     */
3111    public static final String ACTION_MANAGED_PROFILE_ADDED =
3112            "android.intent.action.MANAGED_PROFILE_ADDED";
3113
3114    /**
3115     * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
3116     * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3117     * Only applications (for example Launchers) that need to display merged content across both
3118     * primary and managed profiles need to worry about this broadcast. This is only sent to
3119     * registered receivers, not manifest receivers.
3120     */
3121    public static final String ACTION_MANAGED_PROFILE_REMOVED =
3122            "android.intent.action.MANAGED_PROFILE_REMOVED";
3123
3124    /**
3125     * Broadcast sent to the primary user when the credential-encrypted private storage for
3126     * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3127     * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3128     * Launchers) that need to display merged content across both primary and managed profiles
3129     * need to worry about this broadcast. This is only sent to registered receivers,
3130     * not manifest receivers.
3131     */
3132    public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3133            "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3134
3135    /**
3136     * Broadcast sent to the primary user when an associated managed profile has become available.
3137     * Currently this includes when the user disables quiet mode for the profile. Carries an extra
3138     * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3139     * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3140     * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3141     */
3142    public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3143            "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3144
3145    /**
3146     * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3147     * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3148     * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3149     * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3150     * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3151     */
3152    public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3153            "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
3154
3155    /**
3156     * Broadcast sent to the system user when the 'device locked' state changes for any user.
3157     * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3158     * the device was locked or unlocked.
3159     *
3160     * This is only sent to registered receivers.
3161     *
3162     * @hide
3163     */
3164    public static final String ACTION_DEVICE_LOCKED_CHANGED =
3165            "android.intent.action.DEVICE_LOCKED_CHANGED";
3166
3167    /**
3168     * Sent when the user taps on the clock widget in the system's "quick settings" area.
3169     */
3170    public static final String ACTION_QUICK_CLOCK =
3171            "android.intent.action.QUICK_CLOCK";
3172
3173    /**
3174     * Activity Action: Shows the brightness setting dialog.
3175     * @hide
3176     */
3177    public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3178            "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3179
3180    /**
3181     * Broadcast Action:  A global button was pressed.  Includes a single
3182     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3183     * caused the broadcast.
3184     * @hide
3185     */
3186    public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3187
3188    /**
3189     * Broadcast Action: Sent when media resource is granted.
3190     * <p>
3191     * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3192     * granted.
3193     * </p>
3194     * <p class="note">
3195     * This is a protected intent that can only be sent by the system.
3196     * </p>
3197     * <p class="note">
3198     * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
3199     * </p>
3200     *
3201     * @hide
3202     */
3203    public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3204            "android.intent.action.MEDIA_RESOURCE_GRANTED";
3205
3206    /**
3207     * Broadcast Action: An overlay package has been installed. The data
3208     * contains the name of the added overlay package.
3209     * @hide
3210     */
3211    public static final String ACTION_OVERLAY_ADDED = "android.intent.action.OVERLAY_ADDED";
3212
3213    /**
3214     * Broadcast Action: An overlay package has changed. The data contains the
3215     * name of the overlay package which has changed. This is broadcast on all
3216     * changes to the OverlayInfo returned by {@link
3217     * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3218     * most common change is a state change that will change whether the
3219     * overlay is enabled or not.
3220     * @hide
3221     */
3222    public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3223
3224    /**
3225     * Broadcast Action: An overlay package has been removed. The data contains
3226     * the name of the overlay package which has been removed.
3227     * @hide
3228     */
3229    public static final String ACTION_OVERLAY_REMOVED = "android.intent.action.OVERLAY_REMOVED";
3230
3231    /**
3232     * Broadcast Action: The order of a package's list of overlay packages has
3233     * changed. The data contains the package name of the overlay package that
3234     * had its position in the list adjusted.
3235     * @hide
3236     */
3237    public static final String
3238            ACTION_OVERLAY_PRIORITY_CHANGED = "android.intent.action.OVERLAY_PRIORITY_CHANGED";
3239
3240    /**
3241     * Activity Action: Allow the user to select and return one or more existing
3242     * documents. When invoked, the system will display the various
3243     * {@link DocumentsProvider} instances installed on the device, letting the
3244     * user interactively navigate through them. These documents include local
3245     * media, such as photos and video, and documents provided by installed
3246     * cloud storage providers.
3247     * <p>
3248     * Each document is represented as a {@code content://} URI backed by a
3249     * {@link DocumentsProvider}, which can be opened as a stream with
3250     * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3251     * {@link android.provider.DocumentsContract.Document} metadata.
3252     * <p>
3253     * All selected documents are returned to the calling application with
3254     * persistable read and write permission grants. If you want to maintain
3255     * access to the documents across device reboots, you need to explicitly
3256     * take the persistable permissions using
3257     * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3258     * <p>
3259     * Callers must indicate the acceptable document MIME types through
3260     * {@link #setType(String)}. For example, to select photos, use
3261     * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3262     * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3263     * {@literal *}/*.
3264     * <p>
3265     * If the caller can handle multiple returned items (the user performing
3266     * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3267     * to indicate this.
3268     * <p>
3269     * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3270     * URIs that can be opened with
3271     * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3272     * <p>
3273     * Callers can set a document URI through
3274     * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3275     * location of documents navigator. System will do its best to launch the
3276     * navigator in the specified document if it's a folder, or the folder that
3277     * contains the specified document if not.
3278     * <p>
3279     * Output: The URI of the item that was picked, returned in
3280     * {@link #getData()}. This must be a {@code content://} URI so that any
3281     * receiver can access it. If multiple documents were selected, they are
3282     * returned in {@link #getClipData()}.
3283     *
3284     * @see DocumentsContract
3285     * @see #ACTION_OPEN_DOCUMENT_TREE
3286     * @see #ACTION_CREATE_DOCUMENT
3287     * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3288     */
3289    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3290    public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3291
3292    /**
3293     * Activity Action: Allow the user to create a new document. When invoked,
3294     * the system will display the various {@link DocumentsProvider} instances
3295     * installed on the device, letting the user navigate through them. The
3296     * returned document may be a newly created document with no content, or it
3297     * may be an existing document with the requested MIME type.
3298     * <p>
3299     * Each document is represented as a {@code content://} URI backed by a
3300     * {@link DocumentsProvider}, which can be opened as a stream with
3301     * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3302     * {@link android.provider.DocumentsContract.Document} metadata.
3303     * <p>
3304     * Callers must indicate the concrete MIME type of the document being
3305     * created by setting {@link #setType(String)}. This MIME type cannot be
3306     * changed after the document is created.
3307     * <p>
3308     * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3309     * but the user may change this value before creating the file.
3310     * <p>
3311     * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3312     * URIs that can be opened with
3313     * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3314     * <p>
3315     * Callers can set a document URI through
3316     * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3317     * location of documents navigator. System will do its best to launch the
3318     * navigator in the specified document if it's a folder, or the folder that
3319     * contains the specified document if not.
3320     * <p>
3321     * Output: The URI of the item that was created. This must be a
3322     * {@code content://} URI so that any receiver can access it.
3323     *
3324     * @see DocumentsContract
3325     * @see #ACTION_OPEN_DOCUMENT
3326     * @see #ACTION_OPEN_DOCUMENT_TREE
3327     * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3328     */
3329    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3330    public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3331
3332    /**
3333     * Activity Action: Allow the user to pick a directory subtree. When
3334     * invoked, the system will display the various {@link DocumentsProvider}
3335     * instances installed on the device, letting the user navigate through
3336     * them. Apps can fully manage documents within the returned directory.
3337     * <p>
3338     * To gain access to descendant (child, grandchild, etc) documents, use
3339     * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3340     * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3341     * with the returned URI.
3342     * <p>
3343     * Callers can set a document URI through
3344     * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3345     * location of documents navigator. System will do its best to launch the
3346     * navigator in the specified document if it's a folder, or the folder that
3347     * contains the specified document if not.
3348     * <p>
3349     * Output: The URI representing the selected directory tree.
3350     *
3351     * @see DocumentsContract
3352     */
3353    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3354    public static final String
3355            ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
3356
3357    /**
3358     * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3359     * exisiting sensor being disconnected.
3360     *
3361     * <p class="note">This is a protected intent that can only be sent by the system.</p>
3362     *
3363     * {@hide}
3364     */
3365    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3366    public static final String
3367            ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3368
3369    /**
3370     * Broadcast Action: The default subscription has changed.  This has the following
3371     * extra values:</p>
3372     * The {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default subscription index
3373     */
3374    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3375    public static final String ACTION_DEFAULT_SUBSCRIPTION_CHANGED
3376            = "android.intent.action.ACTION_DEFAULT_SUBSCRIPTION_CHANGED";
3377
3378    /**
3379     * Broadcast Action: The default sms subscription has changed.  This has the following
3380     * extra values:</p>
3381     * {@link #EXTRA_SUBSCRIPTION_INDEX} extra indicates the current default sms
3382     * subscription index
3383     */
3384    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3385    public static final String ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED
3386            = "android.intent.action.ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED";
3387
3388    /**
3389     * Integer extra used with {@link #ACTION_DEFAULT_SUBSCRIPTION_CHANGED} and
3390     * {@link #ACTION_DEFAULT_SMS_SUBSCRIPTION_CHANGED} to indicate the subscription
3391     * which has changed.
3392     */
3393    public static final String EXTRA_SUBSCRIPTION_INDEX = "android.intent.extra.SUBSCRIPTION_INDEX";
3394
3395    /**
3396     * Deprecated - use {@link #ACTION_FACTORY_RESET} instead.
3397     *
3398     * {@hide}
3399     */
3400    @Deprecated
3401    public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3402
3403    /**
3404     * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3405     * is about to be performed.
3406     * @hide
3407     */
3408    @SystemApi
3409    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3410    public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3411            = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3412
3413    /**
3414     * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3415     * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3416     *
3417     * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3418     *
3419     * @hide
3420     */
3421    @Deprecated
3422    public static final String EXTRA_FORCE_MASTER_CLEAR =
3423            "android.intent.extra.FORCE_MASTER_CLEAR";
3424
3425    /**
3426     * A broadcast action to trigger a factory reset.
3427     *
3428     * <p> The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission.
3429     *
3430     * <p>Not for use by third-party applications.
3431     *
3432     * @see #EXTRA_FORCE_MASTER_CLEAR
3433     *
3434     * {@hide}
3435     */
3436    @SystemApi
3437    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3438    public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3439
3440    /**
3441     * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3442     * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3443     *
3444     * <p>Not for use by third-party applications.
3445     *
3446     * @hide
3447     */
3448    @SystemApi
3449    public static final String EXTRA_FORCE_FACTORY_RESET =
3450            "android.intent.extra.FORCE_FACTORY_RESET";
3451
3452    /**
3453     * Broadcast action: report that a settings element is being restored from backup.  The intent
3454     * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3455     * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3456     * is the value of that settings entry prior to the restore operation.  All of these values are
3457     * represented as strings.
3458     *
3459     * <p>This broadcast is sent only for settings provider entries known to require special handling
3460     * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
3461     * the provider's backup agent implementation.
3462     *
3463     * @see #EXTRA_SETTING_NAME
3464     * @see #EXTRA_SETTING_PREVIOUS_VALUE
3465     * @see #EXTRA_SETTING_NEW_VALUE
3466     * {@hide}
3467     */
3468    public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3469
3470    /** {@hide} */
3471    public static final String EXTRA_SETTING_NAME = "setting_name";
3472    /** {@hide} */
3473    public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3474    /** {@hide} */
3475    public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3476
3477    /**
3478     * Activity Action: Process a piece of text.
3479     * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3480     * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3481     * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3482     */
3483    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3484    public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3485
3486    /**
3487     * Broadcast Action: The sim card state has changed.
3488     * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3489     * because TelephonyIntents is an internal class.
3490     * @hide
3491     */
3492    @SystemApi
3493    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3494    public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3495
3496    /**
3497     * The name of the extra used to define the text to be processed, as a
3498     * CharSequence. Note that this may be a styled CharSequence, so you must use
3499     * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
3500     */
3501    public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3502    /**
3503     * The name of the boolean extra used to define if the processed text will be used as read-only.
3504     */
3505    public static final String EXTRA_PROCESS_TEXT_READONLY =
3506            "android.intent.extra.PROCESS_TEXT_READONLY";
3507
3508    /**
3509     * Broadcast action: reports when a new thermal event has been reached. When the device
3510     * is reaching its maximum temperatue, the thermal level reported
3511     * {@hide}
3512     */
3513    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3514    public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3515
3516    /** {@hide} */
3517    public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3518
3519    /**
3520     * Thermal state when the device is normal. This state is sent in the
3521     * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
3522     * {@hide}
3523     */
3524    public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3525
3526    /**
3527     * Thermal state where the device is approaching its maximum threshold. This state is sent in
3528     * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
3529     * {@hide}
3530     */
3531    public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3532
3533    /**
3534     * Thermal state where the device has reached its maximum threshold. This state is sent in the
3535     * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
3536     * {@hide}
3537     */
3538    public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3539
3540
3541    // ---------------------------------------------------------------------
3542    // ---------------------------------------------------------------------
3543    // Standard intent categories (see addCategory()).
3544
3545    /**
3546     * Set if the activity should be an option for the default action
3547     * (center press) to perform on a piece of data.  Setting this will
3548     * hide from the user any activities without it set when performing an
3549     * action on some data.  Note that this is normally -not- set in the
3550     * Intent when initiating an action -- it is for use in intent filters
3551     * specified in packages.
3552     */
3553    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3554    public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3555    /**
3556     * Activities that can be safely invoked from a browser must support this
3557     * category.  For example, if the user is viewing a web page or an e-mail
3558     * and clicks on a link in the text, the Intent generated execute that
3559     * link will require the BROWSABLE category, so that only activities
3560     * supporting this category will be considered as possible actions.  By
3561     * supporting this category, you are promising that there is nothing
3562     * damaging (without user intervention) that can happen by invoking any
3563     * matching Intent.
3564     */
3565    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3566    public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3567    /**
3568     * Categories for activities that can participate in voice interaction.
3569     * An activity that supports this category must be prepared to run with
3570     * no UI shown at all (though in some case it may have a UI shown), and
3571     * rely on {@link android.app.VoiceInteractor} to interact with the user.
3572     */
3573    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3574    public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3575    /**
3576     * Set if the activity should be considered as an alternative action to
3577     * the data the user is currently viewing.  See also
3578     * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3579     * applies to the selection in a list of items.
3580     *
3581     * <p>Supporting this category means that you would like your activity to be
3582     * displayed in the set of alternative things the user can do, usually as
3583     * part of the current activity's options menu.  You will usually want to
3584     * include a specific label in the &lt;intent-filter&gt; of this action
3585     * describing to the user what it does.
3586     *
3587     * <p>The action of IntentFilter with this category is important in that it
3588     * describes the specific action the target will perform.  This generally
3589     * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3590     * a specific name such as "com.android.camera.action.CROP.  Only one
3591     * alternative of any particular action will be shown to the user, so using
3592     * a specific action like this makes sure that your alternative will be
3593     * displayed while also allowing other applications to provide their own
3594     * overrides of that particular action.
3595     */
3596    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3597    public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3598    /**
3599     * Set if the activity should be considered as an alternative selection
3600     * action to the data the user has currently selected.  This is like
3601     * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3602     * of items from which the user can select, giving them alternatives to the
3603     * default action that will be performed on it.
3604     */
3605    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3606    public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3607    /**
3608     * Intended to be used as a tab inside of a containing TabActivity.
3609     */
3610    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3611    public static final String CATEGORY_TAB = "android.intent.category.TAB";
3612    /**
3613     * Should be displayed in the top-level launcher.
3614     */
3615    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3616    public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3617    /**
3618     * Indicates an activity optimized for Leanback mode, and that should
3619     * be displayed in the Leanback launcher.
3620     */
3621    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3622    public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3623    /**
3624     * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3625     * @hide
3626     */
3627    @SystemApi
3628    public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3629    /**
3630     * Provides information about the package it is in; typically used if
3631     * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3632     * a front-door to the user without having to be shown in the all apps list.
3633     */
3634    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3635    public static final String CATEGORY_INFO = "android.intent.category.INFO";
3636    /**
3637     * This is the home activity, that is the first activity that is displayed
3638     * when the device boots.
3639     */
3640    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3641    public static final String CATEGORY_HOME = "android.intent.category.HOME";
3642    /**
3643     * This is the home activity that is displayed when the device is finished setting up and ready
3644     * for use.
3645     * @hide
3646     */
3647    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3648    public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3649    /**
3650     * This is the setup wizard activity, that is the first activity that is displayed
3651     * when the user sets up the device for the first time.
3652     * @hide
3653     */
3654    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3655    public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3656    /**
3657     * This activity is a preference panel.
3658     */
3659    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3660    public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3661    /**
3662     * This activity is a development preference panel.
3663     */
3664    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3665    public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3666    /**
3667     * Capable of running inside a parent activity container.
3668     */
3669    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3670    public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3671    /**
3672     * This activity allows the user to browse and download new applications.
3673     */
3674    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3675    public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3676    /**
3677     * This activity may be exercised by the monkey or other automated test tools.
3678     */
3679    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3680    public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3681    /**
3682     * To be used as a test (not part of the normal user experience).
3683     */
3684    public static final String CATEGORY_TEST = "android.intent.category.TEST";
3685    /**
3686     * To be used as a unit test (run through the Test Harness).
3687     */
3688    public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3689    /**
3690     * To be used as a sample code example (not part of the normal user
3691     * experience).
3692     */
3693    public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
3694
3695    /**
3696     * Used to indicate that an intent only wants URIs that can be opened with
3697     * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3698     * must support at least the columns defined in {@link OpenableColumns} when
3699     * queried.
3700     *
3701     * @see #ACTION_GET_CONTENT
3702     * @see #ACTION_OPEN_DOCUMENT
3703     * @see #ACTION_CREATE_DOCUMENT
3704     */
3705    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3706    public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3707
3708    /**
3709     * Used to indicate that an intent filter can accept files which are not necessarily
3710     * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
3711     * at least streamable via
3712     * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
3713     * using one of the stream types exposed via
3714     * {@link ContentResolver#getStreamTypes(Uri, String)}.
3715     *
3716     * @see #ACTION_SEND
3717     * @see #ACTION_SEND_MULTIPLE
3718     */
3719    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3720    public static final String CATEGORY_TYPED_OPENABLE  =
3721            "android.intent.category.TYPED_OPENABLE";
3722
3723    /**
3724     * To be used as code under test for framework instrumentation tests.
3725     */
3726    public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3727            "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
3728    /**
3729     * An activity to run when device is inserted into a car dock.
3730     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
3731     * information, see {@link android.app.UiModeManager}.
3732     */
3733    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3734    public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3735    /**
3736     * An activity to run when device is inserted into a car dock.
3737     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
3738     * information, see {@link android.app.UiModeManager}.
3739     */
3740    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3741    public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
3742    /**
3743     * An activity to run when device is inserted into a analog (low end) dock.
3744     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
3745     * information, see {@link android.app.UiModeManager}.
3746     */
3747    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3748    public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3749
3750    /**
3751     * An activity to run when device is inserted into a digital (high end) dock.
3752     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
3753     * information, see {@link android.app.UiModeManager}.
3754     */
3755    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3756    public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
3757
3758    /**
3759     * Used to indicate that the activity can be used in a car environment.
3760     */
3761    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3762    public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3763
3764    /**
3765     * An activity to use for the launcher when the device is placed in a VR Headset viewer.
3766     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
3767     * information, see {@link android.app.UiModeManager}.
3768     */
3769    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3770    public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
3771    // ---------------------------------------------------------------------
3772    // ---------------------------------------------------------------------
3773    // Application launch intent categories (see addCategory()).
3774
3775    /**
3776     * Used with {@link #ACTION_MAIN} to launch the browser application.
3777     * The activity should be able to browse the Internet.
3778     * <p>NOTE: This should not be used as the primary key of an Intent,
3779     * since it will not result in the app launching with the correct
3780     * action and category.  Instead, use this with
3781     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3782     * Intent with this category in the selector.</p>
3783     */
3784    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3785    public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3786
3787    /**
3788     * Used with {@link #ACTION_MAIN} to launch the calculator application.
3789     * The activity should be able to perform standard arithmetic operations.
3790     * <p>NOTE: This should not be used as the primary key of an Intent,
3791     * since it will not result in the app launching with the correct
3792     * action and category.  Instead, use this with
3793     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3794     * Intent with this category in the selector.</p>
3795     */
3796    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3797    public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3798
3799    /**
3800     * Used with {@link #ACTION_MAIN} to launch the calendar application.
3801     * The activity should be able to view and manipulate calendar entries.
3802     * <p>NOTE: This should not be used as the primary key of an Intent,
3803     * since it will not result in the app launching with the correct
3804     * action and category.  Instead, use this with
3805     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3806     * Intent with this category in the selector.</p>
3807     */
3808    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3809    public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3810
3811    /**
3812     * Used with {@link #ACTION_MAIN} to launch the contacts application.
3813     * The activity should be able to view and manipulate address book entries.
3814     * <p>NOTE: This should not be used as the primary key of an Intent,
3815     * since it will not result in the app launching with the correct
3816     * action and category.  Instead, use this with
3817     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3818     * Intent with this category in the selector.</p>
3819     */
3820    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3821    public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3822
3823    /**
3824     * Used with {@link #ACTION_MAIN} to launch the email application.
3825     * The activity should be able to send and receive email.
3826     * <p>NOTE: This should not be used as the primary key of an Intent,
3827     * since it will not result in the app launching with the correct
3828     * action and category.  Instead, use this with
3829     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3830     * Intent with this category in the selector.</p>
3831     */
3832    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3833    public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3834
3835    /**
3836     * Used with {@link #ACTION_MAIN} to launch the gallery application.
3837     * The activity should be able to view and manipulate image and video files
3838     * stored on the device.
3839     * <p>NOTE: This should not be used as the primary key of an Intent,
3840     * since it will not result in the app launching with the correct
3841     * action and category.  Instead, use this with
3842     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3843     * Intent with this category in the selector.</p>
3844     */
3845    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3846    public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3847
3848    /**
3849     * Used with {@link #ACTION_MAIN} to launch the maps application.
3850     * The activity should be able to show the user's current location and surroundings.
3851     * <p>NOTE: This should not be used as the primary key of an Intent,
3852     * since it will not result in the app launching with the correct
3853     * action and category.  Instead, use this with
3854     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3855     * Intent with this category in the selector.</p>
3856     */
3857    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3858    public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3859
3860    /**
3861     * Used with {@link #ACTION_MAIN} to launch the messaging application.
3862     * The activity should be able to send and receive text messages.
3863     * <p>NOTE: This should not be used as the primary key of an Intent,
3864     * since it will not result in the app launching with the correct
3865     * action and category.  Instead, use this with
3866     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3867     * Intent with this category in the selector.</p>
3868     */
3869    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3870    public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3871
3872    /**
3873     * Used with {@link #ACTION_MAIN} to launch the music application.
3874     * The activity should be able to play, browse, or manipulate music files
3875     * stored on the device.
3876     * <p>NOTE: This should not be used as the primary key of an Intent,
3877     * since it will not result in the app launching with the correct
3878     * action and category.  Instead, use this with
3879     * {@link #makeMainSelectorActivity(String, String)} to generate a main
3880     * Intent with this category in the selector.</p>
3881     */
3882    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3883    public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3884
3885    // ---------------------------------------------------------------------
3886    // ---------------------------------------------------------------------
3887    // Standard extra data keys.
3888
3889    /**
3890     * The initial data to place in a newly created record.  Use with
3891     * {@link #ACTION_INSERT}.  The data here is a Map containing the same
3892     * fields as would be given to the underlying ContentProvider.insert()
3893     * call.
3894     */
3895    public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3896
3897    /**
3898     * A constant CharSequence that is associated with the Intent, used with
3899     * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
3900     * this may be a styled CharSequence, so you must use
3901     * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3902     * retrieve it.
3903     */
3904    public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3905
3906    /**
3907     * A constant String that is associated with the Intent, used with
3908     * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3909     * as HTML formatted text.  Note that you <em>must</em> also supply
3910     * {@link #EXTRA_TEXT}.
3911     */
3912    public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3913
3914    /**
3915     * A content: URI holding a stream of data associated with the Intent,
3916     * used with {@link #ACTION_SEND} to supply the data being sent.
3917     */
3918    public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3919
3920    /**
3921     * A String[] holding e-mail addresses that should be delivered to.
3922     */
3923    public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
3924
3925    /**
3926     * A String[] holding e-mail addresses that should be carbon copied.
3927     */
3928    public static final String EXTRA_CC       = "android.intent.extra.CC";
3929
3930    /**
3931     * A String[] holding e-mail addresses that should be blind carbon copied.
3932     */
3933    public static final String EXTRA_BCC      = "android.intent.extra.BCC";
3934
3935    /**
3936     * A constant string holding the desired subject line of a message.
3937     */
3938    public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
3939
3940    /**
3941     * An Intent describing the choices you would like shown with
3942     * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
3943     */
3944    public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3945
3946    /**
3947     * An int representing the user id to be used.
3948     *
3949     * @hide
3950     */
3951    public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3952
3953    /**
3954     * An int representing the task id to be retrieved. This is used when a launch from recents is
3955     * intercepted by another action such as credentials confirmation to remember which task should
3956     * be resumed when complete.
3957     *
3958     * @hide
3959     */
3960    public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3961
3962    /**
3963     * An Intent[] describing additional, alternate choices you would like shown with
3964     * {@link #ACTION_CHOOSER}.
3965     *
3966     * <p>An app may be capable of providing several different payload types to complete a
3967     * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3968     * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3969     * several different supported sending mechanisms for sharing, such as the actual "image/*"
3970     * photo data or a hosted link where the photos can be viewed.</p>
3971     *
3972     * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3973     * first/primary/preferred intent in the set. Additional intents specified in
3974     * this extra are ordered; by default intents that appear earlier in the array will be
3975     * preferred over intents that appear later in the array as matches for the same
3976     * target component. To alter this preference, a calling app may also supply
3977     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3978     */
3979    public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3980
3981    /**
3982     * A {@link ComponentName ComponentName[]} describing components that should be filtered out
3983     * and omitted from a list of components presented to the user.
3984     *
3985     * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
3986     * in this array if it otherwise would have shown them. Useful for omitting specific targets
3987     * from your own package or other apps from your organization if the idea of sending to those
3988     * targets would be redundant with other app functionality. Filtered components will not
3989     * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
3990     */
3991    public static final String EXTRA_EXCLUDE_COMPONENTS
3992            = "android.intent.extra.EXCLUDE_COMPONENTS";
3993
3994    /**
3995     * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
3996     * describing additional high-priority deep-link targets for the chooser to present to the user.
3997     *
3998     * <p>Targets provided in this way will be presented inline with all other targets provided
3999     * by services from other apps. They will be prioritized before other service targets, but
4000     * after those targets provided by sources that the user has manually pinned to the front.</p>
4001     *
4002     * @see #ACTION_CHOOSER
4003     */
4004    public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4005
4006    /**
4007     * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4008     * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4009     *
4010     * <p>An app preparing an action for another app to complete may wish to allow the user to
4011     * disambiguate between several options for completing the action based on the chosen target
4012     * or otherwise refine the action before it is invoked.
4013     * </p>
4014     *
4015     * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4016     * <ul>
4017     *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4018     *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4019     *     chosen target beyond the first</li>
4020     *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4021     *     should fill in and send once the disambiguation is complete</li>
4022     * </ul>
4023     */
4024    public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4025            = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4026
4027    /**
4028     * An {@code ArrayList} of {@code String} annotations describing content for
4029     * {@link #ACTION_CHOOSER}.
4030     *
4031     * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4032     * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4033     *
4034     * <p>Annotations should describe the major components or topics of the content. It is up to
4035     * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4036     * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4037     * start {@link #ACTION_CHOOSER}. Performance on customized annotations can suffer, if they are
4038     * rarely used for {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to
4039     * use the following annotations when applicable:</p>
4040     * <ul>
4041     *     <li>"product": represents that the topic of the content is mainly about products, e.g.,
4042     *     health & beauty, and office supplies.</li>
4043     *     <li>"emotion": represents that the topic of the content is mainly about emotions, e.g.,
4044     *     happy, and sad.</li>
4045     *     <li>"person": represents that the topic of the content is mainly about persons, e.g.,
4046     *     face, finger, standing, and walking.</li>
4047     *     <li>"child": represents that the topic of the content is mainly about children, e.g.,
4048     *     child, and baby.</li>
4049     *     <li>"selfie": represents that the topic of the content is mainly about selfies.</li>
4050     *     <li>"crowd": represents that the topic of the content is mainly about crowds.</li>
4051     *     <li>"party": represents that the topic of the content is mainly about parties.</li>
4052     *     <li>"animal": represent that the topic of the content is mainly about animals.</li>
4053     *     <li>"plant": represents that the topic of the content is mainly about plants, e.g.,
4054     *     flowers.</li>
4055     *     <li>"vacation": represents that the topic of the content is mainly about vacations.</li>
4056     *     <li>"fashion": represents that the topic of the content is mainly about fashion, e.g.
4057     *     sunglasses, jewelry, handbags and clothing.</li>
4058     *     <li>"material": represents that the topic of the content is mainly about materials, e.g.,
4059     *     paper, and silk.</li>
4060     *     <li>"vehicle": represents that the topic of the content is mainly about vehicles, like
4061     *     cars, and boats.</li>
4062     *     <li>"document": represents that the topic of the content is mainly about documents, e.g.
4063     *     posters.</li>
4064     *     <li>"design": represents that the topic of the content is mainly about design, e.g. arts
4065     *     and designs of houses.</li>
4066     *     <li>"holiday": represents that the topic of the content is mainly about holidays, e.g.,
4067     *     Christmas and Thanksgiving.</li>
4068     * </ul>
4069     */
4070    public static final String EXTRA_CONTENT_ANNOTATIONS
4071            = "android.intent.extra.CONTENT_ANNOTATIONS";
4072
4073    /**
4074     * A {@link ResultReceiver} used to return data back to the sender.
4075     *
4076     * <p>Used to complete an app-specific
4077     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4078     *
4079     * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4080     * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4081     * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4082     * when the user selects a target component from the chooser. It is up to the recipient
4083     * to send a result to this ResultReceiver to signal that disambiguation is complete
4084     * and that the chooser should invoke the user's choice.</p>
4085     *
4086     * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4087     * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4088     * to match and fill in the final Intent or ChooserTarget before starting it.
4089     * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4090     * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4091     * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4092     *
4093     * <p>The result code passed to the ResultReceiver should be
4094     * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4095     * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4096     * the chooser should finish without starting a target.</p>
4097     */
4098    public static final String EXTRA_RESULT_RECEIVER
4099            = "android.intent.extra.RESULT_RECEIVER";
4100
4101    /**
4102     * A CharSequence dialog title to provide to the user when used with a
4103     * {@link #ACTION_CHOOSER}.
4104     */
4105    public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4106
4107    /**
4108     * A Parcelable[] of {@link Intent} or
4109     * {@link android.content.pm.LabeledIntent} objects as set with
4110     * {@link #putExtra(String, Parcelable[])} of additional activities to place
4111     * a the front of the list of choices, when shown to the user with a
4112     * {@link #ACTION_CHOOSER}.
4113     */
4114    public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4115
4116    /**
4117     * A {@link IntentSender} to start after ephemeral installation success.
4118     * @hide
4119     */
4120    public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4121
4122    /**
4123     * A {@link IntentSender} to start after ephemeral installation failure.
4124     * @hide
4125     */
4126    public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4127
4128    /**
4129     * The host name that triggered an ephemeral resolution.
4130     * @hide
4131     */
4132    public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4133
4134    /**
4135     * An opaque token to track ephemeral resolution.
4136     * @hide
4137     */
4138    public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4139
4140    /**
4141     * The version code of the app to install components from.
4142     * @hide
4143     */
4144    public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4145
4146    /**
4147     * A Bundle forming a mapping of potential target package names to different extras Bundles
4148     * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4149     * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4150     * be currently installed on the device.
4151     *
4152     * <p>An application may choose to provide alternate extras for the case where a user
4153     * selects an activity from a predetermined set of target packages. If the activity
4154     * the user selects from the chooser belongs to a package with its package name as
4155     * a key in this bundle, the corresponding extras for that package will be merged with
4156     * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4157     * extra has the same key as an extra already present in the intent it will overwrite
4158     * the extra from the intent.</p>
4159     *
4160     * <p><em>Examples:</em>
4161     * <ul>
4162     *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
4163     *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4164     *     parameters for that target.</li>
4165     *     <li>An application may offer additional metadata for known targets of a given intent
4166     *     to pass along information only relevant to that target such as account or content
4167     *     identifiers already known to that application.</li>
4168     * </ul></p>
4169     */
4170    public static final String EXTRA_REPLACEMENT_EXTRAS =
4171            "android.intent.extra.REPLACEMENT_EXTRAS";
4172
4173    /**
4174     * An {@link IntentSender} that will be notified if a user successfully chooses a target
4175     * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4176     * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4177     * {@link ComponentName} of the chosen component.
4178     *
4179     * <p>In some situations this callback may never come, for example if the user abandons
4180     * the chooser, switches to another task or any number of other reasons. Apps should not
4181     * be written assuming that this callback will always occur.</p>
4182     */
4183    public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4184            "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4185
4186    /**
4187     * The {@link ComponentName} chosen by the user to complete an action.
4188     *
4189     * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4190     */
4191    public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4192
4193    /**
4194     * A {@link android.view.KeyEvent} object containing the event that
4195     * triggered the creation of the Intent it is in.
4196     */
4197    public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4198
4199    /**
4200     * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4201     * before shutting down.
4202     *
4203     * {@hide}
4204     */
4205    public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4206
4207    /**
4208     * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4209     * requested by the user.
4210     *
4211     * {@hide}
4212     */
4213    public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4214            "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4215
4216    /**
4217     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4218     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4219     * of restarting the application.
4220     */
4221    public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4222
4223    /**
4224     * A String holding the phone number originally entered in
4225     * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4226     * number to call in a {@link android.content.Intent#ACTION_CALL}.
4227     */
4228    public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
4229
4230    /**
4231     * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4232     * intents to supply the uid the package had been assigned.  Also an optional
4233     * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4234     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4235     * purpose.
4236     */
4237    public static final String EXTRA_UID = "android.intent.extra.UID";
4238
4239    /**
4240     * @hide String array of package names.
4241     */
4242    @SystemApi
4243    public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4244
4245    /**
4246     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4247     * intents to indicate whether this represents a full uninstall (removing
4248     * both the code and its data) or a partial uninstall (leaving its data,
4249     * implying that this is an update).
4250     */
4251    public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
4252
4253    /**
4254     * @hide
4255     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4256     * intents to indicate that at this point the package has been removed for
4257     * all users on the device.
4258     */
4259    public static final String EXTRA_REMOVED_FOR_ALL_USERS
4260            = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4261
4262    /**
4263     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4264     * intents to indicate that this is a replacement of the package, so this
4265     * broadcast will immediately be followed by an add broadcast for a
4266     * different version of the same package.
4267     */
4268    public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
4269
4270    /**
4271     * Used as an int extra field in {@link android.app.AlarmManager} intents
4272     * to tell the application being invoked how many pending alarms are being
4273     * delievered with the intent.  For one-shot alarms this will always be 1.
4274     * For recurring alarms, this might be greater than 1 if the device was
4275     * asleep or powered off at the time an earlier alarm would have been
4276     * delivered.
4277     */
4278    public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
4279
4280    /**
4281     * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4282     * intents to request the dock state.  Possible values are
4283     * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4284     * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
4285     * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4286     * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4287     * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
4288     */
4289    public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4290
4291    /**
4292     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4293     * to represent that the phone is not in any dock.
4294     */
4295    public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4296
4297    /**
4298     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4299     * to represent that the phone is in a desk dock.
4300     */
4301    public static final int EXTRA_DOCK_STATE_DESK = 1;
4302
4303    /**
4304     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4305     * to represent that the phone is in a car dock.
4306     */
4307    public static final int EXTRA_DOCK_STATE_CAR = 2;
4308
4309    /**
4310     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4311     * to represent that the phone is in a analog (low end) dock.
4312     */
4313    public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4314
4315    /**
4316     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4317     * to represent that the phone is in a digital (high end) dock.
4318     */
4319    public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4320
4321    /**
4322     * Boolean that can be supplied as meta-data with a dock activity, to
4323     * indicate that the dock should take over the home key when it is active.
4324     */
4325    public static final String METADATA_DOCK_HOME = "android.dock_home";
4326
4327    /**
4328     * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4329     * the bug report.
4330     */
4331    public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4332
4333    /**
4334     * Used in the extra field in the remote intent. It's astring token passed with the
4335     * remote intent.
4336     */
4337    public static final String EXTRA_REMOTE_INTENT_TOKEN =
4338            "android.intent.extra.remote_intent_token";
4339
4340    /**
4341     * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
4342     * will contain only the first name in the list.
4343     */
4344    @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
4345            "android.intent.extra.changed_component_name";
4346
4347    /**
4348     * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
4349     * and contains a string array of all of the components that have changed.  If
4350     * the state of the overall package has changed, then it will contain an entry
4351     * with the package name itself.
4352     */
4353    public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4354            "android.intent.extra.changed_component_name_list";
4355
4356    /**
4357     * This field is part of
4358     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4359     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4360     * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4361     * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
4362     * and contains a string array of all of the components that have changed.
4363     */
4364    public static final String EXTRA_CHANGED_PACKAGE_LIST =
4365            "android.intent.extra.changed_package_list";
4366
4367    /**
4368     * This field is part of
4369     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4370     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
4371     * and contains an integer array of uids of all of the components
4372     * that have changed.
4373     */
4374    public static final String EXTRA_CHANGED_UID_LIST =
4375            "android.intent.extra.changed_uid_list";
4376
4377    /**
4378     * @hide
4379     * Magic extra system code can use when binding, to give a label for
4380     * who it is that has bound to a service.  This is an integer giving
4381     * a framework string resource that can be displayed to the user.
4382     */
4383    public static final String EXTRA_CLIENT_LABEL =
4384            "android.intent.extra.client_label";
4385
4386    /**
4387     * @hide
4388     * Magic extra system code can use when binding, to give a PendingIntent object
4389     * that can be launched for the user to disable the system's use of this
4390     * service.
4391     */
4392    public static final String EXTRA_CLIENT_INTENT =
4393            "android.intent.extra.client_intent";
4394
4395    /**
4396     * Extra used to indicate that an intent should only return data that is on
4397     * the local device. This is a boolean extra; the default is false. If true,
4398     * an implementation should only allow the user to select data that is
4399     * already on the device, not requiring it be downloaded from a remote
4400     * service when opened.
4401     *
4402     * @see #ACTION_GET_CONTENT
4403     * @see #ACTION_OPEN_DOCUMENT
4404     * @see #ACTION_OPEN_DOCUMENT_TREE
4405     * @see #ACTION_CREATE_DOCUMENT
4406     */
4407    public static final String EXTRA_LOCAL_ONLY =
4408            "android.intent.extra.LOCAL_ONLY";
4409
4410    /**
4411     * Extra used to indicate that an intent can allow the user to select and
4412     * return multiple items. This is a boolean extra; the default is false. If
4413     * true, an implementation is allowed to present the user with a UI where
4414     * they can pick multiple items that are all returned to the caller. When
4415     * this happens, they should be returned as the {@link #getClipData()} part
4416     * of the result Intent.
4417     *
4418     * @see #ACTION_GET_CONTENT
4419     * @see #ACTION_OPEN_DOCUMENT
4420     */
4421    public static final String EXTRA_ALLOW_MULTIPLE =
4422            "android.intent.extra.ALLOW_MULTIPLE";
4423
4424    /**
4425     * The integer userHandle carried with broadcast intents related to addition, removal and
4426     * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4427     * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4428     *
4429     * @hide
4430     */
4431    public static final String EXTRA_USER_HANDLE =
4432            "android.intent.extra.user_handle";
4433
4434    /**
4435     * The UserHandle carried with broadcasts intents related to addition and removal of managed
4436     * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4437     */
4438    public static final String EXTRA_USER =
4439            "android.intent.extra.USER";
4440
4441    /**
4442     * Extra used in the response from a BroadcastReceiver that handles
4443     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4444     * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
4445     */
4446    public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4447
4448    /**
4449     * Extra sent in the intent to the BroadcastReceiver that handles
4450     * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4451     * the restrictions as key/value pairs.
4452     */
4453    public static final String EXTRA_RESTRICTIONS_BUNDLE =
4454            "android.intent.extra.restrictions_bundle";
4455
4456    /**
4457     * Extra used in the response from a BroadcastReceiver that handles
4458     * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4459     */
4460    public static final String EXTRA_RESTRICTIONS_INTENT =
4461            "android.intent.extra.restrictions_intent";
4462
4463    /**
4464     * Extra used to communicate a set of acceptable MIME types. The type of the
4465     * extra is {@code String[]}. Values may be a combination of concrete MIME
4466     * types (such as "image/png") and/or partial MIME types (such as
4467     * "audio/*").
4468     *
4469     * @see #ACTION_GET_CONTENT
4470     * @see #ACTION_OPEN_DOCUMENT
4471     */
4472    public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4473
4474    /**
4475     * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4476     * this shutdown is only for the user space of the system, not a complete shutdown.
4477     * When this is true, hardware devices can use this information to determine that
4478     * they shouldn't do a complete shutdown of their device since this is not a
4479     * complete shutdown down to the kernel, but only user space restarting.
4480     * The default if not supplied is false.
4481     */
4482    public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4483            = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4484
4485    /**
4486     * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
4487     * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
4488     * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
4489     * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
4490     *
4491     * @hide for internal use only.
4492     */
4493    public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4494            "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4495    /** @hide */
4496    public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
4497    /** @hide */
4498    public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
4499    /** @hide */
4500    public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
4501
4502    /** {@hide} */
4503    public static final String EXTRA_REASON = "android.intent.extra.REASON";
4504
4505    /** {@hide} */
4506    public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4507
4508    /**
4509     * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4510     * activation request.
4511     * TODO: Add information about the structure and response data used with the pending intent.
4512     * @hide
4513     */
4514    public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4515            "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4516
4517    /**
4518     * Optional index with semantics depending on the intent action.
4519     *
4520     * <p>The value must be an integer greater or equal to 0.
4521     * @see #ACTION_QUICK_VIEW
4522     */
4523    public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4524
4525    /**
4526     * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
4527     * such as opening in other apps, sharing, opening, editing, printing, deleting,
4528     * casting, etc.
4529     *
4530     * <p>The value is boolean. By default false.
4531     * @see #ACTION_QUICK_VIEW
4532     * @removed
4533     */
4534    @Deprecated
4535    public static final String EXTRA_QUICK_VIEW_ADVANCED =
4536            "android.intent.extra.QUICK_VIEW_ADVANCED";
4537
4538    /**
4539     * An optional extra of {@code String[]} indicating which quick view features should be made
4540     * available to the user in the quick view UI while handing a
4541     * {@link Intent#ACTION_QUICK_VIEW} intent.
4542     * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
4543     * Quick viewer can implement features not listed below.
4544     * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
4545     * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DOWNLOAD},
4546     * {@link QuickViewConstants#FEATURE_SEND}, {@link QuickViewConstants#FEATURE_PRINT}.
4547     * <p>
4548     * Requirements:
4549     * <li>Quick viewer shouldn't show a feature if the feature is absent in
4550     * {@link #EXTRA_QUICK_VIEW_FEATURES}.
4551     * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
4552     * internal policies.
4553     * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
4554     * requirement that the feature be shown. Quick viewer may, according to its own policies,
4555     * disable or hide features.
4556     *
4557     * @see #ACTION_QUICK_VIEW
4558     */
4559    public static final String EXTRA_QUICK_VIEW_FEATURES =
4560            "android.intent.extra.QUICK_VIEW_FEATURES";
4561
4562    /**
4563     * Optional boolean extra indicating whether quiet mode has been switched on or off.
4564     * When a profile goes into quiet mode, all apps in the profile are killed and the
4565     * profile user is stopped. Widgets originating from the profile are masked, and app
4566     * launcher icons are grayed out.
4567     */
4568    public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
4569
4570    /**
4571     * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
4572     * intents to specify the resource type granted. Possible values are
4573     * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4574     * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
4575     *
4576     * @hide
4577     */
4578    public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4579            "android.intent.extra.MEDIA_RESOURCE_TYPE";
4580
4581    /**
4582     * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
4583     * whether to show the chooser or not when there is only one application available
4584     * to choose from.
4585     *
4586     * @hide
4587     */
4588    public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
4589            "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
4590
4591    /**
4592     * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
4593     * to represent that a video codec is allowed to use.
4594     *
4595     * @hide
4596     */
4597    public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4598
4599    /**
4600     * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
4601     * to represent that a audio codec is allowed to use.
4602     *
4603     * @hide
4604     */
4605    public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4606
4607    // ---------------------------------------------------------------------
4608    // ---------------------------------------------------------------------
4609    // Intent flags (see mFlags variable).
4610
4611    /** @hide */
4612    @IntDef(flag = true, value = {
4613            FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4614            FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
4615    @Retention(RetentionPolicy.SOURCE)
4616    public @interface GrantUriMode {}
4617
4618    /** @hide */
4619    @IntDef(flag = true, value = {
4620            FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4621    @Retention(RetentionPolicy.SOURCE)
4622    public @interface AccessUriMode {}
4623
4624    /**
4625     * Test if given mode flags specify an access mode, which must be at least
4626     * read and/or write.
4627     *
4628     * @hide
4629     */
4630    public static boolean isAccessUriMode(int modeFlags) {
4631        return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4632                | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4633    }
4634
4635    /**
4636     * If set, the recipient of this Intent will be granted permission to
4637     * perform read operations on the URI in the Intent's data and any URIs
4638     * specified in its ClipData.  When applying to an Intent's ClipData,
4639     * all URIs as well as recursive traversals through data or other ClipData
4640     * in Intent items will be granted; only the grant flags of the top-level
4641     * Intent are used.
4642     */
4643    public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4644    /**
4645     * If set, the recipient of this Intent will be granted permission to
4646     * perform write operations on the URI in the Intent's data and any URIs
4647     * specified in its ClipData.  When applying to an Intent's ClipData,
4648     * all URIs as well as recursive traversals through data or other ClipData
4649     * in Intent items will be granted; only the grant flags of the top-level
4650     * Intent are used.
4651     */
4652    public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4653    /**
4654     * Can be set by the caller to indicate that this Intent is coming from
4655     * a background operation, not from direct user interaction.
4656     */
4657    public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4658    /**
4659     * A flag you can enable for debugging: when set, log messages will be
4660     * printed during the resolution of this intent to show you what has
4661     * been found to create the final resolved list.
4662     */
4663    public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
4664    /**
4665     * If set, this intent will not match any components in packages that
4666     * are currently stopped.  If this is not set, then the default behavior
4667     * is to include such applications in the result.
4668     */
4669    public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4670    /**
4671     * If set, this intent will always match any components in packages that
4672     * are currently stopped.  This is the default behavior when
4673     * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
4674     * flags are set, this one wins (it allows overriding of exclude for
4675     * places where the framework may automatically set the exclude flag).
4676     */
4677    public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
4678
4679    /**
4680     * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4681     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
4682     * persisted across device reboots until explicitly revoked with
4683     * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4684     * grant for possible persisting; the receiving application must call
4685     * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4686     * actually persist.
4687     *
4688     * @see ContentResolver#takePersistableUriPermission(Uri, int)
4689     * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4690     * @see ContentResolver#getPersistedUriPermissions()
4691     * @see ContentResolver#getOutgoingPersistedUriPermissions()
4692     */
4693    public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
4694
4695    /**
4696     * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4697     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4698     * applies to any URI that is a prefix match against the original granted
4699     * URI. (Without this flag, the URI must match exactly for access to be
4700     * granted.) Another URI is considered a prefix match only when scheme,
4701     * authority, and all path segments defined by the prefix are an exact
4702     * match.
4703     */
4704    public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4705
4706    /**
4707     * Internal flag used to indicate that a system component has done their
4708     * homework and verified that they correctly handle packages and components
4709     * that come and go over time. In particular:
4710     * <ul>
4711     * <li>Apps installed on external storage, which will appear to be
4712     * uninstalled while the the device is ejected.
4713     * <li>Apps with encryption unaware components, which will appear to not
4714     * exist while the device is locked.
4715     * </ul>
4716     *
4717     * @hide
4718     */
4719    public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
4720
4721    /**
4722     * Internal flag used to indicate ephemeral applications should not be
4723     * considered when resolving the intent.
4724     *
4725     * @hide
4726     */
4727    public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
4728
4729    /**
4730     * If set, the new activity is not kept in the history stack.  As soon as
4731     * the user navigates away from it, the activity is finished.  This may also
4732     * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4733     * noHistory} attribute.
4734     *
4735     * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4736     * is never invoked when the current activity starts a new activity which
4737     * sets a result and finishes.
4738     */
4739    public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4740    /**
4741     * If set, the activity will not be launched if it is already running
4742     * at the top of the history stack.
4743     */
4744    public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4745    /**
4746     * If set, this activity will become the start of a new task on this
4747     * history stack.  A task (from the activity that started it to the
4748     * next task activity) defines an atomic group of activities that the
4749     * user can move to.  Tasks can be moved to the foreground and background;
4750     * all of the activities inside of a particular task always remain in
4751     * the same order.  See
4752     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4753     * Stack</a> for more information about tasks.
4754     *
4755     * <p>This flag is generally used by activities that want
4756     * to present a "launcher" style behavior: they give the user a list of
4757     * separate things that can be done, which otherwise run completely
4758     * independently of the activity launching them.
4759     *
4760     * <p>When using this flag, if a task is already running for the activity
4761     * you are now starting, then a new activity will not be started; instead,
4762     * the current task will simply be brought to the front of the screen with
4763     * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4764     * to disable this behavior.
4765     *
4766     * <p>This flag can not be used when the caller is requesting a result from
4767     * the activity being launched.
4768     */
4769    public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4770    /**
4771     * This flag is used to create a new task and launch an activity into it.
4772     * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4773     * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4774     * search through existing tasks for ones matching this Intent. Only if no such
4775     * task is found would a new task be created. When paired with
4776     * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4777     * the search for a matching task and unconditionally start a new task.
4778     *
4779     * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4780     * flag unless you are implementing your own
4781     * top-level application launcher.</strong>  Used in conjunction with
4782     * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4783     * behavior of bringing an existing task to the foreground.  When set,
4784     * a new task is <em>always</em> started to host the Activity for the
4785     * Intent, regardless of whether there is already an existing task running
4786     * the same thing.
4787     *
4788     * <p><strong>Because the default system does not include graphical task management,
4789     * you should not use this flag unless you provide some way for a user to
4790     * return back to the tasks you have launched.</strong>
4791     *
4792     * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4793     * creating new document tasks.
4794     *
4795     * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
4796     * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
4797     *
4798     * <p>See
4799     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4800     * Stack</a> for more information about tasks.
4801     *
4802     * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4803     * @see #FLAG_ACTIVITY_NEW_TASK
4804     */
4805    public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4806    /**
4807     * If set, and the activity being launched is already running in the
4808     * current task, then instead of launching a new instance of that activity,
4809     * all of the other activities on top of it will be closed and this Intent
4810     * will be delivered to the (now on top) old activity as a new Intent.
4811     *
4812     * <p>For example, consider a task consisting of the activities: A, B, C, D.
4813     * If D calls startActivity() with an Intent that resolves to the component
4814     * of activity B, then C and D will be finished and B receive the given
4815     * Intent, resulting in the stack now being: A, B.
4816     *
4817     * <p>The currently running instance of activity B in the above example will
4818     * either receive the new intent you are starting here in its
4819     * onNewIntent() method, or be itself finished and restarted with the
4820     * new intent.  If it has declared its launch mode to be "multiple" (the
4821     * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4822     * the same intent, then it will be finished and re-created; for all other
4823     * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4824     * Intent will be delivered to the current instance's onNewIntent().
4825     *
4826     * <p>This launch mode can also be used to good effect in conjunction with
4827     * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4828     * of a task, it will bring any currently running instance of that task
4829     * to the foreground, and then clear it to its root state.  This is
4830     * especially useful, for example, when launching an activity from the
4831     * notification manager.
4832     *
4833     * <p>See
4834     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4835     * Stack</a> for more information about tasks.
4836     */
4837    public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4838    /**
4839     * If set and this intent is being used to launch a new activity from an
4840     * existing one, then the reply target of the existing activity will be
4841     * transfered to the new activity.  This way the new activity can call
4842     * {@link android.app.Activity#setResult} and have that result sent back to
4843     * the reply target of the original activity.
4844     */
4845    public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4846    /**
4847     * If set and this intent is being used to launch a new activity from an
4848     * existing one, the current activity will not be counted as the top
4849     * activity for deciding whether the new intent should be delivered to
4850     * the top instead of starting a new one.  The previous activity will
4851     * be used as the top, with the assumption being that the current activity
4852     * will finish itself immediately.
4853     */
4854    public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4855    /**
4856     * If set, the new activity is not kept in the list of recently launched
4857     * activities.
4858     */
4859    public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4860    /**
4861     * This flag is not normally set by application code, but set for you by
4862     * the system as described in the
4863     * {@link android.R.styleable#AndroidManifestActivity_launchMode
4864     * launchMode} documentation for the singleTask mode.
4865     */
4866    public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4867    /**
4868     * If set, and this activity is either being started in a new task or
4869     * bringing to the top an existing task, then it will be launched as
4870     * the front door of the task.  This will result in the application of
4871     * any affinities needed to have that task in the proper state (either
4872     * moving activities to or from it), or simply resetting that task to
4873     * its initial state if needed.
4874     */
4875    public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4876    /**
4877     * This flag is not normally set by application code, but set for you by
4878     * the system if this activity is being launched from history
4879     * (longpress home key).
4880     */
4881    public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
4882    /**
4883     * @deprecated As of API 21 this performs identically to
4884     * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
4885     */
4886    @Deprecated
4887    public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
4888    /**
4889     * This flag is used to open a document into a new task rooted at the activity launched
4890     * by this Intent. Through the use of this flag, or its equivalent attribute,
4891     * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
4892     * containing different documents will appear in the recent tasks list.
4893     *
4894     * <p>The use of the activity attribute form of this,
4895     * {@link android.R.attr#documentLaunchMode}, is
4896     * preferred over the Intent flag described here. The attribute form allows the
4897     * Activity to specify multiple document behavior for all launchers of the Activity
4898     * whereas using this flag requires each Intent that launches the Activity to specify it.
4899     *
4900     * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4901     * it is kept after the activity is finished is different than the use of
4902     * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4903     * this flag is being used to create a new recents entry, then by default that entry
4904     * will be removed once the activity is finished.  You can modify this behavior with
4905     * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4906     *
4907     * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4908     * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4909     * equivalent of the Activity manifest specifying {@link
4910     * android.R.attr#documentLaunchMode}="intoExisting". When used with
4911     * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4912     * {@link android.R.attr#documentLaunchMode}="always".
4913     *
4914     * Refer to {@link android.R.attr#documentLaunchMode} for more information.
4915     *
4916     * @see android.R.attr#documentLaunchMode
4917     * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4918     */
4919    public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
4920    /**
4921     * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
4922     * callback from occurring on the current frontmost activity before it is
4923     * paused as the newly-started activity is brought to the front.
4924     *
4925     * <p>Typically, an activity can rely on that callback to indicate that an
4926     * explicit user action has caused their activity to be moved out of the
4927     * foreground. The callback marks an appropriate point in the activity's
4928     * lifecycle for it to dismiss any notifications that it intends to display
4929     * "until the user has seen them," such as a blinking LED.
4930     *
4931     * <p>If an activity is ever started via any non-user-driven events such as
4932     * phone-call receipt or an alarm handler, this flag should be passed to {@link
4933     * Context#startActivity Context.startActivity}, ensuring that the pausing
4934     * activity does not think the user has acknowledged its notification.
4935     */
4936    public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
4937    /**
4938     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4939     * this flag will cause the launched activity to be brought to the front of its
4940     * task's history stack if it is already running.
4941     *
4942     * <p>For example, consider a task consisting of four activities: A, B, C, D.
4943     * If D calls startActivity() with an Intent that resolves to the component
4944     * of activity B, then B will be brought to the front of the history stack,
4945     * with this resulting order:  A, C, D, B.
4946     *
4947     * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
4948     * specified.
4949     */
4950    public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
4951    /**
4952     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4953     * this flag will prevent the system from applying an activity transition
4954     * animation to go to the next activity state.  This doesn't mean an
4955     * animation will never run -- if another activity change happens that doesn't
4956     * specify this flag before the activity started here is displayed, then
4957     * that transition will be used.  This flag can be put to good use
4958     * when you are going to do a series of activity operations but the
4959     * animation seen by the user shouldn't be driven by the first activity
4960     * change but rather a later one.
4961     */
4962    public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4963    /**
4964     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4965     * this flag will cause any existing task that would be associated with the
4966     * activity to be cleared before the activity is started.  That is, the activity
4967     * becomes the new root of an otherwise empty task, and any old activities
4968     * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4969     */
4970    public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4971    /**
4972     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4973     * this flag will cause a newly launching task to be placed on top of the current
4974     * home activity task (if there is one).  That is, pressing back from the task
4975     * will always return the user to home even if that was not the last activity they
4976     * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4977     */
4978    public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4979    /**
4980     * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4981     * have its entry in recent tasks removed when the user closes it (with back
4982     * or however else it may finish()). If you would like to instead allow the
4983     * document to be kept in recents so that it can be re-launched, you can use
4984     * this flag. When set and the task's activity is finished, the recents
4985     * entry will remain in the interface for the user to re-launch it, like a
4986     * recents entry for a top-level application.
4987     * <p>
4988     * The receiving activity can override this request with
4989     * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4990     * {@link android.app.Activity#finishAndRemoveTask()
4991     * Activity.finishAndRemoveTask()}.
4992     */
4993    public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
4994
4995    /**
4996     * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4997     * adjacent to the one launching it. This can only be used in conjunction with
4998     * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4999     * required if you want a new instance of an existing activity to be created.
5000     */
5001    public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
5002
5003    /**
5004     * If set, when sending a broadcast only registered receivers will be
5005     * called -- no BroadcastReceiver components will be launched.
5006     */
5007    public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
5008    /**
5009     * If set, when sending a broadcast the new broadcast will replace
5010     * any existing pending broadcast that matches it.  Matching is defined
5011     * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5012     * true for the intents of the two broadcasts.  When a match is found,
5013     * the new broadcast (and receivers associated with it) will replace the
5014     * existing one in the pending broadcast list, remaining at the same
5015     * position in the list.
5016     *
5017     * <p>This flag is most typically used with sticky broadcasts, which
5018     * only care about delivering the most recent values of the broadcast
5019     * to their receivers.
5020     */
5021    public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5022    /**
5023     * If set, when sending a broadcast the recipient is allowed to run at
5024     * foreground priority, with a shorter timeout interval.  During normal
5025     * broadcasts the receivers are not automatically hoisted out of the
5026     * background priority class.
5027     */
5028    public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5029    /**
5030     * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5031     * They can still propagate results through to later receivers, but they can not prevent
5032     * later receivers from seeing the broadcast.
5033     */
5034    public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5035    /**
5036     * If set, when sending a broadcast <i>before boot has completed</i> only
5037     * registered receivers will be called -- no BroadcastReceiver components
5038     * will be launched.  Sticky intent state will be recorded properly even
5039     * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5040     * is specified in the broadcast intent, this flag is unnecessary.
5041     *
5042     * <p>This flag is only for use by system sevices as a convenience to
5043     * avoid having to implement a more complex mechanism around detection
5044     * of boot completion.
5045     *
5046     * @hide
5047     */
5048    public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
5049    /**
5050     * Set when this broadcast is for a boot upgrade, a special mode that
5051     * allows the broadcast to be sent before the system is ready and launches
5052     * the app process with no providers running in it.
5053     * @hide
5054     */
5055    public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
5056    /**
5057     * If set, the broadcast will always go to manifest receivers in background (cached
5058     * or not running) apps, regardless of whether that would be done by default.  By
5059     * default they will only receive broadcasts if the broadcast has specified an
5060     * explicit component or package name.
5061     *
5062     * NOTE: dumpstate uses this flag numerically, so when its value is changed
5063     * the broadcast code there must also be changed to match.
5064     *
5065     * @hide
5066     */
5067    public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5068    /**
5069     * If set, the broadcast will never go to manifest receivers in background (cached
5070     * or not running) apps, regardless of whether that would be done by default.  By
5071     * default they will receive broadcasts if the broadcast has specified an
5072     * explicit component or package name.
5073     * @hide
5074     */
5075    public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
5076    /**
5077     * If set, this broadcast is being sent from the shell.
5078     * @hide
5079     */
5080    public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
5081
5082    /**
5083     * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5084     * will not receive broadcasts.
5085     *
5086     * <em>This flag has no effect when used by an Instant App.</em>
5087     */
5088    public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5089
5090    /**
5091     * @hide Flags that can't be changed with PendingIntent.
5092     */
5093    public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5094            | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5095            | FLAG_GRANT_PREFIX_URI_PERMISSION;
5096
5097    // ---------------------------------------------------------------------
5098    // ---------------------------------------------------------------------
5099    // toUri() and parseUri() options.
5100
5101    /**
5102     * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5103     * always has the "intent:" scheme.  This syntax can be used when you want
5104     * to later disambiguate between URIs that are intended to describe an
5105     * Intent vs. all others that should be treated as raw URIs.  When used
5106     * with {@link #parseUri}, any other scheme will result in a generic
5107     * VIEW action for that raw URI.
5108     */
5109    public static final int URI_INTENT_SCHEME = 1<<0;
5110
5111    /**
5112     * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5113     * always has the "android-app:" scheme.  This is a variation of
5114     * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5115     * http/https URI being delivered to a specific package name.  The format
5116     * is:
5117     *
5118     * <pre class="prettyprint">
5119     * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
5120     *
5121     * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
5122     * you must also include a scheme; including a path also requires both a host and a scheme.
5123     * The final #Intent; fragment can be used without a scheme, host, or path.
5124     * Note that this can not be
5125     * used with intents that have a {@link #setSelector}, since the base intent
5126     * will always have an explicit package name.</p>
5127     *
5128     * <p>Some examples of how this scheme maps to Intent objects:</p>
5129     * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5130     *     <colgroup align="left" />
5131     *     <colgroup align="left" />
5132     *     <thead>
5133     *     <tr><th>URI</th> <th>Intent</th></tr>
5134     *     </thead>
5135     *
5136     *     <tbody>
5137     *     <tr><td><code>android-app://com.example.app</code></td>
5138     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5139     *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5140     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5141     *         </table></td>
5142     *     </tr>
5143     *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5144     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5145     *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5146     *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5147     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5148     *         </table></td>
5149     *     </tr>
5150     *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5151     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5152     *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5153     *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5154     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5155     *         </table></td>
5156     *     </tr>
5157     *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5158     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5159     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5160     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5161     *         </table></td>
5162     *     </tr>
5163     *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5164     *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5165     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5166     *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5167     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5168     *         </table></td>
5169     *     </tr>
5170     *     <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>
5171     *         <td><table border="" style="margin:0" >
5172     *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5173     *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5174     *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5175     *         </table></td>
5176     *     </tr>
5177     *     </tbody>
5178     * </table>
5179     */
5180    public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5181
5182    /**
5183     * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5184     * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5185     * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5186     * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5187     * generated Intent can not cause unexpected data access to happen.
5188     *
5189     * <p>If you do not trust the source of the URI being parsed, you should still do further
5190     * processing to protect yourself from it.  In particular, when using it to start an
5191     * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5192     * that can handle it.</p>
5193     */
5194    public static final int URI_ALLOW_UNSAFE = 1<<2;
5195
5196    // ---------------------------------------------------------------------
5197
5198    private String mAction;
5199    private Uri mData;
5200    private String mType;
5201    private String mPackage;
5202    private ComponentName mComponent;
5203    private int mFlags;
5204    private ArraySet<String> mCategories;
5205    private Bundle mExtras;
5206    private Rect mSourceBounds;
5207    private Intent mSelector;
5208    private ClipData mClipData;
5209    private int mContentUserHint = UserHandle.USER_CURRENT;
5210    /** Token to track instant app launches. Local only; do not copy cross-process. */
5211    private String mLaunchToken;
5212
5213    // ---------------------------------------------------------------------
5214
5215    /**
5216     * Create an empty intent.
5217     */
5218    public Intent() {
5219    }
5220
5221    /**
5222     * Copy constructor.
5223     */
5224    public Intent(Intent o) {
5225        this.mAction = o.mAction;
5226        this.mData = o.mData;
5227        this.mType = o.mType;
5228        this.mPackage = o.mPackage;
5229        this.mComponent = o.mComponent;
5230        this.mFlags = o.mFlags;
5231        this.mContentUserHint = o.mContentUserHint;
5232        this.mLaunchToken = o.mLaunchToken;
5233        if (o.mCategories != null) {
5234            this.mCategories = new ArraySet<String>(o.mCategories);
5235        }
5236        if (o.mExtras != null) {
5237            this.mExtras = new Bundle(o.mExtras);
5238        }
5239        if (o.mSourceBounds != null) {
5240            this.mSourceBounds = new Rect(o.mSourceBounds);
5241        }
5242        if (o.mSelector != null) {
5243            this.mSelector = new Intent(o.mSelector);
5244        }
5245        if (o.mClipData != null) {
5246            this.mClipData = new ClipData(o.mClipData);
5247        }
5248    }
5249
5250    @Override
5251    public Object clone() {
5252        return new Intent(this);
5253    }
5254
5255    private Intent(Intent o, boolean all) {
5256        this.mAction = o.mAction;
5257        this.mData = o.mData;
5258        this.mType = o.mType;
5259        this.mPackage = o.mPackage;
5260        this.mComponent = o.mComponent;
5261        if (o.mCategories != null) {
5262            this.mCategories = new ArraySet<String>(o.mCategories);
5263        }
5264    }
5265
5266    /**
5267     * Make a clone of only the parts of the Intent that are relevant for
5268     * filter matching: the action, data, type, component, and categories.
5269     */
5270    public Intent cloneFilter() {
5271        return new Intent(this, false);
5272    }
5273
5274    /**
5275     * Create an intent with a given action.  All other fields (data, type,
5276     * class) are null.  Note that the action <em>must</em> be in a
5277     * namespace because Intents are used globally in the system -- for
5278     * example the system VIEW action is android.intent.action.VIEW; an
5279     * application's custom action would be something like
5280     * com.google.app.myapp.CUSTOM_ACTION.
5281     *
5282     * @param action The Intent action, such as ACTION_VIEW.
5283     */
5284    public Intent(String action) {
5285        setAction(action);
5286    }
5287
5288    /**
5289     * Create an intent with a given action and for a given data url.  Note
5290     * that the action <em>must</em> be in a namespace because Intents are
5291     * used globally in the system -- for example the system VIEW action is
5292     * android.intent.action.VIEW; an application's custom action would be
5293     * something like com.google.app.myapp.CUSTOM_ACTION.
5294     *
5295     * <p><em>Note: scheme and host name matching in the Android framework is
5296     * case-sensitive, unlike the formal RFC.  As a result,
5297     * you should always ensure that you write your Uri with these elements
5298     * using lower case letters, and normalize any Uris you receive from
5299     * outside of Android to ensure the scheme and host is lower case.</em></p>
5300     *
5301     * @param action The Intent action, such as ACTION_VIEW.
5302     * @param uri The Intent data URI.
5303     */
5304    public Intent(String action, Uri uri) {
5305        setAction(action);
5306        mData = uri;
5307    }
5308
5309    /**
5310     * Create an intent for a specific component.  All other fields (action, data,
5311     * type, class) are null, though they can be modified later with explicit
5312     * calls.  This provides a convenient way to create an intent that is
5313     * intended to execute a hard-coded class name, rather than relying on the
5314     * system to find an appropriate class for you; see {@link #setComponent}
5315     * for more information on the repercussions of this.
5316     *
5317     * @param packageContext A Context of the application package implementing
5318     * this class.
5319     * @param cls The component class that is to be used for the intent.
5320     *
5321     * @see #setClass
5322     * @see #setComponent
5323     * @see #Intent(String, android.net.Uri , Context, Class)
5324     */
5325    public Intent(Context packageContext, Class<?> cls) {
5326        mComponent = new ComponentName(packageContext, cls);
5327    }
5328
5329    /**
5330     * Create an intent for a specific component with a specified action and data.
5331     * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
5332     * construct the Intent and then calling {@link #setClass} to set its
5333     * class.
5334     *
5335     * <p><em>Note: scheme and host name matching in the Android framework is
5336     * case-sensitive, unlike the formal RFC.  As a result,
5337     * you should always ensure that you write your Uri with these elements
5338     * using lower case letters, and normalize any Uris you receive from
5339     * outside of Android to ensure the scheme and host is lower case.</em></p>
5340     *
5341     * @param action The Intent action, such as ACTION_VIEW.
5342     * @param uri The Intent data URI.
5343     * @param packageContext A Context of the application package implementing
5344     * this class.
5345     * @param cls The component class that is to be used for the intent.
5346     *
5347     * @see #Intent(String, android.net.Uri)
5348     * @see #Intent(Context, Class)
5349     * @see #setClass
5350     * @see #setComponent
5351     */
5352    public Intent(String action, Uri uri,
5353            Context packageContext, Class<?> cls) {
5354        setAction(action);
5355        mData = uri;
5356        mComponent = new ComponentName(packageContext, cls);
5357    }
5358
5359    /**
5360     * Create an intent to launch the main (root) activity of a task.  This
5361     * is the Intent that is started when the application's is launched from
5362     * Home.  For anything else that wants to launch an application in the
5363     * same way, it is important that they use an Intent structured the same
5364     * way, and can use this function to ensure this is the case.
5365     *
5366     * <p>The returned Intent has the given Activity component as its explicit
5367     * component, {@link #ACTION_MAIN} as its action, and includes the
5368     * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
5369     * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5370     * to do that through {@link #addFlags(int)} on the returned Intent.
5371     *
5372     * @param mainActivity The main activity component that this Intent will
5373     * launch.
5374     * @return Returns a newly created Intent that can be used to launch the
5375     * activity as a main application entry.
5376     *
5377     * @see #setClass
5378     * @see #setComponent
5379     */
5380    public static Intent makeMainActivity(ComponentName mainActivity) {
5381        Intent intent = new Intent(ACTION_MAIN);
5382        intent.setComponent(mainActivity);
5383        intent.addCategory(CATEGORY_LAUNCHER);
5384        return intent;
5385    }
5386
5387    /**
5388     * Make an Intent for the main activity of an application, without
5389     * specifying a specific activity to run but giving a selector to find
5390     * the activity.  This results in a final Intent that is structured
5391     * the same as when the application is launched from
5392     * Home.  For anything else that wants to launch an application in the
5393     * same way, it is important that they use an Intent structured the same
5394     * way, and can use this function to ensure this is the case.
5395     *
5396     * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
5397     * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
5398     * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
5399     * to do that through {@link #addFlags(int)} on the returned Intent.
5400     *
5401     * @param selectorAction The action name of the Intent's selector.
5402     * @param selectorCategory The name of a category to add to the Intent's
5403     * selector.
5404     * @return Returns a newly created Intent that can be used to launch the
5405     * activity as a main application entry.
5406     *
5407     * @see #setSelector(Intent)
5408     */
5409    public static Intent makeMainSelectorActivity(String selectorAction,
5410            String selectorCategory) {
5411        Intent intent = new Intent(ACTION_MAIN);
5412        intent.addCategory(CATEGORY_LAUNCHER);
5413        Intent selector = new Intent();
5414        selector.setAction(selectorAction);
5415        selector.addCategory(selectorCategory);
5416        intent.setSelector(selector);
5417        return intent;
5418    }
5419
5420    /**
5421     * Make an Intent that can be used to re-launch an application's task
5422     * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
5423     * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
5424     * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
5425     *
5426     * @param mainActivity The activity component that is the root of the
5427     * task; this is the activity that has been published in the application's
5428     * manifest as the main launcher icon.
5429     *
5430     * @return Returns a newly created Intent that can be used to relaunch the
5431     * activity's task in its root state.
5432     */
5433    public static Intent makeRestartActivityTask(ComponentName mainActivity) {
5434        Intent intent = makeMainActivity(mainActivity);
5435        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
5436                | Intent.FLAG_ACTIVITY_CLEAR_TASK);
5437        return intent;
5438    }
5439
5440    /**
5441     * Call {@link #parseUri} with 0 flags.
5442     * @deprecated Use {@link #parseUri} instead.
5443     */
5444    @Deprecated
5445    public static Intent getIntent(String uri) throws URISyntaxException {
5446        return parseUri(uri, 0);
5447    }
5448
5449    /**
5450     * Create an intent from a URI.  This URI may encode the action,
5451     * category, and other intent fields, if it was returned by
5452     * {@link #toUri}.  If the Intent was not generate by toUri(), its data
5453     * will be the entire URI and its action will be ACTION_VIEW.
5454     *
5455     * <p>The URI given here must not be relative -- that is, it must include
5456     * the scheme and full path.
5457     *
5458     * @param uri The URI to turn into an Intent.
5459     * @param flags Additional processing flags.  Either 0,
5460     * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
5461     *
5462     * @return Intent The newly created Intent object.
5463     *
5464     * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5465     * it bad (as parsed by the Uri class) or the Intent data within the
5466     * URI is invalid.
5467     *
5468     * @see #toUri
5469     */
5470    public static Intent parseUri(String uri, int flags) throws URISyntaxException {
5471        int i = 0;
5472        try {
5473            final boolean androidApp = uri.startsWith("android-app:");
5474
5475            // Validate intent scheme if requested.
5476            if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5477                if (!uri.startsWith("intent:") && !androidApp) {
5478                    Intent intent = new Intent(ACTION_VIEW);
5479                    try {
5480                        intent.setData(Uri.parse(uri));
5481                    } catch (IllegalArgumentException e) {
5482                        throw new URISyntaxException(uri, e.getMessage());
5483                    }
5484                    return intent;
5485                }
5486            }
5487
5488            i = uri.lastIndexOf("#");
5489            // simple case
5490            if (i == -1) {
5491                if (!androidApp) {
5492                    return new Intent(ACTION_VIEW, Uri.parse(uri));
5493                }
5494
5495            // old format Intent URI
5496            } else if (!uri.startsWith("#Intent;", i)) {
5497                if (!androidApp) {
5498                    return getIntentOld(uri, flags);
5499                } else {
5500                    i = -1;
5501                }
5502            }
5503
5504            // new format
5505            Intent intent = new Intent(ACTION_VIEW);
5506            Intent baseIntent = intent;
5507            boolean explicitAction = false;
5508            boolean inSelector = false;
5509
5510            // fetch data part, if present
5511            String scheme = null;
5512            String data;
5513            if (i >= 0) {
5514                data = uri.substring(0, i);
5515                i += 8; // length of "#Intent;"
5516            } else {
5517                data = uri;
5518            }
5519
5520            // loop over contents of Intent, all name=value;
5521            while (i >= 0 && !uri.startsWith("end", i)) {
5522                int eq = uri.indexOf('=', i);
5523                if (eq < 0) eq = i-1;
5524                int semi = uri.indexOf(';', i);
5525                String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
5526
5527                // action
5528                if (uri.startsWith("action=", i)) {
5529                    intent.setAction(value);
5530                    if (!inSelector) {
5531                        explicitAction = true;
5532                    }
5533                }
5534
5535                // categories
5536                else if (uri.startsWith("category=", i)) {
5537                    intent.addCategory(value);
5538                }
5539
5540                // type
5541                else if (uri.startsWith("type=", i)) {
5542                    intent.mType = value;
5543                }
5544
5545                // launch flags
5546                else if (uri.startsWith("launchFlags=", i)) {
5547                    intent.mFlags = Integer.decode(value).intValue();
5548                    if ((flags& URI_ALLOW_UNSAFE) == 0) {
5549                        intent.mFlags &= ~IMMUTABLE_FLAGS;
5550                    }
5551                }
5552
5553                // package
5554                else if (uri.startsWith("package=", i)) {
5555                    intent.mPackage = value;
5556                }
5557
5558                // component
5559                else if (uri.startsWith("component=", i)) {
5560                    intent.mComponent = ComponentName.unflattenFromString(value);
5561                }
5562
5563                // scheme
5564                else if (uri.startsWith("scheme=", i)) {
5565                    if (inSelector) {
5566                        intent.mData = Uri.parse(value + ":");
5567                    } else {
5568                        scheme = value;
5569                    }
5570                }
5571
5572                // source bounds
5573                else if (uri.startsWith("sourceBounds=", i)) {
5574                    intent.mSourceBounds = Rect.unflattenFromString(value);
5575                }
5576
5577                // selector
5578                else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5579                    intent = new Intent();
5580                    inSelector = true;
5581                }
5582
5583                // extra
5584                else {
5585                    String key = Uri.decode(uri.substring(i + 2, eq));
5586                    // create Bundle if it doesn't already exist
5587                    if (intent.mExtras == null) intent.mExtras = new Bundle();
5588                    Bundle b = intent.mExtras;
5589                    // add EXTRA
5590                    if      (uri.startsWith("S.", i)) b.putString(key, value);
5591                    else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5592                    else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5593                    else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5594                    else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5595                    else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5596                    else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5597                    else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5598                    else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5599                    else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5600                }
5601
5602                // move to the next item
5603                i = semi + 1;
5604            }
5605
5606            if (inSelector) {
5607                // The Intent had a selector; fix it up.
5608                if (baseIntent.mPackage == null) {
5609                    baseIntent.setSelector(intent);
5610                }
5611                intent = baseIntent;
5612            }
5613
5614            if (data != null) {
5615                if (data.startsWith("intent:")) {
5616                    data = data.substring(7);
5617                    if (scheme != null) {
5618                        data = scheme + ':' + data;
5619                    }
5620                } else if (data.startsWith("android-app:")) {
5621                    if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5622                        // Correctly formed android-app, first part is package name.
5623                        int end = data.indexOf('/', 14);
5624                        if (end < 0) {
5625                            // All we have is a package name.
5626                            intent.mPackage = data.substring(14);
5627                            if (!explicitAction) {
5628                                intent.setAction(ACTION_MAIN);
5629                            }
5630                            data = "";
5631                        } else {
5632                            // Target the Intent at the given package name always.
5633                            String authority = null;
5634                            intent.mPackage = data.substring(14, end);
5635                            int newEnd;
5636                            if ((end+1) < data.length()) {
5637                                if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5638                                    // Found a scheme, remember it.
5639                                    scheme = data.substring(end+1, newEnd);
5640                                    end = newEnd;
5641                                    if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5642                                        // Found a authority, remember it.
5643                                        authority = data.substring(end+1, newEnd);
5644                                        end = newEnd;
5645                                    }
5646                                } else {
5647                                    // All we have is a scheme.
5648                                    scheme = data.substring(end+1);
5649                                }
5650                            }
5651                            if (scheme == null) {
5652                                // If there was no scheme, then this just targets the package.
5653                                if (!explicitAction) {
5654                                    intent.setAction(ACTION_MAIN);
5655                                }
5656                                data = "";
5657                            } else if (authority == null) {
5658                                data = scheme + ":";
5659                            } else {
5660                                data = scheme + "://" + authority + data.substring(end);
5661                            }
5662                        }
5663                    } else {
5664                        data = "";
5665                    }
5666                }
5667
5668                if (data.length() > 0) {
5669                    try {
5670                        intent.mData = Uri.parse(data);
5671                    } catch (IllegalArgumentException e) {
5672                        throw new URISyntaxException(uri, e.getMessage());
5673                    }
5674                }
5675            }
5676
5677            return intent;
5678
5679        } catch (IndexOutOfBoundsException e) {
5680            throw new URISyntaxException(uri, "illegal Intent URI format", i);
5681        }
5682    }
5683
5684    public static Intent getIntentOld(String uri) throws URISyntaxException {
5685        return getIntentOld(uri, 0);
5686    }
5687
5688    private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
5689        Intent intent;
5690
5691        int i = uri.lastIndexOf('#');
5692        if (i >= 0) {
5693            String action = null;
5694            final int intentFragmentStart = i;
5695            boolean isIntentFragment = false;
5696
5697            i++;
5698
5699            if (uri.regionMatches(i, "action(", 0, 7)) {
5700                isIntentFragment = true;
5701                i += 7;
5702                int j = uri.indexOf(')', i);
5703                action = uri.substring(i, j);
5704                i = j + 1;
5705            }
5706
5707            intent = new Intent(action);
5708
5709            if (uri.regionMatches(i, "categories(", 0, 11)) {
5710                isIntentFragment = true;
5711                i += 11;
5712                int j = uri.indexOf(')', i);
5713                while (i < j) {
5714                    int sep = uri.indexOf('!', i);
5715                    if (sep < 0 || sep > j) sep = j;
5716                    if (i < sep) {
5717                        intent.addCategory(uri.substring(i, sep));
5718                    }
5719                    i = sep + 1;
5720                }
5721                i = j + 1;
5722            }
5723
5724            if (uri.regionMatches(i, "type(", 0, 5)) {
5725                isIntentFragment = true;
5726                i += 5;
5727                int j = uri.indexOf(')', i);
5728                intent.mType = uri.substring(i, j);
5729                i = j + 1;
5730            }
5731
5732            if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
5733                isIntentFragment = true;
5734                i += 12;
5735                int j = uri.indexOf(')', i);
5736                intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
5737                if ((flags& URI_ALLOW_UNSAFE) == 0) {
5738                    intent.mFlags &= ~IMMUTABLE_FLAGS;
5739                }
5740                i = j + 1;
5741            }
5742
5743            if (uri.regionMatches(i, "component(", 0, 10)) {
5744                isIntentFragment = true;
5745                i += 10;
5746                int j = uri.indexOf(')', i);
5747                int sep = uri.indexOf('!', i);
5748                if (sep >= 0 && sep < j) {
5749                    String pkg = uri.substring(i, sep);
5750                    String cls = uri.substring(sep + 1, j);
5751                    intent.mComponent = new ComponentName(pkg, cls);
5752                }
5753                i = j + 1;
5754            }
5755
5756            if (uri.regionMatches(i, "extras(", 0, 7)) {
5757                isIntentFragment = true;
5758                i += 7;
5759
5760                final int closeParen = uri.indexOf(')', i);
5761                if (closeParen == -1) throw new URISyntaxException(uri,
5762                        "EXTRA missing trailing ')'", i);
5763
5764                while (i < closeParen) {
5765                    // fetch the key value
5766                    int j = uri.indexOf('=', i);
5767                    if (j <= i + 1 || i >= closeParen) {
5768                        throw new URISyntaxException(uri, "EXTRA missing '='", i);
5769                    }
5770                    char type = uri.charAt(i);
5771                    i++;
5772                    String key = uri.substring(i, j);
5773                    i = j + 1;
5774
5775                    // get type-value
5776                    j = uri.indexOf('!', i);
5777                    if (j == -1 || j >= closeParen) j = closeParen;
5778                    if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5779                    String value = uri.substring(i, j);
5780                    i = j;
5781
5782                    // create Bundle if it doesn't already exist
5783                    if (intent.mExtras == null) intent.mExtras = new Bundle();
5784
5785                    // add item to bundle
5786                    try {
5787                        switch (type) {
5788                            case 'S':
5789                                intent.mExtras.putString(key, Uri.decode(value));
5790                                break;
5791                            case 'B':
5792                                intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5793                                break;
5794                            case 'b':
5795                                intent.mExtras.putByte(key, Byte.parseByte(value));
5796                                break;
5797                            case 'c':
5798                                intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5799                                break;
5800                            case 'd':
5801                                intent.mExtras.putDouble(key, Double.parseDouble(value));
5802                                break;
5803                            case 'f':
5804                                intent.mExtras.putFloat(key, Float.parseFloat(value));
5805                                break;
5806                            case 'i':
5807                                intent.mExtras.putInt(key, Integer.parseInt(value));
5808                                break;
5809                            case 'l':
5810                                intent.mExtras.putLong(key, Long.parseLong(value));
5811                                break;
5812                            case 's':
5813                                intent.mExtras.putShort(key, Short.parseShort(value));
5814                                break;
5815                            default:
5816                                throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5817                        }
5818                    } catch (NumberFormatException e) {
5819                        throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5820                    }
5821
5822                    char ch = uri.charAt(i);
5823                    if (ch == ')') break;
5824                    if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5825                    i++;
5826                }
5827            }
5828
5829            if (isIntentFragment) {
5830                intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5831            } else {
5832                intent.mData = Uri.parse(uri);
5833            }
5834
5835            if (intent.mAction == null) {
5836                // By default, if no action is specified, then use VIEW.
5837                intent.mAction = ACTION_VIEW;
5838            }
5839
5840        } else {
5841            intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5842        }
5843
5844        return intent;
5845    }
5846
5847    /** @hide */
5848    public interface CommandOptionHandler {
5849        boolean handleOption(String opt, ShellCommand cmd);
5850    }
5851
5852    /** @hide */
5853    public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5854            throws URISyntaxException {
5855        Intent intent = new Intent();
5856        Intent baseIntent = intent;
5857        boolean hasIntentInfo = false;
5858
5859        Uri data = null;
5860        String type = null;
5861
5862        String opt;
5863        while ((opt=cmd.getNextOption()) != null) {
5864            switch (opt) {
5865                case "-a":
5866                    intent.setAction(cmd.getNextArgRequired());
5867                    if (intent == baseIntent) {
5868                        hasIntentInfo = true;
5869                    }
5870                    break;
5871                case "-d":
5872                    data = Uri.parse(cmd.getNextArgRequired());
5873                    if (intent == baseIntent) {
5874                        hasIntentInfo = true;
5875                    }
5876                    break;
5877                case "-t":
5878                    type = cmd.getNextArgRequired();
5879                    if (intent == baseIntent) {
5880                        hasIntentInfo = true;
5881                    }
5882                    break;
5883                case "-c":
5884                    intent.addCategory(cmd.getNextArgRequired());
5885                    if (intent == baseIntent) {
5886                        hasIntentInfo = true;
5887                    }
5888                    break;
5889                case "-e":
5890                case "--es": {
5891                    String key = cmd.getNextArgRequired();
5892                    String value = cmd.getNextArgRequired();
5893                    intent.putExtra(key, value);
5894                }
5895                break;
5896                case "--esn": {
5897                    String key = cmd.getNextArgRequired();
5898                    intent.putExtra(key, (String) null);
5899                }
5900                break;
5901                case "--ei": {
5902                    String key = cmd.getNextArgRequired();
5903                    String value = cmd.getNextArgRequired();
5904                    intent.putExtra(key, Integer.decode(value));
5905                }
5906                break;
5907                case "--eu": {
5908                    String key = cmd.getNextArgRequired();
5909                    String value = cmd.getNextArgRequired();
5910                    intent.putExtra(key, Uri.parse(value));
5911                }
5912                break;
5913                case "--ecn": {
5914                    String key = cmd.getNextArgRequired();
5915                    String value = cmd.getNextArgRequired();
5916                    ComponentName cn = ComponentName.unflattenFromString(value);
5917                    if (cn == null)
5918                        throw new IllegalArgumentException("Bad component name: " + value);
5919                    intent.putExtra(key, cn);
5920                }
5921                break;
5922                case "--eia": {
5923                    String key = cmd.getNextArgRequired();
5924                    String value = cmd.getNextArgRequired();
5925                    String[] strings = value.split(",");
5926                    int[] list = new int[strings.length];
5927                    for (int i = 0; i < strings.length; i++) {
5928                        list[i] = Integer.decode(strings[i]);
5929                    }
5930                    intent.putExtra(key, list);
5931                }
5932                break;
5933                case "--eial": {
5934                    String key = cmd.getNextArgRequired();
5935                    String value = cmd.getNextArgRequired();
5936                    String[] strings = value.split(",");
5937                    ArrayList<Integer> list = new ArrayList<>(strings.length);
5938                    for (int i = 0; i < strings.length; i++) {
5939                        list.add(Integer.decode(strings[i]));
5940                    }
5941                    intent.putExtra(key, list);
5942                }
5943                break;
5944                case "--el": {
5945                    String key = cmd.getNextArgRequired();
5946                    String value = cmd.getNextArgRequired();
5947                    intent.putExtra(key, Long.valueOf(value));
5948                }
5949                break;
5950                case "--ela": {
5951                    String key = cmd.getNextArgRequired();
5952                    String value = cmd.getNextArgRequired();
5953                    String[] strings = value.split(",");
5954                    long[] list = new long[strings.length];
5955                    for (int i = 0; i < strings.length; i++) {
5956                        list[i] = Long.valueOf(strings[i]);
5957                    }
5958                    intent.putExtra(key, list);
5959                    hasIntentInfo = true;
5960                }
5961                break;
5962                case "--elal": {
5963                    String key = cmd.getNextArgRequired();
5964                    String value = cmd.getNextArgRequired();
5965                    String[] strings = value.split(",");
5966                    ArrayList<Long> list = new ArrayList<>(strings.length);
5967                    for (int i = 0; i < strings.length; i++) {
5968                        list.add(Long.valueOf(strings[i]));
5969                    }
5970                    intent.putExtra(key, list);
5971                    hasIntentInfo = true;
5972                }
5973                break;
5974                case "--ef": {
5975                    String key = cmd.getNextArgRequired();
5976                    String value = cmd.getNextArgRequired();
5977                    intent.putExtra(key, Float.valueOf(value));
5978                    hasIntentInfo = true;
5979                }
5980                break;
5981                case "--efa": {
5982                    String key = cmd.getNextArgRequired();
5983                    String value = cmd.getNextArgRequired();
5984                    String[] strings = value.split(",");
5985                    float[] list = new float[strings.length];
5986                    for (int i = 0; i < strings.length; i++) {
5987                        list[i] = Float.valueOf(strings[i]);
5988                    }
5989                    intent.putExtra(key, list);
5990                    hasIntentInfo = true;
5991                }
5992                break;
5993                case "--efal": {
5994                    String key = cmd.getNextArgRequired();
5995                    String value = cmd.getNextArgRequired();
5996                    String[] strings = value.split(",");
5997                    ArrayList<Float> list = new ArrayList<>(strings.length);
5998                    for (int i = 0; i < strings.length; i++) {
5999                        list.add(Float.valueOf(strings[i]));
6000                    }
6001                    intent.putExtra(key, list);
6002                    hasIntentInfo = true;
6003                }
6004                break;
6005                case "--esa": {
6006                    String key = cmd.getNextArgRequired();
6007                    String value = cmd.getNextArgRequired();
6008                    // Split on commas unless they are preceeded by an escape.
6009                    // The escape character must be escaped for the string and
6010                    // again for the regex, thus four escape characters become one.
6011                    String[] strings = value.split("(?<!\\\\),");
6012                    intent.putExtra(key, strings);
6013                    hasIntentInfo = true;
6014                }
6015                break;
6016                case "--esal": {
6017                    String key = cmd.getNextArgRequired();
6018                    String value = cmd.getNextArgRequired();
6019                    // Split on commas unless they are preceeded by an escape.
6020                    // The escape character must be escaped for the string and
6021                    // again for the regex, thus four escape characters become one.
6022                    String[] strings = value.split("(?<!\\\\),");
6023                    ArrayList<String> list = new ArrayList<>(strings.length);
6024                    for (int i = 0; i < strings.length; i++) {
6025                        list.add(strings[i]);
6026                    }
6027                    intent.putExtra(key, list);
6028                    hasIntentInfo = true;
6029                }
6030                break;
6031                case "--ez": {
6032                    String key = cmd.getNextArgRequired();
6033                    String value = cmd.getNextArgRequired().toLowerCase();
6034                    // Boolean.valueOf() results in false for anything that is not "true", which is
6035                    // error-prone in shell commands
6036                    boolean arg;
6037                    if ("true".equals(value) || "t".equals(value)) {
6038                        arg = true;
6039                    } else if ("false".equals(value) || "f".equals(value)) {
6040                        arg = false;
6041                    } else {
6042                        try {
6043                            arg = Integer.decode(value) != 0;
6044                        } catch (NumberFormatException ex) {
6045                            throw new IllegalArgumentException("Invalid boolean value: " + value);
6046                        }
6047                    }
6048
6049                    intent.putExtra(key, arg);
6050                }
6051                break;
6052                case "-n": {
6053                    String str = cmd.getNextArgRequired();
6054                    ComponentName cn = ComponentName.unflattenFromString(str);
6055                    if (cn == null)
6056                        throw new IllegalArgumentException("Bad component name: " + str);
6057                    intent.setComponent(cn);
6058                    if (intent == baseIntent) {
6059                        hasIntentInfo = true;
6060                    }
6061                }
6062                break;
6063                case "-p": {
6064                    String str = cmd.getNextArgRequired();
6065                    intent.setPackage(str);
6066                    if (intent == baseIntent) {
6067                        hasIntentInfo = true;
6068                    }
6069                }
6070                break;
6071                case "-f":
6072                    String str = cmd.getNextArgRequired();
6073                    intent.setFlags(Integer.decode(str).intValue());
6074                    break;
6075                case "--grant-read-uri-permission":
6076                    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6077                    break;
6078                case "--grant-write-uri-permission":
6079                    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6080                    break;
6081                case "--grant-persistable-uri-permission":
6082                    intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6083                    break;
6084                case "--grant-prefix-uri-permission":
6085                    intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6086                    break;
6087                case "--exclude-stopped-packages":
6088                    intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6089                    break;
6090                case "--include-stopped-packages":
6091                    intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6092                    break;
6093                case "--debug-log-resolution":
6094                    intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6095                    break;
6096                case "--activity-brought-to-front":
6097                    intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6098                    break;
6099                case "--activity-clear-top":
6100                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6101                    break;
6102                case "--activity-clear-when-task-reset":
6103                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6104                    break;
6105                case "--activity-exclude-from-recents":
6106                    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6107                    break;
6108                case "--activity-launched-from-history":
6109                    intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6110                    break;
6111                case "--activity-multiple-task":
6112                    intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6113                    break;
6114                case "--activity-no-animation":
6115                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6116                    break;
6117                case "--activity-no-history":
6118                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6119                    break;
6120                case "--activity-no-user-action":
6121                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6122                    break;
6123                case "--activity-previous-is-top":
6124                    intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6125                    break;
6126                case "--activity-reorder-to-front":
6127                    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6128                    break;
6129                case "--activity-reset-task-if-needed":
6130                    intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6131                    break;
6132                case "--activity-single-top":
6133                    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6134                    break;
6135                case "--activity-clear-task":
6136                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6137                    break;
6138                case "--activity-task-on-home":
6139                    intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6140                    break;
6141                case "--receiver-registered-only":
6142                    intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6143                    break;
6144                case "--receiver-replace-pending":
6145                    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6146                    break;
6147                case "--receiver-foreground":
6148                    intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6149                    break;
6150                case "--receiver-no-abort":
6151                    intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6152                    break;
6153                case "--receiver-include-background":
6154                    intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6155                    break;
6156                case "--selector":
6157                    intent.setDataAndType(data, type);
6158                    intent = new Intent();
6159                    break;
6160                default:
6161                    if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6162                        // Okay, caller handled this option.
6163                    } else {
6164                        throw new IllegalArgumentException("Unknown option: " + opt);
6165                    }
6166                    break;
6167            }
6168        }
6169        intent.setDataAndType(data, type);
6170
6171        final boolean hasSelector = intent != baseIntent;
6172        if (hasSelector) {
6173            // A selector was specified; fix up.
6174            baseIntent.setSelector(intent);
6175            intent = baseIntent;
6176        }
6177
6178        String arg = cmd.getNextArg();
6179        baseIntent = null;
6180        if (arg == null) {
6181            if (hasSelector) {
6182                // If a selector has been specified, and no arguments
6183                // have been supplied for the main Intent, then we can
6184                // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6185                // need to have a component name specified yet, the
6186                // selector will take care of that.
6187                baseIntent = new Intent(Intent.ACTION_MAIN);
6188                baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6189            }
6190        } else if (arg.indexOf(':') >= 0) {
6191            // The argument is a URI.  Fully parse it, and use that result
6192            // to fill in any data not specified so far.
6193            baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6194                    | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6195        } else if (arg.indexOf('/') >= 0) {
6196            // The argument is a component name.  Build an Intent to launch
6197            // it.
6198            baseIntent = new Intent(Intent.ACTION_MAIN);
6199            baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6200            baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6201        } else {
6202            // Assume the argument is a package name.
6203            baseIntent = new Intent(Intent.ACTION_MAIN);
6204            baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6205            baseIntent.setPackage(arg);
6206        }
6207        if (baseIntent != null) {
6208            Bundle extras = intent.getExtras();
6209            intent.replaceExtras((Bundle)null);
6210            Bundle uriExtras = baseIntent.getExtras();
6211            baseIntent.replaceExtras((Bundle)null);
6212            if (intent.getAction() != null && baseIntent.getCategories() != null) {
6213                HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6214                for (String c : cats) {
6215                    baseIntent.removeCategory(c);
6216                }
6217            }
6218            intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6219            if (extras == null) {
6220                extras = uriExtras;
6221            } else if (uriExtras != null) {
6222                uriExtras.putAll(extras);
6223                extras = uriExtras;
6224            }
6225            intent.replaceExtras(extras);
6226            hasIntentInfo = true;
6227        }
6228
6229        if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6230        return intent;
6231    }
6232
6233    /** @hide */
6234    public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6235        final String[] lines = new String[] {
6236                "<INTENT> specifications include these flags and arguments:",
6237                "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6238                "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
6239                "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6240                "    [--esn <EXTRA_KEY> ...]",
6241                "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6242                "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6243                "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6244                "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6245                "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6246                "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6247                "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6248                "        (mutiple extras passed as Integer[])",
6249                "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6250                "        (mutiple extras passed as List<Integer>)",
6251                "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6252                "        (mutiple extras passed as Long[])",
6253                "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6254                "        (mutiple extras passed as List<Long>)",
6255                "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6256                "        (mutiple extras passed as Float[])",
6257                "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6258                "        (mutiple extras passed as List<Float>)",
6259                "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6260                "        (mutiple extras passed as String[]; to embed a comma into a string,",
6261                "         escape it using \"\\,\")",
6262                "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6263                "        (mutiple extras passed as List<String>; to embed a comma into a string,",
6264                "         escape it using \"\\,\")",
6265                "    [-f <FLAG>]",
6266                "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
6267                "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6268                "    [--debug-log-resolution] [--exclude-stopped-packages]",
6269                "    [--include-stopped-packages]",
6270                "    [--activity-brought-to-front] [--activity-clear-top]",
6271                "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6272                "    [--activity-launched-from-history] [--activity-multiple-task]",
6273                "    [--activity-no-animation] [--activity-no-history]",
6274                "    [--activity-no-user-action] [--activity-previous-is-top]",
6275                "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6276                "    [--activity-single-top] [--activity-clear-task]",
6277                "    [--activity-task-on-home]",
6278                "    [--receiver-registered-only] [--receiver-replace-pending]",
6279                "    [--receiver-foreground] [--receiver-no-abort]",
6280                "    [--receiver-include-background]",
6281                "    [--selector]",
6282                "    [<URI> | <PACKAGE> | <COMPONENT>]"
6283        };
6284        for (String line : lines) {
6285            pw.print(prefix);
6286            pw.println(line);
6287        }
6288    }
6289
6290    /**
6291     * Retrieve the general action to be performed, such as
6292     * {@link #ACTION_VIEW}.  The action describes the general way the rest of
6293     * the information in the intent should be interpreted -- most importantly,
6294     * what to do with the data returned by {@link #getData}.
6295     *
6296     * @return The action of this intent or null if none is specified.
6297     *
6298     * @see #setAction
6299     */
6300    public String getAction() {
6301        return mAction;
6302    }
6303
6304    /**
6305     * Retrieve data this intent is operating on.  This URI specifies the name
6306     * of the data; often it uses the content: scheme, specifying data in a
6307     * content provider.  Other schemes may be handled by specific activities,
6308     * such as http: by the web browser.
6309     *
6310     * @return The URI of the data this intent is targeting or null.
6311     *
6312     * @see #getScheme
6313     * @see #setData
6314     */
6315    public Uri getData() {
6316        return mData;
6317    }
6318
6319    /**
6320     * The same as {@link #getData()}, but returns the URI as an encoded
6321     * String.
6322     */
6323    public String getDataString() {
6324        return mData != null ? mData.toString() : null;
6325    }
6326
6327    /**
6328     * Return the scheme portion of the intent's data.  If the data is null or
6329     * does not include a scheme, null is returned.  Otherwise, the scheme
6330     * prefix without the final ':' is returned, i.e. "http".
6331     *
6332     * <p>This is the same as calling getData().getScheme() (and checking for
6333     * null data).
6334     *
6335     * @return The scheme of this intent.
6336     *
6337     * @see #getData
6338     */
6339    public String getScheme() {
6340        return mData != null ? mData.getScheme() : null;
6341    }
6342
6343    /**
6344     * Retrieve any explicit MIME type included in the intent.  This is usually
6345     * null, as the type is determined by the intent data.
6346     *
6347     * @return If a type was manually set, it is returned; else null is
6348     *         returned.
6349     *
6350     * @see #resolveType(ContentResolver)
6351     * @see #setType
6352     */
6353    public String getType() {
6354        return mType;
6355    }
6356
6357    /**
6358     * Return the MIME data type of this intent.  If the type field is
6359     * explicitly set, that is simply returned.  Otherwise, if the data is set,
6360     * the type of that data is returned.  If neither fields are set, a null is
6361     * returned.
6362     *
6363     * @return The MIME type of this intent.
6364     *
6365     * @see #getType
6366     * @see #resolveType(ContentResolver)
6367     */
6368    public String resolveType(Context context) {
6369        return resolveType(context.getContentResolver());
6370    }
6371
6372    /**
6373     * Return the MIME data type of this intent.  If the type field is
6374     * explicitly set, that is simply returned.  Otherwise, if the data is set,
6375     * the type of that data is returned.  If neither fields are set, a null is
6376     * returned.
6377     *
6378     * @param resolver A ContentResolver that can be used to determine the MIME
6379     *                 type of the intent's data.
6380     *
6381     * @return The MIME type of this intent.
6382     *
6383     * @see #getType
6384     * @see #resolveType(Context)
6385     */
6386    public String resolveType(ContentResolver resolver) {
6387        if (mType != null) {
6388            return mType;
6389        }
6390        if (mData != null) {
6391            if ("content".equals(mData.getScheme())) {
6392                return resolver.getType(mData);
6393            }
6394        }
6395        return null;
6396    }
6397
6398    /**
6399     * Return the MIME data type of this intent, only if it will be needed for
6400     * intent resolution.  This is not generally useful for application code;
6401     * it is used by the frameworks for communicating with back-end system
6402     * services.
6403     *
6404     * @param resolver A ContentResolver that can be used to determine the MIME
6405     *                 type of the intent's data.
6406     *
6407     * @return The MIME type of this intent, or null if it is unknown or not
6408     *         needed.
6409     */
6410    public String resolveTypeIfNeeded(ContentResolver resolver) {
6411        if (mComponent != null) {
6412            return mType;
6413        }
6414        return resolveType(resolver);
6415    }
6416
6417    /**
6418     * Check if a category exists in the intent.
6419     *
6420     * @param category The category to check.
6421     *
6422     * @return boolean True if the intent contains the category, else false.
6423     *
6424     * @see #getCategories
6425     * @see #addCategory
6426     */
6427    public boolean hasCategory(String category) {
6428        return mCategories != null && mCategories.contains(category);
6429    }
6430
6431    /**
6432     * Return the set of all categories in the intent.  If there are no categories,
6433     * returns NULL.
6434     *
6435     * @return The set of categories you can examine.  Do not modify!
6436     *
6437     * @see #hasCategory
6438     * @see #addCategory
6439     */
6440    public Set<String> getCategories() {
6441        return mCategories;
6442    }
6443
6444    /**
6445     * Return the specific selector associated with this Intent.  If there is
6446     * none, returns null.  See {@link #setSelector} for more information.
6447     *
6448     * @see #setSelector
6449     */
6450    public Intent getSelector() {
6451        return mSelector;
6452    }
6453
6454    /**
6455     * Return the {@link ClipData} associated with this Intent.  If there is
6456     * none, returns null.  See {@link #setClipData} for more information.
6457     *
6458     * @see #setClipData
6459     */
6460    public ClipData getClipData() {
6461        return mClipData;
6462    }
6463
6464    /** @hide */
6465    public int getContentUserHint() {
6466        return mContentUserHint;
6467    }
6468
6469    /** @hide */
6470    public String getLaunchToken() {
6471        return mLaunchToken;
6472    }
6473
6474    /** @hide */
6475    public void setLaunchToken(String launchToken) {
6476        mLaunchToken = launchToken;
6477    }
6478
6479    /**
6480     * Sets the ClassLoader that will be used when unmarshalling
6481     * any Parcelable values from the extras of this Intent.
6482     *
6483     * @param loader a ClassLoader, or null to use the default loader
6484     * at the time of unmarshalling.
6485     */
6486    public void setExtrasClassLoader(ClassLoader loader) {
6487        if (mExtras != null) {
6488            mExtras.setClassLoader(loader);
6489        }
6490    }
6491
6492    /**
6493     * Returns true if an extra value is associated with the given name.
6494     * @param name the extra's name
6495     * @return true if the given extra is present.
6496     */
6497    public boolean hasExtra(String name) {
6498        return mExtras != null && mExtras.containsKey(name);
6499    }
6500
6501    /**
6502     * Returns true if the Intent's extras contain a parcelled file descriptor.
6503     * @return true if the Intent contains a parcelled file descriptor.
6504     */
6505    public boolean hasFileDescriptors() {
6506        return mExtras != null && mExtras.hasFileDescriptors();
6507    }
6508
6509    /** {@hide} */
6510    public void setAllowFds(boolean allowFds) {
6511        if (mExtras != null) {
6512            mExtras.setAllowFds(allowFds);
6513        }
6514    }
6515
6516    /** {@hide} */
6517    public void setDefusable(boolean defusable) {
6518        if (mExtras != null) {
6519            mExtras.setDefusable(defusable);
6520        }
6521    }
6522
6523    /**
6524     * Retrieve extended data from the intent.
6525     *
6526     * @param name The name of the desired item.
6527     *
6528     * @return the value of an item that previously added with putExtra()
6529     * or null if none was found.
6530     *
6531     * @deprecated
6532     * @hide
6533     */
6534    @Deprecated
6535    public Object getExtra(String name) {
6536        return getExtra(name, null);
6537    }
6538
6539    /**
6540     * Retrieve extended data from the intent.
6541     *
6542     * @param name The name of the desired item.
6543     * @param defaultValue the value to be returned if no value of the desired
6544     * type is stored with the given name.
6545     *
6546     * @return the value of an item that previously added with putExtra()
6547     * or the default value if none was found.
6548     *
6549     * @see #putExtra(String, boolean)
6550     */
6551    public boolean getBooleanExtra(String name, boolean defaultValue) {
6552        return mExtras == null ? defaultValue :
6553            mExtras.getBoolean(name, defaultValue);
6554    }
6555
6556    /**
6557     * Retrieve extended data from the intent.
6558     *
6559     * @param name The name of the desired item.
6560     * @param defaultValue the value to be returned if no value of the desired
6561     * type is stored with the given name.
6562     *
6563     * @return the value of an item that previously added with putExtra()
6564     * or the default value if none was found.
6565     *
6566     * @see #putExtra(String, byte)
6567     */
6568    public byte getByteExtra(String name, byte defaultValue) {
6569        return mExtras == null ? defaultValue :
6570            mExtras.getByte(name, defaultValue);
6571    }
6572
6573    /**
6574     * Retrieve extended data from the intent.
6575     *
6576     * @param name The name of the desired item.
6577     * @param defaultValue the value to be returned if no value of the desired
6578     * type is stored with the given name.
6579     *
6580     * @return the value of an item that previously added with putExtra()
6581     * or the default value if none was found.
6582     *
6583     * @see #putExtra(String, short)
6584     */
6585    public short getShortExtra(String name, short defaultValue) {
6586        return mExtras == null ? defaultValue :
6587            mExtras.getShort(name, defaultValue);
6588    }
6589
6590    /**
6591     * Retrieve extended data from the intent.
6592     *
6593     * @param name The name of the desired item.
6594     * @param defaultValue the value to be returned if no value of the desired
6595     * type is stored with the given name.
6596     *
6597     * @return the value of an item that previously added with putExtra()
6598     * or the default value if none was found.
6599     *
6600     * @see #putExtra(String, char)
6601     */
6602    public char getCharExtra(String name, char defaultValue) {
6603        return mExtras == null ? defaultValue :
6604            mExtras.getChar(name, defaultValue);
6605    }
6606
6607    /**
6608     * Retrieve extended data from the intent.
6609     *
6610     * @param name The name of the desired item.
6611     * @param defaultValue the value to be returned if no value of the desired
6612     * type is stored with the given name.
6613     *
6614     * @return the value of an item that previously added with putExtra()
6615     * or the default value if none was found.
6616     *
6617     * @see #putExtra(String, int)
6618     */
6619    public int getIntExtra(String name, int defaultValue) {
6620        return mExtras == null ? defaultValue :
6621            mExtras.getInt(name, defaultValue);
6622    }
6623
6624    /**
6625     * Retrieve extended data from the intent.
6626     *
6627     * @param name The name of the desired item.
6628     * @param defaultValue the value to be returned if no value of the desired
6629     * type is stored with the given name.
6630     *
6631     * @return the value of an item that previously added with putExtra()
6632     * or the default value if none was found.
6633     *
6634     * @see #putExtra(String, long)
6635     */
6636    public long getLongExtra(String name, long defaultValue) {
6637        return mExtras == null ? defaultValue :
6638            mExtras.getLong(name, defaultValue);
6639    }
6640
6641    /**
6642     * Retrieve extended data from the intent.
6643     *
6644     * @param name The name of the desired item.
6645     * @param defaultValue the value to be returned if no value of the desired
6646     * type is stored with the given name.
6647     *
6648     * @return the value of an item that previously added with putExtra(),
6649     * or the default value if no such item is present
6650     *
6651     * @see #putExtra(String, float)
6652     */
6653    public float getFloatExtra(String name, float defaultValue) {
6654        return mExtras == null ? defaultValue :
6655            mExtras.getFloat(name, defaultValue);
6656    }
6657
6658    /**
6659     * Retrieve extended data from the intent.
6660     *
6661     * @param name The name of the desired item.
6662     * @param defaultValue the value to be returned if no value of the desired
6663     * type is stored with the given name.
6664     *
6665     * @return the value of an item that previously added with putExtra()
6666     * or the default value if none was found.
6667     *
6668     * @see #putExtra(String, double)
6669     */
6670    public double getDoubleExtra(String name, double defaultValue) {
6671        return mExtras == null ? defaultValue :
6672            mExtras.getDouble(name, defaultValue);
6673    }
6674
6675    /**
6676     * Retrieve extended data from the intent.
6677     *
6678     * @param name The name of the desired item.
6679     *
6680     * @return the value of an item that previously added with putExtra()
6681     * or null if no String value was found.
6682     *
6683     * @see #putExtra(String, String)
6684     */
6685    public String getStringExtra(String name) {
6686        return mExtras == null ? null : mExtras.getString(name);
6687    }
6688
6689    /**
6690     * Retrieve extended data from the intent.
6691     *
6692     * @param name The name of the desired item.
6693     *
6694     * @return the value of an item that previously added with putExtra()
6695     * or null if no CharSequence value was found.
6696     *
6697     * @see #putExtra(String, CharSequence)
6698     */
6699    public CharSequence getCharSequenceExtra(String name) {
6700        return mExtras == null ? null : mExtras.getCharSequence(name);
6701    }
6702
6703    /**
6704     * Retrieve extended data from the intent.
6705     *
6706     * @param name The name of the desired item.
6707     *
6708     * @return the value of an item that previously added with putExtra()
6709     * or null if no Parcelable value was found.
6710     *
6711     * @see #putExtra(String, Parcelable)
6712     */
6713    public <T extends Parcelable> T getParcelableExtra(String name) {
6714        return mExtras == null ? null : mExtras.<T>getParcelable(name);
6715    }
6716
6717    /**
6718     * Retrieve extended data from the intent.
6719     *
6720     * @param name The name of the desired item.
6721     *
6722     * @return the value of an item that previously added with putExtra()
6723     * or null if no Parcelable[] value was found.
6724     *
6725     * @see #putExtra(String, Parcelable[])
6726     */
6727    public Parcelable[] getParcelableArrayExtra(String name) {
6728        return mExtras == null ? null : mExtras.getParcelableArray(name);
6729    }
6730
6731    /**
6732     * Retrieve extended data from the intent.
6733     *
6734     * @param name The name of the desired item.
6735     *
6736     * @return the value of an item that previously added with putExtra()
6737     * or null if no ArrayList<Parcelable> value was found.
6738     *
6739     * @see #putParcelableArrayListExtra(String, ArrayList)
6740     */
6741    public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6742        return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6743    }
6744
6745    /**
6746     * Retrieve extended data from the intent.
6747     *
6748     * @param name The name of the desired item.
6749     *
6750     * @return the value of an item that previously added with putExtra()
6751     * or null if no Serializable value was found.
6752     *
6753     * @see #putExtra(String, Serializable)
6754     */
6755    public Serializable getSerializableExtra(String name) {
6756        return mExtras == null ? null : mExtras.getSerializable(name);
6757    }
6758
6759    /**
6760     * Retrieve extended data from the intent.
6761     *
6762     * @param name The name of the desired item.
6763     *
6764     * @return the value of an item that previously added with putExtra()
6765     * or null if no ArrayList<Integer> value was found.
6766     *
6767     * @see #putIntegerArrayListExtra(String, ArrayList)
6768     */
6769    public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6770        return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6771    }
6772
6773    /**
6774     * Retrieve extended data from the intent.
6775     *
6776     * @param name The name of the desired item.
6777     *
6778     * @return the value of an item that previously added with putExtra()
6779     * or null if no ArrayList<String> value was found.
6780     *
6781     * @see #putStringArrayListExtra(String, ArrayList)
6782     */
6783    public ArrayList<String> getStringArrayListExtra(String name) {
6784        return mExtras == null ? null : mExtras.getStringArrayList(name);
6785    }
6786
6787    /**
6788     * Retrieve extended data from the intent.
6789     *
6790     * @param name The name of the desired item.
6791     *
6792     * @return the value of an item that previously added with putExtra()
6793     * or null if no ArrayList<CharSequence> value was found.
6794     *
6795     * @see #putCharSequenceArrayListExtra(String, ArrayList)
6796     */
6797    public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6798        return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6799    }
6800
6801    /**
6802     * Retrieve extended data from the intent.
6803     *
6804     * @param name The name of the desired item.
6805     *
6806     * @return the value of an item that previously added with putExtra()
6807     * or null if no boolean array value was found.
6808     *
6809     * @see #putExtra(String, boolean[])
6810     */
6811    public boolean[] getBooleanArrayExtra(String name) {
6812        return mExtras == null ? null : mExtras.getBooleanArray(name);
6813    }
6814
6815    /**
6816     * Retrieve extended data from the intent.
6817     *
6818     * @param name The name of the desired item.
6819     *
6820     * @return the value of an item that previously added with putExtra()
6821     * or null if no byte array value was found.
6822     *
6823     * @see #putExtra(String, byte[])
6824     */
6825    public byte[] getByteArrayExtra(String name) {
6826        return mExtras == null ? null : mExtras.getByteArray(name);
6827    }
6828
6829    /**
6830     * Retrieve extended data from the intent.
6831     *
6832     * @param name The name of the desired item.
6833     *
6834     * @return the value of an item that previously added with putExtra()
6835     * or null if no short array value was found.
6836     *
6837     * @see #putExtra(String, short[])
6838     */
6839    public short[] getShortArrayExtra(String name) {
6840        return mExtras == null ? null : mExtras.getShortArray(name);
6841    }
6842
6843    /**
6844     * Retrieve extended data from the intent.
6845     *
6846     * @param name The name of the desired item.
6847     *
6848     * @return the value of an item that previously added with putExtra()
6849     * or null if no char array value was found.
6850     *
6851     * @see #putExtra(String, char[])
6852     */
6853    public char[] getCharArrayExtra(String name) {
6854        return mExtras == null ? null : mExtras.getCharArray(name);
6855    }
6856
6857    /**
6858     * Retrieve extended data from the intent.
6859     *
6860     * @param name The name of the desired item.
6861     *
6862     * @return the value of an item that previously added with putExtra()
6863     * or null if no int array value was found.
6864     *
6865     * @see #putExtra(String, int[])
6866     */
6867    public int[] getIntArrayExtra(String name) {
6868        return mExtras == null ? null : mExtras.getIntArray(name);
6869    }
6870
6871    /**
6872     * Retrieve extended data from the intent.
6873     *
6874     * @param name The name of the desired item.
6875     *
6876     * @return the value of an item that previously added with putExtra()
6877     * or null if no long array value was found.
6878     *
6879     * @see #putExtra(String, long[])
6880     */
6881    public long[] getLongArrayExtra(String name) {
6882        return mExtras == null ? null : mExtras.getLongArray(name);
6883    }
6884
6885    /**
6886     * Retrieve extended data from the intent.
6887     *
6888     * @param name The name of the desired item.
6889     *
6890     * @return the value of an item that previously added with putExtra()
6891     * or null if no float array value was found.
6892     *
6893     * @see #putExtra(String, float[])
6894     */
6895    public float[] getFloatArrayExtra(String name) {
6896        return mExtras == null ? null : mExtras.getFloatArray(name);
6897    }
6898
6899    /**
6900     * Retrieve extended data from the intent.
6901     *
6902     * @param name The name of the desired item.
6903     *
6904     * @return the value of an item that previously added with putExtra()
6905     * or null if no double array value was found.
6906     *
6907     * @see #putExtra(String, double[])
6908     */
6909    public double[] getDoubleArrayExtra(String name) {
6910        return mExtras == null ? null : mExtras.getDoubleArray(name);
6911    }
6912
6913    /**
6914     * Retrieve extended data from the intent.
6915     *
6916     * @param name The name of the desired item.
6917     *
6918     * @return the value of an item that previously added with putExtra()
6919     * or null if no String array value was found.
6920     *
6921     * @see #putExtra(String, String[])
6922     */
6923    public String[] getStringArrayExtra(String name) {
6924        return mExtras == null ? null : mExtras.getStringArray(name);
6925    }
6926
6927    /**
6928     * Retrieve extended data from the intent.
6929     *
6930     * @param name The name of the desired item.
6931     *
6932     * @return the value of an item that previously added with putExtra()
6933     * or null if no CharSequence array value was found.
6934     *
6935     * @see #putExtra(String, CharSequence[])
6936     */
6937    public CharSequence[] getCharSequenceArrayExtra(String name) {
6938        return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6939    }
6940
6941    /**
6942     * Retrieve extended data from the intent.
6943     *
6944     * @param name The name of the desired item.
6945     *
6946     * @return the value of an item that previously added with putExtra()
6947     * or null if no Bundle value was found.
6948     *
6949     * @see #putExtra(String, Bundle)
6950     */
6951    public Bundle getBundleExtra(String name) {
6952        return mExtras == null ? null : mExtras.getBundle(name);
6953    }
6954
6955    /**
6956     * Retrieve extended data from the intent.
6957     *
6958     * @param name The name of the desired item.
6959     *
6960     * @return the value of an item that previously added with putExtra()
6961     * or null if no IBinder value was found.
6962     *
6963     * @see #putExtra(String, IBinder)
6964     *
6965     * @deprecated
6966     * @hide
6967     */
6968    @Deprecated
6969    public IBinder getIBinderExtra(String name) {
6970        return mExtras == null ? null : mExtras.getIBinder(name);
6971    }
6972
6973    /**
6974     * Retrieve extended data from the intent.
6975     *
6976     * @param name The name of the desired item.
6977     * @param defaultValue The default value to return in case no item is
6978     * associated with the key 'name'
6979     *
6980     * @return the value of an item that previously added with putExtra()
6981     * or defaultValue if none was found.
6982     *
6983     * @see #putExtra
6984     *
6985     * @deprecated
6986     * @hide
6987     */
6988    @Deprecated
6989    public Object getExtra(String name, Object defaultValue) {
6990        Object result = defaultValue;
6991        if (mExtras != null) {
6992            Object result2 = mExtras.get(name);
6993            if (result2 != null) {
6994                result = result2;
6995            }
6996        }
6997
6998        return result;
6999    }
7000
7001    /**
7002     * Retrieves a map of extended data from the intent.
7003     *
7004     * @return the map of all extras previously added with putExtra(),
7005     * or null if none have been added.
7006     */
7007    public Bundle getExtras() {
7008        return (mExtras != null)
7009                ? new Bundle(mExtras)
7010                : null;
7011    }
7012
7013    /**
7014     * Filter extras to only basic types.
7015     * @hide
7016     */
7017    public void removeUnsafeExtras() {
7018        if (mExtras != null) {
7019            mExtras = mExtras.filterValues();
7020        }
7021    }
7022
7023    /**
7024     * Retrieve any special flags associated with this intent.  You will
7025     * normally just set them with {@link #setFlags} and let the system
7026     * take the appropriate action with them.
7027     *
7028     * @return int The currently set flags.
7029     *
7030     * @see #setFlags
7031     */
7032    public int getFlags() {
7033        return mFlags;
7034    }
7035
7036    /** @hide */
7037    public boolean isExcludingStopped() {
7038        return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7039                == FLAG_EXCLUDE_STOPPED_PACKAGES;
7040    }
7041
7042    /**
7043     * Retrieve the application package name this Intent is limited to.  When
7044     * resolving an Intent, if non-null this limits the resolution to only
7045     * components in the given application package.
7046     *
7047     * @return The name of the application package for the Intent.
7048     *
7049     * @see #resolveActivity
7050     * @see #setPackage
7051     */
7052    public String getPackage() {
7053        return mPackage;
7054    }
7055
7056    /**
7057     * Retrieve the concrete component associated with the intent.  When receiving
7058     * an intent, this is the component that was found to best handle it (that is,
7059     * yourself) and will always be non-null; in all other cases it will be
7060     * null unless explicitly set.
7061     *
7062     * @return The name of the application component to handle the intent.
7063     *
7064     * @see #resolveActivity
7065     * @see #setComponent
7066     */
7067    public ComponentName getComponent() {
7068        return mComponent;
7069    }
7070
7071    /**
7072     * Get the bounds of the sender of this intent, in screen coordinates.  This can be
7073     * used as a hint to the receiver for animations and the like.  Null means that there
7074     * is no source bounds.
7075     */
7076    public Rect getSourceBounds() {
7077        return mSourceBounds;
7078    }
7079
7080    /**
7081     * Return the Activity component that should be used to handle this intent.
7082     * The appropriate component is determined based on the information in the
7083     * intent, evaluated as follows:
7084     *
7085     * <p>If {@link #getComponent} returns an explicit class, that is returned
7086     * without any further consideration.
7087     *
7088     * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7089     * category to be considered.
7090     *
7091     * <p>If {@link #getAction} is non-NULL, the activity must handle this
7092     * action.
7093     *
7094     * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7095     * this type.
7096     *
7097     * <p>If {@link #addCategory} has added any categories, the activity must
7098     * handle ALL of the categories specified.
7099     *
7100     * <p>If {@link #getPackage} is non-NULL, only activity components in
7101     * that application package will be considered.
7102     *
7103     * <p>If there are no activities that satisfy all of these conditions, a
7104     * null string is returned.
7105     *
7106     * <p>If multiple activities are found to satisfy the intent, the one with
7107     * the highest priority will be used.  If there are multiple activities
7108     * with the same priority, the system will either pick the best activity
7109     * based on user preference, or resolve to a system class that will allow
7110     * the user to pick an activity and forward from there.
7111     *
7112     * <p>This method is implemented simply by calling
7113     * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7114     * true.</p>
7115     * <p> This API is called for you as part of starting an activity from an
7116     * intent.  You do not normally need to call it yourself.</p>
7117     *
7118     * @param pm The package manager with which to resolve the Intent.
7119     *
7120     * @return Name of the component implementing an activity that can
7121     *         display the intent.
7122     *
7123     * @see #setComponent
7124     * @see #getComponent
7125     * @see #resolveActivityInfo
7126     */
7127    public ComponentName resolveActivity(PackageManager pm) {
7128        if (mComponent != null) {
7129            return mComponent;
7130        }
7131
7132        ResolveInfo info = pm.resolveActivity(
7133            this, PackageManager.MATCH_DEFAULT_ONLY);
7134        if (info != null) {
7135            return new ComponentName(
7136                    info.activityInfo.applicationInfo.packageName,
7137                    info.activityInfo.name);
7138        }
7139
7140        return null;
7141    }
7142
7143    /**
7144     * Resolve the Intent into an {@link ActivityInfo}
7145     * describing the activity that should execute the intent.  Resolution
7146     * follows the same rules as described for {@link #resolveActivity}, but
7147     * you get back the completely information about the resolved activity
7148     * instead of just its class name.
7149     *
7150     * @param pm The package manager with which to resolve the Intent.
7151     * @param flags Addition information to retrieve as per
7152     * {@link PackageManager#getActivityInfo(ComponentName, int)
7153     * PackageManager.getActivityInfo()}.
7154     *
7155     * @return PackageManager.ActivityInfo
7156     *
7157     * @see #resolveActivity
7158     */
7159    public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
7160        ActivityInfo ai = null;
7161        if (mComponent != null) {
7162            try {
7163                ai = pm.getActivityInfo(mComponent, flags);
7164            } catch (PackageManager.NameNotFoundException e) {
7165                // ignore
7166            }
7167        } else {
7168            ResolveInfo info = pm.resolveActivity(
7169                this, PackageManager.MATCH_DEFAULT_ONLY | flags);
7170            if (info != null) {
7171                ai = info.activityInfo;
7172            }
7173        }
7174
7175        return ai;
7176    }
7177
7178    /**
7179     * Special function for use by the system to resolve service
7180     * intents to system apps.  Throws an exception if there are
7181     * multiple potential matches to the Intent.  Returns null if
7182     * there are no matches.
7183     * @hide
7184     */
7185    public ComponentName resolveSystemService(PackageManager pm, int flags) {
7186        if (mComponent != null) {
7187            return mComponent;
7188        }
7189
7190        List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7191        if (results == null) {
7192            return null;
7193        }
7194        ComponentName comp = null;
7195        for (int i=0; i<results.size(); i++) {
7196            ResolveInfo ri = results.get(i);
7197            if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7198                continue;
7199            }
7200            ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7201                    ri.serviceInfo.name);
7202            if (comp != null) {
7203                throw new IllegalStateException("Multiple system services handle " + this
7204                        + ": " + comp + ", " + foundComp);
7205            }
7206            comp = foundComp;
7207        }
7208        return comp;
7209    }
7210
7211    /**
7212     * Set the general action to be performed.
7213     *
7214     * @param action An action name, such as ACTION_VIEW.  Application-specific
7215     *               actions should be prefixed with the vendor's package name.
7216     *
7217     * @return Returns the same Intent object, for chaining multiple calls
7218     * into a single statement.
7219     *
7220     * @see #getAction
7221     */
7222    public Intent setAction(String action) {
7223        mAction = action != null ? action.intern() : null;
7224        return this;
7225    }
7226
7227    /**
7228     * Set the data this intent is operating on.  This method automatically
7229     * clears any type that was previously set by {@link #setType} or
7230     * {@link #setTypeAndNormalize}.
7231     *
7232     * <p><em>Note: scheme matching in the Android framework is
7233     * case-sensitive, unlike the formal RFC. As a result,
7234     * you should always write your Uri with a lower case scheme,
7235     * or use {@link Uri#normalizeScheme} or
7236     * {@link #setDataAndNormalize}
7237     * to ensure that the scheme is converted to lower case.</em>
7238     *
7239     * @param data The Uri of the data this intent is now targeting.
7240     *
7241     * @return Returns the same Intent object, for chaining multiple calls
7242     * into a single statement.
7243     *
7244     * @see #getData
7245     * @see #setDataAndNormalize
7246     * @see android.net.Uri#normalizeScheme()
7247     */
7248    public Intent setData(Uri data) {
7249        mData = data;
7250        mType = null;
7251        return this;
7252    }
7253
7254    /**
7255     * Normalize and set the data this intent is operating on.
7256     *
7257     * <p>This method automatically clears any type that was
7258     * previously set (for example, by {@link #setType}).
7259     *
7260     * <p>The data Uri is normalized using
7261     * {@link android.net.Uri#normalizeScheme} before it is set,
7262     * so really this is just a convenience method for
7263     * <pre>
7264     * setData(data.normalize())
7265     * </pre>
7266     *
7267     * @param data The Uri of the data this intent is now targeting.
7268     *
7269     * @return Returns the same Intent object, for chaining multiple calls
7270     * into a single statement.
7271     *
7272     * @see #getData
7273     * @see #setType
7274     * @see android.net.Uri#normalizeScheme
7275     */
7276    public Intent setDataAndNormalize(Uri data) {
7277        return setData(data.normalizeScheme());
7278    }
7279
7280    /**
7281     * Set an explicit MIME data type.
7282     *
7283     * <p>This is used to create intents that only specify a type and not data,
7284     * for example to indicate the type of data to return.
7285     *
7286     * <p>This method automatically clears any data that was
7287     * previously set (for example by {@link #setData}).
7288     *
7289     * <p><em>Note: MIME type matching in the Android framework is
7290     * case-sensitive, unlike formal RFC MIME types.  As a result,
7291     * you should always write your MIME types with lower case letters,
7292     * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
7293     * to ensure that it is converted to lower case.</em>
7294     *
7295     * @param type The MIME type of the data being handled by this intent.
7296     *
7297     * @return Returns the same Intent object, for chaining multiple calls
7298     * into a single statement.
7299     *
7300     * @see #getType
7301     * @see #setTypeAndNormalize
7302     * @see #setDataAndType
7303     * @see #normalizeMimeType
7304     */
7305    public Intent setType(String type) {
7306        mData = null;
7307        mType = type;
7308        return this;
7309    }
7310
7311    /**
7312     * Normalize and set an explicit MIME data type.
7313     *
7314     * <p>This is used to create intents that only specify a type and not data,
7315     * for example to indicate the type of data to return.
7316     *
7317     * <p>This method automatically clears any data that was
7318     * previously set (for example by {@link #setData}).
7319     *
7320     * <p>The MIME type is normalized using
7321     * {@link #normalizeMimeType} before it is set,
7322     * so really this is just a convenience method for
7323     * <pre>
7324     * setType(Intent.normalizeMimeType(type))
7325     * </pre>
7326     *
7327     * @param type The MIME type of the data being handled by this intent.
7328     *
7329     * @return Returns the same Intent object, for chaining multiple calls
7330     * into a single statement.
7331     *
7332     * @see #getType
7333     * @see #setData
7334     * @see #normalizeMimeType
7335     */
7336    public Intent setTypeAndNormalize(String type) {
7337        return setType(normalizeMimeType(type));
7338    }
7339
7340    /**
7341     * (Usually optional) Set the data for the intent along with an explicit
7342     * MIME data type.  This method should very rarely be used -- it allows you
7343     * to override the MIME type that would ordinarily be inferred from the
7344     * data with your own type given here.
7345     *
7346     * <p><em>Note: MIME type and Uri scheme matching in the
7347     * Android framework is case-sensitive, unlike the formal RFC definitions.
7348     * As a result, you should always write these elements with lower case letters,
7349     * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
7350     * {@link #setDataAndTypeAndNormalize}
7351     * to ensure that they are converted to lower case.</em>
7352     *
7353     * @param data The Uri of the data this intent is now targeting.
7354     * @param type The MIME type of the data being handled by this intent.
7355     *
7356     * @return Returns the same Intent object, for chaining multiple calls
7357     * into a single statement.
7358     *
7359     * @see #setType
7360     * @see #setData
7361     * @see #normalizeMimeType
7362     * @see android.net.Uri#normalizeScheme
7363     * @see #setDataAndTypeAndNormalize
7364     */
7365    public Intent setDataAndType(Uri data, String type) {
7366        mData = data;
7367        mType = type;
7368        return this;
7369    }
7370
7371    /**
7372     * (Usually optional) Normalize and set both the data Uri and an explicit
7373     * MIME data type.  This method should very rarely be used -- it allows you
7374     * to override the MIME type that would ordinarily be inferred from the
7375     * data with your own type given here.
7376     *
7377     * <p>The data Uri and the MIME type are normalize using
7378     * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
7379     * before they are set, so really this is just a convenience method for
7380     * <pre>
7381     * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
7382     * </pre>
7383     *
7384     * @param data The Uri of the data this intent is now targeting.
7385     * @param type The MIME type of the data being handled by this intent.
7386     *
7387     * @return Returns the same Intent object, for chaining multiple calls
7388     * into a single statement.
7389     *
7390     * @see #setType
7391     * @see #setData
7392     * @see #setDataAndType
7393     * @see #normalizeMimeType
7394     * @see android.net.Uri#normalizeScheme
7395     */
7396    public Intent setDataAndTypeAndNormalize(Uri data, String type) {
7397        return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
7398    }
7399
7400    /**
7401     * Add a new category to the intent.  Categories provide additional detail
7402     * about the action the intent performs.  When resolving an intent, only
7403     * activities that provide <em>all</em> of the requested categories will be
7404     * used.
7405     *
7406     * @param category The desired category.  This can be either one of the
7407     *               predefined Intent categories, or a custom category in your own
7408     *               namespace.
7409     *
7410     * @return Returns the same Intent object, for chaining multiple calls
7411     * into a single statement.
7412     *
7413     * @see #hasCategory
7414     * @see #removeCategory
7415     */
7416    public Intent addCategory(String category) {
7417        if (mCategories == null) {
7418            mCategories = new ArraySet<String>();
7419        }
7420        mCategories.add(category.intern());
7421        return this;
7422    }
7423
7424    /**
7425     * Remove a category from an intent.
7426     *
7427     * @param category The category to remove.
7428     *
7429     * @see #addCategory
7430     */
7431    public void removeCategory(String category) {
7432        if (mCategories != null) {
7433            mCategories.remove(category);
7434            if (mCategories.size() == 0) {
7435                mCategories = null;
7436            }
7437        }
7438    }
7439
7440    /**
7441     * Set a selector for this Intent.  This is a modification to the kinds of
7442     * things the Intent will match.  If the selector is set, it will be used
7443     * when trying to find entities that can handle the Intent, instead of the
7444     * main contents of the Intent.  This allows you build an Intent containing
7445     * a generic protocol while targeting it more specifically.
7446     *
7447     * <p>An example of where this may be used is with things like
7448     * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
7449     * Intent that will launch the Browser application.  However, the correct
7450     * main entry point of an application is actually {@link #ACTION_MAIN}
7451     * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
7452     * used to specify the actual Activity to launch.  If you launch the browser
7453     * with something different, undesired behavior may happen if the user has
7454     * previously or later launches it the normal way, since they do not match.
7455     * Instead, you can build an Intent with the MAIN action (but no ComponentName
7456     * yet specified) and set a selector with {@link #ACTION_MAIN} and
7457     * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
7458     *
7459     * <p>Setting a selector does not impact the behavior of
7460     * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
7461     * desired behavior of a selector -- it does not impact the base meaning
7462     * of the Intent, just what kinds of things will be matched against it
7463     * when determining who can handle it.</p>
7464     *
7465     * <p>You can not use both a selector and {@link #setPackage(String)} on
7466     * the same base Intent.</p>
7467     *
7468     * @param selector The desired selector Intent; set to null to not use
7469     * a special selector.
7470     */
7471    public void setSelector(Intent selector) {
7472        if (selector == this) {
7473            throw new IllegalArgumentException(
7474                    "Intent being set as a selector of itself");
7475        }
7476        if (selector != null && mPackage != null) {
7477            throw new IllegalArgumentException(
7478                    "Can't set selector when package name is already set");
7479        }
7480        mSelector = selector;
7481    }
7482
7483    /**
7484     * Set a {@link ClipData} associated with this Intent.  This replaces any
7485     * previously set ClipData.
7486     *
7487     * <p>The ClipData in an intent is not used for Intent matching or other
7488     * such operations.  Semantically it is like extras, used to transmit
7489     * additional data with the Intent.  The main feature of using this over
7490     * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7491     * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7492     * items included in the clip data.  This is useful, in particular, if
7493     * you want to transmit an Intent containing multiple <code>content:</code>
7494     * URIs for which the recipient may not have global permission to access the
7495     * content provider.
7496     *
7497     * <p>If the ClipData contains items that are themselves Intents, any
7498     * grant flags in those Intents will be ignored.  Only the top-level flags
7499     * of the main Intent are respected, and will be applied to all Uri or
7500     * Intent items in the clip (or sub-items of the clip).
7501     *
7502     * <p>The MIME type, label, and icon in the ClipData object are not
7503     * directly used by Intent.  Applications should generally rely on the
7504     * MIME type of the Intent itself, not what it may find in the ClipData.
7505     * A common practice is to construct a ClipData for use with an Intent
7506     * with a MIME type of "*&#47;*".
7507     *
7508     * @param clip The new clip to set.  May be null to clear the current clip.
7509     */
7510    public void setClipData(ClipData clip) {
7511        mClipData = clip;
7512    }
7513
7514    /**
7515     * This is NOT a secure mechanism to identify the user who sent the intent.
7516     * When the intent is sent to a different user, it is used to fix uris by adding the userId
7517     * who sent the intent.
7518     * @hide
7519     */
7520    public void prepareToLeaveUser(int userId) {
7521        // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7522        // We want mContentUserHint to refer to the original user, so don't do anything.
7523        if (mContentUserHint == UserHandle.USER_CURRENT) {
7524            mContentUserHint = userId;
7525        }
7526    }
7527
7528    /**
7529     * Add extended data to the intent.  The name must include a package
7530     * prefix, for example the app com.android.contacts would use names
7531     * like "com.android.contacts.ShowAll".
7532     *
7533     * @param name The name of the extra data, with package prefix.
7534     * @param value The boolean data value.
7535     *
7536     * @return Returns the same Intent object, for chaining multiple calls
7537     * into a single statement.
7538     *
7539     * @see #putExtras
7540     * @see #removeExtra
7541     * @see #getBooleanExtra(String, boolean)
7542     */
7543    public Intent putExtra(String name, boolean value) {
7544        if (mExtras == null) {
7545            mExtras = new Bundle();
7546        }
7547        mExtras.putBoolean(name, value);
7548        return this;
7549    }
7550
7551    /**
7552     * Add extended data to the intent.  The name must include a package
7553     * prefix, for example the app com.android.contacts would use names
7554     * like "com.android.contacts.ShowAll".
7555     *
7556     * @param name The name of the extra data, with package prefix.
7557     * @param value The byte data value.
7558     *
7559     * @return Returns the same Intent object, for chaining multiple calls
7560     * into a single statement.
7561     *
7562     * @see #putExtras
7563     * @see #removeExtra
7564     * @see #getByteExtra(String, byte)
7565     */
7566    public Intent putExtra(String name, byte value) {
7567        if (mExtras == null) {
7568            mExtras = new Bundle();
7569        }
7570        mExtras.putByte(name, value);
7571        return this;
7572    }
7573
7574    /**
7575     * Add extended data to the intent.  The name must include a package
7576     * prefix, for example the app com.android.contacts would use names
7577     * like "com.android.contacts.ShowAll".
7578     *
7579     * @param name The name of the extra data, with package prefix.
7580     * @param value The char data value.
7581     *
7582     * @return Returns the same Intent object, for chaining multiple calls
7583     * into a single statement.
7584     *
7585     * @see #putExtras
7586     * @see #removeExtra
7587     * @see #getCharExtra(String, char)
7588     */
7589    public Intent putExtra(String name, char value) {
7590        if (mExtras == null) {
7591            mExtras = new Bundle();
7592        }
7593        mExtras.putChar(name, value);
7594        return this;
7595    }
7596
7597    /**
7598     * Add extended data to the intent.  The name must include a package
7599     * prefix, for example the app com.android.contacts would use names
7600     * like "com.android.contacts.ShowAll".
7601     *
7602     * @param name The name of the extra data, with package prefix.
7603     * @param value The short data value.
7604     *
7605     * @return Returns the same Intent object, for chaining multiple calls
7606     * into a single statement.
7607     *
7608     * @see #putExtras
7609     * @see #removeExtra
7610     * @see #getShortExtra(String, short)
7611     */
7612    public Intent putExtra(String name, short value) {
7613        if (mExtras == null) {
7614            mExtras = new Bundle();
7615        }
7616        mExtras.putShort(name, value);
7617        return this;
7618    }
7619
7620    /**
7621     * Add extended data to the intent.  The name must include a package
7622     * prefix, for example the app com.android.contacts would use names
7623     * like "com.android.contacts.ShowAll".
7624     *
7625     * @param name The name of the extra data, with package prefix.
7626     * @param value The integer data value.
7627     *
7628     * @return Returns the same Intent object, for chaining multiple calls
7629     * into a single statement.
7630     *
7631     * @see #putExtras
7632     * @see #removeExtra
7633     * @see #getIntExtra(String, int)
7634     */
7635    public Intent putExtra(String name, int value) {
7636        if (mExtras == null) {
7637            mExtras = new Bundle();
7638        }
7639        mExtras.putInt(name, value);
7640        return this;
7641    }
7642
7643    /**
7644     * Add extended data to the intent.  The name must include a package
7645     * prefix, for example the app com.android.contacts would use names
7646     * like "com.android.contacts.ShowAll".
7647     *
7648     * @param name The name of the extra data, with package prefix.
7649     * @param value The long data value.
7650     *
7651     * @return Returns the same Intent object, for chaining multiple calls
7652     * into a single statement.
7653     *
7654     * @see #putExtras
7655     * @see #removeExtra
7656     * @see #getLongExtra(String, long)
7657     */
7658    public Intent putExtra(String name, long value) {
7659        if (mExtras == null) {
7660            mExtras = new Bundle();
7661        }
7662        mExtras.putLong(name, value);
7663        return this;
7664    }
7665
7666    /**
7667     * Add extended data to the intent.  The name must include a package
7668     * prefix, for example the app com.android.contacts would use names
7669     * like "com.android.contacts.ShowAll".
7670     *
7671     * @param name The name of the extra data, with package prefix.
7672     * @param value The float data value.
7673     *
7674     * @return Returns the same Intent object, for chaining multiple calls
7675     * into a single statement.
7676     *
7677     * @see #putExtras
7678     * @see #removeExtra
7679     * @see #getFloatExtra(String, float)
7680     */
7681    public Intent putExtra(String name, float value) {
7682        if (mExtras == null) {
7683            mExtras = new Bundle();
7684        }
7685        mExtras.putFloat(name, value);
7686        return this;
7687    }
7688
7689    /**
7690     * Add extended data to the intent.  The name must include a package
7691     * prefix, for example the app com.android.contacts would use names
7692     * like "com.android.contacts.ShowAll".
7693     *
7694     * @param name The name of the extra data, with package prefix.
7695     * @param value The double data value.
7696     *
7697     * @return Returns the same Intent object, for chaining multiple calls
7698     * into a single statement.
7699     *
7700     * @see #putExtras
7701     * @see #removeExtra
7702     * @see #getDoubleExtra(String, double)
7703     */
7704    public Intent putExtra(String name, double value) {
7705        if (mExtras == null) {
7706            mExtras = new Bundle();
7707        }
7708        mExtras.putDouble(name, value);
7709        return this;
7710    }
7711
7712    /**
7713     * Add extended data to the intent.  The name must include a package
7714     * prefix, for example the app com.android.contacts would use names
7715     * like "com.android.contacts.ShowAll".
7716     *
7717     * @param name The name of the extra data, with package prefix.
7718     * @param value The String data value.
7719     *
7720     * @return Returns the same Intent object, for chaining multiple calls
7721     * into a single statement.
7722     *
7723     * @see #putExtras
7724     * @see #removeExtra
7725     * @see #getStringExtra(String)
7726     */
7727    public Intent putExtra(String name, String value) {
7728        if (mExtras == null) {
7729            mExtras = new Bundle();
7730        }
7731        mExtras.putString(name, value);
7732        return this;
7733    }
7734
7735    /**
7736     * Add extended data to the intent.  The name must include a package
7737     * prefix, for example the app com.android.contacts would use names
7738     * like "com.android.contacts.ShowAll".
7739     *
7740     * @param name The name of the extra data, with package prefix.
7741     * @param value The CharSequence data value.
7742     *
7743     * @return Returns the same Intent object, for chaining multiple calls
7744     * into a single statement.
7745     *
7746     * @see #putExtras
7747     * @see #removeExtra
7748     * @see #getCharSequenceExtra(String)
7749     */
7750    public Intent putExtra(String name, CharSequence value) {
7751        if (mExtras == null) {
7752            mExtras = new Bundle();
7753        }
7754        mExtras.putCharSequence(name, value);
7755        return this;
7756    }
7757
7758    /**
7759     * Add extended data to the intent.  The name must include a package
7760     * prefix, for example the app com.android.contacts would use names
7761     * like "com.android.contacts.ShowAll".
7762     *
7763     * @param name The name of the extra data, with package prefix.
7764     * @param value The Parcelable data value.
7765     *
7766     * @return Returns the same Intent object, for chaining multiple calls
7767     * into a single statement.
7768     *
7769     * @see #putExtras
7770     * @see #removeExtra
7771     * @see #getParcelableExtra(String)
7772     */
7773    public Intent putExtra(String name, Parcelable value) {
7774        if (mExtras == null) {
7775            mExtras = new Bundle();
7776        }
7777        mExtras.putParcelable(name, value);
7778        return this;
7779    }
7780
7781    /**
7782     * Add extended data to the intent.  The name must include a package
7783     * prefix, for example the app com.android.contacts would use names
7784     * like "com.android.contacts.ShowAll".
7785     *
7786     * @param name The name of the extra data, with package prefix.
7787     * @param value The Parcelable[] data value.
7788     *
7789     * @return Returns the same Intent object, for chaining multiple calls
7790     * into a single statement.
7791     *
7792     * @see #putExtras
7793     * @see #removeExtra
7794     * @see #getParcelableArrayExtra(String)
7795     */
7796    public Intent putExtra(String name, Parcelable[] value) {
7797        if (mExtras == null) {
7798            mExtras = new Bundle();
7799        }
7800        mExtras.putParcelableArray(name, value);
7801        return this;
7802    }
7803
7804    /**
7805     * Add extended data to the intent.  The name must include a package
7806     * prefix, for example the app com.android.contacts would use names
7807     * like "com.android.contacts.ShowAll".
7808     *
7809     * @param name The name of the extra data, with package prefix.
7810     * @param value The ArrayList<Parcelable> data value.
7811     *
7812     * @return Returns the same Intent object, for chaining multiple calls
7813     * into a single statement.
7814     *
7815     * @see #putExtras
7816     * @see #removeExtra
7817     * @see #getParcelableArrayListExtra(String)
7818     */
7819    public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7820        if (mExtras == null) {
7821            mExtras = new Bundle();
7822        }
7823        mExtras.putParcelableArrayList(name, value);
7824        return this;
7825    }
7826
7827    /**
7828     * Add extended data to the intent.  The name must include a package
7829     * prefix, for example the app com.android.contacts would use names
7830     * like "com.android.contacts.ShowAll".
7831     *
7832     * @param name The name of the extra data, with package prefix.
7833     * @param value The ArrayList<Integer> data value.
7834     *
7835     * @return Returns the same Intent object, for chaining multiple calls
7836     * into a single statement.
7837     *
7838     * @see #putExtras
7839     * @see #removeExtra
7840     * @see #getIntegerArrayListExtra(String)
7841     */
7842    public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7843        if (mExtras == null) {
7844            mExtras = new Bundle();
7845        }
7846        mExtras.putIntegerArrayList(name, value);
7847        return this;
7848    }
7849
7850    /**
7851     * Add extended data to the intent.  The name must include a package
7852     * prefix, for example the app com.android.contacts would use names
7853     * like "com.android.contacts.ShowAll".
7854     *
7855     * @param name The name of the extra data, with package prefix.
7856     * @param value The ArrayList<String> data value.
7857     *
7858     * @return Returns the same Intent object, for chaining multiple calls
7859     * into a single statement.
7860     *
7861     * @see #putExtras
7862     * @see #removeExtra
7863     * @see #getStringArrayListExtra(String)
7864     */
7865    public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7866        if (mExtras == null) {
7867            mExtras = new Bundle();
7868        }
7869        mExtras.putStringArrayList(name, value);
7870        return this;
7871    }
7872
7873    /**
7874     * Add extended data to the intent.  The name must include a package
7875     * prefix, for example the app com.android.contacts would use names
7876     * like "com.android.contacts.ShowAll".
7877     *
7878     * @param name The name of the extra data, with package prefix.
7879     * @param value The ArrayList<CharSequence> data value.
7880     *
7881     * @return Returns the same Intent object, for chaining multiple calls
7882     * into a single statement.
7883     *
7884     * @see #putExtras
7885     * @see #removeExtra
7886     * @see #getCharSequenceArrayListExtra(String)
7887     */
7888    public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7889        if (mExtras == null) {
7890            mExtras = new Bundle();
7891        }
7892        mExtras.putCharSequenceArrayList(name, value);
7893        return this;
7894    }
7895
7896    /**
7897     * Add extended data to the intent.  The name must include a package
7898     * prefix, for example the app com.android.contacts would use names
7899     * like "com.android.contacts.ShowAll".
7900     *
7901     * @param name The name of the extra data, with package prefix.
7902     * @param value The Serializable data value.
7903     *
7904     * @return Returns the same Intent object, for chaining multiple calls
7905     * into a single statement.
7906     *
7907     * @see #putExtras
7908     * @see #removeExtra
7909     * @see #getSerializableExtra(String)
7910     */
7911    public Intent putExtra(String name, Serializable value) {
7912        if (mExtras == null) {
7913            mExtras = new Bundle();
7914        }
7915        mExtras.putSerializable(name, value);
7916        return this;
7917    }
7918
7919    /**
7920     * Add extended data to the intent.  The name must include a package
7921     * prefix, for example the app com.android.contacts would use names
7922     * like "com.android.contacts.ShowAll".
7923     *
7924     * @param name The name of the extra data, with package prefix.
7925     * @param value The boolean array data value.
7926     *
7927     * @return Returns the same Intent object, for chaining multiple calls
7928     * into a single statement.
7929     *
7930     * @see #putExtras
7931     * @see #removeExtra
7932     * @see #getBooleanArrayExtra(String)
7933     */
7934    public Intent putExtra(String name, boolean[] value) {
7935        if (mExtras == null) {
7936            mExtras = new Bundle();
7937        }
7938        mExtras.putBooleanArray(name, value);
7939        return this;
7940    }
7941
7942    /**
7943     * Add extended data to the intent.  The name must include a package
7944     * prefix, for example the app com.android.contacts would use names
7945     * like "com.android.contacts.ShowAll".
7946     *
7947     * @param name The name of the extra data, with package prefix.
7948     * @param value The byte array data value.
7949     *
7950     * @return Returns the same Intent object, for chaining multiple calls
7951     * into a single statement.
7952     *
7953     * @see #putExtras
7954     * @see #removeExtra
7955     * @see #getByteArrayExtra(String)
7956     */
7957    public Intent putExtra(String name, byte[] value) {
7958        if (mExtras == null) {
7959            mExtras = new Bundle();
7960        }
7961        mExtras.putByteArray(name, value);
7962        return this;
7963    }
7964
7965    /**
7966     * Add extended data to the intent.  The name must include a package
7967     * prefix, for example the app com.android.contacts would use names
7968     * like "com.android.contacts.ShowAll".
7969     *
7970     * @param name The name of the extra data, with package prefix.
7971     * @param value The short array data value.
7972     *
7973     * @return Returns the same Intent object, for chaining multiple calls
7974     * into a single statement.
7975     *
7976     * @see #putExtras
7977     * @see #removeExtra
7978     * @see #getShortArrayExtra(String)
7979     */
7980    public Intent putExtra(String name, short[] value) {
7981        if (mExtras == null) {
7982            mExtras = new Bundle();
7983        }
7984        mExtras.putShortArray(name, value);
7985        return this;
7986    }
7987
7988    /**
7989     * Add extended data to the intent.  The name must include a package
7990     * prefix, for example the app com.android.contacts would use names
7991     * like "com.android.contacts.ShowAll".
7992     *
7993     * @param name The name of the extra data, with package prefix.
7994     * @param value The char array data value.
7995     *
7996     * @return Returns the same Intent object, for chaining multiple calls
7997     * into a single statement.
7998     *
7999     * @see #putExtras
8000     * @see #removeExtra
8001     * @see #getCharArrayExtra(String)
8002     */
8003    public Intent putExtra(String name, char[] value) {
8004        if (mExtras == null) {
8005            mExtras = new Bundle();
8006        }
8007        mExtras.putCharArray(name, value);
8008        return this;
8009    }
8010
8011    /**
8012     * Add extended data to the intent.  The name must include a package
8013     * prefix, for example the app com.android.contacts would use names
8014     * like "com.android.contacts.ShowAll".
8015     *
8016     * @param name The name of the extra data, with package prefix.
8017     * @param value The int array data value.
8018     *
8019     * @return Returns the same Intent object, for chaining multiple calls
8020     * into a single statement.
8021     *
8022     * @see #putExtras
8023     * @see #removeExtra
8024     * @see #getIntArrayExtra(String)
8025     */
8026    public Intent putExtra(String name, int[] value) {
8027        if (mExtras == null) {
8028            mExtras = new Bundle();
8029        }
8030        mExtras.putIntArray(name, value);
8031        return this;
8032    }
8033
8034    /**
8035     * Add extended data to the intent.  The name must include a package
8036     * prefix, for example the app com.android.contacts would use names
8037     * like "com.android.contacts.ShowAll".
8038     *
8039     * @param name The name of the extra data, with package prefix.
8040     * @param value The byte array data value.
8041     *
8042     * @return Returns the same Intent object, for chaining multiple calls
8043     * into a single statement.
8044     *
8045     * @see #putExtras
8046     * @see #removeExtra
8047     * @see #getLongArrayExtra(String)
8048     */
8049    public Intent putExtra(String name, long[] value) {
8050        if (mExtras == null) {
8051            mExtras = new Bundle();
8052        }
8053        mExtras.putLongArray(name, value);
8054        return this;
8055    }
8056
8057    /**
8058     * Add extended data to the intent.  The name must include a package
8059     * prefix, for example the app com.android.contacts would use names
8060     * like "com.android.contacts.ShowAll".
8061     *
8062     * @param name The name of the extra data, with package prefix.
8063     * @param value The float array data value.
8064     *
8065     * @return Returns the same Intent object, for chaining multiple calls
8066     * into a single statement.
8067     *
8068     * @see #putExtras
8069     * @see #removeExtra
8070     * @see #getFloatArrayExtra(String)
8071     */
8072    public Intent putExtra(String name, float[] value) {
8073        if (mExtras == null) {
8074            mExtras = new Bundle();
8075        }
8076        mExtras.putFloatArray(name, value);
8077        return this;
8078    }
8079
8080    /**
8081     * Add extended data to the intent.  The name must include a package
8082     * prefix, for example the app com.android.contacts would use names
8083     * like "com.android.contacts.ShowAll".
8084     *
8085     * @param name The name of the extra data, with package prefix.
8086     * @param value The double array data value.
8087     *
8088     * @return Returns the same Intent object, for chaining multiple calls
8089     * into a single statement.
8090     *
8091     * @see #putExtras
8092     * @see #removeExtra
8093     * @see #getDoubleArrayExtra(String)
8094     */
8095    public Intent putExtra(String name, double[] value) {
8096        if (mExtras == null) {
8097            mExtras = new Bundle();
8098        }
8099        mExtras.putDoubleArray(name, value);
8100        return this;
8101    }
8102
8103    /**
8104     * Add extended data to the intent.  The name must include a package
8105     * prefix, for example the app com.android.contacts would use names
8106     * like "com.android.contacts.ShowAll".
8107     *
8108     * @param name The name of the extra data, with package prefix.
8109     * @param value The String array data value.
8110     *
8111     * @return Returns the same Intent object, for chaining multiple calls
8112     * into a single statement.
8113     *
8114     * @see #putExtras
8115     * @see #removeExtra
8116     * @see #getStringArrayExtra(String)
8117     */
8118    public Intent putExtra(String name, String[] value) {
8119        if (mExtras == null) {
8120            mExtras = new Bundle();
8121        }
8122        mExtras.putStringArray(name, value);
8123        return this;
8124    }
8125
8126    /**
8127     * Add extended data to the intent.  The name must include a package
8128     * prefix, for example the app com.android.contacts would use names
8129     * like "com.android.contacts.ShowAll".
8130     *
8131     * @param name The name of the extra data, with package prefix.
8132     * @param value The CharSequence array data value.
8133     *
8134     * @return Returns the same Intent object, for chaining multiple calls
8135     * into a single statement.
8136     *
8137     * @see #putExtras
8138     * @see #removeExtra
8139     * @see #getCharSequenceArrayExtra(String)
8140     */
8141    public Intent putExtra(String name, CharSequence[] value) {
8142        if (mExtras == null) {
8143            mExtras = new Bundle();
8144        }
8145        mExtras.putCharSequenceArray(name, value);
8146        return this;
8147    }
8148
8149    /**
8150     * Add extended data to the intent.  The name must include a package
8151     * prefix, for example the app com.android.contacts would use names
8152     * like "com.android.contacts.ShowAll".
8153     *
8154     * @param name The name of the extra data, with package prefix.
8155     * @param value The Bundle data value.
8156     *
8157     * @return Returns the same Intent object, for chaining multiple calls
8158     * into a single statement.
8159     *
8160     * @see #putExtras
8161     * @see #removeExtra
8162     * @see #getBundleExtra(String)
8163     */
8164    public Intent putExtra(String name, Bundle value) {
8165        if (mExtras == null) {
8166            mExtras = new Bundle();
8167        }
8168        mExtras.putBundle(name, value);
8169        return this;
8170    }
8171
8172    /**
8173     * Add extended data to the intent.  The name must include a package
8174     * prefix, for example the app com.android.contacts would use names
8175     * like "com.android.contacts.ShowAll".
8176     *
8177     * @param name The name of the extra data, with package prefix.
8178     * @param value The IBinder data value.
8179     *
8180     * @return Returns the same Intent object, for chaining multiple calls
8181     * into a single statement.
8182     *
8183     * @see #putExtras
8184     * @see #removeExtra
8185     * @see #getIBinderExtra(String)
8186     *
8187     * @deprecated
8188     * @hide
8189     */
8190    @Deprecated
8191    public Intent putExtra(String name, IBinder value) {
8192        if (mExtras == null) {
8193            mExtras = new Bundle();
8194        }
8195        mExtras.putIBinder(name, value);
8196        return this;
8197    }
8198
8199    /**
8200     * Copy all extras in 'src' in to this intent.
8201     *
8202     * @param src Contains the extras to copy.
8203     *
8204     * @see #putExtra
8205     */
8206    public Intent putExtras(Intent src) {
8207        if (src.mExtras != null) {
8208            if (mExtras == null) {
8209                mExtras = new Bundle(src.mExtras);
8210            } else {
8211                mExtras.putAll(src.mExtras);
8212            }
8213        }
8214        return this;
8215    }
8216
8217    /**
8218     * Add a set of extended data to the intent.  The keys must include a package
8219     * prefix, for example the app com.android.contacts would use names
8220     * like "com.android.contacts.ShowAll".
8221     *
8222     * @param extras The Bundle of extras to add to this intent.
8223     *
8224     * @see #putExtra
8225     * @see #removeExtra
8226     */
8227    public Intent putExtras(Bundle extras) {
8228        if (mExtras == null) {
8229            mExtras = new Bundle();
8230        }
8231        mExtras.putAll(extras);
8232        return this;
8233    }
8234
8235    /**
8236     * Completely replace the extras in the Intent with the extras in the
8237     * given Intent.
8238     *
8239     * @param src The exact extras contained in this Intent are copied
8240     * into the target intent, replacing any that were previously there.
8241     */
8242    public Intent replaceExtras(Intent src) {
8243        mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8244        return this;
8245    }
8246
8247    /**
8248     * Completely replace the extras in the Intent with the given Bundle of
8249     * extras.
8250     *
8251     * @param extras The new set of extras in the Intent, or null to erase
8252     * all extras.
8253     */
8254    public Intent replaceExtras(Bundle extras) {
8255        mExtras = extras != null ? new Bundle(extras) : null;
8256        return this;
8257    }
8258
8259    /**
8260     * Remove extended data from the intent.
8261     *
8262     * @see #putExtra
8263     */
8264    public void removeExtra(String name) {
8265        if (mExtras != null) {
8266            mExtras.remove(name);
8267            if (mExtras.size() == 0) {
8268                mExtras = null;
8269            }
8270        }
8271    }
8272
8273    /**
8274     * Set special flags controlling how this intent is handled.  Most values
8275     * here depend on the type of component being executed by the Intent,
8276     * specifically the FLAG_ACTIVITY_* flags are all for use with
8277     * {@link Context#startActivity Context.startActivity()} and the
8278     * FLAG_RECEIVER_* flags are all for use with
8279     * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8280     *
8281     * <p>See the
8282     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
8283     * Stack</a> documentation for important information on how some of these options impact
8284     * the behavior of your application.
8285     *
8286     * @param flags The desired flags.
8287     *
8288     * @return Returns the same Intent object, for chaining multiple calls
8289     * into a single statement.
8290     *
8291     * @see #getFlags
8292     * @see #addFlags
8293     * @see #removeFlags
8294     *
8295     * @see #FLAG_GRANT_READ_URI_PERMISSION
8296     * @see #FLAG_GRANT_WRITE_URI_PERMISSION
8297     * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
8298     * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
8299     * @see #FLAG_DEBUG_LOG_RESOLUTION
8300     * @see #FLAG_FROM_BACKGROUND
8301     * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
8302     * @see #FLAG_ACTIVITY_CLEAR_TASK
8303     * @see #FLAG_ACTIVITY_CLEAR_TOP
8304     * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
8305     * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
8306     * @see #FLAG_ACTIVITY_FORWARD_RESULT
8307     * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
8308     * @see #FLAG_ACTIVITY_MULTIPLE_TASK
8309     * @see #FLAG_ACTIVITY_NEW_DOCUMENT
8310     * @see #FLAG_ACTIVITY_NEW_TASK
8311     * @see #FLAG_ACTIVITY_NO_ANIMATION
8312     * @see #FLAG_ACTIVITY_NO_HISTORY
8313     * @see #FLAG_ACTIVITY_NO_USER_ACTION
8314     * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
8315     * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8316     * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
8317     * @see #FLAG_ACTIVITY_SINGLE_TOP
8318     * @see #FLAG_ACTIVITY_TASK_ON_HOME
8319     * @see #FLAG_RECEIVER_REGISTERED_ONLY
8320     */
8321    public Intent setFlags(int flags) {
8322        mFlags = flags;
8323        return this;
8324    }
8325
8326    /**
8327     * Add additional flags to the intent (or with existing flags value).
8328     *
8329     * @param flags The new flags to set.
8330     * @return Returns the same Intent object, for chaining multiple calls into
8331     *         a single statement.
8332     * @see #setFlags(int)
8333     * @see #removeFlags(int)
8334     */
8335    public Intent addFlags(int flags) {
8336        mFlags |= flags;
8337        return this;
8338    }
8339
8340    /**
8341     * Remove these flags from the intent.
8342     *
8343     * @param flags The flags to remove.
8344     * @see #setFlags(int)
8345     * @see #addFlags(int)
8346     */
8347    public void removeFlags(int flags) {
8348        mFlags &= ~flags;
8349    }
8350
8351    /**
8352     * (Usually optional) Set an explicit application package name that limits
8353     * the components this Intent will resolve to.  If left to the default
8354     * value of null, all components in all applications will considered.
8355     * If non-null, the Intent can only match the components in the given
8356     * application package.
8357     *
8358     * @param packageName The name of the application package to handle the
8359     * intent, or null to allow any application package.
8360     *
8361     * @return Returns the same Intent object, for chaining multiple calls
8362     * into a single statement.
8363     *
8364     * @see #getPackage
8365     * @see #resolveActivity
8366     */
8367    public Intent setPackage(String packageName) {
8368        if (packageName != null && mSelector != null) {
8369            throw new IllegalArgumentException(
8370                    "Can't set package name when selector is already set");
8371        }
8372        mPackage = packageName;
8373        return this;
8374    }
8375
8376    /**
8377     * (Usually optional) Explicitly set the component to handle the intent.
8378     * If left with the default value of null, the system will determine the
8379     * appropriate class to use based on the other fields (action, data,
8380     * type, categories) in the Intent.  If this class is defined, the
8381     * specified class will always be used regardless of the other fields.  You
8382     * should only set this value when you know you absolutely want a specific
8383     * class to be used; otherwise it is better to let the system find the
8384     * appropriate class so that you will respect the installed applications
8385     * and user preferences.
8386     *
8387     * @param component The name of the application component to handle the
8388     * intent, or null to let the system find one for you.
8389     *
8390     * @return Returns the same Intent object, for chaining multiple calls
8391     * into a single statement.
8392     *
8393     * @see #setClass
8394     * @see #setClassName(Context, String)
8395     * @see #setClassName(String, String)
8396     * @see #getComponent
8397     * @see #resolveActivity
8398     */
8399    public Intent setComponent(ComponentName component) {
8400        mComponent = component;
8401        return this;
8402    }
8403
8404    /**
8405     * Convenience for calling {@link #setComponent} with an
8406     * explicit class name.
8407     *
8408     * @param packageContext A Context of the application package implementing
8409     * this class.
8410     * @param className The name of a class inside of the application package
8411     * that will be used as the component for this Intent.
8412     *
8413     * @return Returns the same Intent object, for chaining multiple calls
8414     * into a single statement.
8415     *
8416     * @see #setComponent
8417     * @see #setClass
8418     */
8419    public Intent setClassName(Context packageContext, String className) {
8420        mComponent = new ComponentName(packageContext, className);
8421        return this;
8422    }
8423
8424    /**
8425     * Convenience for calling {@link #setComponent} with an
8426     * explicit application package name and class name.
8427     *
8428     * @param packageName The name of the package implementing the desired
8429     * component.
8430     * @param className The name of a class inside of the application package
8431     * that will be used as the component for this Intent.
8432     *
8433     * @return Returns the same Intent object, for chaining multiple calls
8434     * into a single statement.
8435     *
8436     * @see #setComponent
8437     * @see #setClass
8438     */
8439    public Intent setClassName(String packageName, String className) {
8440        mComponent = new ComponentName(packageName, className);
8441        return this;
8442    }
8443
8444    /**
8445     * Convenience for calling {@link #setComponent(ComponentName)} with the
8446     * name returned by a {@link Class} object.
8447     *
8448     * @param packageContext A Context of the application package implementing
8449     * this class.
8450     * @param cls The class name to set, equivalent to
8451     *            <code>setClassName(context, cls.getName())</code>.
8452     *
8453     * @return Returns the same Intent object, for chaining multiple calls
8454     * into a single statement.
8455     *
8456     * @see #setComponent
8457     */
8458    public Intent setClass(Context packageContext, Class<?> cls) {
8459        mComponent = new ComponentName(packageContext, cls);
8460        return this;
8461    }
8462
8463    /**
8464     * Set the bounds of the sender of this intent, in screen coordinates.  This can be
8465     * used as a hint to the receiver for animations and the like.  Null means that there
8466     * is no source bounds.
8467     */
8468    public void setSourceBounds(Rect r) {
8469        if (r != null) {
8470            mSourceBounds = new Rect(r);
8471        } else {
8472            mSourceBounds = null;
8473        }
8474    }
8475
8476    /** @hide */
8477    @IntDef(flag = true,
8478            value = {
8479                    FILL_IN_ACTION,
8480                    FILL_IN_DATA,
8481                    FILL_IN_CATEGORIES,
8482                    FILL_IN_COMPONENT,
8483                    FILL_IN_PACKAGE,
8484                    FILL_IN_SOURCE_BOUNDS,
8485                    FILL_IN_SELECTOR,
8486                    FILL_IN_CLIP_DATA
8487            })
8488    @Retention(RetentionPolicy.SOURCE)
8489    public @interface FillInFlags {}
8490
8491    /**
8492     * Use with {@link #fillIn} to allow the current action value to be
8493     * overwritten, even if it is already set.
8494     */
8495    public static final int FILL_IN_ACTION = 1<<0;
8496
8497    /**
8498     * Use with {@link #fillIn} to allow the current data or type value
8499     * overwritten, even if it is already set.
8500     */
8501    public static final int FILL_IN_DATA = 1<<1;
8502
8503    /**
8504     * Use with {@link #fillIn} to allow the current categories to be
8505     * overwritten, even if they are already set.
8506     */
8507    public static final int FILL_IN_CATEGORIES = 1<<2;
8508
8509    /**
8510     * Use with {@link #fillIn} to allow the current component value to be
8511     * overwritten, even if it is already set.
8512     */
8513    public static final int FILL_IN_COMPONENT = 1<<3;
8514
8515    /**
8516     * Use with {@link #fillIn} to allow the current package value to be
8517     * overwritten, even if it is already set.
8518     */
8519    public static final int FILL_IN_PACKAGE = 1<<4;
8520
8521    /**
8522     * Use with {@link #fillIn} to allow the current bounds rectangle to be
8523     * overwritten, even if it is already set.
8524     */
8525    public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8526
8527    /**
8528     * Use with {@link #fillIn} to allow the current selector to be
8529     * overwritten, even if it is already set.
8530     */
8531    public static final int FILL_IN_SELECTOR = 1<<6;
8532
8533    /**
8534     * Use with {@link #fillIn} to allow the current ClipData to be
8535     * overwritten, even if it is already set.
8536     */
8537    public static final int FILL_IN_CLIP_DATA = 1<<7;
8538
8539    /**
8540     * Copy the contents of <var>other</var> in to this object, but only
8541     * where fields are not defined by this object.  For purposes of a field
8542     * being defined, the following pieces of data in the Intent are
8543     * considered to be separate fields:
8544     *
8545     * <ul>
8546     * <li> action, as set by {@link #setAction}.
8547     * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
8548     * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8549     * <li> categories, as set by {@link #addCategory}.
8550     * <li> package, as set by {@link #setPackage}.
8551     * <li> component, as set by {@link #setComponent(ComponentName)} or
8552     * related methods.
8553     * <li> source bounds, as set by {@link #setSourceBounds}.
8554     * <li> selector, as set by {@link #setSelector(Intent)}.
8555     * <li> clip data, as set by {@link #setClipData(ClipData)}.
8556     * <li> each top-level name in the associated extras.
8557     * </ul>
8558     *
8559     * <p>In addition, you can use the {@link #FILL_IN_ACTION},
8560     * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
8561     * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8562     * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8563     * the restriction where the corresponding field will not be replaced if
8564     * it is already set.
8565     *
8566     * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8567     * is explicitly specified.  The selector will only be copied if
8568     * {@link #FILL_IN_SELECTOR} is explicitly specified.
8569     *
8570     * <p>For example, consider Intent A with {data="foo", categories="bar"}
8571     * and Intent B with {action="gotit", data-type="some/thing",
8572     * categories="one","two"}.
8573     *
8574     * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8575     * containing: {action="gotit", data-type="some/thing",
8576     * categories="bar"}.
8577     *
8578     * @param other Another Intent whose values are to be used to fill in
8579     * the current one.
8580     * @param flags Options to control which fields can be filled in.
8581     *
8582     * @return Returns a bit mask of {@link #FILL_IN_ACTION},
8583     * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
8584     * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8585     * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
8586     * changed.
8587     */
8588    @FillInFlags
8589    public int fillIn(Intent other, @FillInFlags int flags) {
8590        int changes = 0;
8591        boolean mayHaveCopiedUris = false;
8592        if (other.mAction != null
8593                && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
8594            mAction = other.mAction;
8595            changes |= FILL_IN_ACTION;
8596        }
8597        if ((other.mData != null || other.mType != null)
8598                && ((mData == null && mType == null)
8599                        || (flags&FILL_IN_DATA) != 0)) {
8600            mData = other.mData;
8601            mType = other.mType;
8602            changes |= FILL_IN_DATA;
8603            mayHaveCopiedUris = true;
8604        }
8605        if (other.mCategories != null
8606                && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
8607            if (other.mCategories != null) {
8608                mCategories = new ArraySet<String>(other.mCategories);
8609            }
8610            changes |= FILL_IN_CATEGORIES;
8611        }
8612        if (other.mPackage != null
8613                && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
8614            // Only do this if mSelector is not set.
8615            if (mSelector == null) {
8616                mPackage = other.mPackage;
8617                changes |= FILL_IN_PACKAGE;
8618            }
8619        }
8620        // Selector is special: it can only be set if explicitly allowed,
8621        // for the same reason as the component name.
8622        if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8623            if (mPackage == null) {
8624                mSelector = new Intent(other.mSelector);
8625                mPackage = null;
8626                changes |= FILL_IN_SELECTOR;
8627            }
8628        }
8629        if (other.mClipData != null
8630                && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8631            mClipData = other.mClipData;
8632            changes |= FILL_IN_CLIP_DATA;
8633            mayHaveCopiedUris = true;
8634        }
8635        // Component is special: it can -only- be set if explicitly allowed,
8636        // since otherwise the sender could force the intent somewhere the
8637        // originator didn't intend.
8638        if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
8639            mComponent = other.mComponent;
8640            changes |= FILL_IN_COMPONENT;
8641        }
8642        mFlags |= other.mFlags;
8643        if (other.mSourceBounds != null
8644                && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8645            mSourceBounds = new Rect(other.mSourceBounds);
8646            changes |= FILL_IN_SOURCE_BOUNDS;
8647        }
8648        if (mExtras == null) {
8649            if (other.mExtras != null) {
8650                mExtras = new Bundle(other.mExtras);
8651                mayHaveCopiedUris = true;
8652            }
8653        } else if (other.mExtras != null) {
8654            try {
8655                Bundle newb = new Bundle(other.mExtras);
8656                newb.putAll(mExtras);
8657                mExtras = newb;
8658                mayHaveCopiedUris = true;
8659            } catch (RuntimeException e) {
8660                // Modifying the extras can cause us to unparcel the contents
8661                // of the bundle, and if we do this in the system process that
8662                // may fail.  We really should handle this (i.e., the Bundle
8663                // impl shouldn't be on top of a plain map), but for now just
8664                // ignore it and keep the original contents. :(
8665                Log.w("Intent", "Failure filling in extras", e);
8666            }
8667        }
8668        if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8669                && other.mContentUserHint != UserHandle.USER_CURRENT) {
8670            mContentUserHint = other.mContentUserHint;
8671        }
8672        return changes;
8673    }
8674
8675    /**
8676     * Wrapper class holding an Intent and implementing comparisons on it for
8677     * the purpose of filtering.  The class implements its
8678     * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8679     * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
8680     * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
8681     * on the wrapped Intent.
8682     */
8683    public static final class FilterComparison {
8684        private final Intent mIntent;
8685        private final int mHashCode;
8686
8687        public FilterComparison(Intent intent) {
8688            mIntent = intent;
8689            mHashCode = intent.filterHashCode();
8690        }
8691
8692        /**
8693         * Return the Intent that this FilterComparison represents.
8694         * @return Returns the Intent held by the FilterComparison.  Do
8695         * not modify!
8696         */
8697        public Intent getIntent() {
8698            return mIntent;
8699        }
8700
8701        @Override
8702        public boolean equals(Object obj) {
8703            if (obj instanceof FilterComparison) {
8704                Intent other = ((FilterComparison)obj).mIntent;
8705                return mIntent.filterEquals(other);
8706            }
8707            return false;
8708        }
8709
8710        @Override
8711        public int hashCode() {
8712            return mHashCode;
8713        }
8714    }
8715
8716    /**
8717     * Determine if two intents are the same for the purposes of intent
8718     * resolution (filtering). That is, if their action, data, type,
8719     * class, and categories are the same.  This does <em>not</em> compare
8720     * any extra data included in the intents.
8721     *
8722     * @param other The other Intent to compare against.
8723     *
8724     * @return Returns true if action, data, type, class, and categories
8725     *         are the same.
8726     */
8727    public boolean filterEquals(Intent other) {
8728        if (other == null) {
8729            return false;
8730        }
8731        if (!Objects.equals(this.mAction, other.mAction)) return false;
8732        if (!Objects.equals(this.mData, other.mData)) return false;
8733        if (!Objects.equals(this.mType, other.mType)) return false;
8734        if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8735        if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8736        if (!Objects.equals(this.mCategories, other.mCategories)) return false;
8737
8738        return true;
8739    }
8740
8741    /**
8742     * Generate hash code that matches semantics of filterEquals().
8743     *
8744     * @return Returns the hash value of the action, data, type, class, and
8745     *         categories.
8746     *
8747     * @see #filterEquals
8748     */
8749    public int filterHashCode() {
8750        int code = 0;
8751        if (mAction != null) {
8752            code += mAction.hashCode();
8753        }
8754        if (mData != null) {
8755            code += mData.hashCode();
8756        }
8757        if (mType != null) {
8758            code += mType.hashCode();
8759        }
8760        if (mPackage != null) {
8761            code += mPackage.hashCode();
8762        }
8763        if (mComponent != null) {
8764            code += mComponent.hashCode();
8765        }
8766        if (mCategories != null) {
8767            code += mCategories.hashCode();
8768        }
8769        return code;
8770    }
8771
8772    @Override
8773    public String toString() {
8774        StringBuilder b = new StringBuilder(128);
8775
8776        b.append("Intent { ");
8777        toShortString(b, true, true, true, false);
8778        b.append(" }");
8779
8780        return b.toString();
8781    }
8782
8783    /** @hide */
8784    public String toInsecureString() {
8785        StringBuilder b = new StringBuilder(128);
8786
8787        b.append("Intent { ");
8788        toShortString(b, false, true, true, false);
8789        b.append(" }");
8790
8791        return b.toString();
8792    }
8793
8794    /** @hide */
8795    public String toInsecureStringWithClip() {
8796        StringBuilder b = new StringBuilder(128);
8797
8798        b.append("Intent { ");
8799        toShortString(b, false, true, true, true);
8800        b.append(" }");
8801
8802        return b.toString();
8803    }
8804
8805    /** @hide */
8806    public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8807        StringBuilder b = new StringBuilder(128);
8808        toShortString(b, secure, comp, extras, clip);
8809        return b.toString();
8810    }
8811
8812    /** @hide */
8813    public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8814            boolean clip) {
8815        boolean first = true;
8816        if (mAction != null) {
8817            b.append("act=").append(mAction);
8818            first = false;
8819        }
8820        if (mCategories != null) {
8821            if (!first) {
8822                b.append(' ');
8823            }
8824            first = false;
8825            b.append("cat=[");
8826            for (int i=0; i<mCategories.size(); i++) {
8827                if (i > 0) b.append(',');
8828                b.append(mCategories.valueAt(i));
8829            }
8830            b.append("]");
8831        }
8832        if (mData != null) {
8833            if (!first) {
8834                b.append(' ');
8835            }
8836            first = false;
8837            b.append("dat=");
8838            if (secure) {
8839                b.append(mData.toSafeString());
8840            } else {
8841                b.append(mData);
8842            }
8843        }
8844        if (mType != null) {
8845            if (!first) {
8846                b.append(' ');
8847            }
8848            first = false;
8849            b.append("typ=").append(mType);
8850        }
8851        if (mFlags != 0) {
8852            if (!first) {
8853                b.append(' ');
8854            }
8855            first = false;
8856            b.append("flg=0x").append(Integer.toHexString(mFlags));
8857        }
8858        if (mPackage != null) {
8859            if (!first) {
8860                b.append(' ');
8861            }
8862            first = false;
8863            b.append("pkg=").append(mPackage);
8864        }
8865        if (comp && mComponent != null) {
8866            if (!first) {
8867                b.append(' ');
8868            }
8869            first = false;
8870            b.append("cmp=").append(mComponent.flattenToShortString());
8871        }
8872        if (mSourceBounds != null) {
8873            if (!first) {
8874                b.append(' ');
8875            }
8876            first = false;
8877            b.append("bnds=").append(mSourceBounds.toShortString());
8878        }
8879        if (mClipData != null) {
8880            if (!first) {
8881                b.append(' ');
8882            }
8883            b.append("clip={");
8884            if (clip) {
8885                mClipData.toShortString(b);
8886            } else {
8887                if (mClipData.getDescription() != null) {
8888                    first = !mClipData.getDescription().toShortStringTypesOnly(b);
8889                } else {
8890                    first = true;
8891                }
8892                mClipData.toShortStringShortItems(b, first);
8893            }
8894            first = false;
8895            b.append('}');
8896        }
8897        if (extras && mExtras != null) {
8898            if (!first) {
8899                b.append(' ');
8900            }
8901            first = false;
8902            b.append("(has extras)");
8903        }
8904        if (mContentUserHint != UserHandle.USER_CURRENT) {
8905            if (!first) {
8906                b.append(' ');
8907            }
8908            first = false;
8909            b.append("u=").append(mContentUserHint);
8910        }
8911        if (mSelector != null) {
8912            b.append(" sel=");
8913            mSelector.toShortString(b, secure, comp, extras, clip);
8914            b.append("}");
8915        }
8916    }
8917
8918    /**
8919     * Call {@link #toUri} with 0 flags.
8920     * @deprecated Use {@link #toUri} instead.
8921     */
8922    @Deprecated
8923    public String toURI() {
8924        return toUri(0);
8925    }
8926
8927    /**
8928     * Convert this Intent into a String holding a URI representation of it.
8929     * The returned URI string has been properly URI encoded, so it can be
8930     * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
8931     * Intent's data as the base URI, with an additional fragment describing
8932     * the action, categories, type, flags, package, component, and extras.
8933     *
8934     * <p>You can convert the returned string back to an Intent with
8935     * {@link #getIntent}.
8936     *
8937     * @param flags Additional operating flags.  Either 0,
8938     * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
8939     *
8940     * @return Returns a URI encoding URI string describing the entire contents
8941     * of the Intent.
8942     */
8943    public String toUri(int flags) {
8944        StringBuilder uri = new StringBuilder(128);
8945        if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8946            if (mPackage == null) {
8947                throw new IllegalArgumentException(
8948                        "Intent must include an explicit package name to build an android-app: "
8949                        + this);
8950            }
8951            uri.append("android-app://");
8952            uri.append(mPackage);
8953            String scheme = null;
8954            if (mData != null) {
8955                scheme = mData.getScheme();
8956                if (scheme != null) {
8957                    uri.append('/');
8958                    uri.append(scheme);
8959                    String authority = mData.getEncodedAuthority();
8960                    if (authority != null) {
8961                        uri.append('/');
8962                        uri.append(authority);
8963                        String path = mData.getEncodedPath();
8964                        if (path != null) {
8965                            uri.append(path);
8966                        }
8967                        String queryParams = mData.getEncodedQuery();
8968                        if (queryParams != null) {
8969                            uri.append('?');
8970                            uri.append(queryParams);
8971                        }
8972                        String fragment = mData.getEncodedFragment();
8973                        if (fragment != null) {
8974                            uri.append('#');
8975                            uri.append(fragment);
8976                        }
8977                    }
8978                }
8979            }
8980            toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8981                    mPackage, flags);
8982            return uri.toString();
8983        }
8984        String scheme = null;
8985        if (mData != null) {
8986            String data = mData.toString();
8987            if ((flags&URI_INTENT_SCHEME) != 0) {
8988                final int N = data.length();
8989                for (int i=0; i<N; i++) {
8990                    char c = data.charAt(i);
8991                    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8992                            || c == '.' || c == '-') {
8993                        continue;
8994                    }
8995                    if (c == ':' && i > 0) {
8996                        // Valid scheme.
8997                        scheme = data.substring(0, i);
8998                        uri.append("intent:");
8999                        data = data.substring(i+1);
9000                        break;
9001                    }
9002
9003                    // No scheme.
9004                    break;
9005                }
9006            }
9007            uri.append(data);
9008
9009        } else if ((flags&URI_INTENT_SCHEME) != 0) {
9010            uri.append("intent:");
9011        }
9012
9013        toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
9014
9015        return uri.toString();
9016    }
9017
9018    private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9019            String defPackage, int flags) {
9020        StringBuilder frag = new StringBuilder(128);
9021
9022        toUriInner(frag, scheme, defAction, defPackage, flags);
9023        if (mSelector != null) {
9024            frag.append("SEL;");
9025            // Note that for now we are not going to try to handle the
9026            // data part; not clear how to represent this as a URI, and
9027            // not much utility in it.
9028            mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9029                    null, null, flags);
9030        }
9031
9032        if (frag.length() > 0) {
9033            uri.append("#Intent;");
9034            uri.append(frag);
9035            uri.append("end");
9036        }
9037    }
9038
9039    private void toUriInner(StringBuilder uri, String scheme, String defAction,
9040            String defPackage, int flags) {
9041        if (scheme != null) {
9042            uri.append("scheme=").append(scheme).append(';');
9043        }
9044        if (mAction != null && !mAction.equals(defAction)) {
9045            uri.append("action=").append(Uri.encode(mAction)).append(';');
9046        }
9047        if (mCategories != null) {
9048            for (int i=0; i<mCategories.size(); i++) {
9049                uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
9050            }
9051        }
9052        if (mType != null) {
9053            uri.append("type=").append(Uri.encode(mType, "/")).append(';');
9054        }
9055        if (mFlags != 0) {
9056            uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9057        }
9058        if (mPackage != null && !mPackage.equals(defPackage)) {
9059            uri.append("package=").append(Uri.encode(mPackage)).append(';');
9060        }
9061        if (mComponent != null) {
9062            uri.append("component=").append(Uri.encode(
9063                    mComponent.flattenToShortString(), "/")).append(';');
9064        }
9065        if (mSourceBounds != null) {
9066            uri.append("sourceBounds=")
9067                    .append(Uri.encode(mSourceBounds.flattenToString()))
9068                    .append(';');
9069        }
9070        if (mExtras != null) {
9071            for (String key : mExtras.keySet()) {
9072                final Object value = mExtras.get(key);
9073                char entryType =
9074                        value instanceof String    ? 'S' :
9075                        value instanceof Boolean   ? 'B' :
9076                        value instanceof Byte      ? 'b' :
9077                        value instanceof Character ? 'c' :
9078                        value instanceof Double    ? 'd' :
9079                        value instanceof Float     ? 'f' :
9080                        value instanceof Integer   ? 'i' :
9081                        value instanceof Long      ? 'l' :
9082                        value instanceof Short     ? 's' :
9083                        '\0';
9084
9085                if (entryType != '\0') {
9086                    uri.append(entryType);
9087                    uri.append('.');
9088                    uri.append(Uri.encode(key));
9089                    uri.append('=');
9090                    uri.append(Uri.encode(value.toString()));
9091                    uri.append(';');
9092                }
9093            }
9094        }
9095    }
9096
9097    public int describeContents() {
9098        return (mExtras != null) ? mExtras.describeContents() : 0;
9099    }
9100
9101    public void writeToParcel(Parcel out, int flags) {
9102        out.writeString(mAction);
9103        Uri.writeToParcel(out, mData);
9104        out.writeString(mType);
9105        out.writeInt(mFlags);
9106        out.writeString(mPackage);
9107        ComponentName.writeToParcel(mComponent, out);
9108
9109        if (mSourceBounds != null) {
9110            out.writeInt(1);
9111            mSourceBounds.writeToParcel(out, flags);
9112        } else {
9113            out.writeInt(0);
9114        }
9115
9116        if (mCategories != null) {
9117            final int N = mCategories.size();
9118            out.writeInt(N);
9119            for (int i=0; i<N; i++) {
9120                out.writeString(mCategories.valueAt(i));
9121            }
9122        } else {
9123            out.writeInt(0);
9124        }
9125
9126        if (mSelector != null) {
9127            out.writeInt(1);
9128            mSelector.writeToParcel(out, flags);
9129        } else {
9130            out.writeInt(0);
9131        }
9132
9133        if (mClipData != null) {
9134            out.writeInt(1);
9135            mClipData.writeToParcel(out, flags);
9136        } else {
9137            out.writeInt(0);
9138        }
9139        out.writeInt(mContentUserHint);
9140        out.writeBundle(mExtras);
9141    }
9142
9143    public static final Parcelable.Creator<Intent> CREATOR
9144            = new Parcelable.Creator<Intent>() {
9145        public Intent createFromParcel(Parcel in) {
9146            return new Intent(in);
9147        }
9148        public Intent[] newArray(int size) {
9149            return new Intent[size];
9150        }
9151    };
9152
9153    /** @hide */
9154    protected Intent(Parcel in) {
9155        readFromParcel(in);
9156    }
9157
9158    public void readFromParcel(Parcel in) {
9159        setAction(in.readString());
9160        mData = Uri.CREATOR.createFromParcel(in);
9161        mType = in.readString();
9162        mFlags = in.readInt();
9163        mPackage = in.readString();
9164        mComponent = ComponentName.readFromParcel(in);
9165
9166        if (in.readInt() != 0) {
9167            mSourceBounds = Rect.CREATOR.createFromParcel(in);
9168        }
9169
9170        int N = in.readInt();
9171        if (N > 0) {
9172            mCategories = new ArraySet<String>();
9173            int i;
9174            for (i=0; i<N; i++) {
9175                mCategories.add(in.readString().intern());
9176            }
9177        } else {
9178            mCategories = null;
9179        }
9180
9181        if (in.readInt() != 0) {
9182            mSelector = new Intent(in);
9183        }
9184
9185        if (in.readInt() != 0) {
9186            mClipData = new ClipData(in);
9187        }
9188        mContentUserHint = in.readInt();
9189        mExtras = in.readBundle();
9190    }
9191
9192    /**
9193     * Parses the "intent" element (and its children) from XML and instantiates
9194     * an Intent object.  The given XML parser should be located at the tag
9195     * where parsing should start (often named "intent"), from which the
9196     * basic action, data, type, and package and class name will be
9197     * retrieved.  The function will then parse in to any child elements,
9198     * looking for <category android:name="xxx"> tags to add categories and
9199     * <extra android:name="xxx" android:value="yyy"> to attach extra data
9200     * to the intent.
9201     *
9202     * @param resources The Resources to use when inflating resources.
9203     * @param parser The XML parser pointing at an "intent" tag.
9204     * @param attrs The AttributeSet interface for retrieving extended
9205     * attribute data at the current <var>parser</var> location.
9206     * @return An Intent object matching the XML data.
9207     * @throws XmlPullParserException If there was an XML parsing error.
9208     * @throws IOException If there was an I/O error.
9209     */
9210    public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
9211            throws XmlPullParserException, IOException {
9212        Intent intent = new Intent();
9213
9214        TypedArray sa = resources.obtainAttributes(attrs,
9215                com.android.internal.R.styleable.Intent);
9216
9217        intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9218
9219        String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9220        String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9221        intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9222
9223        String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9224        String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9225        if (packageName != null && className != null) {
9226            intent.setComponent(new ComponentName(packageName, className));
9227        }
9228
9229        sa.recycle();
9230
9231        int outerDepth = parser.getDepth();
9232        int type;
9233        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9234               && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9235            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9236                continue;
9237            }
9238
9239            String nodeName = parser.getName();
9240            if (nodeName.equals(TAG_CATEGORIES)) {
9241                sa = resources.obtainAttributes(attrs,
9242                        com.android.internal.R.styleable.IntentCategory);
9243                String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9244                sa.recycle();
9245
9246                if (cat != null) {
9247                    intent.addCategory(cat);
9248                }
9249                XmlUtils.skipCurrentTag(parser);
9250
9251            } else if (nodeName.equals(TAG_EXTRA)) {
9252                if (intent.mExtras == null) {
9253                    intent.mExtras = new Bundle();
9254                }
9255                resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
9256                XmlUtils.skipCurrentTag(parser);
9257
9258            } else {
9259                XmlUtils.skipCurrentTag(parser);
9260            }
9261        }
9262
9263        return intent;
9264    }
9265
9266    /** @hide */
9267    public void saveToXml(XmlSerializer out) throws IOException {
9268        if (mAction != null) {
9269            out.attribute(null, ATTR_ACTION, mAction);
9270        }
9271        if (mData != null) {
9272            out.attribute(null, ATTR_DATA, mData.toString());
9273        }
9274        if (mType != null) {
9275            out.attribute(null, ATTR_TYPE, mType);
9276        }
9277        if (mComponent != null) {
9278            out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
9279        }
9280        out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
9281
9282        if (mCategories != null) {
9283            out.startTag(null, TAG_CATEGORIES);
9284            for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
9285                out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
9286            }
9287            out.endTag(null, TAG_CATEGORIES);
9288        }
9289    }
9290
9291    /** @hide */
9292    public static Intent restoreFromXml(XmlPullParser in) throws IOException,
9293            XmlPullParserException {
9294        Intent intent = new Intent();
9295        final int outerDepth = in.getDepth();
9296
9297        int attrCount = in.getAttributeCount();
9298        for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9299            final String attrName = in.getAttributeName(attrNdx);
9300            final String attrValue = in.getAttributeValue(attrNdx);
9301            if (ATTR_ACTION.equals(attrName)) {
9302                intent.setAction(attrValue);
9303            } else if (ATTR_DATA.equals(attrName)) {
9304                intent.setData(Uri.parse(attrValue));
9305            } else if (ATTR_TYPE.equals(attrName)) {
9306                intent.setType(attrValue);
9307            } else if (ATTR_COMPONENT.equals(attrName)) {
9308                intent.setComponent(ComponentName.unflattenFromString(attrValue));
9309            } else if (ATTR_FLAGS.equals(attrName)) {
9310                intent.setFlags(Integer.parseInt(attrValue, 16));
9311            } else {
9312                Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
9313            }
9314        }
9315
9316        int event;
9317        String name;
9318        while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
9319                (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
9320            if (event == XmlPullParser.START_TAG) {
9321                name = in.getName();
9322                if (TAG_CATEGORIES.equals(name)) {
9323                    attrCount = in.getAttributeCount();
9324                    for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
9325                        intent.addCategory(in.getAttributeValue(attrNdx));
9326                    }
9327                } else {
9328                    Log.w("Intent", "restoreFromXml: unknown name=" + name);
9329                    XmlUtils.skipCurrentTag(in);
9330                }
9331            }
9332        }
9333
9334        return intent;
9335    }
9336
9337    /**
9338     * Normalize a MIME data type.
9339     *
9340     * <p>A normalized MIME type has white-space trimmed,
9341     * content-type parameters removed, and is lower-case.
9342     * This aligns the type with Android best practices for
9343     * intent filtering.
9344     *
9345     * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
9346     * "text/x-vCard" becomes "text/x-vcard".
9347     *
9348     * <p>All MIME types received from outside Android (such as user input,
9349     * or external sources like Bluetooth, NFC, or the Internet) should
9350     * be normalized before they are used to create an Intent.
9351     *
9352     * @param type MIME data type to normalize
9353     * @return normalized MIME data type, or null if the input was null
9354     * @see #setType
9355     * @see #setTypeAndNormalize
9356     */
9357    public static String normalizeMimeType(String type) {
9358        if (type == null) {
9359            return null;
9360        }
9361
9362        type = type.trim().toLowerCase(Locale.ROOT);
9363
9364        final int semicolonIndex = type.indexOf(';');
9365        if (semicolonIndex != -1) {
9366            type = type.substring(0, semicolonIndex);
9367        }
9368        return type;
9369    }
9370
9371    /**
9372     * Prepare this {@link Intent} to leave an app process.
9373     *
9374     * @hide
9375     */
9376    public void prepareToLeaveProcess(Context context) {
9377        final boolean leavingPackage = (mComponent == null)
9378                || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
9379        prepareToLeaveProcess(leavingPackage);
9380    }
9381
9382    /**
9383     * Prepare this {@link Intent} to leave an app process.
9384     *
9385     * @hide
9386     */
9387    public void prepareToLeaveProcess(boolean leavingPackage) {
9388        setAllowFds(false);
9389
9390        if (mSelector != null) {
9391            mSelector.prepareToLeaveProcess(leavingPackage);
9392        }
9393        if (mClipData != null) {
9394            mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
9395        }
9396
9397        if (mExtras != null && !mExtras.isParcelled()) {
9398            final Object intent = mExtras.get(Intent.EXTRA_INTENT);
9399            if (intent instanceof Intent) {
9400                ((Intent) intent).prepareToLeaveProcess(leavingPackage);
9401            }
9402        }
9403
9404        if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
9405                && leavingPackage) {
9406            switch (mAction) {
9407                case ACTION_MEDIA_REMOVED:
9408                case ACTION_MEDIA_UNMOUNTED:
9409                case ACTION_MEDIA_CHECKING:
9410                case ACTION_MEDIA_NOFS:
9411                case ACTION_MEDIA_MOUNTED:
9412                case ACTION_MEDIA_SHARED:
9413                case ACTION_MEDIA_UNSHARED:
9414                case ACTION_MEDIA_BAD_REMOVAL:
9415                case ACTION_MEDIA_UNMOUNTABLE:
9416                case ACTION_MEDIA_EJECT:
9417                case ACTION_MEDIA_SCANNER_STARTED:
9418                case ACTION_MEDIA_SCANNER_FINISHED:
9419                case ACTION_MEDIA_SCANNER_SCAN_FILE:
9420                case ACTION_PACKAGE_NEEDS_VERIFICATION:
9421                case ACTION_PACKAGE_VERIFIED:
9422                    // Ignore legacy actions
9423                    break;
9424                default:
9425                    mData.checkFileUriExposed("Intent.getData()");
9426            }
9427        }
9428
9429        if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
9430                && leavingPackage) {
9431            switch (mAction) {
9432                case ACTION_PROVIDER_CHANGED:
9433                    // Ignore actions that don't need to grant
9434                    break;
9435                default:
9436                    mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
9437            }
9438        }
9439    }
9440
9441    /**
9442     * @hide
9443     */
9444    public void prepareToEnterProcess() {
9445        // We just entered destination process, so we should be able to read all
9446        // parcelables inside.
9447        setDefusable(true);
9448
9449        if (mSelector != null) {
9450            mSelector.prepareToEnterProcess();
9451        }
9452        if (mClipData != null) {
9453            mClipData.prepareToEnterProcess();
9454        }
9455
9456        if (mContentUserHint != UserHandle.USER_CURRENT) {
9457            if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
9458                fixUris(mContentUserHint);
9459                mContentUserHint = UserHandle.USER_CURRENT;
9460            }
9461        }
9462    }
9463
9464    /**
9465     * @hide
9466     */
9467     public void fixUris(int contentUserHint) {
9468        Uri data = getData();
9469        if (data != null) {
9470            mData = maybeAddUserId(data, contentUserHint);
9471        }
9472        if (mClipData != null) {
9473            mClipData.fixUris(contentUserHint);
9474        }
9475        String action = getAction();
9476        if (ACTION_SEND.equals(action)) {
9477            final Uri stream = getParcelableExtra(EXTRA_STREAM);
9478            if (stream != null) {
9479                putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
9480            }
9481        } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9482            final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9483            if (streams != null) {
9484                ArrayList<Uri> newStreams = new ArrayList<Uri>();
9485                for (int i = 0; i < streams.size(); i++) {
9486                    newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
9487                }
9488                putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
9489            }
9490        } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9491                || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9492                || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9493            final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9494            if (output != null) {
9495                putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
9496            }
9497        }
9498     }
9499
9500    /**
9501     * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
9502     * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
9503     * intents in {@link #ACTION_CHOOSER}.
9504     *
9505     * @return Whether any contents were migrated.
9506     * @hide
9507     */
9508    public boolean migrateExtraStreamToClipData() {
9509        // Refuse to touch if extras already parcelled
9510        if (mExtras != null && mExtras.isParcelled()) return false;
9511
9512        // Bail when someone already gave us ClipData
9513        if (getClipData() != null) return false;
9514
9515        final String action = getAction();
9516        if (ACTION_CHOOSER.equals(action)) {
9517            // Inspect contained intents to see if we need to migrate extras. We
9518            // don't promote ClipData to the parent, since ChooserActivity will
9519            // already start the picked item as the caller, and we can't combine
9520            // the flags in a safe way.
9521
9522            boolean migrated = false;
9523            try {
9524                final Intent intent = getParcelableExtra(EXTRA_INTENT);
9525                if (intent != null) {
9526                    migrated |= intent.migrateExtraStreamToClipData();
9527                }
9528            } catch (ClassCastException e) {
9529            }
9530            try {
9531                final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9532                if (intents != null) {
9533                    for (int i = 0; i < intents.length; i++) {
9534                        final Intent intent = (Intent) intents[i];
9535                        if (intent != null) {
9536                            migrated |= intent.migrateExtraStreamToClipData();
9537                        }
9538                    }
9539                }
9540            } catch (ClassCastException e) {
9541            }
9542            return migrated;
9543
9544        } else if (ACTION_SEND.equals(action)) {
9545            try {
9546                final Uri stream = getParcelableExtra(EXTRA_STREAM);
9547                final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9548                final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9549                if (stream != null || text != null || htmlText != null) {
9550                    final ClipData clipData = new ClipData(
9551                            null, new String[] { getType() },
9552                            new ClipData.Item(text, htmlText, null, stream));
9553                    setClipData(clipData);
9554                    addFlags(FLAG_GRANT_READ_URI_PERMISSION);
9555                    return true;
9556                }
9557            } catch (ClassCastException e) {
9558            }
9559
9560        } else if (ACTION_SEND_MULTIPLE.equals(action)) {
9561            try {
9562                final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9563                final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9564                final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9565                int num = -1;
9566                if (streams != null) {
9567                    num = streams.size();
9568                }
9569                if (texts != null) {
9570                    if (num >= 0 && num != texts.size()) {
9571                        // Wha...!  F- you.
9572                        return false;
9573                    }
9574                    num = texts.size();
9575                }
9576                if (htmlTexts != null) {
9577                    if (num >= 0 && num != htmlTexts.size()) {
9578                        // Wha...!  F- you.
9579                        return false;
9580                    }
9581                    num = htmlTexts.size();
9582                }
9583                if (num > 0) {
9584                    final ClipData clipData = new ClipData(
9585                            null, new String[] { getType() },
9586                            makeClipItem(streams, texts, htmlTexts, 0));
9587
9588                    for (int i = 1; i < num; i++) {
9589                        clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9590                    }
9591
9592                    setClipData(clipData);
9593                    addFlags(FLAG_GRANT_READ_URI_PERMISSION);
9594                    return true;
9595                }
9596            } catch (ClassCastException e) {
9597            }
9598        } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9599                || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9600                || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9601            final Uri output;
9602            try {
9603                output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9604            } catch (ClassCastException e) {
9605                return false;
9606            }
9607            if (output != null) {
9608                setClipData(ClipData.newRawUri("", output));
9609                addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9610                return true;
9611            }
9612        }
9613
9614        return false;
9615    }
9616
9617    private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9618            ArrayList<String> htmlTexts, int which) {
9619        Uri uri = streams != null ? streams.get(which) : null;
9620        CharSequence text = texts != null ? texts.get(which) : null;
9621        String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9622        return new ClipData.Item(text, htmlText, null, uri);
9623    }
9624
9625    /** @hide */
9626    public boolean isDocument() {
9627        return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9628    }
9629}
9630