Intent.java revision 6dabe240ed0adcf74d0b5eed37d7085095e20ffd
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 org.xmlpull.v1.XmlPullParser;
20import org.xmlpull.v1.XmlPullParserException;
21
22import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
24import android.content.pm.ActivityInfo;
25import android.content.pm.PackageManager;
26import android.content.pm.ResolveInfo;
27import android.content.res.Resources;
28import android.content.res.TypedArray;
29import android.graphics.Rect;
30import android.net.Uri;
31import android.os.Bundle;
32import android.os.IBinder;
33import android.os.Parcel;
34import android.os.Parcelable;
35import android.util.AttributeSet;
36import android.util.Log;
37
38import com.android.internal.util.XmlUtils;
39
40import java.io.IOException;
41import java.io.Serializable;
42import java.net.URISyntaxException;
43import java.util.ArrayList;
44import java.util.HashSet;
45import java.util.Iterator;
46import java.util.Set;
47
48/**
49 * An intent is an abstract description of an operation to be performed.  It
50 * can be used with {@link Context#startActivity(Intent) startActivity} to
51 * launch an {@link android.app.Activity},
52 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
53 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
54 * and {@link android.content.Context#startService} or
55 * {@link android.content.Context#bindService} to communicate with a
56 * background {@link android.app.Service}.
57 *
58 * <p>An Intent provides a facility for performing late runtime binding between
59 * the code in different applications.  Its most significant use is in the
60 * launching of activities, where it can be thought of as the glue between
61 * activities. It is
62 * basically a passive data structure holding an abstract description of an
63 * action to be performed. The primary pieces of information in an intent
64 * are:</p>
65 *
66 * <ul>
67 *   <li> <p><b>action</b> -- The general action to be performed, such as
68 *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
69 *     etc.</p>
70 *   </li>
71 *   <li> <p><b>data</b> -- The data to operate on, such as a person record
72 *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
73 *   </li>
74 * </ul>
75 *
76 *
77 * <p>Some examples of action/data pairs are:</p>
78 *
79 * <ul>
80 *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
81 *     information about the person whose identifier is "1".</p>
82 *   </li>
83 *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
84 *     the phone dialer with the person filled in.</p>
85 *   </li>
86 *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
87 *     the phone dialer with the given number filled in.  Note how the
88 *     VIEW action does what what is considered the most reasonable thing for
89 *     a particular URI.</p>
90 *   </li>
91 *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
92 *     the phone dialer with the given number filled in.</p>
93 *   </li>
94 *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
95 *     information about the person whose identifier is "1".</p>
96 *   </li>
97 *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
98 *     a list of people, which the user can browse through.  This example is a
99 *     typical top-level entry into the Contacts application, showing you the
100 *     list of people. Selecting a particular person to view would result in a
101 *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
102 *     being used to start an activity to display that person.</p>
103 *   </li>
104 * </ul>
105 *
106 * <p>In addition to these primary attributes, there are a number of secondary
107 * attributes that you can also include with an intent:</p>
108 *
109 * <ul>
110 *     <li> <p><b>category</b> -- Gives additional information about the action
111 *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
112 *         appear in the Launcher as a top-level application, while
113 *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
114 *         of alternative actions the user can perform on a piece of data.</p>
115 *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
116 *         intent data.  Normally the type is inferred from the data itself.
117 *         By setting this attribute, you disable that evaluation and force
118 *         an explicit type.</p>
119 *     <li> <p><b>component</b> -- Specifies an explicit name of a component
120 *         class to use for the intent.  Normally this is determined by looking
121 *         at the other information in the intent (the action, data/type, and
122 *         categories) and matching that with a component that can handle it.
123 *         If this attribute is set then none of the evaluation is performed,
124 *         and this component is used exactly as is.  By specifying this attribute,
125 *         all of the other Intent attributes become optional.</p>
126 *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
127 *         This can be used to provide extended information to the component.
128 *         For example, if we have a action to send an e-mail message, we could
129 *         also include extra pieces of data here to supply a subject, body,
130 *         etc.</p>
131 * </ul>
132 *
133 * <p>Here are some examples of other operations you can specify as intents
134 * using these additional parameters:</p>
135 *
136 * <ul>
137 *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
138 *     Launch the home screen.</p>
139 *   </li>
140 *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
141 *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
142 *     vnd.android.cursor.item/phone}</i></b>
143 *     -- Display the list of people's phone numbers, allowing the user to
144 *     browse through them and pick one and return it to the parent activity.</p>
145 *   </li>
146 *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
147 *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
148 *     -- Display all pickers for data that can be opened with
149 *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
150 *     allowing the user to pick one of them and then some data inside of it
151 *     and returning the resulting URI to the caller.  This can be used,
152 *     for example, in an e-mail application to allow the user to pick some
153 *     data to include as an attachment.</p>
154 *   </li>
155 * </ul>
156 *
157 * <p>There are a variety of standard Intent action and category constants
158 * defined in the Intent class, but applications can also define their own.
159 * These strings use java style scoping, to ensure they are unique -- for
160 * example, the standard {@link #ACTION_VIEW} is called
161 * "android.intent.action.VIEW".</p>
162 *
163 * <p>Put together, the set of actions, data types, categories, and extra data
164 * defines a language for the system allowing for the expression of phrases
165 * such as "call john smith's cell".  As applications are added to the system,
166 * they can extend this language by adding new actions, types, and categories, or
167 * they can modify the behavior of existing phrases by supplying their own
168 * activities that handle them.</p>
169 *
170 * <a name="IntentResolution"></a>
171 * <h3>Intent Resolution</h3>
172 *
173 * <p>There are two primary forms of intents you will use.
174 *
175 * <ul>
176 *     <li> <p><b>Explicit Intents</b> have specified a component (via
177 *     {@link #setComponent} or {@link #setClass}), which provides the exact
178 *     class to be run.  Often these will not include any other information,
179 *     simply being a way for an application to launch various internal
180 *     activities it has as the user interacts with the application.
181 *
182 *     <li> <p><b>Implicit Intents</b> have not specified a component;
183 *     instead, they must include enough information for the system to
184 *     determine which of the available components is best to run for that
185 *     intent.
186 * </ul>
187 *
188 * <p>When using implicit intents, given such an arbitrary intent we need to
189 * know what to do with it. This is handled by the process of <em>Intent
190 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
191 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
192 * more activities/receivers) that can handle it.</p>
193 *
194 * <p>The intent resolution mechanism basically revolves around matching an
195 * Intent against all of the &lt;intent-filter&gt; descriptions in the
196 * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
197 * objects explicitly registered with {@link Context#registerReceiver}.)  More
198 * details on this can be found in the documentation on the {@link
199 * IntentFilter} class.</p>
200 *
201 * <p>There are three pieces of information in the Intent that are used for
202 * resolution: the action, type, and category.  Using this information, a query
203 * is done on the {@link PackageManager} for a component that can handle the
204 * intent. The appropriate component is determined based on the intent
205 * information supplied in the <code>AndroidManifest.xml</code> file as
206 * follows:</p>
207 *
208 * <ul>
209 *     <li> <p>The <b>action</b>, if given, must be listed by the component as
210 *         one it handles.</p>
211 *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
212 *         already supplied in the Intent.  Like the action, if a type is
213 *         included in the intent (either explicitly or implicitly in its
214 *         data), then this must be listed by the component as one it handles.</p>
215 *     <li> For data that is not a <code>content:</code> URI and where no explicit
216 *         type is included in the Intent, instead the <b>scheme</b> of the
217 *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
218 *         considered. Again like the action, if we are matching a scheme it
219 *         must be listed by the component as one it can handle.
220 *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
221 *         by the activity as categories it handles.  That is, if you include
222 *         the categories {@link #CATEGORY_LAUNCHER} and
223 *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
224 *         with an intent that lists <em>both</em> of those categories.
225 *         Activities will very often need to support the
226 *         {@link #CATEGORY_DEFAULT} so that they can be found by
227 *         {@link Context#startActivity Context.startActivity()}.</p>
228 * </ul>
229 *
230 * <p>For example, consider the Note Pad sample application that
231 * allows user to browse through a list of notes data and view details about
232 * individual items.  Text in italics indicate places were you would replace a
233 * name with one specific to your own package.</p>
234 *
235 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
236 *       package="<i>com.android.notepad</i>"&gt;
237 *     &lt;application android:icon="@drawable/app_notes"
238 *             android:label="@string/app_name"&gt;
239 *
240 *         &lt;provider class=".NotePadProvider"
241 *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
242 *
243 *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
244 *             &lt;intent-filter&gt;
245 *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
246 *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
247 *             &lt;/intent-filter&gt;
248 *             &lt;intent-filter&gt;
249 *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
250 *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
251 *                 &lt;action android:name="android.intent.action.PICK" /&gt;
252 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
253 *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
254 *             &lt;/intent-filter&gt;
255 *             &lt;intent-filter&gt;
256 *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
257 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
258 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
259 *             &lt;/intent-filter&gt;
260 *         &lt;/activity&gt;
261 *
262 *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
263 *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
264 *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
265 *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
266 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
267 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
268 *             &lt;/intent-filter&gt;
269 *
270 *             &lt;intent-filter&gt;
271 *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
272 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
273 *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
274 *             &lt;/intent-filter&gt;
275 *
276 *         &lt;/activity&gt;
277 *
278 *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
279 *                 android:theme="@android:style/Theme.Dialog"&gt;
280 *             &lt;intent-filter android:label="@string/resolve_title"&gt;
281 *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
282 *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
284 *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
285 *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
286 *             &lt;/intent-filter&gt;
287 *         &lt;/activity&gt;
288 *
289 *     &lt;/application&gt;
290 * &lt;/manifest&gt;</pre>
291 *
292 * <p>The first activity,
293 * <code>com.android.notepad.NotesList</code>, serves as our main
294 * entry into the app.  It can do three things as described by its three intent
295 * templates:
296 * <ol>
297 * <li><pre>
298 * &lt;intent-filter&gt;
299 *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
300 *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
301 * &lt;/intent-filter&gt;</pre>
302 * <p>This provides a top-level entry into the NotePad application: the standard
303 * MAIN action is a main entry point (not requiring any other information in
304 * the Intent), and the LAUNCHER category says that this entry point should be
305 * listed in the application launcher.</p>
306 * <li><pre>
307 * &lt;intent-filter&gt;
308 *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
309 *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
310 *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
311 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
312 *     &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
313 * &lt;/intent-filter&gt;</pre>
314 * <p>This declares the things that the activity can do on a directory of
315 * notes.  The type being supported is given with the &lt;type&gt; tag, where
316 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
317 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
318 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
319 * The activity allows the user to view or edit the directory of data (via
320 * the VIEW and EDIT actions), or to pick a particular note and return it
321 * to the caller (via the PICK action).  Note also the DEFAULT category
322 * supplied here: this is <em>required</em> for the
323 * {@link Context#startActivity Context.startActivity} method to resolve your
324 * activity when its component name is not explicitly specified.</p>
325 * <li><pre>
326 * &lt;intent-filter&gt;
327 *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
328 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
329 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
330 * &lt;/intent-filter&gt;</pre>
331 * <p>This filter describes the ability return to the caller a note selected by
332 * the user without needing to know where it came from.  The data type
333 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
334 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
335 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
336 * The GET_CONTENT action is similar to the PICK action, where the activity
337 * will return to its caller a piece of data selected by the user.  Here,
338 * however, the caller specifies the type of data they desire instead of
339 * the type of data the user will be picking from.</p>
340 * </ol>
341 *
342 * <p>Given these capabilities, the following intents will resolve to the
343 * NotesList activity:</p>
344 *
345 * <ul>
346 *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
347 *         activities that can be used as top-level entry points into an
348 *         application.</p>
349 *     <li> <p><b>{ action=android.app.action.MAIN,
350 *         category=android.app.category.LAUNCHER }</b> is the actual intent
351 *         used by the Launcher to populate its top-level list.</p>
352 *     <li> <p><b>{ action=android.intent.action.VIEW
353 *          data=content://com.google.provider.NotePad/notes }</b>
354 *         displays a list of all the notes under
355 *         "content://com.google.provider.NotePad/notes", which
356 *         the user can browse through and see the details on.</p>
357 *     <li> <p><b>{ action=android.app.action.PICK
358 *          data=content://com.google.provider.NotePad/notes }</b>
359 *         provides a list of the notes under
360 *         "content://com.google.provider.NotePad/notes", from which
361 *         the user can pick a note whose data URL is returned back to the caller.</p>
362 *     <li> <p><b>{ action=android.app.action.GET_CONTENT
363 *          type=vnd.android.cursor.item/vnd.google.note }</b>
364 *         is similar to the pick action, but allows the caller to specify the
365 *         kind of data they want back so that the system can find the appropriate
366 *         activity to pick something of that data type.</p>
367 * </ul>
368 *
369 * <p>The second activity,
370 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
371 * note entry and allows them to edit it.  It can do two things as described
372 * by its two intent templates:
373 * <ol>
374 * <li><pre>
375 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
376 *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
377 *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
378 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
379 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
380 * &lt;/intent-filter&gt;</pre>
381 * <p>The first, primary, purpose of this activity is to let the user interact
382 * with a single note, as decribed by the MIME type
383 * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
384 * either VIEW a note or allow the user to EDIT it.  Again we support the
385 * DEFAULT category to allow the activity to be launched without explicitly
386 * specifying its component.</p>
387 * <li><pre>
388 * &lt;intent-filter&gt;
389 *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
390 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
391 *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
392 * &lt;/intent-filter&gt;</pre>
393 * <p>The secondary use of this activity is to insert a new note entry into
394 * an existing directory of notes.  This is used when the user creates a new
395 * note: the INSERT action is executed on the directory of notes, causing
396 * this activity to run and have the user create the new note data which
397 * it then adds to the content provider.</p>
398 * </ol>
399 *
400 * <p>Given these capabilities, the following intents will resolve to the
401 * NoteEditor activity:</p>
402 *
403 * <ul>
404 *     <li> <p><b>{ action=android.intent.action.VIEW
405 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
406 *         shows the user the content of note <var>{ID}</var>.</p>
407 *     <li> <p><b>{ action=android.app.action.EDIT
408 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
409 *         allows the user to edit the content of note <var>{ID}</var>.</p>
410 *     <li> <p><b>{ action=android.app.action.INSERT
411 *          data=content://com.google.provider.NotePad/notes }</b>
412 *         creates a new, empty note in the notes list at
413 *         "content://com.google.provider.NotePad/notes"
414 *         and allows the user to edit it.  If they keep their changes, the URI
415 *         of the newly created note is returned to the caller.</p>
416 * </ul>
417 *
418 * <p>The last activity,
419 * <code>com.android.notepad.TitleEditor</code>, allows the user to
420 * edit the title of a note.  This could be implemented as a class that the
421 * application directly invokes (by explicitly setting its component in
422 * the Intent), but here we show a way you can publish alternative
423 * operations on existing data:</p>
424 *
425 * <pre>
426 * &lt;intent-filter android:label="@string/resolve_title"&gt;
427 *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
428 *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
429 *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
430 *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
431 *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
432 * &lt;/intent-filter&gt;</pre>
433 *
434 * <p>In the single intent template here, we
435 * have created our own private action called
436 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
437 * edit the title of a note.  It must be invoked on a specific note
438 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
439 * view and edit actions, but here displays and edits the title contained
440 * in the note data.
441 *
442 * <p>In addition to supporting the default category as usual, our title editor
443 * also supports two other standard categories: ALTERNATIVE and
444 * SELECTED_ALTERNATIVE.  Implementing
445 * these categories allows others to find the special action it provides
446 * without directly knowing about it, through the
447 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
448 * more often to build dynamic menu items with
449 * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
450 * template here was also supply an explicit name for the template
451 * (via <code>android:label="@string/resolve_title"</code>) to better control
452 * what the user sees when presented with this activity as an alternative
453 * action to the data they are viewing.
454 *
455 * <p>Given these capabilities, the following intent will resolve to the
456 * TitleEditor activity:</p>
457 *
458 * <ul>
459 *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
460 *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461 *         displays and allows the user to edit the title associated
462 *         with note <var>{ID}</var>.</p>
463 * </ul>
464 *
465 * <h3>Standard Activity Actions</h3>
466 *
467 * <p>These are the current standard actions that Intent defines for launching
468 * activities (usually through {@link Context#startActivity}.  The most
469 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
470 * {@link #ACTION_EDIT}.
471 *
472 * <ul>
473 *     <li> {@link #ACTION_MAIN}
474 *     <li> {@link #ACTION_VIEW}
475 *     <li> {@link #ACTION_ATTACH_DATA}
476 *     <li> {@link #ACTION_EDIT}
477 *     <li> {@link #ACTION_PICK}
478 *     <li> {@link #ACTION_CHOOSER}
479 *     <li> {@link #ACTION_GET_CONTENT}
480 *     <li> {@link #ACTION_DIAL}
481 *     <li> {@link #ACTION_CALL}
482 *     <li> {@link #ACTION_SEND}
483 *     <li> {@link #ACTION_SENDTO}
484 *     <li> {@link #ACTION_ANSWER}
485 *     <li> {@link #ACTION_INSERT}
486 *     <li> {@link #ACTION_DELETE}
487 *     <li> {@link #ACTION_RUN}
488 *     <li> {@link #ACTION_SYNC}
489 *     <li> {@link #ACTION_PICK_ACTIVITY}
490 *     <li> {@link #ACTION_SEARCH}
491 *     <li> {@link #ACTION_WEB_SEARCH}
492 *     <li> {@link #ACTION_FACTORY_TEST}
493 * </ul>
494 *
495 * <h3>Standard Broadcast Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for receiving
498 * broadcasts (usually through {@link Context#registerReceiver} or a
499 * &lt;receiver&gt; tag in a manifest).
500 *
501 * <ul>
502 *     <li> {@link #ACTION_TIME_TICK}
503 *     <li> {@link #ACTION_TIME_CHANGED}
504 *     <li> {@link #ACTION_TIMEZONE_CHANGED}
505 *     <li> {@link #ACTION_BOOT_COMPLETED}
506 *     <li> {@link #ACTION_PACKAGE_ADDED}
507 *     <li> {@link #ACTION_PACKAGE_CHANGED}
508 *     <li> {@link #ACTION_PACKAGE_REMOVED}
509 *     <li> {@link #ACTION_PACKAGE_RESTARTED}
510 *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
511 *     <li> {@link #ACTION_UID_REMOVED}
512 *     <li> {@link #ACTION_BATTERY_CHANGED}
513 *     <li> {@link #ACTION_POWER_CONNECTED}
514 *     <li> {@link #ACTION_POWER_DISCONNECTED}
515 *     <li> {@link #ACTION_SHUTDOWN}
516 * </ul>
517 *
518 * <h3>Standard Categories</h3>
519 *
520 * <p>These are the current standard categories that can be used to further
521 * clarify an Intent via {@link #addCategory}.
522 *
523 * <ul>
524 *     <li> {@link #CATEGORY_DEFAULT}
525 *     <li> {@link #CATEGORY_BROWSABLE}
526 *     <li> {@link #CATEGORY_TAB}
527 *     <li> {@link #CATEGORY_ALTERNATIVE}
528 *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
529 *     <li> {@link #CATEGORY_LAUNCHER}
530 *     <li> {@link #CATEGORY_INFO}
531 *     <li> {@link #CATEGORY_HOME}
532 *     <li> {@link #CATEGORY_PREFERENCE}
533 *     <li> {@link #CATEGORY_TEST}
534 *     <li> {@link #CATEGORY_CAR_DOCK}
535 *     <li> {@link #CATEGORY_DESK_DOCK}
536 *     <li> {@link #CATEGORY_CAR_MODE}
537 *     <li> {@link #CATEGORY_APP_MARKET}
538 * </ul>
539 *
540 * <h3>Standard Extra Data</h3>
541 *
542 * <p>These are the current standard fields that can be used as extra data via
543 * {@link #putExtra}.
544 *
545 * <ul>
546 *     <li> {@link #EXTRA_ALARM_COUNT}
547 *     <li> {@link #EXTRA_BCC}
548 *     <li> {@link #EXTRA_CC}
549 *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
550 *     <li> {@link #EXTRA_DATA_REMOVED}
551 *     <li> {@link #EXTRA_DOCK_STATE}
552 *     <li> {@link #EXTRA_DOCK_STATE_CAR}
553 *     <li> {@link #EXTRA_DOCK_STATE_DESK}
554 *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
555 *     <li> {@link #EXTRA_DONT_KILL_APP}
556 *     <li> {@link #EXTRA_EMAIL}
557 *     <li> {@link #EXTRA_INITIAL_INTENTS}
558 *     <li> {@link #EXTRA_INTENT}
559 *     <li> {@link #EXTRA_KEY_EVENT}
560 *     <li> {@link #EXTRA_PHONE_NUMBER}
561 *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
562 *     <li> {@link #EXTRA_REPLACING}
563 *     <li> {@link #EXTRA_SHORTCUT_ICON}
564 *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
565 *     <li> {@link #EXTRA_SHORTCUT_INTENT}
566 *     <li> {@link #EXTRA_STREAM}
567 *     <li> {@link #EXTRA_SHORTCUT_NAME}
568 *     <li> {@link #EXTRA_SUBJECT}
569 *     <li> {@link #EXTRA_TEMPLATE}
570 *     <li> {@link #EXTRA_TEXT}
571 *     <li> {@link #EXTRA_TITLE}
572 *     <li> {@link #EXTRA_UID}
573 * </ul>
574 *
575 * <h3>Flags</h3>
576 *
577 * <p>These are the possible flags that can be used in the Intent via
578 * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
579 * of all possible flags.
580 */
581public class Intent implements Parcelable, Cloneable {
582    // ---------------------------------------------------------------------
583    // ---------------------------------------------------------------------
584    // Standard intent activity actions (see action variable).
585
586    /**
587     *  Activity Action: Start as a main entry point, does not expect to
588     *  receive data.
589     *  <p>Input: nothing
590     *  <p>Output: nothing
591     */
592    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
593    public static final String ACTION_MAIN = "android.intent.action.MAIN";
594
595    /**
596     * Activity Action: Display the data to the user.  This is the most common
597     * action performed on data -- it is the generic action you can use on
598     * a piece of data to get the most reasonable thing to occur.  For example,
599     * when used on a contacts entry it will view the entry; when used on a
600     * mailto: URI it will bring up a compose window filled with the information
601     * supplied by the URI; when used with a tel: URI it will invoke the
602     * dialer.
603     * <p>Input: {@link #getData} is URI from which to retrieve data.
604     * <p>Output: nothing.
605     */
606    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
607    public static final String ACTION_VIEW = "android.intent.action.VIEW";
608
609    /**
610     * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
611     * performed on a piece of data.
612     */
613    public static final String ACTION_DEFAULT = ACTION_VIEW;
614
615    /**
616     * Used to indicate that some piece of data should be attached to some other
617     * place.  For example, image data could be attached to a contact.  It is up
618     * to the recipient to decide where the data should be attached; the intent
619     * does not specify the ultimate destination.
620     * <p>Input: {@link #getData} is URI of data to be attached.
621     * <p>Output: nothing.
622     */
623    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
624    public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
625
626    /**
627     * Activity Action: Provide explicit editable access to the given data.
628     * <p>Input: {@link #getData} is URI of data to be edited.
629     * <p>Output: nothing.
630     */
631    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
632    public static final String ACTION_EDIT = "android.intent.action.EDIT";
633
634    /**
635     * Activity Action: Pick an existing item, or insert a new item, and then edit it.
636     * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
637     * The extras can contain type specific data to pass through to the editing/creating
638     * activity.
639     * <p>Output: The URI of the item that was picked.  This must be a content:
640     * URI so that any receiver can access it.
641     */
642    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643    public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
644
645    /**
646     * Activity Action: Pick an item from the data, returning what was selected.
647     * <p>Input: {@link #getData} is URI containing a directory of data
648     * (vnd.android.cursor.dir/*) from which to pick an item.
649     * <p>Output: The URI of the item that was picked.
650     */
651    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652    public static final String ACTION_PICK = "android.intent.action.PICK";
653
654    /**
655     * Activity Action: Creates a shortcut.
656     * <p>Input: Nothing.</p>
657     * <p>Output: An Intent representing the shortcut. The intent must contain three
658     * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
659     * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
660     * (value: ShortcutIconResource).</p>
661     *
662     * @see #EXTRA_SHORTCUT_INTENT
663     * @see #EXTRA_SHORTCUT_NAME
664     * @see #EXTRA_SHORTCUT_ICON
665     * @see #EXTRA_SHORTCUT_ICON_RESOURCE
666     * @see android.content.Intent.ShortcutIconResource
667     */
668    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
669    public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
670
671    /**
672     * The name of the extra used to define the Intent of a shortcut.
673     *
674     * @see #ACTION_CREATE_SHORTCUT
675     */
676    public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
677    /**
678     * The name of the extra used to define the name of a shortcut.
679     *
680     * @see #ACTION_CREATE_SHORTCUT
681     */
682    public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
683    /**
684     * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
685     *
686     * @see #ACTION_CREATE_SHORTCUT
687     */
688    public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
689    /**
690     * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
691     *
692     * @see #ACTION_CREATE_SHORTCUT
693     * @see android.content.Intent.ShortcutIconResource
694     */
695    public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
696            "android.intent.extra.shortcut.ICON_RESOURCE";
697
698    /**
699     * Represents a shortcut/live folder icon resource.
700     *
701     * @see Intent#ACTION_CREATE_SHORTCUT
702     * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
703     * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
704     * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
705     */
706    public static class ShortcutIconResource implements Parcelable {
707        /**
708         * The package name of the application containing the icon.
709         */
710        public String packageName;
711
712        /**
713         * The resource name of the icon, including package, name and type.
714         */
715        public String resourceName;
716
717        /**
718         * Creates a new ShortcutIconResource for the specified context and resource
719         * identifier.
720         *
721         * @param context The context of the application.
722         * @param resourceId The resource idenfitier for the icon.
723         * @return A new ShortcutIconResource with the specified's context package name
724         *         and icon resource idenfitier.
725         */
726        public static ShortcutIconResource fromContext(Context context, int resourceId) {
727            ShortcutIconResource icon = new ShortcutIconResource();
728            icon.packageName = context.getPackageName();
729            icon.resourceName = context.getResources().getResourceName(resourceId);
730            return icon;
731        }
732
733        /**
734         * Used to read a ShortcutIconResource from a Parcel.
735         */
736        public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
737            new Parcelable.Creator<ShortcutIconResource>() {
738
739                public ShortcutIconResource createFromParcel(Parcel source) {
740                    ShortcutIconResource icon = new ShortcutIconResource();
741                    icon.packageName = source.readString();
742                    icon.resourceName = source.readString();
743                    return icon;
744                }
745
746                public ShortcutIconResource[] newArray(int size) {
747                    return new ShortcutIconResource[size];
748                }
749            };
750
751        /**
752         * No special parcel contents.
753         */
754        public int describeContents() {
755            return 0;
756        }
757
758        public void writeToParcel(Parcel dest, int flags) {
759            dest.writeString(packageName);
760            dest.writeString(resourceName);
761        }
762
763        @Override
764        public String toString() {
765            return resourceName;
766        }
767    }
768
769    /**
770     * Activity Action: Display an activity chooser, allowing the user to pick
771     * what they want to before proceeding.  This can be used as an alternative
772     * to the standard activity picker that is displayed by the system when
773     * you try to start an activity with multiple possible matches, with these
774     * differences in behavior:
775     * <ul>
776     * <li>You can specify the title that will appear in the activity chooser.
777     * <li>The user does not have the option to make one of the matching
778     * activities a preferred activity, and all possible activities will
779     * always be shown even if one of them is currently marked as the
780     * preferred activity.
781     * </ul>
782     * <p>
783     * This action should be used when the user will naturally expect to
784     * select an activity in order to proceed.  An example if when not to use
785     * it is when the user clicks on a "mailto:" link.  They would naturally
786     * expect to go directly to their mail app, so startActivity() should be
787     * called directly: it will
788     * either launch the current preferred app, or put up a dialog allowing the
789     * user to pick an app to use and optionally marking that as preferred.
790     * <p>
791     * In contrast, if the user is selecting a menu item to send a picture
792     * they are viewing to someone else, there are many different things they
793     * may want to do at this point: send it through e-mail, upload it to a
794     * web service, etc.  In this case the CHOOSER action should be used, to
795     * always present to the user a list of the things they can do, with a
796     * nice title given by the caller such as "Send this photo with:".
797     * <p>
798     * As a convenience, an Intent of this form can be created with the
799     * {@link #createChooser} function.
800     * <p>Input: No data should be specified.  get*Extra must have
801     * a {@link #EXTRA_INTENT} field containing the Intent being executed,
802     * and can optionally have a {@link #EXTRA_TITLE} field containing the
803     * title text to display in the chooser.
804     * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
805     */
806    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
807    public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
808
809    /**
810     * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
811     *
812     * @param target The Intent that the user will be selecting an activity
813     * to perform.
814     * @param title Optional title that will be displayed in the chooser.
815     * @return Return a new Intent object that you can hand to
816     * {@link Context#startActivity(Intent) Context.startActivity()} and
817     * related methods.
818     */
819    public static Intent createChooser(Intent target, CharSequence title) {
820        Intent intent = new Intent(ACTION_CHOOSER);
821        intent.putExtra(EXTRA_INTENT, target);
822        if (title != null) {
823            intent.putExtra(EXTRA_TITLE, title);
824        }
825        return intent;
826    }
827    /**
828     * Activity Action: Allow the user to select a particular kind of data and
829     * return it.  This is different than {@link #ACTION_PICK} in that here we
830     * just say what kind of data is desired, not a URI of existing data from
831     * which the user can pick.  A ACTION_GET_CONTENT could allow the user to
832     * create the data as it runs (for example taking a picture or recording a
833     * sound), let them browser over the web and download the desired data,
834     * etc.
835     * <p>
836     * There are two main ways to use this action: if you want an specific kind
837     * of data, such as a person contact, you set the MIME type to the kind of
838     * data you want and launch it with {@link Context#startActivity(Intent)}.
839     * The system will then launch the best application to select that kind
840     * of data for you.
841     * <p>
842     * You may also be interested in any of a set of types of content the user
843     * can pick.  For example, an e-mail application that wants to allow the
844     * user to add an attachment to an e-mail message can use this action to
845     * bring up a list of all of the types of content the user can attach.
846     * <p>
847     * In this case, you should wrap the GET_CONTENT intent with a chooser
848     * (through {@link #createChooser}), which will give the proper interface
849     * for the user to pick how to send your data and allow you to specify
850     * a prompt indicating what they are doing.  You will usually specify a
851     * broad MIME type (such as image/* or {@literal *}/*), resulting in a
852     * broad range of content types the user can select from.
853     * <p>
854     * When using such a broad GET_CONTENT action, it is often desireable to
855     * only pick from data that can be represented as a stream.  This is
856     * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
857     * <p>
858     * Input: {@link #getType} is the desired MIME type to retrieve.  Note
859     * that no URI is supplied in the intent, as there are no constraints on
860     * where the returned data originally comes from.  You may also include the
861     * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
862     * opened as a stream.
863     * <p>
864     * Output: The URI of the item that was picked.  This must be a content:
865     * URI so that any receiver can access it.
866     */
867    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
868    public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
869    /**
870     * Activity Action: Dial a number as specified by the data.  This shows a
871     * UI with the number being dialed, allowing the user to explicitly
872     * initiate the call.
873     * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
874     * is URI of a phone number to be dialed or a tel: URI of an explicit phone
875     * number.
876     * <p>Output: nothing.
877     */
878    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
879    public static final String ACTION_DIAL = "android.intent.action.DIAL";
880    /**
881     * Activity Action: Perform a call to someone specified by the data.
882     * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
883     * is URI of a phone number to be dialed or a tel: URI of an explicit phone
884     * number.
885     * <p>Output: nothing.
886     *
887     * <p>Note: there will be restrictions on which applications can initiate a
888     * call; most applications should use the {@link #ACTION_DIAL}.
889     * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
890     * numbers.  Applications can <strong>dial</strong> emergency numbers using
891     * {@link #ACTION_DIAL}, however.
892     */
893    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
894    public static final String ACTION_CALL = "android.intent.action.CALL";
895    /**
896     * Activity Action: Perform a call to an emergency number specified by the
897     * data.
898     * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
899     * tel: URI of an explicit phone number.
900     * <p>Output: nothing.
901     * @hide
902     */
903    public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
904    /**
905     * Activity action: Perform a call to any number (emergency or not)
906     * specified by the data.
907     * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
908     * tel: URI of an explicit phone number.
909     * <p>Output: nothing.
910     * @hide
911     */
912    public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
913    /**
914     * Activity Action: Send a message to someone specified by the data.
915     * <p>Input: {@link #getData} is URI describing the target.
916     * <p>Output: nothing.
917     */
918    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
919    public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
920    /**
921     * Activity Action: Deliver some data to someone else.  Who the data is
922     * being delivered to is not specified; it is up to the receiver of this
923     * action to ask the user where the data should be sent.
924     * <p>
925     * When launching a SEND intent, you should usually wrap it in a chooser
926     * (through {@link #createChooser}), which will give the proper interface
927     * for the user to pick how to send your data and allow you to specify
928     * a prompt indicating what they are doing.
929     * <p>
930     * Input: {@link #getType} is the MIME type of the data being sent.
931     * get*Extra can have either a {@link #EXTRA_TEXT}
932     * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
933     * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
934     * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
935     * if the MIME type is unknown (this will only allow senders that can
936     * handle generic data streams).
937     * <p>
938     * Optional standard extras, which may be interpreted by some recipients as
939     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
940     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
941     * <p>
942     * Output: nothing.
943     */
944    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
945    public static final String ACTION_SEND = "android.intent.action.SEND";
946    /**
947     * Activity Action: Deliver multiple data to someone else.
948     * <p>
949     * Like ACTION_SEND, except the data is multiple.
950     * <p>
951     * Input: {@link #getType} is the MIME type of the data being sent.
952     * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
953     * #EXTRA_STREAM} field, containing the data to be sent.
954     * <p>
955     * Multiple types are supported, and receivers should handle mixed types
956     * whenever possible. The right way for the receiver to check them is to
957     * use the content resolver on each URI. The intent sender should try to
958     * put the most concrete mime type in the intent type, but it can fall
959     * back to {@literal <type>/*} or {@literal *}/* as needed.
960     * <p>
961     * e.g. if you are sending image/jpg and image/jpg, the intent's type can
962     * be image/jpg, but if you are sending image/jpg and image/png, then the
963     * intent's type should be image/*.
964     * <p>
965     * Optional standard extras, which may be interpreted by some recipients as
966     * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
967     * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
968     * <p>
969     * Output: nothing.
970     */
971    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
972    public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
973    /**
974     * Activity Action: Handle an incoming phone call.
975     * <p>Input: nothing.
976     * <p>Output: nothing.
977     */
978    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
979    public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
980    /**
981     * Activity Action: Insert an empty item into the given container.
982     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
983     * in which to place the data.
984     * <p>Output: URI of the new data that was created.
985     */
986    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
987    public static final String ACTION_INSERT = "android.intent.action.INSERT";
988    /**
989     * Activity Action: Create a new item in the given container, initializing it
990     * from the current contents of the clipboard.
991     * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
992     * in which to place the data.
993     * <p>Output: URI of the new data that was created.
994     */
995    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
996    public static final String ACTION_PASTE = "android.intent.action.PASTE";
997    /**
998     * Activity Action: Delete the given data from its container.
999     * <p>Input: {@link #getData} is URI of data to be deleted.
1000     * <p>Output: nothing.
1001     */
1002    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1003    public static final String ACTION_DELETE = "android.intent.action.DELETE";
1004    /**
1005     * Activity Action: Run the data, whatever that means.
1006     * <p>Input: ?  (Note: this is currently specific to the test harness.)
1007     * <p>Output: nothing.
1008     */
1009    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1010    public static final String ACTION_RUN = "android.intent.action.RUN";
1011    /**
1012     * Activity Action: Perform a data synchronization.
1013     * <p>Input: ?
1014     * <p>Output: ?
1015     */
1016    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1017    public static final String ACTION_SYNC = "android.intent.action.SYNC";
1018    /**
1019     * Activity Action: Pick an activity given an intent, returning the class
1020     * selected.
1021     * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1022     * used with {@link PackageManager#queryIntentActivities} to determine the
1023     * set of activities from which to pick.
1024     * <p>Output: Class name of the activity that was selected.
1025     */
1026    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1027    public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1028    /**
1029     * Activity Action: Perform a search.
1030     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1031     * is the text to search for.  If empty, simply
1032     * enter your search results Activity with the search UI activated.
1033     * <p>Output: nothing.
1034     */
1035    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1036    public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1037    /**
1038     * Activity Action: Start the platform-defined tutorial
1039     * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1040     * is the text to search for.  If empty, simply
1041     * enter your search results Activity with the search UI activated.
1042     * <p>Output: nothing.
1043     */
1044    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1045    public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1046    /**
1047     * Activity Action: Perform a web search.
1048     * <p>
1049     * Input: {@link android.app.SearchManager#QUERY
1050     * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1051     * a url starts with http or https, the site will be opened. If it is plain
1052     * text, Google search will be applied.
1053     * <p>
1054     * Output: nothing.
1055     */
1056    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1057    public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1058    /**
1059     * Activity Action: List all available applications
1060     * <p>Input: Nothing.
1061     * <p>Output: nothing.
1062     */
1063    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1064    public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1065    /**
1066     * Activity Action: Show settings for choosing wallpaper
1067     * <p>Input: Nothing.
1068     * <p>Output: Nothing.
1069     */
1070    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1071    public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1072
1073    /**
1074     * Activity Action: Show activity for reporting a bug.
1075     * <p>Input: Nothing.
1076     * <p>Output: Nothing.
1077     */
1078    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1079    public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1080
1081    /**
1082     *  Activity Action: Main entry point for factory tests.  Only used when
1083     *  the device is booting in factory test node.  The implementing package
1084     *  must be installed in the system image.
1085     *  <p>Input: nothing
1086     *  <p>Output: nothing
1087     */
1088    public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1089
1090    /**
1091     * Activity Action: The user pressed the "call" button to go to the dialer
1092     * or other appropriate UI for placing a call.
1093     * <p>Input: Nothing.
1094     * <p>Output: Nothing.
1095     */
1096    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1097    public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1098
1099    /**
1100     * Activity Action: Start Voice Command.
1101     * <p>Input: Nothing.
1102     * <p>Output: Nothing.
1103     */
1104    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1105    public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1106
1107    /**
1108     * Activity Action: Start action associated with long pressing on the
1109     * search key.
1110     * <p>Input: Nothing.
1111     * <p>Output: Nothing.
1112     */
1113    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1114    public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1115
1116    /**
1117     * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1118     * This intent is delivered to the package which installed the application, usually
1119     * the Market.
1120     * <p>Input: No data is specified. The bug report is passed in using
1121     * an {@link #EXTRA_BUG_REPORT} field.
1122     * <p>Output: Nothing.
1123     * @hide
1124     */
1125    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126    public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1127
1128    /**
1129     * Activity Action: Show power usage information to the user.
1130     * <p>Input: Nothing.
1131     * <p>Output: Nothing.
1132     */
1133    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1134    public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1135
1136    /**
1137     * Activity Action: Setup wizard to launch after a platform update.  This
1138     * activity should have a string meta-data field associated with it,
1139     * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1140     * the platform for setup.  The activity will be launched only if
1141     * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1142     * same value.
1143     * <p>Input: Nothing.
1144     * <p>Output: Nothing.
1145     * @hide
1146     */
1147    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1148    public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1149
1150    /**
1151     * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1152     * describing the last run version of the platform that was setup.
1153     * @hide
1154     */
1155    public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1156
1157    // ---------------------------------------------------------------------
1158    // ---------------------------------------------------------------------
1159    // Standard intent broadcast actions (see action variable).
1160
1161    /**
1162     * Broadcast Action: Sent after the screen turns off.
1163     *
1164     * <p class="note">This is a protected intent that can only be sent
1165     * by the system.
1166     */
1167    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1168    public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1169    /**
1170     * Broadcast Action: Sent after the screen turns on.
1171     *
1172     * <p class="note">This is a protected intent that can only be sent
1173     * by the system.
1174     */
1175    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1176    public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
1177
1178    /**
1179     * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
1180     * keyguard is gone).
1181     *
1182     * <p class="note">This is a protected intent that can only be sent
1183     * by the system.
1184     */
1185    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1186    public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
1187
1188    /**
1189     * Broadcast Action: The current time has changed.  Sent every
1190     * minute.  You can <em>not</em> receive this through components declared
1191     * in manifests, only by exlicitly registering for it with
1192     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1193     * Context.registerReceiver()}.
1194     *
1195     * <p class="note">This is a protected intent that can only be sent
1196     * by the system.
1197     */
1198    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1199    public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1200    /**
1201     * Broadcast Action: The time was set.
1202     */
1203    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1204    public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1205    /**
1206     * Broadcast Action: The date has changed.
1207     */
1208    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1209    public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1210    /**
1211     * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1212     * <ul>
1213     *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1214     * </ul>
1215     *
1216     * <p class="note">This is a protected intent that can only be sent
1217     * by the system.
1218     */
1219    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1220    public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1221    /**
1222     * Alarm Changed Action: This is broadcast when the AlarmClock
1223     * application's alarm is set or unset.  It is used by the
1224     * AlarmClock application and the StatusBar service.
1225     * @hide
1226     */
1227    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1228    public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1229    /**
1230     * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1231     * been failing for a long time.  It is used by the SyncManager and the StatusBar service.
1232     * @hide
1233     */
1234    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1235    public static final String ACTION_SYNC_STATE_CHANGED
1236            = "android.intent.action.SYNC_STATE_CHANGED";
1237    /**
1238     * Broadcast Action: This is broadcast once, after the system has finished
1239     * booting.  It can be used to perform application-specific initialization,
1240     * such as installing alarms.  You must hold the
1241     * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1242     * in order to receive this broadcast.
1243     *
1244     * <p class="note">This is a protected intent that can only be sent
1245     * by the system.
1246     */
1247    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1248    public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1249    /**
1250     * Broadcast Action: This is broadcast when a user action should request a
1251     * temporary system dialog to dismiss.  Some examples of temporary system
1252     * dialogs are the notification window-shade and the recent tasks dialog.
1253     */
1254    public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1255    /**
1256     * Broadcast Action: Trigger the download and eventual installation
1257     * of a package.
1258     * <p>Input: {@link #getData} is the URI of the package file to download.
1259     *
1260     * <p class="note">This is a protected intent that can only be sent
1261     * by the system.
1262     */
1263    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1264    public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1265    /**
1266     * Broadcast Action: A new application package has been installed on the
1267     * device. The data contains the name of the package.  Note that the
1268     * newly installed package does <em>not</em> receive this broadcast.
1269     * <p>My include the following extras:
1270     * <ul>
1271     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1272     * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1273     * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1274     * </ul>
1275     *
1276     * <p class="note">This is a protected intent that can only be sent
1277     * by the system.
1278     */
1279    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1280    public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1281    /**
1282     * Broadcast Action: A new version of an application package has been
1283     * installed, replacing an existing version that was previously installed.
1284     * The data contains the name of the package.
1285     * <p>My include the following extras:
1286     * <ul>
1287     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1288     * </ul>
1289     *
1290     * <p class="note">This is a protected intent that can only be sent
1291     * by the system.
1292     */
1293    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1294    public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1295    /**
1296     * Broadcast Action: An existing application package has been removed from
1297     * the device.  The data contains the name of the package.  The package
1298     * that is being installed does <em>not</em> receive this Intent.
1299     * <ul>
1300     * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1301     * to the package.
1302     * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1303     * application -- data and code -- is being removed.
1304     * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1305     * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1306     * </ul>
1307     *
1308     * <p class="note">This is a protected intent that can only be sent
1309     * by the system.
1310     */
1311    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1312    public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1313    /**
1314     * Broadcast Action: An existing application package has been changed (e.g.
1315     * a component has been enabled or disabled).  The data contains the name of
1316     * the package.
1317     * <ul>
1318     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1319     * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1320     * of the changed components.
1321     * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1322     * default action of restarting the application.
1323     * </ul>
1324     *
1325     * <p class="note">This is a protected intent that can only be sent
1326     * by the system.
1327     */
1328    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1329    public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1330    /**
1331     * @hide
1332     * Broadcast Action: Ask system services if there is any reason to
1333     * restart the given package.  The data contains the name of the
1334     * package.
1335     * <ul>
1336     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1337     * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1338     * </ul>
1339     *
1340     * <p class="note">This is a protected intent that can only be sent
1341     * by the system.
1342     */
1343    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1344    public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1345    /**
1346     * Broadcast Action: The user has restarted a package, and all of its
1347     * processes have been killed.  All runtime state
1348     * associated with it (processes, alarms, notifications, etc) should
1349     * be removed.  Note that the restarted package does <em>not</em>
1350     * receive this broadcast.
1351     * The data contains the name of the package.
1352     * <ul>
1353     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1354     * </ul>
1355     *
1356     * <p class="note">This is a protected intent that can only be sent
1357     * by the system.
1358     */
1359    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1360    public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1361    /**
1362     * Broadcast Action: The user has cleared the data of a package.  This should
1363     * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
1364     * its persistent data is erased and this broadcast sent.
1365     * Note that the cleared package does <em>not</em>
1366     * receive this broadcast. The data contains the name of the package.
1367     * <ul>
1368     * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1369     * </ul>
1370     *
1371     * <p class="note">This is a protected intent that can only be sent
1372     * by the system.
1373     */
1374    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1375    public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1376    /**
1377     * Broadcast Action: A user ID has been removed from the system.  The user
1378     * ID number is stored in the extra data under {@link #EXTRA_UID}.
1379     *
1380     * <p class="note">This is a protected intent that can only be sent
1381     * by the system.
1382     */
1383    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1384    public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
1385
1386    /**
1387     * Broadcast Action: Resources for a set of packages (which were
1388     * previously unavailable) are currently
1389     * available since the media on which they exist is available.
1390     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1391     * list of packages whose availability changed.
1392     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1393     * list of uids of packages whose availability changed.
1394     * Note that the
1395     * packages in this list do <em>not</em> receive this broadcast.
1396     * The specified set of packages are now available on the system.
1397     * <p>Includes the following extras:
1398     * <ul>
1399     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1400     * whose resources(were previously unavailable) are currently available.
1401     * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1402     * packages whose resources(were previously unavailable)
1403     * are  currently available.
1404     * </ul>
1405     *
1406     * <p class="note">This is a protected intent that can only be sent
1407     * by the system.
1408     */
1409    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1410    public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1411        "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
1412
1413    /**
1414     * Broadcast Action: Resources for a set of packages are currently
1415     * unavailable since the media on which they exist is unavailable.
1416     * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1417     * list of packages whose availability changed.
1418     * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1419     * list of uids of packages whose availability changed.
1420     * The specified set of packages can no longer be
1421     * launched and are practically unavailable on the system.
1422     * <p>Inclues the following extras:
1423     * <ul>
1424     * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1425     * whose resources are no longer available.
1426     * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1427     * whose resources are no longer available.
1428     * </ul>
1429     *
1430     * <p class="note">This is a protected intent that can only be sent
1431     * by the system.
1432     */
1433    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1434    public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
1435        "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
1436
1437    /**
1438     * Broadcast Action:  The current system wallpaper has changed.  See
1439     * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
1440     */
1441    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1442    public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1443    /**
1444     * Broadcast Action: The current device {@link android.content.res.Configuration}
1445     * (orientation, locale, etc) has changed.  When such a change happens, the
1446     * UIs (view hierarchy) will need to be rebuilt based on this new
1447     * information; for the most part, applications don't need to worry about
1448     * this, because the system will take care of stopping and restarting the
1449     * application to make sure it sees the new changes.  Some system code that
1450     * can not be restarted will need to watch for this action and handle it
1451     * appropriately.
1452     *
1453     * <p class="note">
1454     * You can <em>not</em> receive this through components declared
1455     * in manifests, only by explicitly registering for it with
1456     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1457     * Context.registerReceiver()}.
1458     *
1459     * <p class="note">This is a protected intent that can only be sent
1460     * by the system.
1461     *
1462     * @see android.content.res.Configuration
1463     */
1464    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1465    public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1466    /**
1467     * Broadcast Action: The current device's locale has changed.
1468     *
1469     * <p class="note">This is a protected intent that can only be sent
1470     * by the system.
1471     */
1472    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1473    public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1474    /**
1475     * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
1476     * charging state, level, and other information about the battery.
1477     * See {@link android.os.BatteryManager} for documentation on the
1478     * contents of the Intent.
1479     *
1480     * <p class="note">
1481     * You can <em>not</em> receive this through components declared
1482     * in manifests, only by explicitly registering for it with
1483     * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1484     * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
1485     * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1486     * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1487     * broadcasts that are sent and can be received through manifest
1488     * receivers.
1489     *
1490     * <p class="note">This is a protected intent that can only be sent
1491     * by the system.
1492     */
1493    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1494    public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1495    /**
1496     * Broadcast Action:  Indicates low battery condition on the device.
1497     * This broadcast corresponds to the "Low battery warning" system dialog.
1498     *
1499     * <p class="note">This is a protected intent that can only be sent
1500     * by the system.
1501     */
1502    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1503    public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1504    /**
1505     * Broadcast Action:  Indicates the battery is now okay after being low.
1506     * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1507     * gone back up to an okay state.
1508     *
1509     * <p class="note">This is a protected intent that can only be sent
1510     * by the system.
1511     */
1512    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1513    public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1514    /**
1515     * Broadcast Action:  External power has been connected to the device.
1516     * This is intended for applications that wish to register specifically to this notification.
1517     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1518     * stay active to receive this notification.  This action can be used to implement actions
1519     * that wait until power is available to trigger.
1520     *
1521     * <p class="note">This is a protected intent that can only be sent
1522     * by the system.
1523     */
1524    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1525    public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
1526    /**
1527     * Broadcast Action:  External power has been removed from the device.
1528     * This is intended for applications that wish to register specifically to this notification.
1529     * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1530     * stay active to receive this notification.  This action can be used to implement actions
1531     * that wait until power is available to trigger.
1532     *
1533     * <p class="note">This is a protected intent that can only be sent
1534     * by the system.
1535     */
1536    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1537    public static final String ACTION_POWER_DISCONNECTED =
1538            "android.intent.action.ACTION_POWER_DISCONNECTED";
1539    /**
1540     * Broadcast Action:  Device is shutting down.
1541     * This is broadcast when the device is being shut down (completely turned
1542     * off, not sleeping).  Once the broadcast is complete, the final shutdown
1543     * will proceed and all unsaved data lost.  Apps will not normally need
1544     * to handle this, since the foreground activity will be paused as well.
1545     *
1546     * <p class="note">This is a protected intent that can only be sent
1547     * by the system.
1548     */
1549    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1550    public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
1551    /**
1552     * Activity Action:  Start this activity to request system shutdown.
1553     * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1554     * to request confirmation from the user before shutting down.
1555     *
1556     * <p class="note">This is a protected intent that can only be sent
1557     * by the system.
1558     *
1559     * {@hide}
1560     */
1561    public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1562    /**
1563     * Broadcast Action:  A sticky broadcast that indicates low memory
1564     * condition on the device
1565     *
1566     * <p class="note">This is a protected intent that can only be sent
1567     * by the system.
1568     */
1569    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1570    public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1571    /**
1572     * Broadcast Action:  Indicates low memory condition on the device no longer exists
1573     *
1574     * <p class="note">This is a protected intent that can only be sent
1575     * by the system.
1576     */
1577    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1578    public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1579    /**
1580     * Broadcast Action:  Indicates low memory condition notification acknowledged by user
1581     * and package management should be started.
1582     * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1583     * notification.
1584     */
1585    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1586    public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1587    /**
1588     * Broadcast Action:  The device has entered USB Mass Storage mode.
1589     * This is used mainly for the USB Settings panel.
1590     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1591     * when the SD card file system is mounted or unmounted
1592     */
1593    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1594    public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1595
1596    /**
1597     * Broadcast Action:  The device has exited USB Mass Storage mode.
1598     * This is used mainly for the USB Settings panel.
1599     * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1600     * when the SD card file system is mounted or unmounted
1601     */
1602    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1603    public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1604
1605    /**
1606     * Broadcast Action:  External media has been removed.
1607     * The path to the mount point for the removed media is contained in the Intent.mData field.
1608     */
1609    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1610    public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1611
1612    /**
1613     * Broadcast Action:  External media is present, but not mounted at its mount point.
1614     * The path to the mount point for the removed media is contained in the Intent.mData field.
1615     */
1616    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1617    public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1618
1619    /**
1620     * Broadcast Action:  External media is present, and being disk-checked
1621     * The path to the mount point for the checking media is contained in the Intent.mData field.
1622     */
1623    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1624    public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1625
1626    /**
1627     * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
1628     * The path to the mount point for the checking media is contained in the Intent.mData field.
1629     */
1630    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1631    public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1632
1633    /**
1634     * Broadcast Action:  External media is present and mounted at its mount point.
1635     * The path to the mount point for the removed media is contained in the Intent.mData field.
1636     * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1637     * media was mounted read only.
1638     */
1639    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1640    public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1641
1642    /**
1643     * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
1644     * The path to the mount point for the shared media is contained in the Intent.mData field.
1645     */
1646    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1647    public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1648
1649    /**
1650     * Broadcast Action:  External media is no longer being shared via USB mass storage.
1651     * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1652     *
1653     * @hide
1654     */
1655    public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1656
1657    /**
1658     * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
1659     * The path to the mount point for the removed media is contained in the Intent.mData field.
1660     */
1661    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1662    public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1663
1664    /**
1665     * Broadcast Action:  External media is present but cannot be mounted.
1666     * The path to the mount point for the removed media is contained in the Intent.mData field.
1667     */
1668    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1669    public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1670
1671   /**
1672     * Broadcast Action:  User has expressed the desire to remove the external storage media.
1673     * Applications should close all files they have open within the mount point when they receive this intent.
1674     * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1675     */
1676    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1677    public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1678
1679    /**
1680     * Broadcast Action:  The media scanner has started scanning a directory.
1681     * The path to the directory being scanned is contained in the Intent.mData field.
1682     */
1683    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1684    public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1685
1686   /**
1687     * Broadcast Action:  The media scanner has finished scanning a directory.
1688     * The path to the scanned directory is contained in the Intent.mData field.
1689     */
1690    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1691    public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1692
1693   /**
1694     * Broadcast Action:  Request the media scanner to scan a file and add it to the media database.
1695     * The path to the file is contained in the Intent.mData field.
1696     */
1697    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1698    public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1699
1700   /**
1701     * Broadcast Action:  The "Media Button" was pressed.  Includes a single
1702     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1703     * caused the broadcast.
1704     */
1705    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1706    public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1707
1708    /**
1709     * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
1710     * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1711     * caused the broadcast.
1712     */
1713    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1714    public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1715
1716    // *** NOTE: @todo(*) The following really should go into a more domain-specific
1717    // location; they are not general-purpose actions.
1718
1719    /**
1720     * Broadcast Action: An GTalk connection has been established.
1721     */
1722    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1723    public static final String ACTION_GTALK_SERVICE_CONNECTED =
1724            "android.intent.action.GTALK_CONNECTED";
1725
1726    /**
1727     * Broadcast Action: An GTalk connection has been disconnected.
1728     */
1729    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1730    public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1731            "android.intent.action.GTALK_DISCONNECTED";
1732
1733    /**
1734     * Broadcast Action: An input method has been changed.
1735     */
1736    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1737    public static final String ACTION_INPUT_METHOD_CHANGED =
1738            "android.intent.action.INPUT_METHOD_CHANGED";
1739
1740    /**
1741     * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1742     * more radios have been turned off or on. The intent will have the following extra value:</p>
1743     * <ul>
1744     *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1745     *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1746     *   turned off</li>
1747     * </ul>
1748     *
1749     * <p class="note">This is a protected intent that can only be sent
1750     * by the system.
1751     */
1752    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1753    public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1754
1755    /**
1756     * Broadcast Action: Some content providers have parts of their namespace
1757     * where they publish new events or items that the user may be especially
1758     * interested in. For these things, they may broadcast this action when the
1759     * set of interesting items change.
1760     *
1761     * For example, GmailProvider sends this notification when the set of unread
1762     * mail in the inbox changes.
1763     *
1764     * <p>The data of the intent identifies which part of which provider
1765     * changed. When queried through the content resolver, the data URI will
1766     * return the data set in question.
1767     *
1768     * <p>The intent will have the following extra values:
1769     * <ul>
1770     *   <li><em>count</em> - The number of items in the data set. This is the
1771     *       same as the number of items in the cursor returned by querying the
1772     *       data URI. </li>
1773     * </ul>
1774     *
1775     * This intent will be sent at boot (if the count is non-zero) and when the
1776     * data set changes. It is possible for the data set to change without the
1777     * count changing (for example, if a new unread message arrives in the same
1778     * sync operation in which a message is archived). The phone should still
1779     * ring/vibrate/etc as normal in this case.
1780     */
1781    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1782    public static final String ACTION_PROVIDER_CHANGED =
1783            "android.intent.action.PROVIDER_CHANGED";
1784
1785    /**
1786     * Broadcast Action: Wired Headset plugged in or unplugged.
1787     *
1788     * <p>The intent will have the following extra values:
1789     * <ul>
1790     *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1791     *   <li><em>name</em> - Headset type, human readable string </li>
1792     *   <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
1793     * </ul>
1794     * </ul>
1795     */
1796    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1797    public static final String ACTION_HEADSET_PLUG =
1798            "android.intent.action.HEADSET_PLUG";
1799
1800    /**
1801     * Broadcast Action: An outgoing call is about to be placed.
1802     *
1803     * <p>The Intent will have the following extra value:
1804     * <ul>
1805     *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
1806     *       the phone number originally intended to be dialed.</li>
1807     * </ul>
1808     * <p>Once the broadcast is finished, the resultData is used as the actual
1809     * number to call.  If  <code>null</code>, no call will be placed.</p>
1810     * <p>It is perfectly acceptable for multiple receivers to process the
1811     * outgoing call in turn: for example, a parental control application
1812     * might verify that the user is authorized to place the call at that
1813     * time, then a number-rewriting application might add an area code if
1814     * one was not specified.</p>
1815     * <p>For consistency, any receiver whose purpose is to prohibit phone
1816     * calls should have a priority of 0, to ensure it will see the final
1817     * phone number to be dialed.
1818     * Any receiver whose purpose is to rewrite phone numbers to be called
1819     * should have a positive priority.
1820     * Negative priorities are reserved for the system for this broadcast;
1821     * using them may cause problems.</p>
1822     * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
1823     * abort the broadcast.</p>
1824     * <p>Emergency calls cannot be intercepted using this mechanism, and
1825     * other calls cannot be modified to call emergency numbers using this
1826     * mechanism.
1827     * <p>You must hold the
1828     * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
1829     * permission to receive this Intent.</p>
1830     *
1831     * <p class="note">This is a protected intent that can only be sent
1832     * by the system.
1833     */
1834    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1835    public static final String ACTION_NEW_OUTGOING_CALL =
1836            "android.intent.action.NEW_OUTGOING_CALL";
1837
1838    /**
1839     * Broadcast Action: Have the device reboot.  This is only for use by
1840     * system code.
1841     *
1842     * <p class="note">This is a protected intent that can only be sent
1843     * by the system.
1844     */
1845    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1846    public static final String ACTION_REBOOT =
1847            "android.intent.action.REBOOT";
1848
1849    /**
1850     * Broadcast Action:  A sticky broadcast for changes in the physical
1851     * docking state of the device.
1852     *
1853     * <p>The intent will have the following extra values:
1854     * <ul>
1855     *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
1856     *       state, indicating which dock the device is physically in.</li>
1857     * </ul>
1858     * <p>This is intended for monitoring the current physical dock state.
1859     * See {@link android.app.UiModeManager} for the normal API dealing with
1860     * dock mode changes.
1861     */
1862    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1863    public static final String ACTION_DOCK_EVENT =
1864            "android.intent.action.DOCK_EVENT";
1865
1866    /**
1867     * Broadcast Action: a remote intent is to be broadcasted.
1868     *
1869     * A remote intent is used for remote RPC between devices. The remote intent
1870     * is serialized and sent from one device to another device. The receiving
1871     * device parses the remote intent and broadcasts it. Note that anyone can
1872     * broadcast a remote intent. However, if the intent receiver of the remote intent
1873     * does not trust intent broadcasts from arbitrary intent senders, it should require
1874     * the sender to hold certain permissions so only trusted sender's broadcast will be
1875     * let through.
1876     * @hide
1877     */
1878    public static final String ACTION_REMOTE_INTENT =
1879            "com.google.android.c2dm.intent.RECEIVE";
1880
1881    /**
1882     * Broadcast Action: hook for permforming cleanup after a system update.
1883     *
1884     * The broadcast is sent when the system is booting, before the
1885     * BOOT_COMPLETED broadcast.  It is only sent to receivers in the system
1886     * image.  A receiver for this should do its work and then disable itself
1887     * so that it does not get run again at the next boot.
1888     * @hide
1889     */
1890    public static final String ACTION_PRE_BOOT_COMPLETED =
1891            "android.intent.action.PRE_BOOT_COMPLETED";
1892
1893    // ---------------------------------------------------------------------
1894    // ---------------------------------------------------------------------
1895    // Standard intent categories (see addCategory()).
1896
1897    /**
1898     * Set if the activity should be an option for the default action
1899     * (center press) to perform on a piece of data.  Setting this will
1900     * hide from the user any activities without it set when performing an
1901     * action on some data.  Note that this is normal -not- set in the
1902     * Intent when initiating an action -- it is for use in intent filters
1903     * specified in packages.
1904     */
1905    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1906    public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
1907    /**
1908     * Activities that can be safely invoked from a browser must support this
1909     * category.  For example, if the user is viewing a web page or an e-mail
1910     * and clicks on a link in the text, the Intent generated execute that
1911     * link will require the BROWSABLE category, so that only activities
1912     * supporting this category will be considered as possible actions.  By
1913     * supporting this category, you are promising that there is nothing
1914     * damaging (without user intervention) that can happen by invoking any
1915     * matching Intent.
1916     */
1917    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1918    public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
1919    /**
1920     * Set if the activity should be considered as an alternative action to
1921     * the data the user is currently viewing.  See also
1922     * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
1923     * applies to the selection in a list of items.
1924     *
1925     * <p>Supporting this category means that you would like your activity to be
1926     * displayed in the set of alternative things the user can do, usually as
1927     * part of the current activity's options menu.  You will usually want to
1928     * include a specific label in the &lt;intent-filter&gt; of this action
1929     * describing to the user what it does.
1930     *
1931     * <p>The action of IntentFilter with this category is important in that it
1932     * describes the specific action the target will perform.  This generally
1933     * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
1934     * a specific name such as "com.android.camera.action.CROP.  Only one
1935     * alternative of any particular action will be shown to the user, so using
1936     * a specific action like this makes sure that your alternative will be
1937     * displayed while also allowing other applications to provide their own
1938     * overrides of that particular action.
1939     */
1940    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1941    public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
1942    /**
1943     * Set if the activity should be considered as an alternative selection
1944     * action to the data the user has currently selected.  This is like
1945     * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
1946     * of items from which the user can select, giving them alternatives to the
1947     * default action that will be performed on it.
1948     */
1949    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1950    public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
1951    /**
1952     * Intended to be used as a tab inside of an containing TabActivity.
1953     */
1954    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1955    public static final String CATEGORY_TAB = "android.intent.category.TAB";
1956    /**
1957     * Should be displayed in the top-level launcher.
1958     */
1959    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1960    public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
1961    /**
1962     * Provides information about the package it is in; typically used if
1963     * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
1964     * a front-door to the user without having to be shown in the all apps list.
1965     */
1966    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1967    public static final String CATEGORY_INFO = "android.intent.category.INFO";
1968    /**
1969     * This is the home activity, that is the first activity that is displayed
1970     * when the device boots.
1971     */
1972    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1973    public static final String CATEGORY_HOME = "android.intent.category.HOME";
1974    /**
1975     * This activity is a preference panel.
1976     */
1977    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1978    public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
1979    /**
1980     * This activity is a development preference panel.
1981     */
1982    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1983    public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
1984    /**
1985     * Capable of running inside a parent activity container.
1986     */
1987    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1988    public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
1989    /**
1990     * This activity allows the user to browse and download new applications.
1991     */
1992    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1993    public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
1994    /**
1995     * This activity may be exercised by the monkey or other automated test tools.
1996     */
1997    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1998    public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
1999    /**
2000     * To be used as a test (not part of the normal user experience).
2001     */
2002    public static final String CATEGORY_TEST = "android.intent.category.TEST";
2003    /**
2004     * To be used as a unit test (run through the Test Harness).
2005     */
2006    public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2007    /**
2008     * To be used as an sample code example (not part of the normal user
2009     * experience).
2010     */
2011    public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2012    /**
2013     * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2014     * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2015     * when queried, though it is allowable for those columns to be blank.
2016     */
2017    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2018    public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2019
2020    /**
2021     * To be used as code under test for framework instrumentation tests.
2022     */
2023    public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2024            "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
2025    /**
2026     * An activity to run when device is inserted into a car dock.
2027     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
2028     * information, see {@link android.app.UiModeManager}.
2029     */
2030    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2031    public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2032    /**
2033     * An activity to run when device is inserted into a car dock.
2034     * Used with {@link #ACTION_MAIN} to launch an activity.  For more
2035     * information, see {@link android.app.UiModeManager}.
2036     */
2037    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2038    public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
2039
2040    /**
2041     * Used to indicate that the activity can be used in a car environment.
2042     */
2043    @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2044    public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2045
2046    // ---------------------------------------------------------------------
2047    // ---------------------------------------------------------------------
2048    // Standard extra data keys.
2049
2050    /**
2051     * The initial data to place in a newly created record.  Use with
2052     * {@link #ACTION_INSERT}.  The data here is a Map containing the same
2053     * fields as would be given to the underlying ContentProvider.insert()
2054     * call.
2055     */
2056    public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2057
2058    /**
2059     * A constant CharSequence that is associated with the Intent, used with
2060     * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
2061     * this may be a styled CharSequence, so you must use
2062     * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2063     * retrieve it.
2064     */
2065    public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2066
2067    /**
2068     * A content: URI holding a stream of data associated with the Intent,
2069     * used with {@link #ACTION_SEND} to supply the data being sent.
2070     */
2071    public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2072
2073    /**
2074     * A String[] holding e-mail addresses that should be delivered to.
2075     */
2076    public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
2077
2078    /**
2079     * A String[] holding e-mail addresses that should be carbon copied.
2080     */
2081    public static final String EXTRA_CC       = "android.intent.extra.CC";
2082
2083    /**
2084     * A String[] holding e-mail addresses that should be blind carbon copied.
2085     */
2086    public static final String EXTRA_BCC      = "android.intent.extra.BCC";
2087
2088    /**
2089     * A constant string holding the desired subject line of a message.
2090     */
2091    public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
2092
2093    /**
2094     * An Intent describing the choices you would like shown with
2095     * {@link #ACTION_PICK_ACTIVITY}.
2096     */
2097    public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2098
2099    /**
2100     * A CharSequence dialog title to provide to the user when used with a
2101     * {@link #ACTION_CHOOSER}.
2102     */
2103    public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2104
2105    /**
2106     * A Parcelable[] of {@link Intent} or
2107     * {@link android.content.pm.LabeledIntent} objects as set with
2108     * {@link #putExtra(String, Parcelable[])} of additional activities to place
2109     * a the front of the list of choices, when shown to the user with a
2110     * {@link #ACTION_CHOOSER}.
2111     */
2112    public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2113
2114    /**
2115     * A {@link android.view.KeyEvent} object containing the event that
2116     * triggered the creation of the Intent it is in.
2117     */
2118    public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2119
2120    /**
2121     * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2122     * before shutting down.
2123     *
2124     * {@hide}
2125     */
2126    public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2127
2128    /**
2129     * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2130     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2131     * of restarting the application.
2132     */
2133    public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2134
2135    /**
2136     * A String holding the phone number originally entered in
2137     * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2138     * number to call in a {@link android.content.Intent#ACTION_CALL}.
2139     */
2140    public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
2141
2142    /**
2143     * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2144     * intents to supply the uid the package had been assigned.  Also an optional
2145     * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2146     * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2147     * purpose.
2148     */
2149    public static final String EXTRA_UID = "android.intent.extra.UID";
2150
2151    /**
2152     * @hide String array of package names.
2153     */
2154    public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2155
2156    /**
2157     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2158     * intents to indicate whether this represents a full uninstall (removing
2159     * both the code and its data) or a partial uninstall (leaving its data,
2160     * implying that this is an update).
2161     */
2162    public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
2163
2164    /**
2165     * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2166     * intents to indicate that this is a replacement of the package, so this
2167     * broadcast will immediately be followed by an add broadcast for a
2168     * different version of the same package.
2169     */
2170    public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
2171
2172    /**
2173     * Used as an int extra field in {@link android.app.AlarmManager} intents
2174     * to tell the application being invoked how many pending alarms are being
2175     * delievered with the intent.  For one-shot alarms this will always be 1.
2176     * For recurring alarms, this might be greater than 1 if the device was
2177     * asleep or powered off at the time an earlier alarm would have been
2178     * delivered.
2179     */
2180    public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
2181
2182    /**
2183     * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2184     * intents to request the dock state.  Possible values are
2185     * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2186     * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2187     * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
2188     */
2189    public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2190
2191    /**
2192     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2193     * to represent that the phone is not in any dock.
2194     */
2195    public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2196
2197    /**
2198     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2199     * to represent that the phone is in a desk dock.
2200     */
2201    public static final int EXTRA_DOCK_STATE_DESK = 1;
2202
2203    /**
2204     * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2205     * to represent that the phone is in a car dock.
2206     */
2207    public static final int EXTRA_DOCK_STATE_CAR = 2;
2208
2209    /**
2210     * Boolean that can be supplied as meta-data with a dock activity, to
2211     * indicate that the dock should take over the home key when it is active.
2212     */
2213    public static final String METADATA_DOCK_HOME = "android.dock_home";
2214
2215    /**
2216     * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2217     * the bug report.
2218     *
2219     * @hide
2220     */
2221    public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2222
2223    /**
2224     * Used as a string extra field when sending an intent to PackageInstaller to install a
2225     * package. Specifies the installer package name; this package will receive the
2226     * {@link #ACTION_APP_ERROR} intent.
2227     *
2228     * @hide
2229     */
2230    public static final String EXTRA_INSTALLER_PACKAGE_NAME
2231            = "android.intent.extra.INSTALLER_PACKAGE_NAME";
2232
2233    /**
2234     * Used in the extra field in the remote intent. It's astring token passed with the
2235     * remote intent.
2236     */
2237    public static final String EXTRA_REMOTE_INTENT_TOKEN =
2238            "android.intent.extra.remote_intent_token";
2239
2240    /**
2241     * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
2242     * will contain only the first name in the list.
2243     */
2244    @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
2245            "android.intent.extra.changed_component_name";
2246
2247    /**
2248     * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
2249     * and contains a string array of all of the components that have changed.
2250     */
2251    public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2252            "android.intent.extra.changed_component_name_list";
2253
2254    /**
2255     * This field is part of
2256     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2257     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
2258     * and contains a string array of all of the components that have changed.
2259     */
2260    public static final String EXTRA_CHANGED_PACKAGE_LIST =
2261            "android.intent.extra.changed_package_list";
2262
2263    /**
2264     * This field is part of
2265     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2266     * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
2267     * and contains an integer array of uids of all of the components
2268     * that have changed.
2269     */
2270    public static final String EXTRA_CHANGED_UID_LIST =
2271            "android.intent.extra.changed_uid_list";
2272
2273    /**
2274     * @hide
2275     * Magic extra system code can use when binding, to give a label for
2276     * who it is that has bound to a service.  This is an integer giving
2277     * a framework string resource that can be displayed to the user.
2278     */
2279    public static final String EXTRA_CLIENT_LABEL =
2280            "android.intent.extra.client_label";
2281
2282    /**
2283     * @hide
2284     * Magic extra system code can use when binding, to give a PendingIntent object
2285     * that can be launched for the user to disable the system's use of this
2286     * service.
2287     */
2288    public static final String EXTRA_CLIENT_INTENT =
2289            "android.intent.extra.client_intent";
2290
2291    // ---------------------------------------------------------------------
2292    // ---------------------------------------------------------------------
2293    // Intent flags (see mFlags variable).
2294
2295    /**
2296     * If set, the recipient of this Intent will be granted permission to
2297     * perform read operations on the Uri in the Intent's data.
2298     */
2299    public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2300    /**
2301     * If set, the recipient of this Intent will be granted permission to
2302     * perform write operations on the Uri in the Intent's data.
2303     */
2304    public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2305    /**
2306     * Can be set by the caller to indicate that this Intent is coming from
2307     * a background operation, not from direct user interaction.
2308     */
2309    public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2310    /**
2311     * A flag you can enable for debugging: when set, log messages will be
2312     * printed during the resolution of this intent to show you what has
2313     * been found to create the final resolved list.
2314     */
2315    public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
2316
2317    /**
2318     * If set, the new activity is not kept in the history stack.  As soon as
2319     * the user navigates away from it, the activity is finished.  This may also
2320     * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2321     * noHistory} attribute.
2322     */
2323    public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2324    /**
2325     * If set, the activity will not be launched if it is already running
2326     * at the top of the history stack.
2327     */
2328    public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2329    /**
2330     * If set, this activity will become the start of a new task on this
2331     * history stack.  A task (from the activity that started it to the
2332     * next task activity) defines an atomic group of activities that the
2333     * user can move to.  Tasks can be moved to the foreground and background;
2334     * all of the activities inside of a particular task always remain in
2335     * the same order.  See
2336     * <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2337     * Activities and Tasks</a> for more details on tasks.
2338     *
2339     * <p>This flag is generally used by activities that want
2340     * to present a "launcher" style behavior: they give the user a list of
2341     * separate things that can be done, which otherwise run completely
2342     * independently of the activity launching them.
2343     *
2344     * <p>When using this flag, if a task is already running for the activity
2345     * you are now starting, then a new activity will not be started; instead,
2346     * the current task will simply be brought to the front of the screen with
2347     * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2348     * to disable this behavior.
2349     *
2350     * <p>This flag can not be used when the caller is requesting a result from
2351     * the activity being launched.
2352     */
2353    public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2354    /**
2355     * <strong>Do not use this flag unless you are implementing your own
2356     * top-level application launcher.</strong>  Used in conjunction with
2357     * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2358     * behavior of bringing an existing task to the foreground.  When set,
2359     * a new task is <em>always</em> started to host the Activity for the
2360     * Intent, regardless of whether there is already an existing task running
2361     * the same thing.
2362     *
2363     * <p><strong>Because the default system does not include graphical task management,
2364     * you should not use this flag unless you provide some way for a user to
2365     * return back to the tasks you have launched.</strong>
2366     *
2367     * <p>This flag is ignored if
2368     * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2369     *
2370     * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2371     * Activities and Tasks</a> for more details on tasks.
2372     */
2373    public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2374    /**
2375     * If set, and the activity being launched is already running in the
2376     * current task, then instead of launching a new instance of that activity,
2377     * all of the other activities on top of it will be closed and this Intent
2378     * will be delivered to the (now on top) old activity as a new Intent.
2379     *
2380     * <p>For example, consider a task consisting of the activities: A, B, C, D.
2381     * If D calls startActivity() with an Intent that resolves to the component
2382     * of activity B, then C and D will be finished and B receive the given
2383     * Intent, resulting in the stack now being: A, B.
2384     *
2385     * <p>The currently running instance of activity B in the above example will
2386     * either receive the new intent you are starting here in its
2387     * onNewIntent() method, or be itself finished and restarted with the
2388     * new intent.  If it has declared its launch mode to be "multiple" (the
2389     * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2390     * the same intent, then it will be finished and re-created; for all other
2391     * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2392     * Intent will be delivered to the current instance's onNewIntent().
2393     *
2394     * <p>This launch mode can also be used to good effect in conjunction with
2395     * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2396     * of a task, it will bring any currently running instance of that task
2397     * to the foreground, and then clear it to its root state.  This is
2398     * especially useful, for example, when launching an activity from the
2399     * notification manager.
2400     *
2401     * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2402     * Activities and Tasks</a> for more details on tasks.
2403     */
2404    public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2405    /**
2406     * If set and this intent is being used to launch a new activity from an
2407     * existing one, then the reply target of the existing activity will be
2408     * transfered to the new activity.  This way the new activity can call
2409     * {@link android.app.Activity#setResult} and have that result sent back to
2410     * the reply target of the original activity.
2411     */
2412    public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2413    /**
2414     * If set and this intent is being used to launch a new activity from an
2415     * existing one, the current activity will not be counted as the top
2416     * activity for deciding whether the new intent should be delivered to
2417     * the top instead of starting a new one.  The previous activity will
2418     * be used as the top, with the assumption being that the current activity
2419     * will finish itself immediately.
2420     */
2421    public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2422    /**
2423     * If set, the new activity is not kept in the list of recently launched
2424     * activities.
2425     */
2426    public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2427    /**
2428     * This flag is not normally set by application code, but set for you by
2429     * the system as described in the
2430     * {@link android.R.styleable#AndroidManifestActivity_launchMode
2431     * launchMode} documentation for the singleTask mode.
2432     */
2433    public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2434    /**
2435     * If set, and this activity is either being started in a new task or
2436     * bringing to the top an existing task, then it will be launched as
2437     * the front door of the task.  This will result in the application of
2438     * any affinities needed to have that task in the proper state (either
2439     * moving activities to or from it), or simply resetting that task to
2440     * its initial state if needed.
2441     */
2442    public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2443    /**
2444     * This flag is not normally set by application code, but set for you by
2445     * the system if this activity is being launched from history
2446     * (longpress home key).
2447     */
2448    public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
2449    /**
2450     * If set, this marks a point in the task's activity stack that should
2451     * be cleared when the task is reset.  That is, the next time the task
2452     * is brought to the foreground with
2453     * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2454     * the user re-launching it from home), this activity and all on top of
2455     * it will be finished so that the user does not return to them, but
2456     * instead returns to whatever activity preceeded it.
2457     *
2458     * <p>This is useful for cases where you have a logical break in your
2459     * application.  For example, an e-mail application may have a command
2460     * to view an attachment, which launches an image view activity to
2461     * display it.  This activity should be part of the e-mail application's
2462     * task, since it is a part of the task the user is involved in.  However,
2463     * if the user leaves that task, and later selects the e-mail app from
2464     * home, we may like them to return to the conversation they were
2465     * viewing, not the picture attachment, since that is confusing.  By
2466     * setting this flag when launching the image viewer, that viewer and
2467     * any activities it starts will be removed the next time the user returns
2468     * to mail.
2469     */
2470    public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
2471    /**
2472     * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
2473     * callback from occurring on the current frontmost activity before it is
2474     * paused as the newly-started activity is brought to the front.
2475     *
2476     * <p>Typically, an activity can rely on that callback to indicate that an
2477     * explicit user action has caused their activity to be moved out of the
2478     * foreground. The callback marks an appropriate point in the activity's
2479     * lifecycle for it to dismiss any notifications that it intends to display
2480     * "until the user has seen them," such as a blinking LED.
2481     *
2482     * <p>If an activity is ever started via any non-user-driven events such as
2483     * phone-call receipt or an alarm handler, this flag should be passed to {@link
2484     * Context#startActivity Context.startActivity}, ensuring that the pausing
2485     * activity does not think the user has acknowledged its notification.
2486     */
2487    public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
2488    /**
2489     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2490     * this flag will cause the launched activity to be brought to the front of its
2491     * task's history stack if it is already running.
2492     *
2493     * <p>For example, consider a task consisting of four activities: A, B, C, D.
2494     * If D calls startActivity() with an Intent that resolves to the component
2495     * of activity B, then B will be brought to the front of the history stack,
2496     * with this resulting order:  A, C, D, B.
2497     *
2498     * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
2499     * specified.
2500     */
2501    public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
2502    /**
2503     * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2504     * this flag will prevent the system from applying an activity transition
2505     * animation to go to the next activity state.  This doesn't mean an
2506     * animation will never run -- if another activity change happens that doesn't
2507     * specify this flag before the activity started here is displayed, then
2508     * that transition will be used.  This this flag can be put to good use
2509     * when you are going to do a series of activity operations but the
2510     * animation seen by the user shouldn't be driven by the first activity
2511     * change but rather a later one.
2512     */
2513    public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2514    /**
2515     * If set, when sending a broadcast only registered receivers will be
2516     * called -- no BroadcastReceiver components will be launched.
2517     */
2518    public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
2519    /**
2520     * If set, when sending a broadcast the new broadcast will replace
2521     * any existing pending broadcast that matches it.  Matching is defined
2522     * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2523     * true for the intents of the two broadcasts.  When a match is found,
2524     * the new broadcast (and receivers associated with it) will replace the
2525     * existing one in the pending broadcast list, remaining at the same
2526     * position in the list.
2527     *
2528     * <p>This flag is most typically used with sticky broadcasts, which
2529     * only care about delivering the most recent values of the broadcast
2530     * to their receivers.
2531     */
2532    public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2533    /**
2534     * If set, when sending a broadcast <i>before boot has completed</i> only
2535     * registered receivers will be called -- no BroadcastReceiver components
2536     * will be launched.  Sticky intent state will be recorded properly even
2537     * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2538     * is specified in the broadcast intent, this flag is unnecessary.
2539     *
2540     * <p>This flag is only for use by system sevices as a convenience to
2541     * avoid having to implement a more complex mechanism around detection
2542     * of boot completion.
2543     *
2544     * @hide
2545     */
2546    public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
2547    /**
2548     * Set when this broadcast is for a boot upgrade, a special mode that
2549     * allows the broadcast to be sent before the system is ready and launches
2550     * the app process with no providers running in it.
2551     * @hide
2552     */
2553    public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
2554
2555    /**
2556     * @hide Flags that can't be changed with PendingIntent.
2557     */
2558    public static final int IMMUTABLE_FLAGS =
2559            FLAG_GRANT_READ_URI_PERMISSION
2560            | FLAG_GRANT_WRITE_URI_PERMISSION;
2561
2562    // ---------------------------------------------------------------------
2563    // ---------------------------------------------------------------------
2564    // toUri() and parseUri() options.
2565
2566    /**
2567     * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2568     * always has the "intent:" scheme.  This syntax can be used when you want
2569     * to later disambiguate between URIs that are intended to describe an
2570     * Intent vs. all others that should be treated as raw URIs.  When used
2571     * with {@link #parseUri}, any other scheme will result in a generic
2572     * VIEW action for that raw URI.
2573     */
2574    public static final int URI_INTENT_SCHEME = 1<<0;
2575
2576    // ---------------------------------------------------------------------
2577
2578    private String mAction;
2579    private Uri mData;
2580    private String mType;
2581    private String mPackage;
2582    private ComponentName mComponent;
2583    private int mFlags;
2584    private HashSet<String> mCategories;
2585    private Bundle mExtras;
2586    private Rect mSourceBounds;
2587
2588    // ---------------------------------------------------------------------
2589
2590    /**
2591     * Create an empty intent.
2592     */
2593    public Intent() {
2594    }
2595
2596    /**
2597     * Copy constructor.
2598     */
2599    public Intent(Intent o) {
2600        this.mAction = o.mAction;
2601        this.mData = o.mData;
2602        this.mType = o.mType;
2603        this.mPackage = o.mPackage;
2604        this.mComponent = o.mComponent;
2605        this.mFlags = o.mFlags;
2606        if (o.mCategories != null) {
2607            this.mCategories = new HashSet<String>(o.mCategories);
2608        }
2609        if (o.mExtras != null) {
2610            this.mExtras = new Bundle(o.mExtras);
2611        }
2612        if (o.mSourceBounds != null) {
2613            this.mSourceBounds = new Rect(o.mSourceBounds);
2614        }
2615    }
2616
2617    @Override
2618    public Object clone() {
2619        return new Intent(this);
2620    }
2621
2622    private Intent(Intent o, boolean all) {
2623        this.mAction = o.mAction;
2624        this.mData = o.mData;
2625        this.mType = o.mType;
2626        this.mPackage = o.mPackage;
2627        this.mComponent = o.mComponent;
2628        if (o.mCategories != null) {
2629            this.mCategories = new HashSet<String>(o.mCategories);
2630        }
2631    }
2632
2633    /**
2634     * Make a clone of only the parts of the Intent that are relevant for
2635     * filter matching: the action, data, type, component, and categories.
2636     */
2637    public Intent cloneFilter() {
2638        return new Intent(this, false);
2639    }
2640
2641    /**
2642     * Create an intent with a given action.  All other fields (data, type,
2643     * class) are null.  Note that the action <em>must</em> be in a
2644     * namespace because Intents are used globally in the system -- for
2645     * example the system VIEW action is android.intent.action.VIEW; an
2646     * application's custom action would be something like
2647     * com.google.app.myapp.CUSTOM_ACTION.
2648     *
2649     * @param action The Intent action, such as ACTION_VIEW.
2650     */
2651    public Intent(String action) {
2652        mAction = action;
2653    }
2654
2655    /**
2656     * Create an intent with a given action and for a given data url.  Note
2657     * that the action <em>must</em> be in a namespace because Intents are
2658     * used globally in the system -- for example the system VIEW action is
2659     * android.intent.action.VIEW; an application's custom action would be
2660     * something like com.google.app.myapp.CUSTOM_ACTION.
2661     *
2662     * <p><em>Note: scheme and host name matching in the Android framework is
2663     * case-sensitive, unlike the formal RFC.  As a result,
2664     * you should always ensure that you write your Uri with these elements
2665     * using lower case letters, and normalize any Uris you receive from
2666     * outside of Android to ensure the scheme and host is lower case.</em></p>
2667     *
2668     * @param action The Intent action, such as ACTION_VIEW.
2669     * @param uri The Intent data URI.
2670     */
2671    public Intent(String action, Uri uri) {
2672        mAction = action;
2673        mData = uri;
2674    }
2675
2676    /**
2677     * Create an intent for a specific component.  All other fields (action, data,
2678     * type, class) are null, though they can be modified later with explicit
2679     * calls.  This provides a convenient way to create an intent that is
2680     * intended to execute a hard-coded class name, rather than relying on the
2681     * system to find an appropriate class for you; see {@link #setComponent}
2682     * for more information on the repercussions of this.
2683     *
2684     * @param packageContext A Context of the application package implementing
2685     * this class.
2686     * @param cls The component class that is to be used for the intent.
2687     *
2688     * @see #setClass
2689     * @see #setComponent
2690     * @see #Intent(String, android.net.Uri , Context, Class)
2691     */
2692    public Intent(Context packageContext, Class<?> cls) {
2693        mComponent = new ComponentName(packageContext, cls);
2694    }
2695
2696    /**
2697     * Create an intent for a specific component with a specified action and data.
2698     * This is equivalent using {@link #Intent(String, android.net.Uri)} to
2699     * construct the Intent and then calling {@link #setClass} to set its
2700     * class.
2701     *
2702     * <p><em>Note: scheme and host name matching in the Android framework is
2703     * case-sensitive, unlike the formal RFC.  As a result,
2704     * you should always ensure that you write your Uri with these elements
2705     * using lower case letters, and normalize any Uris you receive from
2706     * outside of Android to ensure the scheme and host is lower case.</em></p>
2707     *
2708     * @param action The Intent action, such as ACTION_VIEW.
2709     * @param uri The Intent data URI.
2710     * @param packageContext A Context of the application package implementing
2711     * this class.
2712     * @param cls The component class that is to be used for the intent.
2713     *
2714     * @see #Intent(String, android.net.Uri)
2715     * @see #Intent(Context, Class)
2716     * @see #setClass
2717     * @see #setComponent
2718     */
2719    public Intent(String action, Uri uri,
2720            Context packageContext, Class<?> cls) {
2721        mAction = action;
2722        mData = uri;
2723        mComponent = new ComponentName(packageContext, cls);
2724    }
2725
2726    /**
2727     * Call {@link #parseUri} with 0 flags.
2728     * @deprecated Use {@link #parseUri} instead.
2729     */
2730    @Deprecated
2731    public static Intent getIntent(String uri) throws URISyntaxException {
2732        return parseUri(uri, 0);
2733    }
2734
2735    /**
2736     * Create an intent from a URI.  This URI may encode the action,
2737     * category, and other intent fields, if it was returned by
2738     * {@link #toUri}.  If the Intent was not generate by toUri(), its data
2739     * will be the entire URI and its action will be ACTION_VIEW.
2740     *
2741     * <p>The URI given here must not be relative -- that is, it must include
2742     * the scheme and full path.
2743     *
2744     * @param uri The URI to turn into an Intent.
2745     * @param flags Additional processing flags.  Either 0 or
2746     * {@link #URI_INTENT_SCHEME}.
2747     *
2748     * @return Intent The newly created Intent object.
2749     *
2750     * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
2751     * it bad (as parsed by the Uri class) or the Intent data within the
2752     * URI is invalid.
2753     *
2754     * @see #toUri
2755     */
2756    public static Intent parseUri(String uri, int flags) throws URISyntaxException {
2757        int i = 0;
2758        try {
2759            // Validate intent scheme for if requested.
2760            if ((flags&URI_INTENT_SCHEME) != 0) {
2761                if (!uri.startsWith("intent:")) {
2762                    Intent intent = new Intent(ACTION_VIEW);
2763                    try {
2764                        intent.setData(Uri.parse(uri));
2765                    } catch (IllegalArgumentException e) {
2766                        throw new URISyntaxException(uri, e.getMessage());
2767                    }
2768                    return intent;
2769                }
2770            }
2771
2772            // simple case
2773            i = uri.lastIndexOf("#");
2774            if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
2775
2776            // old format Intent URI
2777            if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
2778
2779            // new format
2780            Intent intent = new Intent(ACTION_VIEW);
2781
2782            // fetch data part, if present
2783            String data = i >= 0 ? uri.substring(0, i) : null;
2784            String scheme = null;
2785            i += "#Intent;".length();
2786
2787            // loop over contents of Intent, all name=value;
2788            while (!uri.startsWith("end", i)) {
2789                int eq = uri.indexOf('=', i);
2790                int semi = uri.indexOf(';', eq);
2791                String value = Uri.decode(uri.substring(eq + 1, semi));
2792
2793                // action
2794                if (uri.startsWith("action=", i)) {
2795                    intent.mAction = value;
2796                }
2797
2798                // categories
2799                else if (uri.startsWith("category=", i)) {
2800                    intent.addCategory(value);
2801                }
2802
2803                // type
2804                else if (uri.startsWith("type=", i)) {
2805                    intent.mType = value;
2806                }
2807
2808                // launch flags
2809                else if (uri.startsWith("launchFlags=", i)) {
2810                    intent.mFlags = Integer.decode(value).intValue();
2811                }
2812
2813                // package
2814                else if (uri.startsWith("package=", i)) {
2815                    intent.mPackage = value;
2816                }
2817
2818                // component
2819                else if (uri.startsWith("component=", i)) {
2820                    intent.mComponent = ComponentName.unflattenFromString(value);
2821                }
2822
2823                // scheme
2824                else if (uri.startsWith("scheme=", i)) {
2825                    scheme = value;
2826                }
2827
2828                // source bounds
2829                else if (uri.startsWith("sourceBounds=", i)) {
2830                    intent.mSourceBounds = Rect.unflattenFromString(value);
2831                }
2832
2833                // extra
2834                else {
2835                    String key = Uri.decode(uri.substring(i + 2, eq));
2836                    // create Bundle if it doesn't already exist
2837                    if (intent.mExtras == null) intent.mExtras = new Bundle();
2838                    Bundle b = intent.mExtras;
2839                    // add EXTRA
2840                    if      (uri.startsWith("S.", i)) b.putString(key, value);
2841                    else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
2842                    else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
2843                    else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
2844                    else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
2845                    else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
2846                    else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
2847                    else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
2848                    else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
2849                    else throw new URISyntaxException(uri, "unknown EXTRA type", i);
2850                }
2851
2852                // move to the next item
2853                i = semi + 1;
2854            }
2855
2856            if (data != null) {
2857                if (data.startsWith("intent:")) {
2858                    data = data.substring(7);
2859                    if (scheme != null) {
2860                        data = scheme + ':' + data;
2861                    }
2862                }
2863
2864                if (data.length() > 0) {
2865                    try {
2866                        intent.mData = Uri.parse(data);
2867                    } catch (IllegalArgumentException e) {
2868                        throw new URISyntaxException(uri, e.getMessage());
2869                    }
2870                }
2871            }
2872
2873            return intent;
2874
2875        } catch (IndexOutOfBoundsException e) {
2876            throw new URISyntaxException(uri, "illegal Intent URI format", i);
2877        }
2878    }
2879
2880    public static Intent getIntentOld(String uri) throws URISyntaxException {
2881        Intent intent;
2882
2883        int i = uri.lastIndexOf('#');
2884        if (i >= 0) {
2885            String action = null;
2886            final int intentFragmentStart = i;
2887            boolean isIntentFragment = false;
2888
2889            i++;
2890
2891            if (uri.regionMatches(i, "action(", 0, 7)) {
2892                isIntentFragment = true;
2893                i += 7;
2894                int j = uri.indexOf(')', i);
2895                action = uri.substring(i, j);
2896                i = j + 1;
2897            }
2898
2899            intent = new Intent(action);
2900
2901            if (uri.regionMatches(i, "categories(", 0, 11)) {
2902                isIntentFragment = true;
2903                i += 11;
2904                int j = uri.indexOf(')', i);
2905                while (i < j) {
2906                    int sep = uri.indexOf('!', i);
2907                    if (sep < 0) sep = j;
2908                    if (i < sep) {
2909                        intent.addCategory(uri.substring(i, sep));
2910                    }
2911                    i = sep + 1;
2912                }
2913                i = j + 1;
2914            }
2915
2916            if (uri.regionMatches(i, "type(", 0, 5)) {
2917                isIntentFragment = true;
2918                i += 5;
2919                int j = uri.indexOf(')', i);
2920                intent.mType = uri.substring(i, j);
2921                i = j + 1;
2922            }
2923
2924            if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
2925                isIntentFragment = true;
2926                i += 12;
2927                int j = uri.indexOf(')', i);
2928                intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
2929                i = j + 1;
2930            }
2931
2932            if (uri.regionMatches(i, "component(", 0, 10)) {
2933                isIntentFragment = true;
2934                i += 10;
2935                int j = uri.indexOf(')', i);
2936                int sep = uri.indexOf('!', i);
2937                if (sep >= 0 && sep < j) {
2938                    String pkg = uri.substring(i, sep);
2939                    String cls = uri.substring(sep + 1, j);
2940                    intent.mComponent = new ComponentName(pkg, cls);
2941                }
2942                i = j + 1;
2943            }
2944
2945            if (uri.regionMatches(i, "extras(", 0, 7)) {
2946                isIntentFragment = true;
2947                i += 7;
2948
2949                final int closeParen = uri.indexOf(')', i);
2950                if (closeParen == -1) throw new URISyntaxException(uri,
2951                        "EXTRA missing trailing ')'", i);
2952
2953                while (i < closeParen) {
2954                    // fetch the key value
2955                    int j = uri.indexOf('=', i);
2956                    if (j <= i + 1 || i >= closeParen) {
2957                        throw new URISyntaxException(uri, "EXTRA missing '='", i);
2958                    }
2959                    char type = uri.charAt(i);
2960                    i++;
2961                    String key = uri.substring(i, j);
2962                    i = j + 1;
2963
2964                    // get type-value
2965                    j = uri.indexOf('!', i);
2966                    if (j == -1 || j >= closeParen) j = closeParen;
2967                    if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
2968                    String value = uri.substring(i, j);
2969                    i = j;
2970
2971                    // create Bundle if it doesn't already exist
2972                    if (intent.mExtras == null) intent.mExtras = new Bundle();
2973
2974                    // add item to bundle
2975                    try {
2976                        switch (type) {
2977                            case 'S':
2978                                intent.mExtras.putString(key, Uri.decode(value));
2979                                break;
2980                            case 'B':
2981                                intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
2982                                break;
2983                            case 'b':
2984                                intent.mExtras.putByte(key, Byte.parseByte(value));
2985                                break;
2986                            case 'c':
2987                                intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
2988                                break;
2989                            case 'd':
2990                                intent.mExtras.putDouble(key, Double.parseDouble(value));
2991                                break;
2992                            case 'f':
2993                                intent.mExtras.putFloat(key, Float.parseFloat(value));
2994                                break;
2995                            case 'i':
2996                                intent.mExtras.putInt(key, Integer.parseInt(value));
2997                                break;
2998                            case 'l':
2999                                intent.mExtras.putLong(key, Long.parseLong(value));
3000                                break;
3001                            case 's':
3002                                intent.mExtras.putShort(key, Short.parseShort(value));
3003                                break;
3004                            default:
3005                                throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3006                        }
3007                    } catch (NumberFormatException e) {
3008                        throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3009                    }
3010
3011                    char ch = uri.charAt(i);
3012                    if (ch == ')') break;
3013                    if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3014                    i++;
3015                }
3016            }
3017
3018            if (isIntentFragment) {
3019                intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3020            } else {
3021                intent.mData = Uri.parse(uri);
3022            }
3023
3024            if (intent.mAction == null) {
3025                // By default, if no action is specified, then use VIEW.
3026                intent.mAction = ACTION_VIEW;
3027            }
3028
3029        } else {
3030            intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3031        }
3032
3033        return intent;
3034    }
3035
3036    /**
3037     * Retrieve the general action to be performed, such as
3038     * {@link #ACTION_VIEW}.  The action describes the general way the rest of
3039     * the information in the intent should be interpreted -- most importantly,
3040     * what to do with the data returned by {@link #getData}.
3041     *
3042     * @return The action of this intent or null if none is specified.
3043     *
3044     * @see #setAction
3045     */
3046    public String getAction() {
3047        return mAction;
3048    }
3049
3050    /**
3051     * Retrieve data this intent is operating on.  This URI specifies the name
3052     * of the data; often it uses the content: scheme, specifying data in a
3053     * content provider.  Other schemes may be handled by specific activities,
3054     * such as http: by the web browser.
3055     *
3056     * @return The URI of the data this intent is targeting or null.
3057     *
3058     * @see #getScheme
3059     * @see #setData
3060     */
3061    public Uri getData() {
3062        return mData;
3063    }
3064
3065    /**
3066     * The same as {@link #getData()}, but returns the URI as an encoded
3067     * String.
3068     */
3069    public String getDataString() {
3070        return mData != null ? mData.toString() : null;
3071    }
3072
3073    /**
3074     * Return the scheme portion of the intent's data.  If the data is null or
3075     * does not include a scheme, null is returned.  Otherwise, the scheme
3076     * prefix without the final ':' is returned, i.e. "http".
3077     *
3078     * <p>This is the same as calling getData().getScheme() (and checking for
3079     * null data).
3080     *
3081     * @return The scheme of this intent.
3082     *
3083     * @see #getData
3084     */
3085    public String getScheme() {
3086        return mData != null ? mData.getScheme() : null;
3087    }
3088
3089    /**
3090     * Retrieve any explicit MIME type included in the intent.  This is usually
3091     * null, as the type is determined by the intent data.
3092     *
3093     * @return If a type was manually set, it is returned; else null is
3094     *         returned.
3095     *
3096     * @see #resolveType(ContentResolver)
3097     * @see #setType
3098     */
3099    public String getType() {
3100        return mType;
3101    }
3102
3103    /**
3104     * Return the MIME data type of this intent.  If the type field is
3105     * explicitly set, that is simply returned.  Otherwise, if the data is set,
3106     * the type of that data is returned.  If neither fields are set, a null is
3107     * returned.
3108     *
3109     * @return The MIME type of this intent.
3110     *
3111     * @see #getType
3112     * @see #resolveType(ContentResolver)
3113     */
3114    public String resolveType(Context context) {
3115        return resolveType(context.getContentResolver());
3116    }
3117
3118    /**
3119     * Return the MIME data type of this intent.  If the type field is
3120     * explicitly set, that is simply returned.  Otherwise, if the data is set,
3121     * the type of that data is returned.  If neither fields are set, a null is
3122     * returned.
3123     *
3124     * @param resolver A ContentResolver that can be used to determine the MIME
3125     *                 type of the intent's data.
3126     *
3127     * @return The MIME type of this intent.
3128     *
3129     * @see #getType
3130     * @see #resolveType(Context)
3131     */
3132    public String resolveType(ContentResolver resolver) {
3133        if (mType != null) {
3134            return mType;
3135        }
3136        if (mData != null) {
3137            if ("content".equals(mData.getScheme())) {
3138                return resolver.getType(mData);
3139            }
3140        }
3141        return null;
3142    }
3143
3144    /**
3145     * Return the MIME data type of this intent, only if it will be needed for
3146     * intent resolution.  This is not generally useful for application code;
3147     * it is used by the frameworks for communicating with back-end system
3148     * services.
3149     *
3150     * @param resolver A ContentResolver that can be used to determine the MIME
3151     *                 type of the intent's data.
3152     *
3153     * @return The MIME type of this intent, or null if it is unknown or not
3154     *         needed.
3155     */
3156    public String resolveTypeIfNeeded(ContentResolver resolver) {
3157        if (mComponent != null) {
3158            return mType;
3159        }
3160        return resolveType(resolver);
3161    }
3162
3163    /**
3164     * Check if an category exists in the intent.
3165     *
3166     * @param category The category to check.
3167     *
3168     * @return boolean True if the intent contains the category, else false.
3169     *
3170     * @see #getCategories
3171     * @see #addCategory
3172     */
3173    public boolean hasCategory(String category) {
3174        return mCategories != null && mCategories.contains(category);
3175    }
3176
3177    /**
3178     * Return the set of all categories in the intent.  If there are no categories,
3179     * returns NULL.
3180     *
3181     * @return Set The set of categories you can examine.  Do not modify!
3182     *
3183     * @see #hasCategory
3184     * @see #addCategory
3185     */
3186    public Set<String> getCategories() {
3187        return mCategories;
3188    }
3189
3190    /**
3191     * Sets the ClassLoader that will be used when unmarshalling
3192     * any Parcelable values from the extras of this Intent.
3193     *
3194     * @param loader a ClassLoader, or null to use the default loader
3195     * at the time of unmarshalling.
3196     */
3197    public void setExtrasClassLoader(ClassLoader loader) {
3198        if (mExtras != null) {
3199            mExtras.setClassLoader(loader);
3200        }
3201    }
3202
3203    /**
3204     * Returns true if an extra value is associated with the given name.
3205     * @param name the extra's name
3206     * @return true if the given extra is present.
3207     */
3208    public boolean hasExtra(String name) {
3209        return mExtras != null && mExtras.containsKey(name);
3210    }
3211
3212    /**
3213     * Returns true if the Intent's extras contain a parcelled file descriptor.
3214     * @return true if the Intent contains a parcelled file descriptor.
3215     */
3216    public boolean hasFileDescriptors() {
3217        return mExtras != null && mExtras.hasFileDescriptors();
3218    }
3219
3220    /**
3221     * Retrieve extended data from the intent.
3222     *
3223     * @param name The name of the desired item.
3224     *
3225     * @return the value of an item that previously added with putExtra()
3226     * or null if none was found.
3227     *
3228     * @deprecated
3229     * @hide
3230     */
3231    @Deprecated
3232    public Object getExtra(String name) {
3233        return getExtra(name, null);
3234    }
3235
3236    /**
3237     * Retrieve extended data from the intent.
3238     *
3239     * @param name The name of the desired item.
3240     * @param defaultValue the value to be returned if no value of the desired
3241     * type is stored with the given name.
3242     *
3243     * @return the value of an item that previously added with putExtra()
3244     * or the default value if none was found.
3245     *
3246     * @see #putExtra(String, boolean)
3247     */
3248    public boolean getBooleanExtra(String name, boolean defaultValue) {
3249        return mExtras == null ? defaultValue :
3250            mExtras.getBoolean(name, defaultValue);
3251    }
3252
3253    /**
3254     * Retrieve extended data from the intent.
3255     *
3256     * @param name The name of the desired item.
3257     * @param defaultValue the value to be returned if no value of the desired
3258     * type is stored with the given name.
3259     *
3260     * @return the value of an item that previously added with putExtra()
3261     * or the default value if none was found.
3262     *
3263     * @see #putExtra(String, byte)
3264     */
3265    public byte getByteExtra(String name, byte defaultValue) {
3266        return mExtras == null ? defaultValue :
3267            mExtras.getByte(name, defaultValue);
3268    }
3269
3270    /**
3271     * Retrieve extended data from the intent.
3272     *
3273     * @param name The name of the desired item.
3274     * @param defaultValue the value to be returned if no value of the desired
3275     * type is stored with the given name.
3276     *
3277     * @return the value of an item that previously added with putExtra()
3278     * or the default value if none was found.
3279     *
3280     * @see #putExtra(String, short)
3281     */
3282    public short getShortExtra(String name, short defaultValue) {
3283        return mExtras == null ? defaultValue :
3284            mExtras.getShort(name, defaultValue);
3285    }
3286
3287    /**
3288     * Retrieve extended data from the intent.
3289     *
3290     * @param name The name of the desired item.
3291     * @param defaultValue the value to be returned if no value of the desired
3292     * type is stored with the given name.
3293     *
3294     * @return the value of an item that previously added with putExtra()
3295     * or the default value if none was found.
3296     *
3297     * @see #putExtra(String, char)
3298     */
3299    public char getCharExtra(String name, char defaultValue) {
3300        return mExtras == null ? defaultValue :
3301            mExtras.getChar(name, defaultValue);
3302    }
3303
3304    /**
3305     * Retrieve extended data from the intent.
3306     *
3307     * @param name The name of the desired item.
3308     * @param defaultValue the value to be returned if no value of the desired
3309     * type is stored with the given name.
3310     *
3311     * @return the value of an item that previously added with putExtra()
3312     * or the default value if none was found.
3313     *
3314     * @see #putExtra(String, int)
3315     */
3316    public int getIntExtra(String name, int defaultValue) {
3317        return mExtras == null ? defaultValue :
3318            mExtras.getInt(name, defaultValue);
3319    }
3320
3321    /**
3322     * Retrieve extended data from the intent.
3323     *
3324     * @param name The name of the desired item.
3325     * @param defaultValue the value to be returned if no value of the desired
3326     * type is stored with the given name.
3327     *
3328     * @return the value of an item that previously added with putExtra()
3329     * or the default value if none was found.
3330     *
3331     * @see #putExtra(String, long)
3332     */
3333    public long getLongExtra(String name, long defaultValue) {
3334        return mExtras == null ? defaultValue :
3335            mExtras.getLong(name, defaultValue);
3336    }
3337
3338    /**
3339     * Retrieve extended data from the intent.
3340     *
3341     * @param name The name of the desired item.
3342     * @param defaultValue the value to be returned if no value of the desired
3343     * type is stored with the given name.
3344     *
3345     * @return the value of an item that previously added with putExtra(),
3346     * or the default value if no such item is present
3347     *
3348     * @see #putExtra(String, float)
3349     */
3350    public float getFloatExtra(String name, float defaultValue) {
3351        return mExtras == null ? defaultValue :
3352            mExtras.getFloat(name, defaultValue);
3353    }
3354
3355    /**
3356     * Retrieve extended data from the intent.
3357     *
3358     * @param name The name of the desired item.
3359     * @param defaultValue the value to be returned if no value of the desired
3360     * type is stored with the given name.
3361     *
3362     * @return the value of an item that previously added with putExtra()
3363     * or the default value if none was found.
3364     *
3365     * @see #putExtra(String, double)
3366     */
3367    public double getDoubleExtra(String name, double defaultValue) {
3368        return mExtras == null ? defaultValue :
3369            mExtras.getDouble(name, defaultValue);
3370    }
3371
3372    /**
3373     * Retrieve extended data from the intent.
3374     *
3375     * @param name The name of the desired item.
3376     *
3377     * @return the value of an item that previously added with putExtra()
3378     * or null if no String value was found.
3379     *
3380     * @see #putExtra(String, String)
3381     */
3382    public String getStringExtra(String name) {
3383        return mExtras == null ? null : mExtras.getString(name);
3384    }
3385
3386    /**
3387     * Retrieve extended data from the intent.
3388     *
3389     * @param name The name of the desired item.
3390     *
3391     * @return the value of an item that previously added with putExtra()
3392     * or null if no CharSequence value was found.
3393     *
3394     * @see #putExtra(String, CharSequence)
3395     */
3396    public CharSequence getCharSequenceExtra(String name) {
3397        return mExtras == null ? null : mExtras.getCharSequence(name);
3398    }
3399
3400    /**
3401     * Retrieve extended data from the intent.
3402     *
3403     * @param name The name of the desired item.
3404     *
3405     * @return the value of an item that previously added with putExtra()
3406     * or null if no Parcelable value was found.
3407     *
3408     * @see #putExtra(String, Parcelable)
3409     */
3410    public <T extends Parcelable> T getParcelableExtra(String name) {
3411        return mExtras == null ? null : mExtras.<T>getParcelable(name);
3412    }
3413
3414    /**
3415     * Retrieve extended data from the intent.
3416     *
3417     * @param name The name of the desired item.
3418     *
3419     * @return the value of an item that previously added with putExtra()
3420     * or null if no Parcelable[] value was found.
3421     *
3422     * @see #putExtra(String, Parcelable[])
3423     */
3424    public Parcelable[] getParcelableArrayExtra(String name) {
3425        return mExtras == null ? null : mExtras.getParcelableArray(name);
3426    }
3427
3428    /**
3429     * Retrieve extended data from the intent.
3430     *
3431     * @param name The name of the desired item.
3432     *
3433     * @return the value of an item that previously added with putExtra()
3434     * or null if no ArrayList<Parcelable> value was found.
3435     *
3436     * @see #putParcelableArrayListExtra(String, ArrayList)
3437     */
3438    public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3439        return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3440    }
3441
3442    /**
3443     * Retrieve extended data from the intent.
3444     *
3445     * @param name The name of the desired item.
3446     *
3447     * @return the value of an item that previously added with putExtra()
3448     * or null if no Serializable value was found.
3449     *
3450     * @see #putExtra(String, Serializable)
3451     */
3452    public Serializable getSerializableExtra(String name) {
3453        return mExtras == null ? null : mExtras.getSerializable(name);
3454    }
3455
3456    /**
3457     * Retrieve extended data from the intent.
3458     *
3459     * @param name The name of the desired item.
3460     *
3461     * @return the value of an item that previously added with putExtra()
3462     * or null if no ArrayList<Integer> value was found.
3463     *
3464     * @see #putIntegerArrayListExtra(String, ArrayList)
3465     */
3466    public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3467        return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3468    }
3469
3470    /**
3471     * Retrieve extended data from the intent.
3472     *
3473     * @param name The name of the desired item.
3474     *
3475     * @return the value of an item that previously added with putExtra()
3476     * or null if no ArrayList<String> value was found.
3477     *
3478     * @see #putStringArrayListExtra(String, ArrayList)
3479     */
3480    public ArrayList<String> getStringArrayListExtra(String name) {
3481        return mExtras == null ? null : mExtras.getStringArrayList(name);
3482    }
3483
3484    /**
3485     * Retrieve extended data from the intent.
3486     *
3487     * @param name The name of the desired item.
3488     *
3489     * @return the value of an item that previously added with putExtra()
3490     * or null if no ArrayList<CharSequence> value was found.
3491     *
3492     * @see #putCharSequenceArrayListExtra(String, ArrayList)
3493     */
3494    public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3495        return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3496    }
3497
3498    /**
3499     * Retrieve extended data from the intent.
3500     *
3501     * @param name The name of the desired item.
3502     *
3503     * @return the value of an item that previously added with putExtra()
3504     * or null if no boolean array value was found.
3505     *
3506     * @see #putExtra(String, boolean[])
3507     */
3508    public boolean[] getBooleanArrayExtra(String name) {
3509        return mExtras == null ? null : mExtras.getBooleanArray(name);
3510    }
3511
3512    /**
3513     * Retrieve extended data from the intent.
3514     *
3515     * @param name The name of the desired item.
3516     *
3517     * @return the value of an item that previously added with putExtra()
3518     * or null if no byte array value was found.
3519     *
3520     * @see #putExtra(String, byte[])
3521     */
3522    public byte[] getByteArrayExtra(String name) {
3523        return mExtras == null ? null : mExtras.getByteArray(name);
3524    }
3525
3526    /**
3527     * Retrieve extended data from the intent.
3528     *
3529     * @param name The name of the desired item.
3530     *
3531     * @return the value of an item that previously added with putExtra()
3532     * or null if no short array value was found.
3533     *
3534     * @see #putExtra(String, short[])
3535     */
3536    public short[] getShortArrayExtra(String name) {
3537        return mExtras == null ? null : mExtras.getShortArray(name);
3538    }
3539
3540    /**
3541     * Retrieve extended data from the intent.
3542     *
3543     * @param name The name of the desired item.
3544     *
3545     * @return the value of an item that previously added with putExtra()
3546     * or null if no char array value was found.
3547     *
3548     * @see #putExtra(String, char[])
3549     */
3550    public char[] getCharArrayExtra(String name) {
3551        return mExtras == null ? null : mExtras.getCharArray(name);
3552    }
3553
3554    /**
3555     * Retrieve extended data from the intent.
3556     *
3557     * @param name The name of the desired item.
3558     *
3559     * @return the value of an item that previously added with putExtra()
3560     * or null if no int array value was found.
3561     *
3562     * @see #putExtra(String, int[])
3563     */
3564    public int[] getIntArrayExtra(String name) {
3565        return mExtras == null ? null : mExtras.getIntArray(name);
3566    }
3567
3568    /**
3569     * Retrieve extended data from the intent.
3570     *
3571     * @param name The name of the desired item.
3572     *
3573     * @return the value of an item that previously added with putExtra()
3574     * or null if no long array value was found.
3575     *
3576     * @see #putExtra(String, long[])
3577     */
3578    public long[] getLongArrayExtra(String name) {
3579        return mExtras == null ? null : mExtras.getLongArray(name);
3580    }
3581
3582    /**
3583     * Retrieve extended data from the intent.
3584     *
3585     * @param name The name of the desired item.
3586     *
3587     * @return the value of an item that previously added with putExtra()
3588     * or null if no float array value was found.
3589     *
3590     * @see #putExtra(String, float[])
3591     */
3592    public float[] getFloatArrayExtra(String name) {
3593        return mExtras == null ? null : mExtras.getFloatArray(name);
3594    }
3595
3596    /**
3597     * Retrieve extended data from the intent.
3598     *
3599     * @param name The name of the desired item.
3600     *
3601     * @return the value of an item that previously added with putExtra()
3602     * or null if no double array value was found.
3603     *
3604     * @see #putExtra(String, double[])
3605     */
3606    public double[] getDoubleArrayExtra(String name) {
3607        return mExtras == null ? null : mExtras.getDoubleArray(name);
3608    }
3609
3610    /**
3611     * Retrieve extended data from the intent.
3612     *
3613     * @param name The name of the desired item.
3614     *
3615     * @return the value of an item that previously added with putExtra()
3616     * or null if no String array value was found.
3617     *
3618     * @see #putExtra(String, String[])
3619     */
3620    public String[] getStringArrayExtra(String name) {
3621        return mExtras == null ? null : mExtras.getStringArray(name);
3622    }
3623
3624    /**
3625     * Retrieve extended data from the intent.
3626     *
3627     * @param name The name of the desired item.
3628     *
3629     * @return the value of an item that previously added with putExtra()
3630     * or null if no CharSequence array value was found.
3631     *
3632     * @see #putExtra(String, CharSequence[])
3633     */
3634    public CharSequence[] getCharSequenceArrayExtra(String name) {
3635        return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3636    }
3637
3638    /**
3639     * Retrieve extended data from the intent.
3640     *
3641     * @param name The name of the desired item.
3642     *
3643     * @return the value of an item that previously added with putExtra()
3644     * or null if no Bundle value was found.
3645     *
3646     * @see #putExtra(String, Bundle)
3647     */
3648    public Bundle getBundleExtra(String name) {
3649        return mExtras == null ? null : mExtras.getBundle(name);
3650    }
3651
3652    /**
3653     * Retrieve extended data from the intent.
3654     *
3655     * @param name The name of the desired item.
3656     *
3657     * @return the value of an item that previously added with putExtra()
3658     * or null if no IBinder value was found.
3659     *
3660     * @see #putExtra(String, IBinder)
3661     *
3662     * @deprecated
3663     * @hide
3664     */
3665    @Deprecated
3666    public IBinder getIBinderExtra(String name) {
3667        return mExtras == null ? null : mExtras.getIBinder(name);
3668    }
3669
3670    /**
3671     * Retrieve extended data from the intent.
3672     *
3673     * @param name The name of the desired item.
3674     * @param defaultValue The default value to return in case no item is
3675     * associated with the key 'name'
3676     *
3677     * @return the value of an item that previously added with putExtra()
3678     * or defaultValue if none was found.
3679     *
3680     * @see #putExtra
3681     *
3682     * @deprecated
3683     * @hide
3684     */
3685    @Deprecated
3686    public Object getExtra(String name, Object defaultValue) {
3687        Object result = defaultValue;
3688        if (mExtras != null) {
3689            Object result2 = mExtras.get(name);
3690            if (result2 != null) {
3691                result = result2;
3692            }
3693        }
3694
3695        return result;
3696    }
3697
3698    /**
3699     * Retrieves a map of extended data from the intent.
3700     *
3701     * @return the map of all extras previously added with putExtra(),
3702     * or null if none have been added.
3703     */
3704    public Bundle getExtras() {
3705        return (mExtras != null)
3706                ? new Bundle(mExtras)
3707                : null;
3708    }
3709
3710    /**
3711     * Retrieve any special flags associated with this intent.  You will
3712     * normally just set them with {@link #setFlags} and let the system
3713     * take the appropriate action with them.
3714     *
3715     * @return int The currently set flags.
3716     *
3717     * @see #setFlags
3718     */
3719    public int getFlags() {
3720        return mFlags;
3721    }
3722
3723    /**
3724     * Retrieve the application package name this Intent is limited to.  When
3725     * resolving an Intent, if non-null this limits the resolution to only
3726     * components in the given application package.
3727     *
3728     * @return The name of the application package for the Intent.
3729     *
3730     * @see #resolveActivity
3731     * @see #setPackage
3732     */
3733    public String getPackage() {
3734        return mPackage;
3735    }
3736
3737    /**
3738     * Retrieve the concrete component associated with the intent.  When receiving
3739     * an intent, this is the component that was found to best handle it (that is,
3740     * yourself) and will always be non-null; in all other cases it will be
3741     * null unless explicitly set.
3742     *
3743     * @return The name of the application component to handle the intent.
3744     *
3745     * @see #resolveActivity
3746     * @see #setComponent
3747     */
3748    public ComponentName getComponent() {
3749        return mComponent;
3750    }
3751
3752    /**
3753     * Get the bounds of the sender of this intent, in screen coordinates.  This can be
3754     * used as a hint to the receiver for animations and the like.  Null means that there
3755     * is no source bounds.
3756     */
3757    public Rect getSourceBounds() {
3758        return mSourceBounds;
3759    }
3760
3761    /**
3762     * Return the Activity component that should be used to handle this intent.
3763     * The appropriate component is determined based on the information in the
3764     * intent, evaluated as follows:
3765     *
3766     * <p>If {@link #getComponent} returns an explicit class, that is returned
3767     * without any further consideration.
3768     *
3769     * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
3770     * category to be considered.
3771     *
3772     * <p>If {@link #getAction} is non-NULL, the activity must handle this
3773     * action.
3774     *
3775     * <p>If {@link #resolveType} returns non-NULL, the activity must handle
3776     * this type.
3777     *
3778     * <p>If {@link #addCategory} has added any categories, the activity must
3779     * handle ALL of the categories specified.
3780     *
3781     * <p>If {@link #getPackage} is non-NULL, only activity components in
3782     * that application package will be considered.
3783     *
3784     * <p>If there are no activities that satisfy all of these conditions, a
3785     * null string is returned.
3786     *
3787     * <p>If multiple activities are found to satisfy the intent, the one with
3788     * the highest priority will be used.  If there are multiple activities
3789     * with the same priority, the system will either pick the best activity
3790     * based on user preference, or resolve to a system class that will allow
3791     * the user to pick an activity and forward from there.
3792     *
3793     * <p>This method is implemented simply by calling
3794     * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
3795     * true.</p>
3796     * <p> This API is called for you as part of starting an activity from an
3797     * intent.  You do not normally need to call it yourself.</p>
3798     *
3799     * @param pm The package manager with which to resolve the Intent.
3800     *
3801     * @return Name of the component implementing an activity that can
3802     *         display the intent.
3803     *
3804     * @see #setComponent
3805     * @see #getComponent
3806     * @see #resolveActivityInfo
3807     */
3808    public ComponentName resolveActivity(PackageManager pm) {
3809        if (mComponent != null) {
3810            return mComponent;
3811        }
3812
3813        ResolveInfo info = pm.resolveActivity(
3814            this, PackageManager.MATCH_DEFAULT_ONLY);
3815        if (info != null) {
3816            return new ComponentName(
3817                    info.activityInfo.applicationInfo.packageName,
3818                    info.activityInfo.name);
3819        }
3820
3821        return null;
3822    }
3823
3824    /**
3825     * Resolve the Intent into an {@link ActivityInfo}
3826     * describing the activity that should execute the intent.  Resolution
3827     * follows the same rules as described for {@link #resolveActivity}, but
3828     * you get back the completely information about the resolved activity
3829     * instead of just its class name.
3830     *
3831     * @param pm The package manager with which to resolve the Intent.
3832     * @param flags Addition information to retrieve as per
3833     * {@link PackageManager#getActivityInfo(ComponentName, int)
3834     * PackageManager.getActivityInfo()}.
3835     *
3836     * @return PackageManager.ActivityInfo
3837     *
3838     * @see #resolveActivity
3839     */
3840    public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
3841        ActivityInfo ai = null;
3842        if (mComponent != null) {
3843            try {
3844                ai = pm.getActivityInfo(mComponent, flags);
3845            } catch (PackageManager.NameNotFoundException e) {
3846                // ignore
3847            }
3848        } else {
3849            ResolveInfo info = pm.resolveActivity(
3850                this, PackageManager.MATCH_DEFAULT_ONLY | flags);
3851            if (info != null) {
3852                ai = info.activityInfo;
3853            }
3854        }
3855
3856        return ai;
3857    }
3858
3859    /**
3860     * Set the general action to be performed.
3861     *
3862     * @param action An action name, such as ACTION_VIEW.  Application-specific
3863     *               actions should be prefixed with the vendor's package name.
3864     *
3865     * @return Returns the same Intent object, for chaining multiple calls
3866     * into a single statement.
3867     *
3868     * @see #getAction
3869     */
3870    public Intent setAction(String action) {
3871        mAction = action;
3872        return this;
3873    }
3874
3875    /**
3876     * Set the data this intent is operating on.  This method automatically
3877     * clears any type that was previously set by {@link #setType}.
3878     *
3879     * <p><em>Note: scheme and host name matching in the Android framework is
3880     * case-sensitive, unlike the formal RFC.  As a result,
3881     * you should always ensure that you write your Uri with these elements
3882     * using lower case letters, and normalize any Uris you receive from
3883     * outside of Android to ensure the scheme and host is lower case.</em></p>
3884     *
3885     * @param data The URI of the data this intent is now targeting.
3886     *
3887     * @return Returns the same Intent object, for chaining multiple calls
3888     * into a single statement.
3889     *
3890     * @see #getData
3891     * @see #setType
3892     * @see #setDataAndType
3893     */
3894    public Intent setData(Uri data) {
3895        mData = data;
3896        mType = null;
3897        return this;
3898    }
3899
3900    /**
3901     * Set an explicit MIME data type.  This is used to create intents that
3902     * only specify a type and not data, for example to indicate the type of
3903     * data to return.  This method automatically clears any data that was
3904     * previously set by {@link #setData}.
3905     *
3906     * <p><em>Note: MIME type matching in the Android framework is
3907     * case-sensitive, unlike formal RFC MIME types.  As a result,
3908     * you should always write your MIME types with lower case letters,
3909     * and any MIME types you receive from outside of Android should be
3910     * converted to lower case before supplying them here.</em></p>
3911     *
3912     * @param type The MIME type of the data being handled by this intent.
3913     *
3914     * @return Returns the same Intent object, for chaining multiple calls
3915     * into a single statement.
3916     *
3917     * @see #getType
3918     * @see #setData
3919     * @see #setDataAndType
3920     */
3921    public Intent setType(String type) {
3922        mData = null;
3923        mType = type;
3924        return this;
3925    }
3926
3927    /**
3928     * (Usually optional) Set the data for the intent along with an explicit
3929     * MIME data type.  This method should very rarely be used -- it allows you
3930     * to override the MIME type that would ordinarily be inferred from the
3931     * data with your own type given here.
3932     *
3933     * <p><em>Note: MIME type, Uri scheme, and host name matching in the
3934     * Android framework is case-sensitive, unlike the formal RFC definitions.
3935     * As a result, you should always write these elements with lower case letters,
3936     * and normalize any MIME types or Uris you receive from
3937     * outside of Android to ensure these elements are lower case before
3938     * supplying them here.</em></p>
3939     *
3940     * @param data The URI of the data this intent is now targeting.
3941     * @param type The MIME type of the data being handled by this intent.
3942     *
3943     * @return Returns the same Intent object, for chaining multiple calls
3944     * into a single statement.
3945     *
3946     * @see #setData
3947     * @see #setType
3948     */
3949    public Intent setDataAndType(Uri data, String type) {
3950        mData = data;
3951        mType = type;
3952        return this;
3953    }
3954
3955    /**
3956     * Add a new category to the intent.  Categories provide additional detail
3957     * about the action the intent is perform.  When resolving an intent, only
3958     * activities that provide <em>all</em> of the requested categories will be
3959     * used.
3960     *
3961     * @param category The desired category.  This can be either one of the
3962     *               predefined Intent categories, or a custom category in your own
3963     *               namespace.
3964     *
3965     * @return Returns the same Intent object, for chaining multiple calls
3966     * into a single statement.
3967     *
3968     * @see #hasCategory
3969     * @see #removeCategory
3970     */
3971    public Intent addCategory(String category) {
3972        if (mCategories == null) {
3973            mCategories = new HashSet<String>();
3974        }
3975        mCategories.add(category);
3976        return this;
3977    }
3978
3979    /**
3980     * Remove an category from an intent.
3981     *
3982     * @param category The category to remove.
3983     *
3984     * @see #addCategory
3985     */
3986    public void removeCategory(String category) {
3987        if (mCategories != null) {
3988            mCategories.remove(category);
3989            if (mCategories.size() == 0) {
3990                mCategories = null;
3991            }
3992        }
3993    }
3994
3995    /**
3996     * Add extended data to the intent.  The name must include a package
3997     * prefix, for example the app com.android.contacts would use names
3998     * like "com.android.contacts.ShowAll".
3999     *
4000     * @param name The name of the extra data, with package prefix.
4001     * @param value The boolean data value.
4002     *
4003     * @return Returns the same Intent object, for chaining multiple calls
4004     * into a single statement.
4005     *
4006     * @see #putExtras
4007     * @see #removeExtra
4008     * @see #getBooleanExtra(String, boolean)
4009     */
4010    public Intent putExtra(String name, boolean value) {
4011        if (mExtras == null) {
4012            mExtras = new Bundle();
4013        }
4014        mExtras.putBoolean(name, value);
4015        return this;
4016    }
4017
4018    /**
4019     * Add extended data to the intent.  The name must include a package
4020     * prefix, for example the app com.android.contacts would use names
4021     * like "com.android.contacts.ShowAll".
4022     *
4023     * @param name The name of the extra data, with package prefix.
4024     * @param value The byte data value.
4025     *
4026     * @return Returns the same Intent object, for chaining multiple calls
4027     * into a single statement.
4028     *
4029     * @see #putExtras
4030     * @see #removeExtra
4031     * @see #getByteExtra(String, byte)
4032     */
4033    public Intent putExtra(String name, byte value) {
4034        if (mExtras == null) {
4035            mExtras = new Bundle();
4036        }
4037        mExtras.putByte(name, value);
4038        return this;
4039    }
4040
4041    /**
4042     * Add extended data to the intent.  The name must include a package
4043     * prefix, for example the app com.android.contacts would use names
4044     * like "com.android.contacts.ShowAll".
4045     *
4046     * @param name The name of the extra data, with package prefix.
4047     * @param value The char data value.
4048     *
4049     * @return Returns the same Intent object, for chaining multiple calls
4050     * into a single statement.
4051     *
4052     * @see #putExtras
4053     * @see #removeExtra
4054     * @see #getCharExtra(String, char)
4055     */
4056    public Intent putExtra(String name, char value) {
4057        if (mExtras == null) {
4058            mExtras = new Bundle();
4059        }
4060        mExtras.putChar(name, value);
4061        return this;
4062    }
4063
4064    /**
4065     * Add extended data to the intent.  The name must include a package
4066     * prefix, for example the app com.android.contacts would use names
4067     * like "com.android.contacts.ShowAll".
4068     *
4069     * @param name The name of the extra data, with package prefix.
4070     * @param value The short data value.
4071     *
4072     * @return Returns the same Intent object, for chaining multiple calls
4073     * into a single statement.
4074     *
4075     * @see #putExtras
4076     * @see #removeExtra
4077     * @see #getShortExtra(String, short)
4078     */
4079    public Intent putExtra(String name, short value) {
4080        if (mExtras == null) {
4081            mExtras = new Bundle();
4082        }
4083        mExtras.putShort(name, value);
4084        return this;
4085    }
4086
4087    /**
4088     * Add extended data to the intent.  The name must include a package
4089     * prefix, for example the app com.android.contacts would use names
4090     * like "com.android.contacts.ShowAll".
4091     *
4092     * @param name The name of the extra data, with package prefix.
4093     * @param value The integer data value.
4094     *
4095     * @return Returns the same Intent object, for chaining multiple calls
4096     * into a single statement.
4097     *
4098     * @see #putExtras
4099     * @see #removeExtra
4100     * @see #getIntExtra(String, int)
4101     */
4102    public Intent putExtra(String name, int value) {
4103        if (mExtras == null) {
4104            mExtras = new Bundle();
4105        }
4106        mExtras.putInt(name, value);
4107        return this;
4108    }
4109
4110    /**
4111     * Add extended data to the intent.  The name must include a package
4112     * prefix, for example the app com.android.contacts would use names
4113     * like "com.android.contacts.ShowAll".
4114     *
4115     * @param name The name of the extra data, with package prefix.
4116     * @param value The long data value.
4117     *
4118     * @return Returns the same Intent object, for chaining multiple calls
4119     * into a single statement.
4120     *
4121     * @see #putExtras
4122     * @see #removeExtra
4123     * @see #getLongExtra(String, long)
4124     */
4125    public Intent putExtra(String name, long value) {
4126        if (mExtras == null) {
4127            mExtras = new Bundle();
4128        }
4129        mExtras.putLong(name, value);
4130        return this;
4131    }
4132
4133    /**
4134     * Add extended data to the intent.  The name must include a package
4135     * prefix, for example the app com.android.contacts would use names
4136     * like "com.android.contacts.ShowAll".
4137     *
4138     * @param name The name of the extra data, with package prefix.
4139     * @param value The float data value.
4140     *
4141     * @return Returns the same Intent object, for chaining multiple calls
4142     * into a single statement.
4143     *
4144     * @see #putExtras
4145     * @see #removeExtra
4146     * @see #getFloatExtra(String, float)
4147     */
4148    public Intent putExtra(String name, float value) {
4149        if (mExtras == null) {
4150            mExtras = new Bundle();
4151        }
4152        mExtras.putFloat(name, value);
4153        return this;
4154    }
4155
4156    /**
4157     * Add extended data to the intent.  The name must include a package
4158     * prefix, for example the app com.android.contacts would use names
4159     * like "com.android.contacts.ShowAll".
4160     *
4161     * @param name The name of the extra data, with package prefix.
4162     * @param value The double data value.
4163     *
4164     * @return Returns the same Intent object, for chaining multiple calls
4165     * into a single statement.
4166     *
4167     * @see #putExtras
4168     * @see #removeExtra
4169     * @see #getDoubleExtra(String, double)
4170     */
4171    public Intent putExtra(String name, double value) {
4172        if (mExtras == null) {
4173            mExtras = new Bundle();
4174        }
4175        mExtras.putDouble(name, value);
4176        return this;
4177    }
4178
4179    /**
4180     * Add extended data to the intent.  The name must include a package
4181     * prefix, for example the app com.android.contacts would use names
4182     * like "com.android.contacts.ShowAll".
4183     *
4184     * @param name The name of the extra data, with package prefix.
4185     * @param value The String data value.
4186     *
4187     * @return Returns the same Intent object, for chaining multiple calls
4188     * into a single statement.
4189     *
4190     * @see #putExtras
4191     * @see #removeExtra
4192     * @see #getStringExtra(String)
4193     */
4194    public Intent putExtra(String name, String value) {
4195        if (mExtras == null) {
4196            mExtras = new Bundle();
4197        }
4198        mExtras.putString(name, value);
4199        return this;
4200    }
4201
4202    /**
4203     * Add extended data to the intent.  The name must include a package
4204     * prefix, for example the app com.android.contacts would use names
4205     * like "com.android.contacts.ShowAll".
4206     *
4207     * @param name The name of the extra data, with package prefix.
4208     * @param value The CharSequence data value.
4209     *
4210     * @return Returns the same Intent object, for chaining multiple calls
4211     * into a single statement.
4212     *
4213     * @see #putExtras
4214     * @see #removeExtra
4215     * @see #getCharSequenceExtra(String)
4216     */
4217    public Intent putExtra(String name, CharSequence value) {
4218        if (mExtras == null) {
4219            mExtras = new Bundle();
4220        }
4221        mExtras.putCharSequence(name, value);
4222        return this;
4223    }
4224
4225    /**
4226     * Add extended data to the intent.  The name must include a package
4227     * prefix, for example the app com.android.contacts would use names
4228     * like "com.android.contacts.ShowAll".
4229     *
4230     * @param name The name of the extra data, with package prefix.
4231     * @param value The Parcelable data value.
4232     *
4233     * @return Returns the same Intent object, for chaining multiple calls
4234     * into a single statement.
4235     *
4236     * @see #putExtras
4237     * @see #removeExtra
4238     * @see #getParcelableExtra(String)
4239     */
4240    public Intent putExtra(String name, Parcelable value) {
4241        if (mExtras == null) {
4242            mExtras = new Bundle();
4243        }
4244        mExtras.putParcelable(name, value);
4245        return this;
4246    }
4247
4248    /**
4249     * Add extended data to the intent.  The name must include a package
4250     * prefix, for example the app com.android.contacts would use names
4251     * like "com.android.contacts.ShowAll".
4252     *
4253     * @param name The name of the extra data, with package prefix.
4254     * @param value The Parcelable[] data value.
4255     *
4256     * @return Returns the same Intent object, for chaining multiple calls
4257     * into a single statement.
4258     *
4259     * @see #putExtras
4260     * @see #removeExtra
4261     * @see #getParcelableArrayExtra(String)
4262     */
4263    public Intent putExtra(String name, Parcelable[] value) {
4264        if (mExtras == null) {
4265            mExtras = new Bundle();
4266        }
4267        mExtras.putParcelableArray(name, value);
4268        return this;
4269    }
4270
4271    /**
4272     * Add extended data to the intent.  The name must include a package
4273     * prefix, for example the app com.android.contacts would use names
4274     * like "com.android.contacts.ShowAll".
4275     *
4276     * @param name The name of the extra data, with package prefix.
4277     * @param value The ArrayList<Parcelable> data value.
4278     *
4279     * @return Returns the same Intent object, for chaining multiple calls
4280     * into a single statement.
4281     *
4282     * @see #putExtras
4283     * @see #removeExtra
4284     * @see #getParcelableArrayListExtra(String)
4285     */
4286    public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4287        if (mExtras == null) {
4288            mExtras = new Bundle();
4289        }
4290        mExtras.putParcelableArrayList(name, value);
4291        return this;
4292    }
4293
4294    /**
4295     * Add extended data to the intent.  The name must include a package
4296     * prefix, for example the app com.android.contacts would use names
4297     * like "com.android.contacts.ShowAll".
4298     *
4299     * @param name The name of the extra data, with package prefix.
4300     * @param value The ArrayList<Integer> data value.
4301     *
4302     * @return Returns the same Intent object, for chaining multiple calls
4303     * into a single statement.
4304     *
4305     * @see #putExtras
4306     * @see #removeExtra
4307     * @see #getIntegerArrayListExtra(String)
4308     */
4309    public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4310        if (mExtras == null) {
4311            mExtras = new Bundle();
4312        }
4313        mExtras.putIntegerArrayList(name, value);
4314        return this;
4315    }
4316
4317    /**
4318     * Add extended data to the intent.  The name must include a package
4319     * prefix, for example the app com.android.contacts would use names
4320     * like "com.android.contacts.ShowAll".
4321     *
4322     * @param name The name of the extra data, with package prefix.
4323     * @param value The ArrayList<String> data value.
4324     *
4325     * @return Returns the same Intent object, for chaining multiple calls
4326     * into a single statement.
4327     *
4328     * @see #putExtras
4329     * @see #removeExtra
4330     * @see #getStringArrayListExtra(String)
4331     */
4332    public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4333        if (mExtras == null) {
4334            mExtras = new Bundle();
4335        }
4336        mExtras.putStringArrayList(name, value);
4337        return this;
4338    }
4339
4340    /**
4341     * Add extended data to the intent.  The name must include a package
4342     * prefix, for example the app com.android.contacts would use names
4343     * like "com.android.contacts.ShowAll".
4344     *
4345     * @param name The name of the extra data, with package prefix.
4346     * @param value The ArrayList<CharSequence> data value.
4347     *
4348     * @return Returns the same Intent object, for chaining multiple calls
4349     * into a single statement.
4350     *
4351     * @see #putExtras
4352     * @see #removeExtra
4353     * @see #getCharSequenceArrayListExtra(String)
4354     */
4355    public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4356        if (mExtras == null) {
4357            mExtras = new Bundle();
4358        }
4359        mExtras.putCharSequenceArrayList(name, value);
4360        return this;
4361    }
4362
4363    /**
4364     * Add extended data to the intent.  The name must include a package
4365     * prefix, for example the app com.android.contacts would use names
4366     * like "com.android.contacts.ShowAll".
4367     *
4368     * @param name The name of the extra data, with package prefix.
4369     * @param value The Serializable data value.
4370     *
4371     * @return Returns the same Intent object, for chaining multiple calls
4372     * into a single statement.
4373     *
4374     * @see #putExtras
4375     * @see #removeExtra
4376     * @see #getSerializableExtra(String)
4377     */
4378    public Intent putExtra(String name, Serializable value) {
4379        if (mExtras == null) {
4380            mExtras = new Bundle();
4381        }
4382        mExtras.putSerializable(name, value);
4383        return this;
4384    }
4385
4386    /**
4387     * Add extended data to the intent.  The name must include a package
4388     * prefix, for example the app com.android.contacts would use names
4389     * like "com.android.contacts.ShowAll".
4390     *
4391     * @param name The name of the extra data, with package prefix.
4392     * @param value The boolean array data value.
4393     *
4394     * @return Returns the same Intent object, for chaining multiple calls
4395     * into a single statement.
4396     *
4397     * @see #putExtras
4398     * @see #removeExtra
4399     * @see #getBooleanArrayExtra(String)
4400     */
4401    public Intent putExtra(String name, boolean[] value) {
4402        if (mExtras == null) {
4403            mExtras = new Bundle();
4404        }
4405        mExtras.putBooleanArray(name, value);
4406        return this;
4407    }
4408
4409    /**
4410     * Add extended data to the intent.  The name must include a package
4411     * prefix, for example the app com.android.contacts would use names
4412     * like "com.android.contacts.ShowAll".
4413     *
4414     * @param name The name of the extra data, with package prefix.
4415     * @param value The byte array data value.
4416     *
4417     * @return Returns the same Intent object, for chaining multiple calls
4418     * into a single statement.
4419     *
4420     * @see #putExtras
4421     * @see #removeExtra
4422     * @see #getByteArrayExtra(String)
4423     */
4424    public Intent putExtra(String name, byte[] value) {
4425        if (mExtras == null) {
4426            mExtras = new Bundle();
4427        }
4428        mExtras.putByteArray(name, value);
4429        return this;
4430    }
4431
4432    /**
4433     * Add extended data to the intent.  The name must include a package
4434     * prefix, for example the app com.android.contacts would use names
4435     * like "com.android.contacts.ShowAll".
4436     *
4437     * @param name The name of the extra data, with package prefix.
4438     * @param value The short array data value.
4439     *
4440     * @return Returns the same Intent object, for chaining multiple calls
4441     * into a single statement.
4442     *
4443     * @see #putExtras
4444     * @see #removeExtra
4445     * @see #getShortArrayExtra(String)
4446     */
4447    public Intent putExtra(String name, short[] value) {
4448        if (mExtras == null) {
4449            mExtras = new Bundle();
4450        }
4451        mExtras.putShortArray(name, value);
4452        return this;
4453    }
4454
4455    /**
4456     * Add extended data to the intent.  The name must include a package
4457     * prefix, for example the app com.android.contacts would use names
4458     * like "com.android.contacts.ShowAll".
4459     *
4460     * @param name The name of the extra data, with package prefix.
4461     * @param value The char array data value.
4462     *
4463     * @return Returns the same Intent object, for chaining multiple calls
4464     * into a single statement.
4465     *
4466     * @see #putExtras
4467     * @see #removeExtra
4468     * @see #getCharArrayExtra(String)
4469     */
4470    public Intent putExtra(String name, char[] value) {
4471        if (mExtras == null) {
4472            mExtras = new Bundle();
4473        }
4474        mExtras.putCharArray(name, value);
4475        return this;
4476    }
4477
4478    /**
4479     * Add extended data to the intent.  The name must include a package
4480     * prefix, for example the app com.android.contacts would use names
4481     * like "com.android.contacts.ShowAll".
4482     *
4483     * @param name The name of the extra data, with package prefix.
4484     * @param value The int array data value.
4485     *
4486     * @return Returns the same Intent object, for chaining multiple calls
4487     * into a single statement.
4488     *
4489     * @see #putExtras
4490     * @see #removeExtra
4491     * @see #getIntArrayExtra(String)
4492     */
4493    public Intent putExtra(String name, int[] value) {
4494        if (mExtras == null) {
4495            mExtras = new Bundle();
4496        }
4497        mExtras.putIntArray(name, value);
4498        return this;
4499    }
4500
4501    /**
4502     * Add extended data to the intent.  The name must include a package
4503     * prefix, for example the app com.android.contacts would use names
4504     * like "com.android.contacts.ShowAll".
4505     *
4506     * @param name The name of the extra data, with package prefix.
4507     * @param value The byte array data value.
4508     *
4509     * @return Returns the same Intent object, for chaining multiple calls
4510     * into a single statement.
4511     *
4512     * @see #putExtras
4513     * @see #removeExtra
4514     * @see #getLongArrayExtra(String)
4515     */
4516    public Intent putExtra(String name, long[] value) {
4517        if (mExtras == null) {
4518            mExtras = new Bundle();
4519        }
4520        mExtras.putLongArray(name, value);
4521        return this;
4522    }
4523
4524    /**
4525     * Add extended data to the intent.  The name must include a package
4526     * prefix, for example the app com.android.contacts would use names
4527     * like "com.android.contacts.ShowAll".
4528     *
4529     * @param name The name of the extra data, with package prefix.
4530     * @param value The float array data value.
4531     *
4532     * @return Returns the same Intent object, for chaining multiple calls
4533     * into a single statement.
4534     *
4535     * @see #putExtras
4536     * @see #removeExtra
4537     * @see #getFloatArrayExtra(String)
4538     */
4539    public Intent putExtra(String name, float[] value) {
4540        if (mExtras == null) {
4541            mExtras = new Bundle();
4542        }
4543        mExtras.putFloatArray(name, value);
4544        return this;
4545    }
4546
4547    /**
4548     * Add extended data to the intent.  The name must include a package
4549     * prefix, for example the app com.android.contacts would use names
4550     * like "com.android.contacts.ShowAll".
4551     *
4552     * @param name The name of the extra data, with package prefix.
4553     * @param value The double array data value.
4554     *
4555     * @return Returns the same Intent object, for chaining multiple calls
4556     * into a single statement.
4557     *
4558     * @see #putExtras
4559     * @see #removeExtra
4560     * @see #getDoubleArrayExtra(String)
4561     */
4562    public Intent putExtra(String name, double[] value) {
4563        if (mExtras == null) {
4564            mExtras = new Bundle();
4565        }
4566        mExtras.putDoubleArray(name, value);
4567        return this;
4568    }
4569
4570    /**
4571     * Add extended data to the intent.  The name must include a package
4572     * prefix, for example the app com.android.contacts would use names
4573     * like "com.android.contacts.ShowAll".
4574     *
4575     * @param name The name of the extra data, with package prefix.
4576     * @param value The String array data value.
4577     *
4578     * @return Returns the same Intent object, for chaining multiple calls
4579     * into a single statement.
4580     *
4581     * @see #putExtras
4582     * @see #removeExtra
4583     * @see #getStringArrayExtra(String)
4584     */
4585    public Intent putExtra(String name, String[] value) {
4586        if (mExtras == null) {
4587            mExtras = new Bundle();
4588        }
4589        mExtras.putStringArray(name, value);
4590        return this;
4591    }
4592
4593    /**
4594     * Add extended data to the intent.  The name must include a package
4595     * prefix, for example the app com.android.contacts would use names
4596     * like "com.android.contacts.ShowAll".
4597     *
4598     * @param name The name of the extra data, with package prefix.
4599     * @param value The CharSequence array data value.
4600     *
4601     * @return Returns the same Intent object, for chaining multiple calls
4602     * into a single statement.
4603     *
4604     * @see #putExtras
4605     * @see #removeExtra
4606     * @see #getCharSequenceArrayExtra(String)
4607     */
4608    public Intent putExtra(String name, CharSequence[] value) {
4609        if (mExtras == null) {
4610            mExtras = new Bundle();
4611        }
4612        mExtras.putCharSequenceArray(name, value);
4613        return this;
4614    }
4615
4616    /**
4617     * Add extended data to the intent.  The name must include a package
4618     * prefix, for example the app com.android.contacts would use names
4619     * like "com.android.contacts.ShowAll".
4620     *
4621     * @param name The name of the extra data, with package prefix.
4622     * @param value The Bundle data value.
4623     *
4624     * @return Returns the same Intent object, for chaining multiple calls
4625     * into a single statement.
4626     *
4627     * @see #putExtras
4628     * @see #removeExtra
4629     * @see #getBundleExtra(String)
4630     */
4631    public Intent putExtra(String name, Bundle value) {
4632        if (mExtras == null) {
4633            mExtras = new Bundle();
4634        }
4635        mExtras.putBundle(name, value);
4636        return this;
4637    }
4638
4639    /**
4640     * Add extended data to the intent.  The name must include a package
4641     * prefix, for example the app com.android.contacts would use names
4642     * like "com.android.contacts.ShowAll".
4643     *
4644     * @param name The name of the extra data, with package prefix.
4645     * @param value The IBinder data value.
4646     *
4647     * @return Returns the same Intent object, for chaining multiple calls
4648     * into a single statement.
4649     *
4650     * @see #putExtras
4651     * @see #removeExtra
4652     * @see #getIBinderExtra(String)
4653     *
4654     * @deprecated
4655     * @hide
4656     */
4657    @Deprecated
4658    public Intent putExtra(String name, IBinder value) {
4659        if (mExtras == null) {
4660            mExtras = new Bundle();
4661        }
4662        mExtras.putIBinder(name, value);
4663        return this;
4664    }
4665
4666    /**
4667     * Copy all extras in 'src' in to this intent.
4668     *
4669     * @param src Contains the extras to copy.
4670     *
4671     * @see #putExtra
4672     */
4673    public Intent putExtras(Intent src) {
4674        if (src.mExtras != null) {
4675            if (mExtras == null) {
4676                mExtras = new Bundle(src.mExtras);
4677            } else {
4678                mExtras.putAll(src.mExtras);
4679            }
4680        }
4681        return this;
4682    }
4683
4684    /**
4685     * Add a set of extended data to the intent.  The keys must include a package
4686     * prefix, for example the app com.android.contacts would use names
4687     * like "com.android.contacts.ShowAll".
4688     *
4689     * @param extras The Bundle of extras to add to this intent.
4690     *
4691     * @see #putExtra
4692     * @see #removeExtra
4693     */
4694    public Intent putExtras(Bundle extras) {
4695        if (mExtras == null) {
4696            mExtras = new Bundle();
4697        }
4698        mExtras.putAll(extras);
4699        return this;
4700    }
4701
4702    /**
4703     * Completely replace the extras in the Intent with the extras in the
4704     * given Intent.
4705     *
4706     * @param src The exact extras contained in this Intent are copied
4707     * into the target intent, replacing any that were previously there.
4708     */
4709    public Intent replaceExtras(Intent src) {
4710        mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
4711        return this;
4712    }
4713
4714    /**
4715     * Completely replace the extras in the Intent with the given Bundle of
4716     * extras.
4717     *
4718     * @param extras The new set of extras in the Intent, or null to erase
4719     * all extras.
4720     */
4721    public Intent replaceExtras(Bundle extras) {
4722        mExtras = extras != null ? new Bundle(extras) : null;
4723        return this;
4724    }
4725
4726    /**
4727     * Remove extended data from the intent.
4728     *
4729     * @see #putExtra
4730     */
4731    public void removeExtra(String name) {
4732        if (mExtras != null) {
4733            mExtras.remove(name);
4734            if (mExtras.size() == 0) {
4735                mExtras = null;
4736            }
4737        }
4738    }
4739
4740    /**
4741     * Set special flags controlling how this intent is handled.  Most values
4742     * here depend on the type of component being executed by the Intent,
4743     * specifically the FLAG_ACTIVITY_* flags are all for use with
4744     * {@link Context#startActivity Context.startActivity()} and the
4745     * FLAG_RECEIVER_* flags are all for use with
4746     * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
4747     *
4748     * <p>See the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
4749     * Activities and Tasks</a> documentation for important information on how some of these options impact
4750     * the behavior of your application.
4751     *
4752     * @param flags The desired flags.
4753     *
4754     * @return Returns the same Intent object, for chaining multiple calls
4755     * into a single statement.
4756     *
4757     * @see #getFlags
4758     * @see #addFlags
4759     *
4760     * @see #FLAG_GRANT_READ_URI_PERMISSION
4761     * @see #FLAG_GRANT_WRITE_URI_PERMISSION
4762     * @see #FLAG_DEBUG_LOG_RESOLUTION
4763     * @see #FLAG_FROM_BACKGROUND
4764     * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
4765     * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
4766     * @see #FLAG_ACTIVITY_CLEAR_TOP
4767     * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
4768     * @see #FLAG_ACTIVITY_FORWARD_RESULT
4769     * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
4770     * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4771     * @see #FLAG_ACTIVITY_NEW_TASK
4772     * @see #FLAG_ACTIVITY_NO_HISTORY
4773     * @see #FLAG_ACTIVITY_NO_USER_ACTION
4774     * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
4775     * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
4776     * @see #FLAG_ACTIVITY_SINGLE_TOP
4777     * @see #FLAG_RECEIVER_REGISTERED_ONLY
4778     */
4779    public Intent setFlags(int flags) {
4780        mFlags = flags;
4781        return this;
4782    }
4783
4784    /**
4785     * Add additional flags to the intent (or with existing flags
4786     * value).
4787     *
4788     * @param flags The new flags to set.
4789     *
4790     * @return Returns the same Intent object, for chaining multiple calls
4791     * into a single statement.
4792     *
4793     * @see #setFlags
4794     */
4795    public Intent addFlags(int flags) {
4796        mFlags |= flags;
4797        return this;
4798    }
4799
4800    /**
4801     * (Usually optional) Set an explicit application package name that limits
4802     * the components this Intent will resolve to.  If left to the default
4803     * value of null, all components in all applications will considered.
4804     * If non-null, the Intent can only match the components in the given
4805     * application package.
4806     *
4807     * @param packageName The name of the application package to handle the
4808     * intent, or null to allow any application package.
4809     *
4810     * @return Returns the same Intent object, for chaining multiple calls
4811     * into a single statement.
4812     *
4813     * @see #getPackage
4814     * @see #resolveActivity
4815     */
4816    public Intent setPackage(String packageName) {
4817        mPackage = packageName;
4818        return this;
4819    }
4820
4821    /**
4822     * (Usually optional) Explicitly set the component to handle the intent.
4823     * If left with the default value of null, the system will determine the
4824     * appropriate class to use based on the other fields (action, data,
4825     * type, categories) in the Intent.  If this class is defined, the
4826     * specified class will always be used regardless of the other fields.  You
4827     * should only set this value when you know you absolutely want a specific
4828     * class to be used; otherwise it is better to let the system find the
4829     * appropriate class so that you will respect the installed applications
4830     * and user preferences.
4831     *
4832     * @param component The name of the application component to handle the
4833     * intent, or null to let the system find one for you.
4834     *
4835     * @return Returns the same Intent object, for chaining multiple calls
4836     * into a single statement.
4837     *
4838     * @see #setClass
4839     * @see #setClassName(Context, String)
4840     * @see #setClassName(String, String)
4841     * @see #getComponent
4842     * @see #resolveActivity
4843     */
4844    public Intent setComponent(ComponentName component) {
4845        mComponent = component;
4846        return this;
4847    }
4848
4849    /**
4850     * Convenience for calling {@link #setComponent} with an
4851     * explicit class name.
4852     *
4853     * @param packageContext A Context of the application package implementing
4854     * this class.
4855     * @param className The name of a class inside of the application package
4856     * that will be used as the component for this Intent.
4857     *
4858     * @return Returns the same Intent object, for chaining multiple calls
4859     * into a single statement.
4860     *
4861     * @see #setComponent
4862     * @see #setClass
4863     */
4864    public Intent setClassName(Context packageContext, String className) {
4865        mComponent = new ComponentName(packageContext, className);
4866        return this;
4867    }
4868
4869    /**
4870     * Convenience for calling {@link #setComponent} with an
4871     * explicit application package name and class name.
4872     *
4873     * @param packageName The name of the package implementing the desired
4874     * component.
4875     * @param className The name of a class inside of the application package
4876     * that will be used as the component for this Intent.
4877     *
4878     * @return Returns the same Intent object, for chaining multiple calls
4879     * into a single statement.
4880     *
4881     * @see #setComponent
4882     * @see #setClass
4883     */
4884    public Intent setClassName(String packageName, String className) {
4885        mComponent = new ComponentName(packageName, className);
4886        return this;
4887    }
4888
4889    /**
4890     * Convenience for calling {@link #setComponent(ComponentName)} with the
4891     * name returned by a {@link Class} object.
4892     *
4893     * @param packageContext A Context of the application package implementing
4894     * this class.
4895     * @param cls The class name to set, equivalent to
4896     *            <code>setClassName(context, cls.getName())</code>.
4897     *
4898     * @return Returns the same Intent object, for chaining multiple calls
4899     * into a single statement.
4900     *
4901     * @see #setComponent
4902     */
4903    public Intent setClass(Context packageContext, Class<?> cls) {
4904        mComponent = new ComponentName(packageContext, cls);
4905        return this;
4906    }
4907
4908    /**
4909     * Set the bounds of the sender of this intent, in screen coordinates.  This can be
4910     * used as a hint to the receiver for animations and the like.  Null means that there
4911     * is no source bounds.
4912     */
4913    public void setSourceBounds(Rect r) {
4914        if (r != null) {
4915            mSourceBounds = new Rect(r);
4916        } else {
4917            r = null;
4918        }
4919    }
4920
4921    /**
4922     * Use with {@link #fillIn} to allow the current action value to be
4923     * overwritten, even if it is already set.
4924     */
4925    public static final int FILL_IN_ACTION = 1<<0;
4926
4927    /**
4928     * Use with {@link #fillIn} to allow the current data or type value
4929     * overwritten, even if it is already set.
4930     */
4931    public static final int FILL_IN_DATA = 1<<1;
4932
4933    /**
4934     * Use with {@link #fillIn} to allow the current categories to be
4935     * overwritten, even if they are already set.
4936     */
4937    public static final int FILL_IN_CATEGORIES = 1<<2;
4938
4939    /**
4940     * Use with {@link #fillIn} to allow the current component value to be
4941     * overwritten, even if it is already set.
4942     */
4943    public static final int FILL_IN_COMPONENT = 1<<3;
4944
4945    /**
4946     * Use with {@link #fillIn} to allow the current package value to be
4947     * overwritten, even if it is already set.
4948     */
4949    public static final int FILL_IN_PACKAGE = 1<<4;
4950
4951    /**
4952     * Use with {@link #fillIn} to allow the current package value to be
4953     * overwritten, even if it is already set.
4954     */
4955    public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
4956
4957    /**
4958     * Copy the contents of <var>other</var> in to this object, but only
4959     * where fields are not defined by this object.  For purposes of a field
4960     * being defined, the following pieces of data in the Intent are
4961     * considered to be separate fields:
4962     *
4963     * <ul>
4964     * <li> action, as set by {@link #setAction}.
4965     * <li> data URI and MIME type, as set by {@link #setData(Uri)},
4966     * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
4967     * <li> categories, as set by {@link #addCategory}.
4968     * <li> package, as set by {@link #setPackage}.
4969     * <li> component, as set by {@link #setComponent(ComponentName)} or
4970     * related methods.
4971     * <li> source bounds, as set by {@link #setSourceBounds}
4972     * <li> each top-level name in the associated extras.
4973     * </ul>
4974     *
4975     * <p>In addition, you can use the {@link #FILL_IN_ACTION},
4976     * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4977     * and {@link #FILL_IN_COMPONENT} to override the restriction where the
4978     * corresponding field will not be replaced if it is already set.
4979     *
4980     * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
4981     * specified.
4982     *
4983     * <p>For example, consider Intent A with {data="foo", categories="bar"}
4984     * and Intent B with {action="gotit", data-type="some/thing",
4985     * categories="one","two"}.
4986     *
4987     * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
4988     * containing: {action="gotit", data-type="some/thing",
4989     * categories="bar"}.
4990     *
4991     * @param other Another Intent whose values are to be used to fill in
4992     * the current one.
4993     * @param flags Options to control which fields can be filled in.
4994     *
4995     * @return Returns a bit mask of {@link #FILL_IN_ACTION},
4996     * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4997     * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
4998     */
4999    public int fillIn(Intent other, int flags) {
5000        int changes = 0;
5001        if (other.mAction != null
5002                && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
5003            mAction = other.mAction;
5004            changes |= FILL_IN_ACTION;
5005        }
5006        if ((other.mData != null || other.mType != null)
5007                && ((mData == null && mType == null)
5008                        || (flags&FILL_IN_DATA) != 0)) {
5009            mData = other.mData;
5010            mType = other.mType;
5011            changes |= FILL_IN_DATA;
5012        }
5013        if (other.mCategories != null
5014                && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
5015            if (other.mCategories != null) {
5016                mCategories = new HashSet<String>(other.mCategories);
5017            }
5018            changes |= FILL_IN_CATEGORIES;
5019        }
5020        if (other.mPackage != null
5021                && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5022            mPackage = other.mPackage;
5023            changes |= FILL_IN_PACKAGE;
5024        }
5025        // Component is special: it can -only- be set if explicitly allowed,
5026        // since otherwise the sender could force the intent somewhere the
5027        // originator didn't intend.
5028        if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
5029            mComponent = other.mComponent;
5030            changes |= FILL_IN_COMPONENT;
5031        }
5032        mFlags |= other.mFlags;
5033        if (other.mSourceBounds != null
5034                && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5035            mSourceBounds = new Rect(other.mSourceBounds);
5036            changes |= FILL_IN_SOURCE_BOUNDS;
5037        }
5038        if (mExtras == null) {
5039            if (other.mExtras != null) {
5040                mExtras = new Bundle(other.mExtras);
5041            }
5042        } else if (other.mExtras != null) {
5043            try {
5044                Bundle newb = new Bundle(other.mExtras);
5045                newb.putAll(mExtras);
5046                mExtras = newb;
5047            } catch (RuntimeException e) {
5048                // Modifying the extras can cause us to unparcel the contents
5049                // of the bundle, and if we do this in the system process that
5050                // may fail.  We really should handle this (i.e., the Bundle
5051                // impl shouldn't be on top of a plain map), but for now just
5052                // ignore it and keep the original contents. :(
5053                Log.w("Intent", "Failure filling in extras", e);
5054            }
5055        }
5056        return changes;
5057    }
5058
5059    /**
5060     * Wrapper class holding an Intent and implementing comparisons on it for
5061     * the purpose of filtering.  The class implements its
5062     * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5063     * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
5064     * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
5065     * on the wrapped Intent.
5066     */
5067    public static final class FilterComparison {
5068        private final Intent mIntent;
5069        private final int mHashCode;
5070
5071        public FilterComparison(Intent intent) {
5072            mIntent = intent;
5073            mHashCode = intent.filterHashCode();
5074        }
5075
5076        /**
5077         * Return the Intent that this FilterComparison represents.
5078         * @return Returns the Intent held by the FilterComparison.  Do
5079         * not modify!
5080         */
5081        public Intent getIntent() {
5082            return mIntent;
5083        }
5084
5085        @Override
5086        public boolean equals(Object obj) {
5087            if (obj instanceof FilterComparison) {
5088                Intent other = ((FilterComparison)obj).mIntent;
5089                return mIntent.filterEquals(other);
5090            }
5091            return false;
5092        }
5093
5094        @Override
5095        public int hashCode() {
5096            return mHashCode;
5097        }
5098    }
5099
5100    /**
5101     * Determine if two intents are the same for the purposes of intent
5102     * resolution (filtering). That is, if their action, data, type,
5103     * class, and categories are the same.  This does <em>not</em> compare
5104     * any extra data included in the intents.
5105     *
5106     * @param other The other Intent to compare against.
5107     *
5108     * @return Returns true if action, data, type, class, and categories
5109     *         are the same.
5110     */
5111    public boolean filterEquals(Intent other) {
5112        if (other == null) {
5113            return false;
5114        }
5115        if (mAction != other.mAction) {
5116            if (mAction != null) {
5117                if (!mAction.equals(other.mAction)) {
5118                    return false;
5119                }
5120            } else {
5121                if (!other.mAction.equals(mAction)) {
5122                    return false;
5123                }
5124            }
5125        }
5126        if (mData != other.mData) {
5127            if (mData != null) {
5128                if (!mData.equals(other.mData)) {
5129                    return false;
5130                }
5131            } else {
5132                if (!other.mData.equals(mData)) {
5133                    return false;
5134                }
5135            }
5136        }
5137        if (mType != other.mType) {
5138            if (mType != null) {
5139                if (!mType.equals(other.mType)) {
5140                    return false;
5141                }
5142            } else {
5143                if (!other.mType.equals(mType)) {
5144                    return false;
5145                }
5146            }
5147        }
5148        if (mPackage != other.mPackage) {
5149            if (mPackage != null) {
5150                if (!mPackage.equals(other.mPackage)) {
5151                    return false;
5152                }
5153            } else {
5154                if (!other.mPackage.equals(mPackage)) {
5155                    return false;
5156                }
5157            }
5158        }
5159        if (mComponent != other.mComponent) {
5160            if (mComponent != null) {
5161                if (!mComponent.equals(other.mComponent)) {
5162                    return false;
5163                }
5164            } else {
5165                if (!other.mComponent.equals(mComponent)) {
5166                    return false;
5167                }
5168            }
5169        }
5170        if (mCategories != other.mCategories) {
5171            if (mCategories != null) {
5172                if (!mCategories.equals(other.mCategories)) {
5173                    return false;
5174                }
5175            } else {
5176                if (!other.mCategories.equals(mCategories)) {
5177                    return false;
5178                }
5179            }
5180        }
5181
5182        return true;
5183    }
5184
5185    /**
5186     * Generate hash code that matches semantics of filterEquals().
5187     *
5188     * @return Returns the hash value of the action, data, type, class, and
5189     *         categories.
5190     *
5191     * @see #filterEquals
5192     */
5193    public int filterHashCode() {
5194        int code = 0;
5195        if (mAction != null) {
5196            code += mAction.hashCode();
5197        }
5198        if (mData != null) {
5199            code += mData.hashCode();
5200        }
5201        if (mType != null) {
5202            code += mType.hashCode();
5203        }
5204        if (mPackage != null) {
5205            code += mPackage.hashCode();
5206        }
5207        if (mComponent != null) {
5208            code += mComponent.hashCode();
5209        }
5210        if (mCategories != null) {
5211            code += mCategories.hashCode();
5212        }
5213        return code;
5214    }
5215
5216    @Override
5217    public String toString() {
5218        StringBuilder   b = new StringBuilder(128);
5219
5220        b.append("Intent { ");
5221        toShortString(b, true, true);
5222        b.append(" }");
5223
5224        return b.toString();
5225    }
5226
5227    /** @hide */
5228    public String toShortString(boolean comp, boolean extras) {
5229        StringBuilder   b = new StringBuilder(128);
5230        toShortString(b, comp, extras);
5231        return b.toString();
5232    }
5233
5234    /** @hide */
5235    public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5236        boolean first = true;
5237        if (mAction != null) {
5238            b.append("act=").append(mAction);
5239            first = false;
5240        }
5241        if (mCategories != null) {
5242            if (!first) {
5243                b.append(' ');
5244            }
5245            first = false;
5246            b.append("cat=[");
5247            Iterator<String> i = mCategories.iterator();
5248            boolean didone = false;
5249            while (i.hasNext()) {
5250                if (didone) b.append(",");
5251                didone = true;
5252                b.append(i.next());
5253            }
5254            b.append("]");
5255        }
5256        if (mData != null) {
5257            if (!first) {
5258                b.append(' ');
5259            }
5260            first = false;
5261            b.append("dat=").append(mData);
5262        }
5263        if (mType != null) {
5264            if (!first) {
5265                b.append(' ');
5266            }
5267            first = false;
5268            b.append("typ=").append(mType);
5269        }
5270        if (mFlags != 0) {
5271            if (!first) {
5272                b.append(' ');
5273            }
5274            first = false;
5275            b.append("flg=0x").append(Integer.toHexString(mFlags));
5276        }
5277        if (mPackage != null) {
5278            if (!first) {
5279                b.append(' ');
5280            }
5281            first = false;
5282            b.append("pkg=").append(mPackage);
5283        }
5284        if (comp && mComponent != null) {
5285            if (!first) {
5286                b.append(' ');
5287            }
5288            first = false;
5289            b.append("cmp=").append(mComponent.flattenToShortString());
5290        }
5291        if (mSourceBounds != null) {
5292            if (!first) {
5293                b.append(' ');
5294            }
5295            first = false;
5296            b.append("bnds=").append(mSourceBounds.toShortString());
5297        }
5298        if (extras && mExtras != null) {
5299            if (!first) {
5300                b.append(' ');
5301            }
5302            first = false;
5303            b.append("(has extras)");
5304        }
5305    }
5306
5307    /**
5308     * Call {@link #toUri} with 0 flags.
5309     * @deprecated Use {@link #toUri} instead.
5310     */
5311    @Deprecated
5312    public String toURI() {
5313        return toUri(0);
5314    }
5315
5316    /**
5317     * Convert this Intent into a String holding a URI representation of it.
5318     * The returned URI string has been properly URI encoded, so it can be
5319     * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
5320     * Intent's data as the base URI, with an additional fragment describing
5321     * the action, categories, type, flags, package, component, and extras.
5322     *
5323     * <p>You can convert the returned string back to an Intent with
5324     * {@link #getIntent}.
5325     *
5326     * @param flags Additional operating flags.  Either 0 or
5327     * {@link #URI_INTENT_SCHEME}.
5328     *
5329     * @return Returns a URI encoding URI string describing the entire contents
5330     * of the Intent.
5331     */
5332    public String toUri(int flags) {
5333        StringBuilder uri = new StringBuilder(128);
5334        String scheme = null;
5335        if (mData != null) {
5336            String data = mData.toString();
5337            if ((flags&URI_INTENT_SCHEME) != 0) {
5338                final int N = data.length();
5339                for (int i=0; i<N; i++) {
5340                    char c = data.charAt(i);
5341                    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5342                            || c == '.' || c == '-') {
5343                        continue;
5344                    }
5345                    if (c == ':' && i > 0) {
5346                        // Valid scheme.
5347                        scheme = data.substring(0, i);
5348                        uri.append("intent:");
5349                        data = data.substring(i+1);
5350                        break;
5351                    }
5352
5353                    // No scheme.
5354                    break;
5355                }
5356            }
5357            uri.append(data);
5358
5359        } else if ((flags&URI_INTENT_SCHEME) != 0) {
5360            uri.append("intent:");
5361        }
5362
5363        uri.append("#Intent;");
5364
5365        if (scheme != null) {
5366            uri.append("scheme=").append(scheme).append(';');
5367        }
5368        if (mAction != null) {
5369            uri.append("action=").append(Uri.encode(mAction)).append(';');
5370        }
5371        if (mCategories != null) {
5372            for (String category : mCategories) {
5373                uri.append("category=").append(Uri.encode(category)).append(';');
5374            }
5375        }
5376        if (mType != null) {
5377            uri.append("type=").append(Uri.encode(mType, "/")).append(';');
5378        }
5379        if (mFlags != 0) {
5380            uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5381        }
5382        if (mPackage != null) {
5383            uri.append("package=").append(Uri.encode(mPackage)).append(';');
5384        }
5385        if (mComponent != null) {
5386            uri.append("component=").append(Uri.encode(
5387                    mComponent.flattenToShortString(), "/")).append(';');
5388        }
5389        if (mSourceBounds != null) {
5390            uri.append("sourceBounds=")
5391                    .append(Uri.encode(mSourceBounds.flattenToString()))
5392                    .append(';');
5393        }
5394        if (mExtras != null) {
5395            for (String key : mExtras.keySet()) {
5396                final Object value = mExtras.get(key);
5397                char entryType =
5398                        value instanceof String    ? 'S' :
5399                        value instanceof Boolean   ? 'B' :
5400                        value instanceof Byte      ? 'b' :
5401                        value instanceof Character ? 'c' :
5402                        value instanceof Double    ? 'd' :
5403                        value instanceof Float     ? 'f' :
5404                        value instanceof Integer   ? 'i' :
5405                        value instanceof Long      ? 'l' :
5406                        value instanceof Short     ? 's' :
5407                        '\0';
5408
5409                if (entryType != '\0') {
5410                    uri.append(entryType);
5411                    uri.append('.');
5412                    uri.append(Uri.encode(key));
5413                    uri.append('=');
5414                    uri.append(Uri.encode(value.toString()));
5415                    uri.append(';');
5416                }
5417            }
5418        }
5419
5420        uri.append("end");
5421
5422        return uri.toString();
5423    }
5424
5425    public int describeContents() {
5426        return (mExtras != null) ? mExtras.describeContents() : 0;
5427    }
5428
5429    public void writeToParcel(Parcel out, int flags) {
5430        out.writeString(mAction);
5431        Uri.writeToParcel(out, mData);
5432        out.writeString(mType);
5433        out.writeInt(mFlags);
5434        out.writeString(mPackage);
5435        ComponentName.writeToParcel(mComponent, out);
5436
5437        if (mSourceBounds != null) {
5438            out.writeInt(1);
5439            mSourceBounds.writeToParcel(out, flags);
5440        } else {
5441            out.writeInt(0);
5442        }
5443
5444        if (mCategories != null) {
5445            out.writeInt(mCategories.size());
5446            for (String category : mCategories) {
5447                out.writeString(category);
5448            }
5449        } else {
5450            out.writeInt(0);
5451        }
5452
5453        out.writeBundle(mExtras);
5454    }
5455
5456    public static final Parcelable.Creator<Intent> CREATOR
5457            = new Parcelable.Creator<Intent>() {
5458        public Intent createFromParcel(Parcel in) {
5459            return new Intent(in);
5460        }
5461        public Intent[] newArray(int size) {
5462            return new Intent[size];
5463        }
5464    };
5465
5466    /** @hide */
5467    protected Intent(Parcel in) {
5468        readFromParcel(in);
5469    }
5470
5471    public void readFromParcel(Parcel in) {
5472        mAction = in.readString();
5473        mData = Uri.CREATOR.createFromParcel(in);
5474        mType = in.readString();
5475        mFlags = in.readInt();
5476        mPackage = in.readString();
5477        mComponent = ComponentName.readFromParcel(in);
5478
5479        if (in.readInt() != 0) {
5480            mSourceBounds = Rect.CREATOR.createFromParcel(in);
5481        }
5482
5483        int N = in.readInt();
5484        if (N > 0) {
5485            mCategories = new HashSet<String>();
5486            int i;
5487            for (i=0; i<N; i++) {
5488                mCategories.add(in.readString());
5489            }
5490        } else {
5491            mCategories = null;
5492        }
5493
5494        mExtras = in.readBundle();
5495    }
5496
5497    /**
5498     * Parses the "intent" element (and its children) from XML and instantiates
5499     * an Intent object.  The given XML parser should be located at the tag
5500     * where parsing should start (often named "intent"), from which the
5501     * basic action, data, type, and package and class name will be
5502     * retrieved.  The function will then parse in to any child elements,
5503     * looking for <category android:name="xxx"> tags to add categories and
5504     * <extra android:name="xxx" android:value="yyy"> to attach extra data
5505     * to the intent.
5506     *
5507     * @param resources The Resources to use when inflating resources.
5508     * @param parser The XML parser pointing at an "intent" tag.
5509     * @param attrs The AttributeSet interface for retrieving extended
5510     * attribute data at the current <var>parser</var> location.
5511     * @return An Intent object matching the XML data.
5512     * @throws XmlPullParserException If there was an XML parsing error.
5513     * @throws IOException If there was an I/O error.
5514     */
5515    public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5516            throws XmlPullParserException, IOException {
5517        Intent intent = new Intent();
5518
5519        TypedArray sa = resources.obtainAttributes(attrs,
5520                com.android.internal.R.styleable.Intent);
5521
5522        intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5523
5524        String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5525        String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5526        intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5527
5528        String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5529        String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5530        if (packageName != null && className != null) {
5531            intent.setComponent(new ComponentName(packageName, className));
5532        }
5533
5534        sa.recycle();
5535
5536        int outerDepth = parser.getDepth();
5537        int type;
5538        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5539               && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5540            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5541                continue;
5542            }
5543
5544            String nodeName = parser.getName();
5545            if (nodeName.equals("category")) {
5546                sa = resources.obtainAttributes(attrs,
5547                        com.android.internal.R.styleable.IntentCategory);
5548                String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5549                sa.recycle();
5550
5551                if (cat != null) {
5552                    intent.addCategory(cat);
5553                }
5554                XmlUtils.skipCurrentTag(parser);
5555
5556            } else if (nodeName.equals("extra")) {
5557                if (intent.mExtras == null) {
5558                    intent.mExtras = new Bundle();
5559                }
5560                resources.parseBundleExtra("extra", attrs, intent.mExtras);
5561                XmlUtils.skipCurrentTag(parser);
5562
5563            } else {
5564                XmlUtils.skipCurrentTag(parser);
5565            }
5566        }
5567
5568        return intent;
5569    }
5570}
5571