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