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