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