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