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