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