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