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