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