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