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