blob: 607605da4b5e5e2bff6335b02103ffc3f92a849c [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;
Tom Taylord4a47292009-12-21 13:59:18 -080037import com.android.common.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070038
39import java.io.IOException;
40import java.io.Serializable;
41import java.net.URISyntaxException;
42import java.util.ArrayList;
43import java.util.HashSet;
44import java.util.Iterator;
45import java.util.Set;
46
47/**
48 * An intent is an abstract description of an operation to be performed. It
49 * can be used with {@link Context#startActivity(Intent) startActivity} to
50 * launch an {@link android.app.Activity},
51 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
52 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
53 * and {@link android.content.Context#startService} or
54 * {@link android.content.Context#bindService} to communicate with a
55 * background {@link android.app.Service}.
56 *
57 * <p>An Intent provides a facility for performing late runtime binding between
58 * the code in different applications. Its most significant use is in the
59 * launching of activities, where it can be thought of as the glue between
60 * activities. It is
61 * basically a passive data structure holding an abstract description of an
62 * action to be performed. The primary pieces of information in an intent
63 * are:</p>
64 *
65 * <ul>
66 * <li> <p><b>action</b> -- The general action to be performed, such as
67 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
68 * etc.</p>
69 * </li>
70 * <li> <p><b>data</b> -- The data to operate on, such as a person record
71 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
72 * </li>
73 * </ul>
74 *
75 *
76 * <p>Some examples of action/data pairs are:</p>
77 *
78 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070079 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070080 * information about the person whose identifier is "1".</p>
81 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070082 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070083 * the phone dialer with the person filled in.</p>
84 * </li>
85 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
86 * the phone dialer with the given number filled in. Note how the
87 * VIEW action does what what is considered the most reasonable thing for
88 * a particular URI.</p>
89 * </li>
90 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
91 * the phone dialer with the given number filled in.</p>
92 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070093 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070094 * information about the person whose identifier is "1".</p>
95 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070096 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070097 * a list of people, which the user can browse through. This example is a
98 * typical top-level entry into the Contacts application, showing you the
99 * list of people. Selecting a particular person to view would result in a
100 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
101 * being used to start an activity to display that person.</p>
102 * </li>
103 * </ul>
104 *
105 * <p>In addition to these primary attributes, there are a number of secondary
106 * attributes that you can also include with an intent:</p>
107 *
108 * <ul>
109 * <li> <p><b>category</b> -- Gives additional information about the action
110 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
111 * appear in the Launcher as a top-level application, while
112 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
113 * of alternative actions the user can perform on a piece of data.</p>
114 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
115 * intent data. Normally the type is inferred from the data itself.
116 * By setting this attribute, you disable that evaluation and force
117 * an explicit type.</p>
118 * <li> <p><b>component</b> -- Specifies an explicit name of a component
119 * class to use for the intent. Normally this is determined by looking
120 * at the other information in the intent (the action, data/type, and
121 * categories) and matching that with a component that can handle it.
122 * If this attribute is set then none of the evaluation is performed,
123 * and this component is used exactly as is. By specifying this attribute,
124 * all of the other Intent attributes become optional.</p>
125 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
126 * This can be used to provide extended information to the component.
127 * For example, if we have a action to send an e-mail message, we could
128 * also include extra pieces of data here to supply a subject, body,
129 * etc.</p>
130 * </ul>
131 *
132 * <p>Here are some examples of other operations you can specify as intents
133 * using these additional parameters:</p>
134 *
135 * <ul>
136 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
137 * Launch the home screen.</p>
138 * </li>
139 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
140 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
141 * vnd.android.cursor.item/phone}</i></b>
142 * -- Display the list of people's phone numbers, allowing the user to
143 * browse through them and pick one and return it to the parent activity.</p>
144 * </li>
145 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
146 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
147 * -- Display all pickers for data that can be opened with
148 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
149 * allowing the user to pick one of them and then some data inside of it
150 * and returning the resulting URI to the caller. This can be used,
151 * for example, in an e-mail application to allow the user to pick some
152 * data to include as an attachment.</p>
153 * </li>
154 * </ul>
155 *
156 * <p>There are a variety of standard Intent action and category constants
157 * defined in the Intent class, but applications can also define their own.
158 * These strings use java style scoping, to ensure they are unique -- for
159 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700160 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700161 *
162 * <p>Put together, the set of actions, data types, categories, and extra data
163 * defines a language for the system allowing for the expression of phrases
164 * such as "call john smith's cell". As applications are added to the system,
165 * they can extend this language by adding new actions, types, and categories, or
166 * they can modify the behavior of existing phrases by supplying their own
167 * activities that handle them.</p>
168 *
169 * <a name="IntentResolution"></a>
170 * <h3>Intent Resolution</h3>
171 *
172 * <p>There are two primary forms of intents you will use.
173 *
174 * <ul>
175 * <li> <p><b>Explicit Intents</b> have specified a component (via
176 * {@link #setComponent} or {@link #setClass}), which provides the exact
177 * class to be run. Often these will not include any other information,
178 * simply being a way for an application to launch various internal
179 * activities it has as the user interacts with the application.
180 *
181 * <li> <p><b>Implicit Intents</b> have not specified a component;
182 * instead, they must include enough information for the system to
183 * determine which of the available components is best to run for that
184 * intent.
185 * </ul>
186 *
187 * <p>When using implicit intents, given such an arbitrary intent we need to
188 * know what to do with it. This is handled by the process of <em>Intent
189 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
190 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
191 * more activities/receivers) that can handle it.</p>
192 *
193 * <p>The intent resolution mechanism basically revolves around matching an
194 * Intent against all of the &lt;intent-filter&gt; descriptions in the
195 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
196 * objects explicitly registered with {@link Context#registerReceiver}.) More
197 * details on this can be found in the documentation on the {@link
198 * IntentFilter} class.</p>
199 *
200 * <p>There are three pieces of information in the Intent that are used for
201 * resolution: the action, type, and category. Using this information, a query
202 * is done on the {@link PackageManager} for a component that can handle the
203 * intent. The appropriate component is determined based on the intent
204 * information supplied in the <code>AndroidManifest.xml</code> file as
205 * follows:</p>
206 *
207 * <ul>
208 * <li> <p>The <b>action</b>, if given, must be listed by the component as
209 * one it handles.</p>
210 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
211 * already supplied in the Intent. Like the action, if a type is
212 * included in the intent (either explicitly or implicitly in its
213 * data), then this must be listed by the component as one it handles.</p>
214 * <li> For data that is not a <code>content:</code> URI and where no explicit
215 * type is included in the Intent, instead the <b>scheme</b> of the
216 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
217 * considered. Again like the action, if we are matching a scheme it
218 * must be listed by the component as one it can handle.
219 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
220 * by the activity as categories it handles. That is, if you include
221 * the categories {@link #CATEGORY_LAUNCHER} and
222 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
223 * with an intent that lists <em>both</em> of those categories.
224 * Activities will very often need to support the
225 * {@link #CATEGORY_DEFAULT} so that they can be found by
226 * {@link Context#startActivity Context.startActivity()}.</p>
227 * </ul>
228 *
229 * <p>For example, consider the Note Pad sample application that
230 * allows user to browse through a list of notes data and view details about
231 * individual items. Text in italics indicate places were you would replace a
232 * name with one specific to your own package.</p>
233 *
234 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
235 * package="<i>com.android.notepad</i>"&gt;
236 * &lt;application android:icon="@drawable/app_notes"
237 * android:label="@string/app_name"&gt;
238 *
239 * &lt;provider class=".NotePadProvider"
240 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
241 *
242 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
243 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700244 * &lt;action android:name="android.intent.action.MAIN" /&gt;
245 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700246 * &lt;/intent-filter&gt;
247 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700248 * &lt;action android:name="android.intent.action.VIEW" /&gt;
249 * &lt;action android:name="android.intent.action.EDIT" /&gt;
250 * &lt;action android:name="android.intent.action.PICK" /&gt;
251 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
252 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700253 * &lt;/intent-filter&gt;
254 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700255 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
256 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
257 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700258 * &lt;/intent-filter&gt;
259 * &lt;/activity&gt;
260 *
261 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
262 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700263 * &lt;action android:name="android.intent.action.VIEW" /&gt;
264 * &lt;action android:name="android.intent.action.EDIT" /&gt;
265 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
266 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700267 * &lt;/intent-filter&gt;
268 *
269 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700270 * &lt;action android:name="android.intent.action.INSERT" /&gt;
271 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
272 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700273 * &lt;/intent-filter&gt;
274 *
275 * &lt;/activity&gt;
276 *
277 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
278 * android:theme="@android:style/Theme.Dialog"&gt;
279 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700280 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
281 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
282 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
283 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
284 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700285 * &lt;/intent-filter&gt;
286 * &lt;/activity&gt;
287 *
288 * &lt;/application&gt;
289 * &lt;/manifest&gt;</pre>
290 *
291 * <p>The first activity,
292 * <code>com.android.notepad.NotesList</code>, serves as our main
293 * entry into the app. It can do three things as described by its three intent
294 * templates:
295 * <ol>
296 * <li><pre>
297 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700298 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
299 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;</pre>
301 * <p>This provides a top-level entry into the NotePad application: the standard
302 * MAIN action is a main entry point (not requiring any other information in
303 * the Intent), and the LAUNCHER category says that this entry point should be
304 * listed in the application launcher.</p>
305 * <li><pre>
306 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700307 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
308 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
309 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
310 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
311 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700312 * &lt;/intent-filter&gt;</pre>
313 * <p>This declares the things that the activity can do on a directory of
314 * notes. The type being supported is given with the &lt;type&gt; tag, where
315 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
316 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
317 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
318 * The activity allows the user to view or edit the directory of data (via
319 * the VIEW and EDIT actions), or to pick a particular note and return it
320 * to the caller (via the PICK action). Note also the DEFAULT category
321 * supplied here: this is <em>required</em> for the
322 * {@link Context#startActivity Context.startActivity} method to resolve your
323 * activity when its component name is not explicitly specified.</p>
324 * <li><pre>
325 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700326 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
327 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
328 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700329 * &lt;/intent-filter&gt;</pre>
330 * <p>This filter describes the ability return to the caller a note selected by
331 * the user without needing to know where it came from. The data type
332 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
333 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
334 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
335 * The GET_CONTENT action is similar to the PICK action, where the activity
336 * will return to its caller a piece of data selected by the user. Here,
337 * however, the caller specifies the type of data they desire instead of
338 * the type of data the user will be picking from.</p>
339 * </ol>
340 *
341 * <p>Given these capabilities, the following intents will resolve to the
342 * NotesList activity:</p>
343 *
344 * <ul>
345 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
346 * activities that can be used as top-level entry points into an
347 * application.</p>
348 * <li> <p><b>{ action=android.app.action.MAIN,
349 * category=android.app.category.LAUNCHER }</b> is the actual intent
350 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700351 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700352 * data=content://com.google.provider.NotePad/notes }</b>
353 * displays a list of all the notes under
354 * "content://com.google.provider.NotePad/notes", which
355 * the user can browse through and see the details on.</p>
356 * <li> <p><b>{ action=android.app.action.PICK
357 * data=content://com.google.provider.NotePad/notes }</b>
358 * provides a list of the notes under
359 * "content://com.google.provider.NotePad/notes", from which
360 * the user can pick a note whose data URL is returned back to the caller.</p>
361 * <li> <p><b>{ action=android.app.action.GET_CONTENT
362 * type=vnd.android.cursor.item/vnd.google.note }</b>
363 * is similar to the pick action, but allows the caller to specify the
364 * kind of data they want back so that the system can find the appropriate
365 * activity to pick something of that data type.</p>
366 * </ul>
367 *
368 * <p>The second activity,
369 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
370 * note entry and allows them to edit it. It can do two things as described
371 * by its two intent templates:
372 * <ol>
373 * <li><pre>
374 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700375 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
376 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
377 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
378 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700379 * &lt;/intent-filter&gt;</pre>
380 * <p>The first, primary, purpose of this activity is to let the user interact
381 * with a single note, as decribed by the MIME type
382 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
383 * either VIEW a note or allow the user to EDIT it. Again we support the
384 * DEFAULT category to allow the activity to be launched without explicitly
385 * specifying its component.</p>
386 * <li><pre>
387 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700388 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
389 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
390 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700391 * &lt;/intent-filter&gt;</pre>
392 * <p>The secondary use of this activity is to insert a new note entry into
393 * an existing directory of notes. This is used when the user creates a new
394 * note: the INSERT action is executed on the directory of notes, causing
395 * this activity to run and have the user create the new note data which
396 * it then adds to the content provider.</p>
397 * </ol>
398 *
399 * <p>Given these capabilities, the following intents will resolve to the
400 * NoteEditor activity:</p>
401 *
402 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700403 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700404 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
405 * shows the user the content of note <var>{ID}</var>.</p>
406 * <li> <p><b>{ action=android.app.action.EDIT
407 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
408 * allows the user to edit the content of note <var>{ID}</var>.</p>
409 * <li> <p><b>{ action=android.app.action.INSERT
410 * data=content://com.google.provider.NotePad/notes }</b>
411 * creates a new, empty note in the notes list at
412 * "content://com.google.provider.NotePad/notes"
413 * and allows the user to edit it. If they keep their changes, the URI
414 * of the newly created note is returned to the caller.</p>
415 * </ul>
416 *
417 * <p>The last activity,
418 * <code>com.android.notepad.TitleEditor</code>, allows the user to
419 * edit the title of a note. This could be implemented as a class that the
420 * application directly invokes (by explicitly setting its component in
421 * the Intent), but here we show a way you can publish alternative
422 * operations on existing data:</p>
423 *
424 * <pre>
425 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700426 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
427 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
428 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
429 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
430 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700431 * &lt;/intent-filter&gt;</pre>
432 *
433 * <p>In the single intent template here, we
434 * have created our own private action called
435 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
436 * edit the title of a note. It must be invoked on a specific note
437 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
438 * view and edit actions, but here displays and edits the title contained
439 * in the note data.
440 *
441 * <p>In addition to supporting the default category as usual, our title editor
442 * also supports two other standard categories: ALTERNATIVE and
443 * SELECTED_ALTERNATIVE. Implementing
444 * these categories allows others to find the special action it provides
445 * without directly knowing about it, through the
446 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
447 * more often to build dynamic menu items with
448 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
449 * template here was also supply an explicit name for the template
450 * (via <code>android:label="@string/resolve_title"</code>) to better control
451 * what the user sees when presented with this activity as an alternative
452 * action to the data they are viewing.
453 *
454 * <p>Given these capabilities, the following intent will resolve to the
455 * TitleEditor activity:</p>
456 *
457 * <ul>
458 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
459 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
460 * displays and allows the user to edit the title associated
461 * with note <var>{ID}</var>.</p>
462 * </ul>
463 *
464 * <h3>Standard Activity Actions</h3>
465 *
466 * <p>These are the current standard actions that Intent defines for launching
467 * activities (usually through {@link Context#startActivity}. The most
468 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
469 * {@link #ACTION_EDIT}.
470 *
471 * <ul>
472 * <li> {@link #ACTION_MAIN}
473 * <li> {@link #ACTION_VIEW}
474 * <li> {@link #ACTION_ATTACH_DATA}
475 * <li> {@link #ACTION_EDIT}
476 * <li> {@link #ACTION_PICK}
477 * <li> {@link #ACTION_CHOOSER}
478 * <li> {@link #ACTION_GET_CONTENT}
479 * <li> {@link #ACTION_DIAL}
480 * <li> {@link #ACTION_CALL}
481 * <li> {@link #ACTION_SEND}
482 * <li> {@link #ACTION_SENDTO}
483 * <li> {@link #ACTION_ANSWER}
484 * <li> {@link #ACTION_INSERT}
485 * <li> {@link #ACTION_DELETE}
486 * <li> {@link #ACTION_RUN}
487 * <li> {@link #ACTION_SYNC}
488 * <li> {@link #ACTION_PICK_ACTIVITY}
489 * <li> {@link #ACTION_SEARCH}
490 * <li> {@link #ACTION_WEB_SEARCH}
491 * <li> {@link #ACTION_FACTORY_TEST}
492 * </ul>
493 *
494 * <h3>Standard Broadcast Actions</h3>
495 *
496 * <p>These are the current standard actions that Intent defines for receiving
497 * broadcasts (usually through {@link Context#registerReceiver} or a
498 * &lt;receiver&gt; tag in a manifest).
499 *
500 * <ul>
501 * <li> {@link #ACTION_TIME_TICK}
502 * <li> {@link #ACTION_TIME_CHANGED}
503 * <li> {@link #ACTION_TIMEZONE_CHANGED}
504 * <li> {@link #ACTION_BOOT_COMPLETED}
505 * <li> {@link #ACTION_PACKAGE_ADDED}
506 * <li> {@link #ACTION_PACKAGE_CHANGED}
507 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 * <li> {@link #ACTION_PACKAGE_RESTARTED}
509 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700510 * <li> {@link #ACTION_UID_REMOVED}
511 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700512 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700513 * <li> {@link #ACTION_POWER_DISCONNECTED}
514 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700515 * </ul>
516 *
517 * <h3>Standard Categories</h3>
518 *
519 * <p>These are the current standard categories that can be used to further
520 * clarify an Intent via {@link #addCategory}.
521 *
522 * <ul>
523 * <li> {@link #CATEGORY_DEFAULT}
524 * <li> {@link #CATEGORY_BROWSABLE}
525 * <li> {@link #CATEGORY_TAB}
526 * <li> {@link #CATEGORY_ALTERNATIVE}
527 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
528 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700530 * <li> {@link #CATEGORY_HOME}
531 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700532 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400533 * <li> {@link #CATEGORY_CAR_DOCK}
534 * <li> {@link #CATEGORY_DESK_DOCK}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700535 * </ul>
536 *
537 * <h3>Standard Extra Data</h3>
538 *
539 * <p>These are the current standard fields that can be used as extra data via
540 * {@link #putExtra}.
541 *
542 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800543 * <li> {@link #EXTRA_ALARM_COUNT}
544 * <li> {@link #EXTRA_BCC}
545 * <li> {@link #EXTRA_CC}
546 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
547 * <li> {@link #EXTRA_DATA_REMOVED}
548 * <li> {@link #EXTRA_DOCK_STATE}
549 * <li> {@link #EXTRA_DOCK_STATE_CAR}
550 * <li> {@link #EXTRA_DOCK_STATE_DESK}
551 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
552 * <li> {@link #EXTRA_DONT_KILL_APP}
553 * <li> {@link #EXTRA_EMAIL}
554 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700555 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800556 * <li> {@link #EXTRA_KEY_EVENT}
557 * <li> {@link #EXTRA_PHONE_NUMBER}
558 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
559 * <li> {@link #EXTRA_REPLACING}
560 * <li> {@link #EXTRA_SHORTCUT_ICON}
561 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
562 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800564 * <li> {@link #EXTRA_SHORTCUT_NAME}
565 * <li> {@link #EXTRA_SUBJECT}
566 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800568 * <li> {@link #EXTRA_TITLE}
569 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * </ul>
571 *
572 * <h3>Flags</h3>
573 *
574 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800575 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
576 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700577 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800578public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700579 // ---------------------------------------------------------------------
580 // ---------------------------------------------------------------------
581 // Standard intent activity actions (see action variable).
582
583 /**
584 * Activity Action: Start as a main entry point, does not expect to
585 * receive data.
586 * <p>Input: nothing
587 * <p>Output: nothing
588 */
589 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
590 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800591
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 /**
593 * Activity Action: Display the data to the user. This is the most common
594 * action performed on data -- it is the generic action you can use on
595 * a piece of data to get the most reasonable thing to occur. For example,
596 * when used on a contacts entry it will view the entry; when used on a
597 * mailto: URI it will bring up a compose window filled with the information
598 * supplied by the URI; when used with a tel: URI it will invoke the
599 * dialer.
600 * <p>Input: {@link #getData} is URI from which to retrieve data.
601 * <p>Output: nothing.
602 */
603 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
604 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800605
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 /**
607 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
608 * performed on a piece of data.
609 */
610 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800611
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 /**
613 * Used to indicate that some piece of data should be attached to some other
614 * place. For example, image data could be attached to a contact. It is up
615 * to the recipient to decide where the data should be attached; the intent
616 * does not specify the ultimate destination.
617 * <p>Input: {@link #getData} is URI of data to be attached.
618 * <p>Output: nothing.
619 */
620 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
621 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800622
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700623 /**
624 * Activity Action: Provide explicit editable access to the given data.
625 * <p>Input: {@link #getData} is URI of data to be edited.
626 * <p>Output: nothing.
627 */
628 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
629 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800630
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631 /**
632 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
633 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
634 * The extras can contain type specific data to pass through to the editing/creating
635 * activity.
636 * <p>Output: The URI of the item that was picked. This must be a content:
637 * URI so that any receiver can access it.
638 */
639 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
640 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700642 /**
643 * Activity Action: Pick an item from the data, returning what was selected.
644 * <p>Input: {@link #getData} is URI containing a directory of data
645 * (vnd.android.cursor.dir/*) from which to pick an item.
646 * <p>Output: The URI of the item that was picked.
647 */
648 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
649 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800650
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700651 /**
652 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 * <p>Output: An Intent representing the shortcut. The intent must contain three
655 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
656 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800657 * (value: ShortcutIconResource).</p>
658 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 * @see #EXTRA_SHORTCUT_INTENT
660 * @see #EXTRA_SHORTCUT_NAME
661 * @see #EXTRA_SHORTCUT_ICON
662 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
663 * @see android.content.Intent.ShortcutIconResource
664 */
665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
666 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
667
668 /**
669 * The name of the extra used to define the Intent of a shortcut.
670 *
671 * @see #ACTION_CREATE_SHORTCUT
672 */
673 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
674 /**
675 * The name of the extra used to define the name of a shortcut.
676 *
677 * @see #ACTION_CREATE_SHORTCUT
678 */
679 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
680 /**
681 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
682 *
683 * @see #ACTION_CREATE_SHORTCUT
684 */
685 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
686 /**
687 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
688 *
689 * @see #ACTION_CREATE_SHORTCUT
690 * @see android.content.Intent.ShortcutIconResource
691 */
692 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
693 "android.intent.extra.shortcut.ICON_RESOURCE";
694
695 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800696 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700697 *
698 * @see Intent#ACTION_CREATE_SHORTCUT
699 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800700 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
701 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 */
703 public static class ShortcutIconResource implements Parcelable {
704 /**
705 * The package name of the application containing the icon.
706 */
707 public String packageName;
708
709 /**
710 * The resource name of the icon, including package, name and type.
711 */
712 public String resourceName;
713
714 /**
715 * Creates a new ShortcutIconResource for the specified context and resource
716 * identifier.
717 *
718 * @param context The context of the application.
719 * @param resourceId The resource idenfitier for the icon.
720 * @return A new ShortcutIconResource with the specified's context package name
721 * and icon resource idenfitier.
722 */
723 public static ShortcutIconResource fromContext(Context context, int resourceId) {
724 ShortcutIconResource icon = new ShortcutIconResource();
725 icon.packageName = context.getPackageName();
726 icon.resourceName = context.getResources().getResourceName(resourceId);
727 return icon;
728 }
729
730 /**
731 * Used to read a ShortcutIconResource from a Parcel.
732 */
733 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
734 new Parcelable.Creator<ShortcutIconResource>() {
735
736 public ShortcutIconResource createFromParcel(Parcel source) {
737 ShortcutIconResource icon = new ShortcutIconResource();
738 icon.packageName = source.readString();
739 icon.resourceName = source.readString();
740 return icon;
741 }
742
743 public ShortcutIconResource[] newArray(int size) {
744 return new ShortcutIconResource[size];
745 }
746 };
747
748 /**
749 * No special parcel contents.
750 */
751 public int describeContents() {
752 return 0;
753 }
754
755 public void writeToParcel(Parcel dest, int flags) {
756 dest.writeString(packageName);
757 dest.writeString(resourceName);
758 }
759
760 @Override
761 public String toString() {
762 return resourceName;
763 }
764 }
765
766 /**
767 * Activity Action: Display an activity chooser, allowing the user to pick
768 * what they want to before proceeding. This can be used as an alternative
769 * to the standard activity picker that is displayed by the system when
770 * you try to start an activity with multiple possible matches, with these
771 * differences in behavior:
772 * <ul>
773 * <li>You can specify the title that will appear in the activity chooser.
774 * <li>The user does not have the option to make one of the matching
775 * activities a preferred activity, and all possible activities will
776 * always be shown even if one of them is currently marked as the
777 * preferred activity.
778 * </ul>
779 * <p>
780 * This action should be used when the user will naturally expect to
781 * select an activity in order to proceed. An example if when not to use
782 * it is when the user clicks on a "mailto:" link. They would naturally
783 * expect to go directly to their mail app, so startActivity() should be
784 * called directly: it will
785 * either launch the current preferred app, or put up a dialog allowing the
786 * user to pick an app to use and optionally marking that as preferred.
787 * <p>
788 * In contrast, if the user is selecting a menu item to send a picture
789 * they are viewing to someone else, there are many different things they
790 * may want to do at this point: send it through e-mail, upload it to a
791 * web service, etc. In this case the CHOOSER action should be used, to
792 * always present to the user a list of the things they can do, with a
793 * nice title given by the caller such as "Send this photo with:".
794 * <p>
795 * As a convenience, an Intent of this form can be created with the
796 * {@link #createChooser} function.
797 * <p>Input: No data should be specified. get*Extra must have
798 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
799 * and can optionally have a {@link #EXTRA_TITLE} field containing the
800 * title text to display in the chooser.
801 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
802 */
803 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
804 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
805
806 /**
807 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
808 *
809 * @param target The Intent that the user will be selecting an activity
810 * to perform.
811 * @param title Optional title that will be displayed in the chooser.
812 * @return Return a new Intent object that you can hand to
813 * {@link Context#startActivity(Intent) Context.startActivity()} and
814 * related methods.
815 */
816 public static Intent createChooser(Intent target, CharSequence title) {
817 Intent intent = new Intent(ACTION_CHOOSER);
818 intent.putExtra(EXTRA_INTENT, target);
819 if (title != null) {
820 intent.putExtra(EXTRA_TITLE, title);
821 }
822 return intent;
823 }
824 /**
825 * Activity Action: Allow the user to select a particular kind of data and
826 * return it. This is different than {@link #ACTION_PICK} in that here we
827 * just say what kind of data is desired, not a URI of existing data from
828 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
829 * create the data as it runs (for example taking a picture or recording a
830 * sound), let them browser over the web and download the desired data,
831 * etc.
832 * <p>
833 * There are two main ways to use this action: if you want an specific kind
834 * of data, such as a person contact, you set the MIME type to the kind of
835 * data you want and launch it with {@link Context#startActivity(Intent)}.
836 * The system will then launch the best application to select that kind
837 * of data for you.
838 * <p>
839 * You may also be interested in any of a set of types of content the user
840 * can pick. For example, an e-mail application that wants to allow the
841 * user to add an attachment to an e-mail message can use this action to
842 * bring up a list of all of the types of content the user can attach.
843 * <p>
844 * In this case, you should wrap the GET_CONTENT intent with a chooser
845 * (through {@link #createChooser}), which will give the proper interface
846 * for the user to pick how to send your data and allow you to specify
847 * a prompt indicating what they are doing. You will usually specify a
848 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
849 * broad range of content types the user can select from.
850 * <p>
851 * When using such a broad GET_CONTENT action, it is often desireable to
852 * only pick from data that can be represented as a stream. This is
853 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
854 * <p>
855 * Input: {@link #getType} is the desired MIME type to retrieve. Note
856 * that no URI is supplied in the intent, as there are no constraints on
857 * where the returned data originally comes from. You may also include the
858 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
859 * opened as a stream.
860 * <p>
861 * Output: The URI of the item that was picked. This must be a content:
862 * URI so that any receiver can access it.
863 */
864 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
865 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
866 /**
867 * Activity Action: Dial a number as specified by the data. This shows a
868 * UI with the number being dialed, allowing the user to explicitly
869 * initiate the call.
870 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
871 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
872 * number.
873 * <p>Output: nothing.
874 */
875 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
876 public static final String ACTION_DIAL = "android.intent.action.DIAL";
877 /**
878 * Activity Action: Perform a call to someone specified by the data.
879 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
880 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
881 * number.
882 * <p>Output: nothing.
883 *
884 * <p>Note: there will be restrictions on which applications can initiate a
885 * call; most applications should use the {@link #ACTION_DIAL}.
886 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
887 * numbers. Applications can <strong>dial</strong> emergency numbers using
888 * {@link #ACTION_DIAL}, however.
889 */
890 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
891 public static final String ACTION_CALL = "android.intent.action.CALL";
892 /**
893 * Activity Action: Perform a call to an emergency number specified by the
894 * data.
895 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
896 * tel: URI of an explicit phone number.
897 * <p>Output: nothing.
898 * @hide
899 */
900 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
901 /**
902 * Activity action: Perform a call to any number (emergency or not)
903 * specified by the data.
904 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
905 * tel: URI of an explicit phone number.
906 * <p>Output: nothing.
907 * @hide
908 */
909 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
910 /**
911 * Activity Action: Send a message to someone specified by the data.
912 * <p>Input: {@link #getData} is URI describing the target.
913 * <p>Output: nothing.
914 */
915 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
916 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
917 /**
918 * Activity Action: Deliver some data to someone else. Who the data is
919 * being delivered to is not specified; it is up to the receiver of this
920 * action to ask the user where the data should be sent.
921 * <p>
922 * When launching a SEND intent, you should usually wrap it in a chooser
923 * (through {@link #createChooser}), which will give the proper interface
924 * for the user to pick how to send your data and allow you to specify
925 * a prompt indicating what they are doing.
926 * <p>
927 * Input: {@link #getType} is the MIME type of the data being sent.
928 * get*Extra can have either a {@link #EXTRA_TEXT}
929 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
930 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
931 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
932 * if the MIME type is unknown (this will only allow senders that can
933 * handle generic data streams).
934 * <p>
935 * Optional standard extras, which may be interpreted by some recipients as
936 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
937 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
938 * <p>
939 * Output: nothing.
940 */
941 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
942 public static final String ACTION_SEND = "android.intent.action.SEND";
943 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800944 * Activity Action: Deliver multiple data to someone else.
945 * <p>
946 * Like ACTION_SEND, except the data is multiple.
947 * <p>
948 * Input: {@link #getType} is the MIME type of the data being sent.
949 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
950 * #EXTRA_STREAM} field, containing the data to be sent.
951 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800952 * Multiple types are supported, and receivers should handle mixed types
953 * whenever possible. The right way for the receiver to check them is to
954 * use the content resolver on each URI. The intent sender should try to
955 * put the most concrete mime type in the intent type, but it can fall
956 * back to {@literal <type>/*} or {@literal *}/* as needed.
957 * <p>
958 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
959 * be image/jpg, but if you are sending image/jpg and image/png, then the
960 * intent's type should be image/*.
961 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800962 * Optional standard extras, which may be interpreted by some recipients as
963 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
964 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
965 * <p>
966 * Output: nothing.
967 */
968 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
969 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
970 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700971 * Activity Action: Handle an incoming phone call.
972 * <p>Input: nothing.
973 * <p>Output: nothing.
974 */
975 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
976 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
977 /**
978 * Activity Action: Insert an empty item into the given container.
979 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
980 * in which to place the data.
981 * <p>Output: URI of the new data that was created.
982 */
983 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
984 public static final String ACTION_INSERT = "android.intent.action.INSERT";
985 /**
986 * Activity Action: Delete the given data from its container.
987 * <p>Input: {@link #getData} is URI of data to be deleted.
988 * <p>Output: nothing.
989 */
990 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
991 public static final String ACTION_DELETE = "android.intent.action.DELETE";
992 /**
993 * Activity Action: Run the data, whatever that means.
994 * <p>Input: ? (Note: this is currently specific to the test harness.)
995 * <p>Output: nothing.
996 */
997 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
998 public static final String ACTION_RUN = "android.intent.action.RUN";
999 /**
1000 * Activity Action: Perform a data synchronization.
1001 * <p>Input: ?
1002 * <p>Output: ?
1003 */
1004 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1005 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1006 /**
1007 * Activity Action: Pick an activity given an intent, returning the class
1008 * selected.
1009 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1010 * used with {@link PackageManager#queryIntentActivities} to determine the
1011 * set of activities from which to pick.
1012 * <p>Output: Class name of the activity that was selected.
1013 */
1014 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1015 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1016 /**
1017 * Activity Action: Perform a search.
1018 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1019 * is the text to search for. If empty, simply
1020 * enter your search results Activity with the search UI activated.
1021 * <p>Output: nothing.
1022 */
1023 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1024 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1025 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001026 * Activity Action: Start the platform-defined tutorial
1027 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1028 * is the text to search for. If empty, simply
1029 * enter your search results Activity with the search UI activated.
1030 * <p>Output: nothing.
1031 */
1032 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1033 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1034 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001035 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001036 * <p>
1037 * Input: {@link android.app.SearchManager#QUERY
1038 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1039 * a url starts with http or https, the site will be opened. If it is plain
1040 * text, Google search will be applied.
1041 * <p>
1042 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001043 */
1044 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1045 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1046 /**
1047 * Activity Action: List all available applications
1048 * <p>Input: Nothing.
1049 * <p>Output: nothing.
1050 */
1051 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1052 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1053 /**
1054 * Activity Action: Show settings for choosing wallpaper
1055 * <p>Input: Nothing.
1056 * <p>Output: Nothing.
1057 */
1058 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1059 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1060
1061 /**
1062 * Activity Action: Show activity for reporting a bug.
1063 * <p>Input: Nothing.
1064 * <p>Output: Nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1068
1069 /**
1070 * Activity Action: Main entry point for factory tests. Only used when
1071 * the device is booting in factory test node. The implementing package
1072 * must be installed in the system image.
1073 * <p>Input: nothing
1074 * <p>Output: nothing
1075 */
1076 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1077
1078 /**
1079 * Activity Action: The user pressed the "call" button to go to the dialer
1080 * or other appropriate UI for placing a call.
1081 * <p>Input: Nothing.
1082 * <p>Output: Nothing.
1083 */
1084 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1085 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1086
1087 /**
1088 * Activity Action: Start Voice Command.
1089 * <p>Input: Nothing.
1090 * <p>Output: Nothing.
1091 */
1092 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1093 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001094
1095 /**
1096 * Activity Action: Start action associated with long pressing on the
1097 * search key.
1098 * <p>Input: Nothing.
1099 * <p>Output: Nothing.
1100 */
1101 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1102 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001103
Jacek Surazski86b6c532009-05-13 14:38:28 +02001104 /**
1105 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1106 * This intent is delivered to the package which installed the application, usually
1107 * the Market.
1108 * <p>Input: No data is specified. The bug report is passed in using
1109 * an {@link #EXTRA_BUG_REPORT} field.
1110 * <p>Output: Nothing.
1111 * @hide
1112 */
1113 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1114 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001115
1116 /**
1117 * Activity Action: Show power usage information to the user.
1118 * <p>Input: Nothing.
1119 * <p>Output: Nothing.
1120 */
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1122 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001123
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001124 /**
1125 * Activity Action: Setup wizard to launch after a platform update. This
1126 * activity should have a string meta-data field associated with it,
1127 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1128 * the platform for setup. The activity will be launched only if
1129 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1130 * same value.
1131 * <p>Input: Nothing.
1132 * <p>Output: Nothing.
1133 * @hide
1134 */
1135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1136 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001137
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001138 /**
1139 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1140 * describing the last run version of the platform that was setup.
1141 * @hide
1142 */
1143 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1144
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001145 // ---------------------------------------------------------------------
1146 // ---------------------------------------------------------------------
1147 // Standard intent broadcast actions (see action variable).
1148
1149 /**
1150 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001151 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001152 * <p class="note">This is a protected intent that can only be sent
1153 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001154 */
1155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1156 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1157 /**
1158 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001159 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001160 * <p class="note">This is a protected intent that can only be sent
1161 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001162 */
1163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1164 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001165
1166 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001167 * 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 -07001168 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001169 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001170 * <p class="note">This is a protected intent that can only be sent
1171 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001172 */
1173 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001174 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001175
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001176 /**
1177 * Broadcast Action: The current time has changed. Sent every
1178 * minute. You can <em>not</em> receive this through components declared
1179 * in manifests, only by exlicitly registering for it with
1180 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1181 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001182 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001183 * <p class="note">This is a protected intent that can only be sent
1184 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001185 */
1186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1187 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1188 /**
1189 * Broadcast Action: The time was set.
1190 */
1191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1192 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1193 /**
1194 * Broadcast Action: The date has changed.
1195 */
1196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1197 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1198 /**
1199 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1200 * <ul>
1201 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1202 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001203 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001204 * <p class="note">This is a protected intent that can only be sent
1205 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001206 */
1207 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1208 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1209 /**
1210 * Alarm Changed Action: This is broadcast when the AlarmClock
1211 * application's alarm is set or unset. It is used by the
1212 * AlarmClock application and the StatusBar service.
1213 * @hide
1214 */
1215 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1216 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1217 /**
1218 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1219 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1220 * @hide
1221 */
1222 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1223 public static final String ACTION_SYNC_STATE_CHANGED
1224 = "android.intent.action.SYNC_STATE_CHANGED";
1225 /**
1226 * Broadcast Action: This is broadcast once, after the system has finished
1227 * booting. It can be used to perform application-specific initialization,
1228 * such as installing alarms. You must hold the
1229 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1230 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001231 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001232 * <p class="note">This is a protected intent that can only be sent
1233 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001234 */
1235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1236 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1237 /**
1238 * Broadcast Action: This is broadcast when a user action should request a
1239 * temporary system dialog to dismiss. Some examples of temporary system
1240 * dialogs are the notification window-shade and the recent tasks dialog.
1241 */
1242 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1243 /**
1244 * Broadcast Action: Trigger the download and eventual installation
1245 * of a package.
1246 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001247 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001248 * <p class="note">This is a protected intent that can only be sent
1249 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001250 */
1251 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1252 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1253 /**
1254 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001255 * device. The data contains the name of the package. Note that the
1256 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001257 * <p>My include the following extras:
1258 * <ul>
1259 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1260 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1261 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1262 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001263 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001264 * <p class="note">This is a protected intent that can only be sent
1265 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001266 */
1267 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1268 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1269 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001270 * Broadcast Action: A new version of an application package has been
1271 * installed, replacing an existing version that was previously installed.
1272 * The data contains the name of the package.
1273 * <p>My include the following extras:
1274 * <ul>
1275 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1276 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001277 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001278 * <p class="note">This is a protected intent that can only be sent
1279 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001280 */
1281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1282 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1283 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 * Broadcast Action: An existing application package has been removed from
1285 * the device. The data contains the name of the package. The package
1286 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001287 * <ul>
1288 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1289 * to the package.
1290 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1291 * application -- data and code -- is being removed.
1292 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1293 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1294 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001295 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001296 * <p class="note">This is a protected intent that can only be sent
1297 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001298 */
1299 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1300 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1301 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001302 * Broadcast Action: An existing application package has been changed (e.g.
1303 * a component has been enabled or disabled). The data contains the name of
1304 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001305 * <ul>
1306 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001307 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1308 * of the changed components.
1309 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1310 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001311 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001312 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001313 * <p class="note">This is a protected intent that can only be sent
1314 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001315 */
1316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1317 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1318 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001319 * @hide
1320 * Broadcast Action: Ask system services if there is any reason to
1321 * restart the given package. The data contains the name of the
1322 * package.
1323 * <ul>
1324 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1325 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1326 * </ul>
1327 *
1328 * <p class="note">This is a protected intent that can only be sent
1329 * by the system.
1330 */
1331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1332 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1333 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001334 * Broadcast Action: The user has restarted a package, and all of its
1335 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001336 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001337 * be removed. Note that the restarted package does <em>not</em>
1338 * receive this broadcast.
1339 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001340 * <ul>
1341 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1342 * </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_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1349 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001350 * Broadcast Action: The user has cleared the data of a package. This should
1351 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001352 * its persistent data is erased and this broadcast sent.
1353 * Note that the cleared package does <em>not</em>
1354 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001355 * <ul>
1356 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1357 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001358 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001359 * <p class="note">This is a protected intent that can only be sent
1360 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001361 */
1362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1363 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1364 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001365 * Broadcast Action: A user ID has been removed from the system. The user
1366 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001367 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001368 * <p class="note">This is a protected intent that can only be sent
1369 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001370 */
1371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1372 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001373
1374 /**
1375 * Broadcast Action: Resources for a set of packages (which were
1376 * previously unavailable) are currently
1377 * available since the media on which they exist is available.
1378 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1379 * list of packages whose availability changed.
1380 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1381 * list of uids of packages whose availability changed.
1382 * Note that the
1383 * packages in this list do <em>not</em> receive this broadcast.
1384 * The specified set of packages are now available on the system.
1385 * <p>Includes the following extras:
1386 * <ul>
1387 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1388 * whose resources(were previously unavailable) are currently available.
1389 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1390 * packages whose resources(were previously unavailable)
1391 * are currently available.
1392 * </ul>
1393 *
1394 * <p class="note">This is a protected intent that can only be sent
1395 * by the system.
1396 * @hide
1397 */
1398 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001399 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1400 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001401
1402 /**
1403 * Broadcast Action: Resources for a set of packages are currently
1404 * unavailable since the media on which they exist is unavailable.
1405 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1406 * list of packages whose availability changed.
1407 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1408 * list of uids of packages whose availability changed.
1409 * The specified set of packages can no longer be
1410 * launched and are practically unavailable on the system.
1411 * <p>Inclues the following extras:
1412 * <ul>
1413 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1414 * whose resources are no longer available.
1415 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1416 * whose resources are no longer available.
1417 * </ul>
1418 *
1419 * <p class="note">This is a protected intent that can only be sent
1420 * by the system.
1421 * @hide
1422 */
1423 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001424 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
1425 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABILE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001426
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001427 /**
1428 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001429 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001430 */
1431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1432 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1433 /**
1434 * Broadcast Action: The current device {@link android.content.res.Configuration}
1435 * (orientation, locale, etc) has changed. When such a change happens, the
1436 * UIs (view hierarchy) will need to be rebuilt based on this new
1437 * information; for the most part, applications don't need to worry about
1438 * this, because the system will take care of stopping and restarting the
1439 * application to make sure it sees the new changes. Some system code that
1440 * can not be restarted will need to watch for this action and handle it
1441 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001442 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001443 * <p class="note">
1444 * You can <em>not</em> receive this through components declared
1445 * in manifests, only by explicitly registering for it with
1446 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1447 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001448 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001449 * <p class="note">This is a protected intent that can only be sent
1450 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001451 *
1452 * @see android.content.res.Configuration
1453 */
1454 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1455 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1456 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001457 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001458 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001459 * <p class="note">This is a protected intent that can only be sent
1460 * by the system.
1461 */
1462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1463 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1464 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001465 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1466 * charging state, level, and other information about the battery.
1467 * See {@link android.os.BatteryManager} for documentation on the
1468 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001469 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001470 * <p class="note">
1471 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001472 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001473 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001474 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1475 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1476 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1477 * broadcasts that are sent and can be received through manifest
1478 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001479 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001480 * <p class="note">This is a protected intent that can only be sent
1481 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001482 */
1483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1484 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1485 /**
1486 * Broadcast Action: Indicates low battery condition on the device.
1487 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001488 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001489 * <p class="note">This is a protected intent that can only be sent
1490 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001491 */
1492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1493 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1494 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001495 * Broadcast Action: Indicates the battery is now okay after being low.
1496 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1497 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001498 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001499 * <p class="note">This is a protected intent that can only be sent
1500 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001501 */
1502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1503 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1504 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001505 * Broadcast Action: External power has been connected to the device.
1506 * This is intended for applications that wish to register specifically to this notification.
1507 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1508 * stay active to receive this notification. This action can be used to implement actions
1509 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001510 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001511 * <p class="note">This is a protected intent that can only be sent
1512 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001513 */
1514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001515 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001516 /**
1517 * Broadcast Action: External power has been removed from the device.
1518 * This is intended for applications that wish to register specifically to this notification.
1519 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1520 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001521 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001522 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001523 * <p class="note">This is a protected intent that can only be sent
1524 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001525 */
1526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001527 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001528 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001529 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001530 * Broadcast Action: Device is shutting down.
1531 * This is broadcast when the device is being shut down (completely turned
1532 * off, not sleeping). Once the broadcast is complete, the final shutdown
1533 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001534 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001535 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001536 * <p class="note">This is a protected intent that can only be sent
1537 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001538 */
1539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001540 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001541 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001542 * Activity Action: Start this activity to request system shutdown.
1543 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1544 * to request confirmation from the user before shutting down.
1545 *
1546 * <p class="note">This is a protected intent that can only be sent
1547 * by the system.
1548 *
1549 * {@hide}
1550 */
1551 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1552 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001553 * Broadcast Action: A sticky broadcast that indicates low memory
1554 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001555 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001556 * <p class="note">This is a protected intent that can only be sent
1557 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001558 */
1559 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1560 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1561 /**
1562 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001563 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001564 * <p class="note">This is a protected intent that can only be sent
1565 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001566 */
1567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1568 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1569 /**
1570 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1571 * and package management should be started.
1572 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1573 * notification.
1574 */
1575 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1576 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1577 /**
1578 * Broadcast Action: The device has entered USB Mass Storage mode.
1579 * This is used mainly for the USB Settings panel.
1580 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1581 * when the SD card file system is mounted or unmounted
1582 */
1583 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1584 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1585
1586 /**
1587 * Broadcast Action: The device has exited USB Mass Storage mode.
1588 * This is used mainly for the USB Settings panel.
1589 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1590 * when the SD card file system is mounted or unmounted
1591 */
1592 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1593 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1594
1595 /**
1596 * Broadcast Action: External media has been removed.
1597 * The path to the mount point for the removed media is contained in the Intent.mData field.
1598 */
1599 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1600 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1601
1602 /**
1603 * Broadcast Action: External media is present, but not mounted at its mount point.
1604 * The path to the mount point for the removed media is contained in the Intent.mData field.
1605 */
1606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1607 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1608
1609 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001610 * Broadcast Action: External media is present, and being disk-checked
1611 * 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 -08001612 */
1613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1614 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1615
1616 /**
1617 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1618 * 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 -08001619 */
1620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1621 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1622
1623 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001624 * Broadcast Action: External media is present and mounted at its mount point.
1625 * The path to the mount point for the removed media is contained in the Intent.mData field.
1626 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1627 * media was mounted read only.
1628 */
1629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1630 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1631
1632 /**
1633 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
1634 * The path to the mount point for the removed media is contained in the Intent.mData field.
1635 */
1636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1637 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1638
1639 /**
1640 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1641 * The path to the mount point for the removed media is contained in the Intent.mData field.
1642 */
1643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1644 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1645
1646 /**
1647 * Broadcast Action: External media is present but cannot be mounted.
1648 * The path to the mount point for the removed media is contained in the Intent.mData field.
1649 */
1650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1651 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1652
1653 /**
1654 * Broadcast Action: User has expressed the desire to remove the external storage media.
1655 * Applications should close all files they have open within the mount point when they receive this intent.
1656 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1657 */
1658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1659 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1660
1661 /**
1662 * Broadcast Action: The media scanner has started scanning a directory.
1663 * The path to the directory being scanned is contained in the Intent.mData field.
1664 */
1665 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1666 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1667
1668 /**
1669 * Broadcast Action: The media scanner has finished scanning a directory.
1670 * The path to the scanned directory is contained in the Intent.mData field.
1671 */
1672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1673 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1674
1675 /**
1676 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1677 * The path to the file is contained in the Intent.mData field.
1678 */
1679 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1680 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1681
1682 /**
1683 * Broadcast Action: The "Media Button" was pressed. Includes a single
1684 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1685 * caused the broadcast.
1686 */
1687 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1688 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1689
1690 /**
1691 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1692 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1693 * caused the broadcast.
1694 */
1695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1696 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1697
1698 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1699 // location; they are not general-purpose actions.
1700
1701 /**
1702 * Broadcast Action: An GTalk connection has been established.
1703 */
1704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1705 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1706 "android.intent.action.GTALK_CONNECTED";
1707
1708 /**
1709 * Broadcast Action: An GTalk connection has been disconnected.
1710 */
1711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1712 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1713 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001714
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001715 /**
1716 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001717 */
1718 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1719 public static final String ACTION_INPUT_METHOD_CHANGED =
1720 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001721
1722 /**
1723 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1724 * more radios have been turned off or on. The intent will have the following extra value:</p>
1725 * <ul>
1726 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1727 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1728 * turned off</li>
1729 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001730 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001731 * <p class="note">This is a protected intent that can only be sent
1732 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001733 */
1734 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1735 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1736
1737 /**
1738 * Broadcast Action: Some content providers have parts of their namespace
1739 * where they publish new events or items that the user may be especially
1740 * interested in. For these things, they may broadcast this action when the
1741 * set of interesting items change.
1742 *
1743 * For example, GmailProvider sends this notification when the set of unread
1744 * mail in the inbox changes.
1745 *
1746 * <p>The data of the intent identifies which part of which provider
1747 * changed. When queried through the content resolver, the data URI will
1748 * return the data set in question.
1749 *
1750 * <p>The intent will have the following extra values:
1751 * <ul>
1752 * <li><em>count</em> - The number of items in the data set. This is the
1753 * same as the number of items in the cursor returned by querying the
1754 * data URI. </li>
1755 * </ul>
1756 *
1757 * This intent will be sent at boot (if the count is non-zero) and when the
1758 * data set changes. It is possible for the data set to change without the
1759 * count changing (for example, if a new unread message arrives in the same
1760 * sync operation in which a message is archived). The phone should still
1761 * ring/vibrate/etc as normal in this case.
1762 */
1763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1764 public static final String ACTION_PROVIDER_CHANGED =
1765 "android.intent.action.PROVIDER_CHANGED";
1766
1767 /**
1768 * Broadcast Action: Wired Headset plugged in or unplugged.
1769 *
1770 * <p>The intent will have the following extra values:
1771 * <ul>
1772 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1773 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001774 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001775 * </ul>
1776 * </ul>
1777 */
1778 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1779 public static final String ACTION_HEADSET_PLUG =
1780 "android.intent.action.HEADSET_PLUG";
1781
1782 /**
1783 * Broadcast Action: An outgoing call is about to be placed.
1784 *
1785 * <p>The Intent will have the following extra value:
1786 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07001787 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001788 * the phone number originally intended to be dialed.</li>
1789 * </ul>
1790 * <p>Once the broadcast is finished, the resultData is used as the actual
1791 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07001792 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001793 * outgoing call in turn: for example, a parental control application
1794 * might verify that the user is authorized to place the call at that
1795 * time, then a number-rewriting application might add an area code if
1796 * one was not specified.</p>
1797 * <p>For consistency, any receiver whose purpose is to prohibit phone
1798 * calls should have a priority of 0, to ensure it will see the final
1799 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07001800 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001801 * should have a positive priority.
1802 * Negative priorities are reserved for the system for this broadcast;
1803 * using them may cause problems.</p>
1804 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
1805 * abort the broadcast.</p>
1806 * <p>Emergency calls cannot be intercepted using this mechanism, and
1807 * other calls cannot be modified to call emergency numbers using this
1808 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07001809 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001810 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
1811 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08001812 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001813 * <p class="note">This is a protected intent that can only be sent
1814 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001815 */
1816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1817 public static final String ACTION_NEW_OUTGOING_CALL =
1818 "android.intent.action.NEW_OUTGOING_CALL";
1819
1820 /**
1821 * Broadcast Action: Have the device reboot. This is only for use by
1822 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08001823 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001824 * <p class="note">This is a protected intent that can only be sent
1825 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001826 */
1827 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1828 public static final String ACTION_REBOOT =
1829 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001830
Wei Huang97ecc9c2009-05-11 17:44:20 -07001831 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001832 * Broadcast Action: A sticky broadcast indicating the phone was docked
Tobias Haamel154f7a12010-02-17 11:56:39 -08001833 * or undocked.
1834 *
1835 * <p>The intent will have the following extra values:
1836 * <ul>
1837 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
1838 * state, which depends on the state of the car mode.</li>
1839 * <li><em>{@link #EXTRA_PHYSICAL_DOCK_STATE}</em> - the physical dock
1840 * state.</li>
1841 * <li><em>{@link #EXTRA_CAR_MODE_ENABLED}</em> - a boolean indicating the
1842 * state of the car mode.</li>
1843 * </ul>
1844 * <p>This is intended for monitoring the current dock state.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001845 * To launch an activity from a dock state change, use {@link #CATEGORY_CAR_DOCK}
1846 * or {@link #CATEGORY_DESK_DOCK} instead.
1847 */
1848 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1849 public static final String ACTION_DOCK_EVENT =
1850 "android.intent.action.DOCK_EVENT";
1851
1852 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07001853 * Broadcast Action: a remote intent is to be broadcasted.
1854 *
1855 * A remote intent is used for remote RPC between devices. The remote intent
1856 * is serialized and sent from one device to another device. The receiving
1857 * device parses the remote intent and broadcasts it. Note that anyone can
1858 * broadcast a remote intent. However, if the intent receiver of the remote intent
1859 * does not trust intent broadcasts from arbitrary intent senders, it should require
1860 * the sender to hold certain permissions so only trusted sender's broadcast will be
1861 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001862 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07001863 */
1864 public static final String ACTION_REMOTE_INTENT =
Costin Manolache63cfebf2010-02-04 16:52:34 -08001865 "com.google.android.pushmessaging.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07001866
Dianne Hackborn9acc0302009-08-25 00:27:12 -07001867 /**
1868 * Broadcast Action: hook for permforming cleanup after a system update.
1869 *
1870 * The broadcast is sent when the system is booting, before the
1871 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
1872 * image. A receiver for this should do its work and then disable itself
1873 * so that it does not get run again at the next boot.
1874 * @hide
1875 */
1876 public static final String ACTION_PRE_BOOT_COMPLETED =
1877 "android.intent.action.PRE_BOOT_COMPLETED";
1878
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001879 // ---------------------------------------------------------------------
1880 // ---------------------------------------------------------------------
1881 // Standard intent categories (see addCategory()).
1882
1883 /**
1884 * Set if the activity should be an option for the default action
1885 * (center press) to perform on a piece of data. Setting this will
1886 * hide from the user any activities without it set when performing an
1887 * action on some data. Note that this is normal -not- set in the
1888 * Intent when initiating an action -- it is for use in intent filters
1889 * specified in packages.
1890 */
1891 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1892 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
1893 /**
1894 * Activities that can be safely invoked from a browser must support this
1895 * category. For example, if the user is viewing a web page or an e-mail
1896 * and clicks on a link in the text, the Intent generated execute that
1897 * link will require the BROWSABLE category, so that only activities
1898 * supporting this category will be considered as possible actions. By
1899 * supporting this category, you are promising that there is nothing
1900 * damaging (without user intervention) that can happen by invoking any
1901 * matching Intent.
1902 */
1903 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1904 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
1905 /**
1906 * Set if the activity should be considered as an alternative action to
1907 * the data the user is currently viewing. See also
1908 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
1909 * applies to the selection in a list of items.
1910 *
1911 * <p>Supporting this category means that you would like your activity to be
1912 * displayed in the set of alternative things the user can do, usually as
1913 * part of the current activity's options menu. You will usually want to
1914 * include a specific label in the &lt;intent-filter&gt; of this action
1915 * describing to the user what it does.
1916 *
1917 * <p>The action of IntentFilter with this category is important in that it
1918 * describes the specific action the target will perform. This generally
1919 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
1920 * a specific name such as "com.android.camera.action.CROP. Only one
1921 * alternative of any particular action will be shown to the user, so using
1922 * a specific action like this makes sure that your alternative will be
1923 * displayed while also allowing other applications to provide their own
1924 * overrides of that particular action.
1925 */
1926 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1927 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
1928 /**
1929 * Set if the activity should be considered as an alternative selection
1930 * action to the data the user has currently selected. This is like
1931 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
1932 * of items from which the user can select, giving them alternatives to the
1933 * default action that will be performed on it.
1934 */
1935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1936 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
1937 /**
1938 * Intended to be used as a tab inside of an containing TabActivity.
1939 */
1940 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1941 public static final String CATEGORY_TAB = "android.intent.category.TAB";
1942 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001943 * Should be displayed in the top-level launcher.
1944 */
1945 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1946 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
1947 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001948 * Provides information about the package it is in; typically used if
1949 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
1950 * a front-door to the user without having to be shown in the all apps list.
1951 */
1952 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1953 public static final String CATEGORY_INFO = "android.intent.category.INFO";
1954 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001955 * This is the home activity, that is the first activity that is displayed
1956 * when the device boots.
1957 */
1958 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1959 public static final String CATEGORY_HOME = "android.intent.category.HOME";
1960 /**
1961 * This activity is a preference panel.
1962 */
1963 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1964 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
1965 /**
1966 * This activity is a development preference panel.
1967 */
1968 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1969 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
1970 /**
1971 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001972 */
1973 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1974 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
1975 /**
1976 * This activity may be exercised by the monkey or other automated test tools.
1977 */
1978 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1979 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
1980 /**
1981 * To be used as a test (not part of the normal user experience).
1982 */
1983 public static final String CATEGORY_TEST = "android.intent.category.TEST";
1984 /**
1985 * To be used as a unit test (run through the Test Harness).
1986 */
1987 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
1988 /**
1989 * To be used as an sample code example (not part of the normal user
1990 * experience).
1991 */
1992 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
1993 /**
1994 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
1995 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
1996 * when queried, though it is allowable for those columns to be blank.
1997 */
1998 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1999 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2000
2001 /**
2002 * To be used as code under test for framework instrumentation tests.
2003 */
2004 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2005 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002006 /**
2007 * An activity to run when device is inserted into a car dock.
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002008 * Used with {@link #ACTION_MAIN} to launch an activity.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002009 * To monitor dock state, use {@link #ACTION_DOCK_EVENT} instead.
2010 */
2011 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2012 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2013 /**
2014 * An activity to run when device is inserted into a car dock.
2015 * Used with {@link #ACTION_MAIN} to launch an activity.
2016 * To monitor dock state, use {@link #ACTION_DOCK_EVENT} instead.
2017 */
2018 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2019 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002020
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 // ---------------------------------------------------------------------
2022 // ---------------------------------------------------------------------
2023 // Standard extra data keys.
2024
2025 /**
2026 * The initial data to place in a newly created record. Use with
2027 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2028 * fields as would be given to the underlying ContentProvider.insert()
2029 * call.
2030 */
2031 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2032
2033 /**
2034 * A constant CharSequence that is associated with the Intent, used with
2035 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2036 * this may be a styled CharSequence, so you must use
2037 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2038 * retrieve it.
2039 */
2040 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2041
2042 /**
2043 * A content: URI holding a stream of data associated with the Intent,
2044 * used with {@link #ACTION_SEND} to supply the data being sent.
2045 */
2046 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2047
2048 /**
2049 * A String[] holding e-mail addresses that should be delivered to.
2050 */
2051 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2052
2053 /**
2054 * A String[] holding e-mail addresses that should be carbon copied.
2055 */
2056 public static final String EXTRA_CC = "android.intent.extra.CC";
2057
2058 /**
2059 * A String[] holding e-mail addresses that should be blind carbon copied.
2060 */
2061 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2062
2063 /**
2064 * A constant string holding the desired subject line of a message.
2065 */
2066 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2067
2068 /**
2069 * An Intent describing the choices you would like shown with
2070 * {@link #ACTION_PICK_ACTIVITY}.
2071 */
2072 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2073
2074 /**
2075 * A CharSequence dialog title to provide to the user when used with a
2076 * {@link #ACTION_CHOOSER}.
2077 */
2078 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2079
2080 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002081 * A Parcelable[] of {@link Intent} or
2082 * {@link android.content.pm.LabeledIntent} objects as set with
2083 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2084 * a the front of the list of choices, when shown to the user with a
2085 * {@link #ACTION_CHOOSER}.
2086 */
2087 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2088
2089 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002090 * A {@link android.view.KeyEvent} object containing the event that
2091 * triggered the creation of the Intent it is in.
2092 */
2093 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2094
2095 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002096 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2097 * before shutting down.
2098 *
2099 * {@hide}
2100 */
2101 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2102
2103 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2105 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2106 * of restarting the application.
2107 */
2108 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2109
2110 /**
2111 * A String holding the phone number originally entered in
2112 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2113 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2114 */
2115 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002116
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002117 /**
2118 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2119 * intents to supply the uid the package had been assigned. Also an optional
2120 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2121 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2122 * purpose.
2123 */
2124 public static final String EXTRA_UID = "android.intent.extra.UID";
2125
2126 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002127 * @hide String array of package names.
2128 */
2129 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2130
2131 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002132 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2133 * intents to indicate whether this represents a full uninstall (removing
2134 * both the code and its data) or a partial uninstall (leaving its data,
2135 * implying that this is an update).
2136 */
2137 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002138
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002139 /**
2140 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2141 * intents to indicate that this is a replacement of the package, so this
2142 * broadcast will immediately be followed by an add broadcast for a
2143 * different version of the same package.
2144 */
2145 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002146
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002147 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002148 * Used as an int extra field in {@link android.app.AlarmManager} intents
2149 * to tell the application being invoked how many pending alarms are being
2150 * delievered with the intent. For one-shot alarms this will always be 1.
2151 * For recurring alarms, this might be greater than 1 if the device was
2152 * asleep or powered off at the time an earlier alarm would have been
2153 * delivered.
2154 */
2155 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002156
Jacek Surazski86b6c532009-05-13 14:38:28 +02002157 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002158 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2159 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002160 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2161 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2162 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002163 */
2164 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2165
2166 /**
2167 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2168 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002169 */
2170 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2171
2172 /**
2173 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2174 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002175 */
2176 public static final int EXTRA_DOCK_STATE_DESK = 1;
2177
2178 /**
2179 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2180 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002181 */
2182 public static final int EXTRA_DOCK_STATE_CAR = 2;
2183
2184 /**
Tobias Haamel154f7a12010-02-17 11:56:39 -08002185 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2186 * intents to request the physical dock state. Possible values are
2187 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2188 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2189 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
2190 */
2191 public static final String EXTRA_PHYSICAL_DOCK_STATE =
2192 "android.intent.extra.PHYSICAL_DOCK_STATE";
2193
2194 /**
Tobias Haamel27b28b32010-02-09 23:09:17 +01002195 * Used as an boolean extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2196 * intents to indicate that the car mode is enabled or not.
2197 */
2198 public static final String EXTRA_CAR_MODE_ENABLED = "android.intent.extra.CAR_MODE_ENABLED";
2199
2200 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002201 * Boolean that can be supplied as meta-data with a dock activity, to
2202 * indicate that the dock should take over the home key when it is active.
2203 */
2204 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002205
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002206 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002207 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2208 * the bug report.
Romain Guy4969af72009-06-17 10:53:19 -07002209 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002210 * @hide
2211 */
2212 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2213
2214 /**
Romain Guy4969af72009-06-17 10:53:19 -07002215 * Used as a string extra field when sending an intent to PackageInstaller to install a
Jacek Surazski86b6c532009-05-13 14:38:28 +02002216 * package. Specifies the installer package name; this package will receive the
2217 * {@link #ACTION_APP_ERROR} intent.
Romain Guy4969af72009-06-17 10:53:19 -07002218 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002219 * @hide
2220 */
Romain Guy4969af72009-06-17 10:53:19 -07002221 public static final String EXTRA_INSTALLER_PACKAGE_NAME
Jacek Surazski86b6c532009-05-13 14:38:28 +02002222 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002223
Wei Huang97ecc9c2009-05-11 17:44:20 -07002224 /**
2225 * Used in the extra field in the remote intent. It's astring token passed with the
2226 * remote intent.
2227 */
2228 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2229 "android.intent.extra.remote_intent_token";
2230
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002231 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002232 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002233 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002234 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002235 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002236 "android.intent.extra.changed_component_name";
2237
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002238 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002239 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002240 * and contains a string array of all of the components that have changed.
2241 */
2242 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2243 "android.intent.extra.changed_component_name_list";
2244
2245 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002246 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002247 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2248 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002249 * and contains a string array of all of the components that have changed.
2250 * @hide
2251 */
2252 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2253 "android.intent.extra.changed_package_list";
2254
2255 /**
2256 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002257 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2258 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002259 * and contains an integer array of uids of all of the components
2260 * that have changed.
2261 * @hide
2262 */
2263 public static final String EXTRA_CHANGED_UID_LIST =
2264 "android.intent.extra.changed_uid_list";
2265
2266 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002267 * @hide
2268 * Magic extra system code can use when binding, to give a label for
2269 * who it is that has bound to a service. This is an integer giving
2270 * a framework string resource that can be displayed to the user.
2271 */
2272 public static final String EXTRA_CLIENT_LABEL =
2273 "android.intent.extra.client_label";
2274
2275 /**
2276 * @hide
2277 * Magic extra system code can use when binding, to give a PendingIntent object
2278 * that can be launched for the user to disable the system's use of this
2279 * service.
2280 */
2281 public static final String EXTRA_CLIENT_INTENT =
2282 "android.intent.extra.client_intent";
2283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002284 // ---------------------------------------------------------------------
2285 // ---------------------------------------------------------------------
2286 // Intent flags (see mFlags variable).
2287
2288 /**
2289 * If set, the recipient of this Intent will be granted permission to
2290 * perform read operations on the Uri in the Intent's data.
2291 */
2292 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2293 /**
2294 * If set, the recipient of this Intent will be granted permission to
2295 * perform write operations on the Uri in the Intent's data.
2296 */
2297 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2298 /**
2299 * Can be set by the caller to indicate that this Intent is coming from
2300 * a background operation, not from direct user interaction.
2301 */
2302 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2303 /**
2304 * A flag you can enable for debugging: when set, log messages will be
2305 * printed during the resolution of this intent to show you what has
2306 * been found to create the final resolved list.
2307 */
2308 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
2309
2310 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002311 * If set, the new activity is not kept in the history stack. As soon as
2312 * the user navigates away from it, the activity is finished. This may also
2313 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2314 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002315 */
2316 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2317 /**
2318 * If set, the activity will not be launched if it is already running
2319 * at the top of the history stack.
2320 */
2321 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2322 /**
2323 * If set, this activity will become the start of a new task on this
2324 * history stack. A task (from the activity that started it to the
2325 * next task activity) defines an atomic group of activities that the
2326 * user can move to. Tasks can be moved to the foreground and background;
2327 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002328 * the same order. See
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002329 * <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2330 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002331 *
2332 * <p>This flag is generally used by activities that want
2333 * to present a "launcher" style behavior: they give the user a list of
2334 * separate things that can be done, which otherwise run completely
2335 * independently of the activity launching them.
2336 *
2337 * <p>When using this flag, if a task is already running for the activity
2338 * you are now starting, then a new activity will not be started; instead,
2339 * the current task will simply be brought to the front of the screen with
2340 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2341 * to disable this behavior.
2342 *
2343 * <p>This flag can not be used when the caller is requesting a result from
2344 * the activity being launched.
2345 */
2346 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2347 /**
2348 * <strong>Do not use this flag unless you are implementing your own
2349 * top-level application launcher.</strong> Used in conjunction with
2350 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2351 * behavior of bringing an existing task to the foreground. When set,
2352 * a new task is <em>always</em> started to host the Activity for the
2353 * Intent, regardless of whether there is already an existing task running
2354 * the same thing.
2355 *
2356 * <p><strong>Because the default system does not include graphical task management,
2357 * you should not use this flag unless you provide some way for a user to
2358 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002359 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002360 * <p>This flag is ignored if
2361 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2362 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002363 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2364 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002365 */
2366 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2367 /**
2368 * If set, and the activity being launched is already running in the
2369 * current task, then instead of launching a new instance of that activity,
2370 * all of the other activities on top of it will be closed and this Intent
2371 * will be delivered to the (now on top) old activity as a new Intent.
2372 *
2373 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2374 * If D calls startActivity() with an Intent that resolves to the component
2375 * of activity B, then C and D will be finished and B receive the given
2376 * Intent, resulting in the stack now being: A, B.
2377 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002378 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002379 * either receive the new intent you are starting here in its
2380 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002381 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002382 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2383 * the same intent, then it will be finished and re-created; for all other
2384 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2385 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002386 *
2387 * <p>This launch mode can also be used to good effect in conjunction with
2388 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2389 * of a task, it will bring any currently running instance of that task
2390 * to the foreground, and then clear it to its root state. This is
2391 * especially useful, for example, when launching an activity from the
2392 * notification manager.
2393 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002394 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2395 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002396 */
2397 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2398 /**
2399 * If set and this intent is being used to launch a new activity from an
2400 * existing one, then the reply target of the existing activity will be
2401 * transfered to the new activity. This way the new activity can call
2402 * {@link android.app.Activity#setResult} and have that result sent back to
2403 * the reply target of the original activity.
2404 */
2405 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2406 /**
2407 * If set and this intent is being used to launch a new activity from an
2408 * existing one, the current activity will not be counted as the top
2409 * activity for deciding whether the new intent should be delivered to
2410 * the top instead of starting a new one. The previous activity will
2411 * be used as the top, with the assumption being that the current activity
2412 * will finish itself immediately.
2413 */
2414 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2415 /**
2416 * If set, the new activity is not kept in the list of recently launched
2417 * activities.
2418 */
2419 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2420 /**
2421 * This flag is not normally set by application code, but set for you by
2422 * the system as described in the
2423 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2424 * launchMode} documentation for the singleTask mode.
2425 */
2426 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2427 /**
2428 * If set, and this activity is either being started in a new task or
2429 * bringing to the top an existing task, then it will be launched as
2430 * the front door of the task. This will result in the application of
2431 * any affinities needed to have that task in the proper state (either
2432 * moving activities to or from it), or simply resetting that task to
2433 * its initial state if needed.
2434 */
2435 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2436 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002437 * This flag is not normally set by application code, but set for you by
2438 * the system if this activity is being launched from history
2439 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002440 */
2441 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002442 /**
2443 * If set, this marks a point in the task's activity stack that should
2444 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002445 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002446 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2447 * the user re-launching it from home), this activity and all on top of
2448 * it will be finished so that the user does not return to them, but
2449 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002450 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002451 * <p>This is useful for cases where you have a logical break in your
2452 * application. For example, an e-mail application may have a command
2453 * to view an attachment, which launches an image view activity to
2454 * display it. This activity should be part of the e-mail application's
2455 * task, since it is a part of the task the user is involved in. However,
2456 * if the user leaves that task, and later selects the e-mail app from
2457 * home, we may like them to return to the conversation they were
2458 * viewing, not the picture attachment, since that is confusing. By
2459 * setting this flag when launching the image viewer, that viewer and
2460 * any activities it starts will be removed the next time the user returns
2461 * to mail.
2462 */
2463 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002464 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002465 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002466 * callback from occurring on the current frontmost activity before it is
2467 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002468 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002469 * <p>Typically, an activity can rely on that callback to indicate that an
2470 * explicit user action has caused their activity to be moved out of the
2471 * foreground. The callback marks an appropriate point in the activity's
2472 * lifecycle for it to dismiss any notifications that it intends to display
2473 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002474 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002475 * <p>If an activity is ever started via any non-user-driven events such as
2476 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2477 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002478 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002479 */
2480 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002481 /**
2482 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2483 * this flag will cause the launched activity to be brought to the front of its
2484 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002485 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002486 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2487 * If D calls startActivity() with an Intent that resolves to the component
2488 * of activity B, then B will be brought to the front of the history stack,
2489 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002490 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002491 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002492 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002493 */
2494 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002495 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002496 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2497 * this flag will prevent the system from applying an activity transition
2498 * animation to go to the next activity state. This doesn't mean an
2499 * animation will never run -- if another activity change happens that doesn't
2500 * specify this flag before the activity started here is displayed, then
2501 * that transition will be used. This this flag can be put to good use
2502 * when you are going to do a series of activity operations but the
2503 * animation seen by the user shouldn't be driven by the first activity
2504 * change but rather a later one.
2505 */
2506 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2507 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002508 * If set, when sending a broadcast only registered receivers will be
2509 * called -- no BroadcastReceiver components will be launched.
2510 */
2511 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002512 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002513 * If set, when sending a broadcast the new broadcast will replace
2514 * any existing pending broadcast that matches it. Matching is defined
2515 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2516 * true for the intents of the two broadcasts. When a match is found,
2517 * the new broadcast (and receivers associated with it) will replace the
2518 * existing one in the pending broadcast list, remaining at the same
2519 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002520 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002521 * <p>This flag is most typically used with sticky broadcasts, which
2522 * only care about delivering the most recent values of the broadcast
2523 * to their receivers.
2524 */
2525 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2526 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002527 * If set, when sending a broadcast <i>before boot has completed</i> only
2528 * registered receivers will be called -- no BroadcastReceiver components
2529 * will be launched. Sticky intent state will be recorded properly even
2530 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2531 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002532 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002533 * <p>This flag is only for use by system sevices as a convenience to
2534 * avoid having to implement a more complex mechanism around detection
2535 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002536 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002537 * @hide
2538 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002539 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002540 /**
2541 * Set when this broadcast is for a boot upgrade, a special mode that
2542 * allows the broadcast to be sent before the system is ready and launches
2543 * the app process with no providers running in it.
2544 * @hide
2545 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002546 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002547
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002548 /**
2549 * @hide Flags that can't be changed with PendingIntent.
2550 */
2551 public static final int IMMUTABLE_FLAGS =
2552 FLAG_GRANT_READ_URI_PERMISSION
2553 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002554
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002555 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002556 // ---------------------------------------------------------------------
2557 // toUri() and parseUri() options.
2558
2559 /**
2560 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2561 * always has the "intent:" scheme. This syntax can be used when you want
2562 * to later disambiguate between URIs that are intended to describe an
2563 * Intent vs. all others that should be treated as raw URIs. When used
2564 * with {@link #parseUri}, any other scheme will result in a generic
2565 * VIEW action for that raw URI.
2566 */
2567 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002568
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002569 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002570
2571 private String mAction;
2572 private Uri mData;
2573 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002574 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002575 private ComponentName mComponent;
2576 private int mFlags;
2577 private HashSet<String> mCategories;
2578 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002579 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002580
2581 // ---------------------------------------------------------------------
2582
2583 /**
2584 * Create an empty intent.
2585 */
2586 public Intent() {
2587 }
2588
2589 /**
2590 * Copy constructor.
2591 */
2592 public Intent(Intent o) {
2593 this.mAction = o.mAction;
2594 this.mData = o.mData;
2595 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002596 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002597 this.mComponent = o.mComponent;
2598 this.mFlags = o.mFlags;
2599 if (o.mCategories != null) {
2600 this.mCategories = new HashSet<String>(o.mCategories);
2601 }
2602 if (o.mExtras != null) {
2603 this.mExtras = new Bundle(o.mExtras);
2604 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002605 if (o.mSourceBounds != null) {
2606 this.mSourceBounds = new Rect(o.mSourceBounds);
2607 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002608 }
2609
2610 @Override
2611 public Object clone() {
2612 return new Intent(this);
2613 }
2614
2615 private Intent(Intent o, boolean all) {
2616 this.mAction = o.mAction;
2617 this.mData = o.mData;
2618 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002619 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002620 this.mComponent = o.mComponent;
2621 if (o.mCategories != null) {
2622 this.mCategories = new HashSet<String>(o.mCategories);
2623 }
2624 }
2625
2626 /**
2627 * Make a clone of only the parts of the Intent that are relevant for
2628 * filter matching: the action, data, type, component, and categories.
2629 */
2630 public Intent cloneFilter() {
2631 return new Intent(this, false);
2632 }
2633
2634 /**
2635 * Create an intent with a given action. All other fields (data, type,
2636 * class) are null. Note that the action <em>must</em> be in a
2637 * namespace because Intents are used globally in the system -- for
2638 * example the system VIEW action is android.intent.action.VIEW; an
2639 * application's custom action would be something like
2640 * com.google.app.myapp.CUSTOM_ACTION.
2641 *
2642 * @param action The Intent action, such as ACTION_VIEW.
2643 */
2644 public Intent(String action) {
2645 mAction = action;
2646 }
2647
2648 /**
2649 * Create an intent with a given action and for a given data url. Note
2650 * that the action <em>must</em> be in a namespace because Intents are
2651 * used globally in the system -- for example the system VIEW action is
2652 * android.intent.action.VIEW; an application's custom action would be
2653 * something like com.google.app.myapp.CUSTOM_ACTION.
2654 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002655 * <p><em>Note: scheme and host name matching in the Android framework is
2656 * case-sensitive, unlike the formal RFC. As a result,
2657 * you should always ensure that you write your Uri with these elements
2658 * using lower case letters, and normalize any Uris you receive from
2659 * outside of Android to ensure the scheme and host is lower case.</em></p>
2660 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002661 * @param action The Intent action, such as ACTION_VIEW.
2662 * @param uri The Intent data URI.
2663 */
2664 public Intent(String action, Uri uri) {
2665 mAction = action;
2666 mData = uri;
2667 }
2668
2669 /**
2670 * Create an intent for a specific component. All other fields (action, data,
2671 * type, class) are null, though they can be modified later with explicit
2672 * calls. This provides a convenient way to create an intent that is
2673 * intended to execute a hard-coded class name, rather than relying on the
2674 * system to find an appropriate class for you; see {@link #setComponent}
2675 * for more information on the repercussions of this.
2676 *
2677 * @param packageContext A Context of the application package implementing
2678 * this class.
2679 * @param cls The component class that is to be used for the intent.
2680 *
2681 * @see #setClass
2682 * @see #setComponent
2683 * @see #Intent(String, android.net.Uri , Context, Class)
2684 */
2685 public Intent(Context packageContext, Class<?> cls) {
2686 mComponent = new ComponentName(packageContext, cls);
2687 }
2688
2689 /**
2690 * Create an intent for a specific component with a specified action and data.
2691 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
2692 * construct the Intent and then calling {@link #setClass} to set its
2693 * class.
2694 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002695 * <p><em>Note: scheme and host name matching in the Android framework is
2696 * case-sensitive, unlike the formal RFC. As a result,
2697 * you should always ensure that you write your Uri with these elements
2698 * using lower case letters, and normalize any Uris you receive from
2699 * outside of Android to ensure the scheme and host is lower case.</em></p>
2700 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002701 * @param action The Intent action, such as ACTION_VIEW.
2702 * @param uri The Intent data URI.
2703 * @param packageContext A Context of the application package implementing
2704 * this class.
2705 * @param cls The component class that is to be used for the intent.
2706 *
2707 * @see #Intent(String, android.net.Uri)
2708 * @see #Intent(Context, Class)
2709 * @see #setClass
2710 * @see #setComponent
2711 */
2712 public Intent(String action, Uri uri,
2713 Context packageContext, Class<?> cls) {
2714 mAction = action;
2715 mData = uri;
2716 mComponent = new ComponentName(packageContext, cls);
2717 }
2718
2719 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002720 * Call {@link #parseUri} with 0 flags.
2721 * @deprecated Use {@link #parseUri} instead.
2722 */
2723 @Deprecated
2724 public static Intent getIntent(String uri) throws URISyntaxException {
2725 return parseUri(uri, 0);
2726 }
Tom Taylord4a47292009-12-21 13:59:18 -08002727
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002728 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002729 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002730 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07002731 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002732 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 *
2734 * <p>The URI given here must not be relative -- that is, it must include
2735 * the scheme and full path.
2736 *
2737 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002738 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002739 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002740 *
2741 * @return Intent The newly created Intent object.
2742 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002743 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
2744 * it bad (as parsed by the Uri class) or the Intent data within the
2745 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08002746 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002747 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002748 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002749 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002750 int i = 0;
2751 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002752 // Validate intent scheme for if requested.
2753 if ((flags&URI_INTENT_SCHEME) != 0) {
2754 if (!uri.startsWith("intent:")) {
2755 Intent intent = new Intent(ACTION_VIEW);
2756 try {
2757 intent.setData(Uri.parse(uri));
2758 } catch (IllegalArgumentException e) {
2759 throw new URISyntaxException(uri, e.getMessage());
2760 }
2761 return intent;
2762 }
2763 }
Tom Taylord4a47292009-12-21 13:59:18 -08002764
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002765 // simple case
2766 i = uri.lastIndexOf("#");
2767 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
2768
2769 // old format Intent URI
2770 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07002771
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002772 // new format
2773 Intent intent = new Intent(ACTION_VIEW);
2774
2775 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002776 String data = i >= 0 ? uri.substring(0, i) : null;
2777 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002778 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07002779
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002780 // loop over contents of Intent, all name=value;
2781 while (!uri.startsWith("end", i)) {
2782 int eq = uri.indexOf('=', i);
2783 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002784 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002785
2786 // action
2787 if (uri.startsWith("action=", i)) {
2788 intent.mAction = value;
2789 }
2790
2791 // categories
2792 else if (uri.startsWith("category=", i)) {
2793 intent.addCategory(value);
2794 }
2795
2796 // type
2797 else if (uri.startsWith("type=", i)) {
2798 intent.mType = value;
2799 }
2800
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002801 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 else if (uri.startsWith("launchFlags=", i)) {
2803 intent.mFlags = Integer.decode(value).intValue();
2804 }
2805
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002806 // package
2807 else if (uri.startsWith("package=", i)) {
2808 intent.mPackage = value;
2809 }
2810
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002811 // component
2812 else if (uri.startsWith("component=", i)) {
2813 intent.mComponent = ComponentName.unflattenFromString(value);
2814 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002815
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002816 // scheme
2817 else if (uri.startsWith("scheme=", i)) {
2818 scheme = value;
2819 }
2820
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002821 // source bounds
2822 else if (uri.startsWith("sourceBounds=", i)) {
2823 intent.mSourceBounds = Rect.unflattenFromString(value);
2824 }
2825
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002826 // extra
2827 else {
2828 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002829 // create Bundle if it doesn't already exist
2830 if (intent.mExtras == null) intent.mExtras = new Bundle();
2831 Bundle b = intent.mExtras;
2832 // add EXTRA
2833 if (uri.startsWith("S.", i)) b.putString(key, value);
2834 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
2835 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
2836 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
2837 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
2838 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
2839 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
2840 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
2841 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
2842 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
2843 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002844
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002845 // move to the next item
2846 i = semi + 1;
2847 }
2848
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002849 if (data != null) {
2850 if (data.startsWith("intent:")) {
2851 data = data.substring(7);
2852 if (scheme != null) {
2853 data = scheme + ':' + data;
2854 }
2855 }
Tom Taylord4a47292009-12-21 13:59:18 -08002856
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002857 if (data.length() > 0) {
2858 try {
2859 intent.mData = Uri.parse(data);
2860 } catch (IllegalArgumentException e) {
2861 throw new URISyntaxException(uri, e.getMessage());
2862 }
2863 }
2864 }
Tom Taylord4a47292009-12-21 13:59:18 -08002865
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002866 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07002867
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002868 } catch (IndexOutOfBoundsException e) {
2869 throw new URISyntaxException(uri, "illegal Intent URI format", i);
2870 }
2871 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002872
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 public static Intent getIntentOld(String uri) throws URISyntaxException {
2874 Intent intent;
2875
2876 int i = uri.lastIndexOf('#');
2877 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002878 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002879 final int intentFragmentStart = i;
2880 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002881
2882 i++;
2883
2884 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002885 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002886 i += 7;
2887 int j = uri.indexOf(')', i);
2888 action = uri.substring(i, j);
2889 i = j + 1;
2890 }
2891
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002892 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002893
2894 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002895 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002896 i += 11;
2897 int j = uri.indexOf(')', i);
2898 while (i < j) {
2899 int sep = uri.indexOf('!', i);
2900 if (sep < 0) sep = j;
2901 if (i < sep) {
2902 intent.addCategory(uri.substring(i, sep));
2903 }
2904 i = sep + 1;
2905 }
2906 i = j + 1;
2907 }
2908
2909 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002910 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002911 i += 5;
2912 int j = uri.indexOf(')', i);
2913 intent.mType = uri.substring(i, j);
2914 i = j + 1;
2915 }
2916
2917 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002918 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002919 i += 12;
2920 int j = uri.indexOf(')', i);
2921 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
2922 i = j + 1;
2923 }
2924
2925 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002926 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002927 i += 10;
2928 int j = uri.indexOf(')', i);
2929 int sep = uri.indexOf('!', i);
2930 if (sep >= 0 && sep < j) {
2931 String pkg = uri.substring(i, sep);
2932 String cls = uri.substring(sep + 1, j);
2933 intent.mComponent = new ComponentName(pkg, cls);
2934 }
2935 i = j + 1;
2936 }
2937
2938 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002939 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002940 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07002941
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002942 final int closeParen = uri.indexOf(')', i);
2943 if (closeParen == -1) throw new URISyntaxException(uri,
2944 "EXTRA missing trailing ')'", i);
2945
2946 while (i < closeParen) {
2947 // fetch the key value
2948 int j = uri.indexOf('=', i);
2949 if (j <= i + 1 || i >= closeParen) {
2950 throw new URISyntaxException(uri, "EXTRA missing '='", i);
2951 }
2952 char type = uri.charAt(i);
2953 i++;
2954 String key = uri.substring(i, j);
2955 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07002956
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002957 // get type-value
2958 j = uri.indexOf('!', i);
2959 if (j == -1 || j >= closeParen) j = closeParen;
2960 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
2961 String value = uri.substring(i, j);
2962 i = j;
2963
2964 // create Bundle if it doesn't already exist
2965 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07002966
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002967 // add item to bundle
2968 try {
2969 switch (type) {
2970 case 'S':
2971 intent.mExtras.putString(key, Uri.decode(value));
2972 break;
2973 case 'B':
2974 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
2975 break;
2976 case 'b':
2977 intent.mExtras.putByte(key, Byte.parseByte(value));
2978 break;
2979 case 'c':
2980 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
2981 break;
2982 case 'd':
2983 intent.mExtras.putDouble(key, Double.parseDouble(value));
2984 break;
2985 case 'f':
2986 intent.mExtras.putFloat(key, Float.parseFloat(value));
2987 break;
2988 case 'i':
2989 intent.mExtras.putInt(key, Integer.parseInt(value));
2990 break;
2991 case 'l':
2992 intent.mExtras.putLong(key, Long.parseLong(value));
2993 break;
2994 case 's':
2995 intent.mExtras.putShort(key, Short.parseShort(value));
2996 break;
2997 default:
2998 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
2999 }
3000 } catch (NumberFormatException e) {
3001 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3002 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003003
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003004 char ch = uri.charAt(i);
3005 if (ch == ')') break;
3006 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3007 i++;
3008 }
3009 }
3010
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003011 if (isIntentFragment) {
3012 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3013 } else {
3014 intent.mData = Uri.parse(uri);
3015 }
Tom Taylord4a47292009-12-21 13:59:18 -08003016
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003017 if (intent.mAction == null) {
3018 // By default, if no action is specified, then use VIEW.
3019 intent.mAction = ACTION_VIEW;
3020 }
3021
3022 } else {
3023 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3024 }
3025
3026 return intent;
3027 }
3028
3029 /**
3030 * Retrieve the general action to be performed, such as
3031 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3032 * the information in the intent should be interpreted -- most importantly,
3033 * what to do with the data returned by {@link #getData}.
3034 *
3035 * @return The action of this intent or null if none is specified.
3036 *
3037 * @see #setAction
3038 */
3039 public String getAction() {
3040 return mAction;
3041 }
3042
3043 /**
3044 * Retrieve data this intent is operating on. This URI specifies the name
3045 * of the data; often it uses the content: scheme, specifying data in a
3046 * content provider. Other schemes may be handled by specific activities,
3047 * such as http: by the web browser.
3048 *
3049 * @return The URI of the data this intent is targeting or null.
3050 *
3051 * @see #getScheme
3052 * @see #setData
3053 */
3054 public Uri getData() {
3055 return mData;
3056 }
3057
3058 /**
3059 * The same as {@link #getData()}, but returns the URI as an encoded
3060 * String.
3061 */
3062 public String getDataString() {
3063 return mData != null ? mData.toString() : null;
3064 }
3065
3066 /**
3067 * Return the scheme portion of the intent's data. If the data is null or
3068 * does not include a scheme, null is returned. Otherwise, the scheme
3069 * prefix without the final ':' is returned, i.e. "http".
3070 *
3071 * <p>This is the same as calling getData().getScheme() (and checking for
3072 * null data).
3073 *
3074 * @return The scheme of this intent.
3075 *
3076 * @see #getData
3077 */
3078 public String getScheme() {
3079 return mData != null ? mData.getScheme() : null;
3080 }
3081
3082 /**
3083 * Retrieve any explicit MIME type included in the intent. This is usually
3084 * null, as the type is determined by the intent data.
3085 *
3086 * @return If a type was manually set, it is returned; else null is
3087 * returned.
3088 *
3089 * @see #resolveType(ContentResolver)
3090 * @see #setType
3091 */
3092 public String getType() {
3093 return mType;
3094 }
3095
3096 /**
3097 * Return the MIME data type of this intent. If the type field is
3098 * explicitly set, that is simply returned. Otherwise, if the data is set,
3099 * the type of that data is returned. If neither fields are set, a null is
3100 * returned.
3101 *
3102 * @return The MIME type of this intent.
3103 *
3104 * @see #getType
3105 * @see #resolveType(ContentResolver)
3106 */
3107 public String resolveType(Context context) {
3108 return resolveType(context.getContentResolver());
3109 }
3110
3111 /**
3112 * Return the MIME data type of this intent. If the type field is
3113 * explicitly set, that is simply returned. Otherwise, if the data is set,
3114 * the type of that data is returned. If neither fields are set, a null is
3115 * returned.
3116 *
3117 * @param resolver A ContentResolver that can be used to determine the MIME
3118 * type of the intent's data.
3119 *
3120 * @return The MIME type of this intent.
3121 *
3122 * @see #getType
3123 * @see #resolveType(Context)
3124 */
3125 public String resolveType(ContentResolver resolver) {
3126 if (mType != null) {
3127 return mType;
3128 }
3129 if (mData != null) {
3130 if ("content".equals(mData.getScheme())) {
3131 return resolver.getType(mData);
3132 }
3133 }
3134 return null;
3135 }
3136
3137 /**
3138 * Return the MIME data type of this intent, only if it will be needed for
3139 * intent resolution. This is not generally useful for application code;
3140 * it is used by the frameworks for communicating with back-end system
3141 * services.
3142 *
3143 * @param resolver A ContentResolver that can be used to determine the MIME
3144 * type of the intent's data.
3145 *
3146 * @return The MIME type of this intent, or null if it is unknown or not
3147 * needed.
3148 */
3149 public String resolveTypeIfNeeded(ContentResolver resolver) {
3150 if (mComponent != null) {
3151 return mType;
3152 }
3153 return resolveType(resolver);
3154 }
3155
3156 /**
3157 * Check if an category exists in the intent.
3158 *
3159 * @param category The category to check.
3160 *
3161 * @return boolean True if the intent contains the category, else false.
3162 *
3163 * @see #getCategories
3164 * @see #addCategory
3165 */
3166 public boolean hasCategory(String category) {
3167 return mCategories != null && mCategories.contains(category);
3168 }
3169
3170 /**
3171 * Return the set of all categories in the intent. If there are no categories,
3172 * returns NULL.
3173 *
3174 * @return Set The set of categories you can examine. Do not modify!
3175 *
3176 * @see #hasCategory
3177 * @see #addCategory
3178 */
3179 public Set<String> getCategories() {
3180 return mCategories;
3181 }
3182
3183 /**
3184 * Sets the ClassLoader that will be used when unmarshalling
3185 * any Parcelable values from the extras of this Intent.
3186 *
3187 * @param loader a ClassLoader, or null to use the default loader
3188 * at the time of unmarshalling.
3189 */
3190 public void setExtrasClassLoader(ClassLoader loader) {
3191 if (mExtras != null) {
3192 mExtras.setClassLoader(loader);
3193 }
3194 }
3195
3196 /**
3197 * Returns true if an extra value is associated with the given name.
3198 * @param name the extra's name
3199 * @return true if the given extra is present.
3200 */
3201 public boolean hasExtra(String name) {
3202 return mExtras != null && mExtras.containsKey(name);
3203 }
3204
3205 /**
3206 * Returns true if the Intent's extras contain a parcelled file descriptor.
3207 * @return true if the Intent contains a parcelled file descriptor.
3208 */
3209 public boolean hasFileDescriptors() {
3210 return mExtras != null && mExtras.hasFileDescriptors();
3211 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003212
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003213 /**
3214 * Retrieve extended data from the intent.
3215 *
3216 * @param name The name of the desired item.
3217 *
3218 * @return the value of an item that previously added with putExtra()
3219 * or null if none was found.
3220 *
3221 * @deprecated
3222 * @hide
3223 */
3224 @Deprecated
3225 public Object getExtra(String name) {
3226 return getExtra(name, null);
3227 }
3228
3229 /**
3230 * Retrieve extended data from the intent.
3231 *
3232 * @param name The name of the desired item.
3233 * @param defaultValue the value to be returned if no value of the desired
3234 * type is stored with the given name.
3235 *
3236 * @return the value of an item that previously added with putExtra()
3237 * or the default value if none was found.
3238 *
3239 * @see #putExtra(String, boolean)
3240 */
3241 public boolean getBooleanExtra(String name, boolean defaultValue) {
3242 return mExtras == null ? defaultValue :
3243 mExtras.getBoolean(name, defaultValue);
3244 }
3245
3246 /**
3247 * Retrieve extended data from the intent.
3248 *
3249 * @param name The name of the desired item.
3250 * @param defaultValue the value to be returned if no value of the desired
3251 * type is stored with the given name.
3252 *
3253 * @return the value of an item that previously added with putExtra()
3254 * or the default value if none was found.
3255 *
3256 * @see #putExtra(String, byte)
3257 */
3258 public byte getByteExtra(String name, byte defaultValue) {
3259 return mExtras == null ? defaultValue :
3260 mExtras.getByte(name, defaultValue);
3261 }
3262
3263 /**
3264 * Retrieve extended data from the intent.
3265 *
3266 * @param name The name of the desired item.
3267 * @param defaultValue the value to be returned if no value of the desired
3268 * type is stored with the given name.
3269 *
3270 * @return the value of an item that previously added with putExtra()
3271 * or the default value if none was found.
3272 *
3273 * @see #putExtra(String, short)
3274 */
3275 public short getShortExtra(String name, short defaultValue) {
3276 return mExtras == null ? defaultValue :
3277 mExtras.getShort(name, defaultValue);
3278 }
3279
3280 /**
3281 * Retrieve extended data from the intent.
3282 *
3283 * @param name The name of the desired item.
3284 * @param defaultValue the value to be returned if no value of the desired
3285 * type is stored with the given name.
3286 *
3287 * @return the value of an item that previously added with putExtra()
3288 * or the default value if none was found.
3289 *
3290 * @see #putExtra(String, char)
3291 */
3292 public char getCharExtra(String name, char defaultValue) {
3293 return mExtras == null ? defaultValue :
3294 mExtras.getChar(name, defaultValue);
3295 }
3296
3297 /**
3298 * Retrieve extended data from the intent.
3299 *
3300 * @param name The name of the desired item.
3301 * @param defaultValue the value to be returned if no value of the desired
3302 * type is stored with the given name.
3303 *
3304 * @return the value of an item that previously added with putExtra()
3305 * or the default value if none was found.
3306 *
3307 * @see #putExtra(String, int)
3308 */
3309 public int getIntExtra(String name, int defaultValue) {
3310 return mExtras == null ? defaultValue :
3311 mExtras.getInt(name, defaultValue);
3312 }
3313
3314 /**
3315 * Retrieve extended data from the intent.
3316 *
3317 * @param name The name of the desired item.
3318 * @param defaultValue the value to be returned if no value of the desired
3319 * type is stored with the given name.
3320 *
3321 * @return the value of an item that previously added with putExtra()
3322 * or the default value if none was found.
3323 *
3324 * @see #putExtra(String, long)
3325 */
3326 public long getLongExtra(String name, long defaultValue) {
3327 return mExtras == null ? defaultValue :
3328 mExtras.getLong(name, defaultValue);
3329 }
3330
3331 /**
3332 * Retrieve extended data from the intent.
3333 *
3334 * @param name The name of the desired item.
3335 * @param defaultValue the value to be returned if no value of the desired
3336 * type is stored with the given name.
3337 *
3338 * @return the value of an item that previously added with putExtra(),
3339 * or the default value if no such item is present
3340 *
3341 * @see #putExtra(String, float)
3342 */
3343 public float getFloatExtra(String name, float defaultValue) {
3344 return mExtras == null ? defaultValue :
3345 mExtras.getFloat(name, defaultValue);
3346 }
3347
3348 /**
3349 * Retrieve extended data from the intent.
3350 *
3351 * @param name The name of the desired item.
3352 * @param defaultValue the value to be returned if no value of the desired
3353 * type is stored with the given name.
3354 *
3355 * @return the value of an item that previously added with putExtra()
3356 * or the default value if none was found.
3357 *
3358 * @see #putExtra(String, double)
3359 */
3360 public double getDoubleExtra(String name, double defaultValue) {
3361 return mExtras == null ? defaultValue :
3362 mExtras.getDouble(name, defaultValue);
3363 }
3364
3365 /**
3366 * Retrieve extended data from the intent.
3367 *
3368 * @param name The name of the desired item.
3369 *
3370 * @return the value of an item that previously added with putExtra()
3371 * or null if no String value was found.
3372 *
3373 * @see #putExtra(String, String)
3374 */
3375 public String getStringExtra(String name) {
3376 return mExtras == null ? null : mExtras.getString(name);
3377 }
3378
3379 /**
3380 * Retrieve extended data from the intent.
3381 *
3382 * @param name The name of the desired item.
3383 *
3384 * @return the value of an item that previously added with putExtra()
3385 * or null if no CharSequence value was found.
3386 *
3387 * @see #putExtra(String, CharSequence)
3388 */
3389 public CharSequence getCharSequenceExtra(String name) {
3390 return mExtras == null ? null : mExtras.getCharSequence(name);
3391 }
3392
3393 /**
3394 * Retrieve extended data from the intent.
3395 *
3396 * @param name The name of the desired item.
3397 *
3398 * @return the value of an item that previously added with putExtra()
3399 * or null if no Parcelable value was found.
3400 *
3401 * @see #putExtra(String, Parcelable)
3402 */
3403 public <T extends Parcelable> T getParcelableExtra(String name) {
3404 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3405 }
3406
3407 /**
3408 * Retrieve extended data from the intent.
3409 *
3410 * @param name The name of the desired item.
3411 *
3412 * @return the value of an item that previously added with putExtra()
3413 * or null if no Parcelable[] value was found.
3414 *
3415 * @see #putExtra(String, Parcelable[])
3416 */
3417 public Parcelable[] getParcelableArrayExtra(String name) {
3418 return mExtras == null ? null : mExtras.getParcelableArray(name);
3419 }
3420
3421 /**
3422 * Retrieve extended data from the intent.
3423 *
3424 * @param name The name of the desired item.
3425 *
3426 * @return the value of an item that previously added with putExtra()
3427 * or null if no ArrayList<Parcelable> value was found.
3428 *
3429 * @see #putParcelableArrayListExtra(String, ArrayList)
3430 */
3431 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3432 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3433 }
3434
3435 /**
3436 * Retrieve extended data from the intent.
3437 *
3438 * @param name The name of the desired item.
3439 *
3440 * @return the value of an item that previously added with putExtra()
3441 * or null if no Serializable value was found.
3442 *
3443 * @see #putExtra(String, Serializable)
3444 */
3445 public Serializable getSerializableExtra(String name) {
3446 return mExtras == null ? null : mExtras.getSerializable(name);
3447 }
3448
3449 /**
3450 * Retrieve extended data from the intent.
3451 *
3452 * @param name The name of the desired item.
3453 *
3454 * @return the value of an item that previously added with putExtra()
3455 * or null if no ArrayList<Integer> value was found.
3456 *
3457 * @see #putIntegerArrayListExtra(String, ArrayList)
3458 */
3459 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3460 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3461 }
3462
3463 /**
3464 * Retrieve extended data from the intent.
3465 *
3466 * @param name The name of the desired item.
3467 *
3468 * @return the value of an item that previously added with putExtra()
3469 * or null if no ArrayList<String> value was found.
3470 *
3471 * @see #putStringArrayListExtra(String, ArrayList)
3472 */
3473 public ArrayList<String> getStringArrayListExtra(String name) {
3474 return mExtras == null ? null : mExtras.getStringArrayList(name);
3475 }
3476
3477 /**
3478 * Retrieve extended data from the intent.
3479 *
3480 * @param name The name of the desired item.
3481 *
3482 * @return the value of an item that previously added with putExtra()
3483 * or null if no boolean array value was found.
3484 *
3485 * @see #putExtra(String, boolean[])
3486 */
3487 public boolean[] getBooleanArrayExtra(String name) {
3488 return mExtras == null ? null : mExtras.getBooleanArray(name);
3489 }
3490
3491 /**
3492 * Retrieve extended data from the intent.
3493 *
3494 * @param name The name of the desired item.
3495 *
3496 * @return the value of an item that previously added with putExtra()
3497 * or null if no byte array value was found.
3498 *
3499 * @see #putExtra(String, byte[])
3500 */
3501 public byte[] getByteArrayExtra(String name) {
3502 return mExtras == null ? null : mExtras.getByteArray(name);
3503 }
3504
3505 /**
3506 * Retrieve extended data from the intent.
3507 *
3508 * @param name The name of the desired item.
3509 *
3510 * @return the value of an item that previously added with putExtra()
3511 * or null if no short array value was found.
3512 *
3513 * @see #putExtra(String, short[])
3514 */
3515 public short[] getShortArrayExtra(String name) {
3516 return mExtras == null ? null : mExtras.getShortArray(name);
3517 }
3518
3519 /**
3520 * Retrieve extended data from the intent.
3521 *
3522 * @param name The name of the desired item.
3523 *
3524 * @return the value of an item that previously added with putExtra()
3525 * or null if no char array value was found.
3526 *
3527 * @see #putExtra(String, char[])
3528 */
3529 public char[] getCharArrayExtra(String name) {
3530 return mExtras == null ? null : mExtras.getCharArray(name);
3531 }
3532
3533 /**
3534 * Retrieve extended data from the intent.
3535 *
3536 * @param name The name of the desired item.
3537 *
3538 * @return the value of an item that previously added with putExtra()
3539 * or null if no int array value was found.
3540 *
3541 * @see #putExtra(String, int[])
3542 */
3543 public int[] getIntArrayExtra(String name) {
3544 return mExtras == null ? null : mExtras.getIntArray(name);
3545 }
3546
3547 /**
3548 * Retrieve extended data from the intent.
3549 *
3550 * @param name The name of the desired item.
3551 *
3552 * @return the value of an item that previously added with putExtra()
3553 * or null if no long array value was found.
3554 *
3555 * @see #putExtra(String, long[])
3556 */
3557 public long[] getLongArrayExtra(String name) {
3558 return mExtras == null ? null : mExtras.getLongArray(name);
3559 }
3560
3561 /**
3562 * Retrieve extended data from the intent.
3563 *
3564 * @param name The name of the desired item.
3565 *
3566 * @return the value of an item that previously added with putExtra()
3567 * or null if no float array value was found.
3568 *
3569 * @see #putExtra(String, float[])
3570 */
3571 public float[] getFloatArrayExtra(String name) {
3572 return mExtras == null ? null : mExtras.getFloatArray(name);
3573 }
3574
3575 /**
3576 * Retrieve extended data from the intent.
3577 *
3578 * @param name The name of the desired item.
3579 *
3580 * @return the value of an item that previously added with putExtra()
3581 * or null if no double array value was found.
3582 *
3583 * @see #putExtra(String, double[])
3584 */
3585 public double[] getDoubleArrayExtra(String name) {
3586 return mExtras == null ? null : mExtras.getDoubleArray(name);
3587 }
3588
3589 /**
3590 * Retrieve extended data from the intent.
3591 *
3592 * @param name The name of the desired item.
3593 *
3594 * @return the value of an item that previously added with putExtra()
3595 * or null if no String array value was found.
3596 *
3597 * @see #putExtra(String, String[])
3598 */
3599 public String[] getStringArrayExtra(String name) {
3600 return mExtras == null ? null : mExtras.getStringArray(name);
3601 }
3602
3603 /**
3604 * Retrieve extended data from the intent.
3605 *
3606 * @param name The name of the desired item.
3607 *
3608 * @return the value of an item that previously added with putExtra()
3609 * or null if no Bundle value was found.
3610 *
3611 * @see #putExtra(String, Bundle)
3612 */
3613 public Bundle getBundleExtra(String name) {
3614 return mExtras == null ? null : mExtras.getBundle(name);
3615 }
3616
3617 /**
3618 * Retrieve extended data from the intent.
3619 *
3620 * @param name The name of the desired item.
3621 *
3622 * @return the value of an item that previously added with putExtra()
3623 * or null if no IBinder value was found.
3624 *
3625 * @see #putExtra(String, IBinder)
3626 *
3627 * @deprecated
3628 * @hide
3629 */
3630 @Deprecated
3631 public IBinder getIBinderExtra(String name) {
3632 return mExtras == null ? null : mExtras.getIBinder(name);
3633 }
3634
3635 /**
3636 * Retrieve extended data from the intent.
3637 *
3638 * @param name The name of the desired item.
3639 * @param defaultValue The default value to return in case no item is
3640 * associated with the key 'name'
3641 *
3642 * @return the value of an item that previously added with putExtra()
3643 * or defaultValue if none was found.
3644 *
3645 * @see #putExtra
3646 *
3647 * @deprecated
3648 * @hide
3649 */
3650 @Deprecated
3651 public Object getExtra(String name, Object defaultValue) {
3652 Object result = defaultValue;
3653 if (mExtras != null) {
3654 Object result2 = mExtras.get(name);
3655 if (result2 != null) {
3656 result = result2;
3657 }
3658 }
3659
3660 return result;
3661 }
3662
3663 /**
3664 * Retrieves a map of extended data from the intent.
3665 *
3666 * @return the map of all extras previously added with putExtra(),
3667 * or null if none have been added.
3668 */
3669 public Bundle getExtras() {
3670 return (mExtras != null)
3671 ? new Bundle(mExtras)
3672 : null;
3673 }
3674
3675 /**
3676 * Retrieve any special flags associated with this intent. You will
3677 * normally just set them with {@link #setFlags} and let the system
3678 * take the appropriate action with them.
3679 *
3680 * @return int The currently set flags.
3681 *
3682 * @see #setFlags
3683 */
3684 public int getFlags() {
3685 return mFlags;
3686 }
3687
3688 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003689 * Retrieve the application package name this Intent is limited to. When
3690 * resolving an Intent, if non-null this limits the resolution to only
3691 * components in the given application package.
3692 *
3693 * @return The name of the application package for the Intent.
3694 *
3695 * @see #resolveActivity
3696 * @see #setPackage
3697 */
3698 public String getPackage() {
3699 return mPackage;
3700 }
3701
3702 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003703 * Retrieve the concrete component associated with the intent. When receiving
3704 * an intent, this is the component that was found to best handle it (that is,
3705 * yourself) and will always be non-null; in all other cases it will be
3706 * null unless explicitly set.
3707 *
3708 * @return The name of the application component to handle the intent.
3709 *
3710 * @see #resolveActivity
3711 * @see #setComponent
3712 */
3713 public ComponentName getComponent() {
3714 return mComponent;
3715 }
3716
3717 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003718 * Get the bounds of the sender of this intent, in screen coordinates. This can be
3719 * used as a hint to the receiver for animations and the like. Null means that there
3720 * is no source bounds.
3721 */
3722 public Rect getSourceBounds() {
3723 return mSourceBounds;
3724 }
3725
3726 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003727 * Return the Activity component that should be used to handle this intent.
3728 * The appropriate component is determined based on the information in the
3729 * intent, evaluated as follows:
3730 *
3731 * <p>If {@link #getComponent} returns an explicit class, that is returned
3732 * without any further consideration.
3733 *
3734 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
3735 * category to be considered.
3736 *
3737 * <p>If {@link #getAction} is non-NULL, the activity must handle this
3738 * action.
3739 *
3740 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
3741 * this type.
3742 *
3743 * <p>If {@link #addCategory} has added any categories, the activity must
3744 * handle ALL of the categories specified.
3745 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003746 * <p>If {@link #getPackage} is non-NULL, only activity components in
3747 * that application package will be considered.
3748 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003749 * <p>If there are no activities that satisfy all of these conditions, a
3750 * null string is returned.
3751 *
3752 * <p>If multiple activities are found to satisfy the intent, the one with
3753 * the highest priority will be used. If there are multiple activities
3754 * with the same priority, the system will either pick the best activity
3755 * based on user preference, or resolve to a system class that will allow
3756 * the user to pick an activity and forward from there.
3757 *
3758 * <p>This method is implemented simply by calling
3759 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
3760 * true.</p>
3761 * <p> This API is called for you as part of starting an activity from an
3762 * intent. You do not normally need to call it yourself.</p>
3763 *
3764 * @param pm The package manager with which to resolve the Intent.
3765 *
3766 * @return Name of the component implementing an activity that can
3767 * display the intent.
3768 *
3769 * @see #setComponent
3770 * @see #getComponent
3771 * @see #resolveActivityInfo
3772 */
3773 public ComponentName resolveActivity(PackageManager pm) {
3774 if (mComponent != null) {
3775 return mComponent;
3776 }
3777
3778 ResolveInfo info = pm.resolveActivity(
3779 this, PackageManager.MATCH_DEFAULT_ONLY);
3780 if (info != null) {
3781 return new ComponentName(
3782 info.activityInfo.applicationInfo.packageName,
3783 info.activityInfo.name);
3784 }
3785
3786 return null;
3787 }
3788
3789 /**
3790 * Resolve the Intent into an {@link ActivityInfo}
3791 * describing the activity that should execute the intent. Resolution
3792 * follows the same rules as described for {@link #resolveActivity}, but
3793 * you get back the completely information about the resolved activity
3794 * instead of just its class name.
3795 *
3796 * @param pm The package manager with which to resolve the Intent.
3797 * @param flags Addition information to retrieve as per
3798 * {@link PackageManager#getActivityInfo(ComponentName, int)
3799 * PackageManager.getActivityInfo()}.
3800 *
3801 * @return PackageManager.ActivityInfo
3802 *
3803 * @see #resolveActivity
3804 */
3805 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
3806 ActivityInfo ai = null;
3807 if (mComponent != null) {
3808 try {
3809 ai = pm.getActivityInfo(mComponent, flags);
3810 } catch (PackageManager.NameNotFoundException e) {
3811 // ignore
3812 }
3813 } else {
3814 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003815 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003816 if (info != null) {
3817 ai = info.activityInfo;
3818 }
3819 }
3820
3821 return ai;
3822 }
3823
3824 /**
3825 * Set the general action to be performed.
3826 *
3827 * @param action An action name, such as ACTION_VIEW. Application-specific
3828 * actions should be prefixed with the vendor's package name.
3829 *
3830 * @return Returns the same Intent object, for chaining multiple calls
3831 * into a single statement.
3832 *
3833 * @see #getAction
3834 */
3835 public Intent setAction(String action) {
3836 mAction = action;
3837 return this;
3838 }
3839
3840 /**
3841 * Set the data this intent is operating on. This method automatically
3842 * clears any type that was previously set by {@link #setType}.
3843 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003844 * <p><em>Note: scheme and host name matching in the Android framework is
3845 * case-sensitive, unlike the formal RFC. As a result,
3846 * you should always ensure that you write your Uri with these elements
3847 * using lower case letters, and normalize any Uris you receive from
3848 * outside of Android to ensure the scheme and host is lower case.</em></p>
3849 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003850 * @param data The URI of the data this intent is now targeting.
3851 *
3852 * @return Returns the same Intent object, for chaining multiple calls
3853 * into a single statement.
3854 *
3855 * @see #getData
3856 * @see #setType
3857 * @see #setDataAndType
3858 */
3859 public Intent setData(Uri data) {
3860 mData = data;
3861 mType = null;
3862 return this;
3863 }
3864
3865 /**
3866 * Set an explicit MIME data type. This is used to create intents that
3867 * only specify a type and not data, for example to indicate the type of
3868 * data to return. This method automatically clears any data that was
3869 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07003870 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003871 * <p><em>Note: MIME type matching in the Android framework is
3872 * case-sensitive, unlike formal RFC MIME types. As a result,
3873 * you should always write your MIME types with lower case letters,
3874 * and any MIME types you receive from outside of Android should be
3875 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003876 *
3877 * @param type The MIME type of the data being handled by this intent.
3878 *
3879 * @return Returns the same Intent object, for chaining multiple calls
3880 * into a single statement.
3881 *
3882 * @see #getType
3883 * @see #setData
3884 * @see #setDataAndType
3885 */
3886 public Intent setType(String type) {
3887 mData = null;
3888 mType = type;
3889 return this;
3890 }
3891
3892 /**
3893 * (Usually optional) Set the data for the intent along with an explicit
3894 * MIME data type. This method should very rarely be used -- it allows you
3895 * to override the MIME type that would ordinarily be inferred from the
3896 * data with your own type given here.
3897 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003898 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
3899 * Android framework is case-sensitive, unlike the formal RFC definitions.
3900 * As a result, you should always write these elements with lower case letters,
3901 * and normalize any MIME types or Uris you receive from
3902 * outside of Android to ensure these elements are lower case before
3903 * supplying them here.</em></p>
3904 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003905 * @param data The URI of the data this intent is now targeting.
3906 * @param type The MIME type of the data being handled by this intent.
3907 *
3908 * @return Returns the same Intent object, for chaining multiple calls
3909 * into a single statement.
3910 *
3911 * @see #setData
3912 * @see #setType
3913 */
3914 public Intent setDataAndType(Uri data, String type) {
3915 mData = data;
3916 mType = type;
3917 return this;
3918 }
3919
3920 /**
3921 * Add a new category to the intent. Categories provide additional detail
3922 * about the action the intent is perform. When resolving an intent, only
3923 * activities that provide <em>all</em> of the requested categories will be
3924 * used.
3925 *
3926 * @param category The desired category. This can be either one of the
3927 * predefined Intent categories, or a custom category in your own
3928 * namespace.
3929 *
3930 * @return Returns the same Intent object, for chaining multiple calls
3931 * into a single statement.
3932 *
3933 * @see #hasCategory
3934 * @see #removeCategory
3935 */
3936 public Intent addCategory(String category) {
3937 if (mCategories == null) {
3938 mCategories = new HashSet<String>();
3939 }
3940 mCategories.add(category);
3941 return this;
3942 }
3943
3944 /**
3945 * Remove an category from an intent.
3946 *
3947 * @param category The category to remove.
3948 *
3949 * @see #addCategory
3950 */
3951 public void removeCategory(String category) {
3952 if (mCategories != null) {
3953 mCategories.remove(category);
3954 if (mCategories.size() == 0) {
3955 mCategories = null;
3956 }
3957 }
3958 }
3959
3960 /**
3961 * Add extended data to the intent. The name must include a package
3962 * prefix, for example the app com.android.contacts would use names
3963 * like "com.android.contacts.ShowAll".
3964 *
3965 * @param name The name of the extra data, with package prefix.
3966 * @param value The boolean data value.
3967 *
3968 * @return Returns the same Intent object, for chaining multiple calls
3969 * into a single statement.
3970 *
3971 * @see #putExtras
3972 * @see #removeExtra
3973 * @see #getBooleanExtra(String, boolean)
3974 */
3975 public Intent putExtra(String name, boolean value) {
3976 if (mExtras == null) {
3977 mExtras = new Bundle();
3978 }
3979 mExtras.putBoolean(name, value);
3980 return this;
3981 }
3982
3983 /**
3984 * Add extended data to the intent. The name must include a package
3985 * prefix, for example the app com.android.contacts would use names
3986 * like "com.android.contacts.ShowAll".
3987 *
3988 * @param name The name of the extra data, with package prefix.
3989 * @param value The byte data value.
3990 *
3991 * @return Returns the same Intent object, for chaining multiple calls
3992 * into a single statement.
3993 *
3994 * @see #putExtras
3995 * @see #removeExtra
3996 * @see #getByteExtra(String, byte)
3997 */
3998 public Intent putExtra(String name, byte value) {
3999 if (mExtras == null) {
4000 mExtras = new Bundle();
4001 }
4002 mExtras.putByte(name, value);
4003 return this;
4004 }
4005
4006 /**
4007 * Add extended data to the intent. The name must include a package
4008 * prefix, for example the app com.android.contacts would use names
4009 * like "com.android.contacts.ShowAll".
4010 *
4011 * @param name The name of the extra data, with package prefix.
4012 * @param value The char data value.
4013 *
4014 * @return Returns the same Intent object, for chaining multiple calls
4015 * into a single statement.
4016 *
4017 * @see #putExtras
4018 * @see #removeExtra
4019 * @see #getCharExtra(String, char)
4020 */
4021 public Intent putExtra(String name, char value) {
4022 if (mExtras == null) {
4023 mExtras = new Bundle();
4024 }
4025 mExtras.putChar(name, value);
4026 return this;
4027 }
4028
4029 /**
4030 * Add extended data to the intent. The name must include a package
4031 * prefix, for example the app com.android.contacts would use names
4032 * like "com.android.contacts.ShowAll".
4033 *
4034 * @param name The name of the extra data, with package prefix.
4035 * @param value The short data value.
4036 *
4037 * @return Returns the same Intent object, for chaining multiple calls
4038 * into a single statement.
4039 *
4040 * @see #putExtras
4041 * @see #removeExtra
4042 * @see #getShortExtra(String, short)
4043 */
4044 public Intent putExtra(String name, short value) {
4045 if (mExtras == null) {
4046 mExtras = new Bundle();
4047 }
4048 mExtras.putShort(name, value);
4049 return this;
4050 }
4051
4052 /**
4053 * Add extended data to the intent. The name must include a package
4054 * prefix, for example the app com.android.contacts would use names
4055 * like "com.android.contacts.ShowAll".
4056 *
4057 * @param name The name of the extra data, with package prefix.
4058 * @param value The integer data value.
4059 *
4060 * @return Returns the same Intent object, for chaining multiple calls
4061 * into a single statement.
4062 *
4063 * @see #putExtras
4064 * @see #removeExtra
4065 * @see #getIntExtra(String, int)
4066 */
4067 public Intent putExtra(String name, int value) {
4068 if (mExtras == null) {
4069 mExtras = new Bundle();
4070 }
4071 mExtras.putInt(name, value);
4072 return this;
4073 }
4074
4075 /**
4076 * Add extended data to the intent. The name must include a package
4077 * prefix, for example the app com.android.contacts would use names
4078 * like "com.android.contacts.ShowAll".
4079 *
4080 * @param name The name of the extra data, with package prefix.
4081 * @param value The long data value.
4082 *
4083 * @return Returns the same Intent object, for chaining multiple calls
4084 * into a single statement.
4085 *
4086 * @see #putExtras
4087 * @see #removeExtra
4088 * @see #getLongExtra(String, long)
4089 */
4090 public Intent putExtra(String name, long value) {
4091 if (mExtras == null) {
4092 mExtras = new Bundle();
4093 }
4094 mExtras.putLong(name, value);
4095 return this;
4096 }
4097
4098 /**
4099 * Add extended data to the intent. The name must include a package
4100 * prefix, for example the app com.android.contacts would use names
4101 * like "com.android.contacts.ShowAll".
4102 *
4103 * @param name The name of the extra data, with package prefix.
4104 * @param value The float data value.
4105 *
4106 * @return Returns the same Intent object, for chaining multiple calls
4107 * into a single statement.
4108 *
4109 * @see #putExtras
4110 * @see #removeExtra
4111 * @see #getFloatExtra(String, float)
4112 */
4113 public Intent putExtra(String name, float value) {
4114 if (mExtras == null) {
4115 mExtras = new Bundle();
4116 }
4117 mExtras.putFloat(name, value);
4118 return this;
4119 }
4120
4121 /**
4122 * Add extended data to the intent. The name must include a package
4123 * prefix, for example the app com.android.contacts would use names
4124 * like "com.android.contacts.ShowAll".
4125 *
4126 * @param name The name of the extra data, with package prefix.
4127 * @param value The double data value.
4128 *
4129 * @return Returns the same Intent object, for chaining multiple calls
4130 * into a single statement.
4131 *
4132 * @see #putExtras
4133 * @see #removeExtra
4134 * @see #getDoubleExtra(String, double)
4135 */
4136 public Intent putExtra(String name, double value) {
4137 if (mExtras == null) {
4138 mExtras = new Bundle();
4139 }
4140 mExtras.putDouble(name, value);
4141 return this;
4142 }
4143
4144 /**
4145 * Add extended data to the intent. The name must include a package
4146 * prefix, for example the app com.android.contacts would use names
4147 * like "com.android.contacts.ShowAll".
4148 *
4149 * @param name The name of the extra data, with package prefix.
4150 * @param value The String data value.
4151 *
4152 * @return Returns the same Intent object, for chaining multiple calls
4153 * into a single statement.
4154 *
4155 * @see #putExtras
4156 * @see #removeExtra
4157 * @see #getStringExtra(String)
4158 */
4159 public Intent putExtra(String name, String value) {
4160 if (mExtras == null) {
4161 mExtras = new Bundle();
4162 }
4163 mExtras.putString(name, value);
4164 return this;
4165 }
4166
4167 /**
4168 * Add extended data to the intent. The name must include a package
4169 * prefix, for example the app com.android.contacts would use names
4170 * like "com.android.contacts.ShowAll".
4171 *
4172 * @param name The name of the extra data, with package prefix.
4173 * @param value The CharSequence data value.
4174 *
4175 * @return Returns the same Intent object, for chaining multiple calls
4176 * into a single statement.
4177 *
4178 * @see #putExtras
4179 * @see #removeExtra
4180 * @see #getCharSequenceExtra(String)
4181 */
4182 public Intent putExtra(String name, CharSequence value) {
4183 if (mExtras == null) {
4184 mExtras = new Bundle();
4185 }
4186 mExtras.putCharSequence(name, value);
4187 return this;
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 Parcelable 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 #getParcelableExtra(String)
4204 */
4205 public Intent putExtra(String name, Parcelable value) {
4206 if (mExtras == null) {
4207 mExtras = new Bundle();
4208 }
4209 mExtras.putParcelable(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 Parcelable[] 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 #getParcelableArrayExtra(String)
4227 */
4228 public Intent putExtra(String name, Parcelable[] value) {
4229 if (mExtras == null) {
4230 mExtras = new Bundle();
4231 }
4232 mExtras.putParcelableArray(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 ArrayList<Parcelable> 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 #getParcelableArrayListExtra(String)
4250 */
4251 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4252 if (mExtras == null) {
4253 mExtras = new Bundle();
4254 }
4255 mExtras.putParcelableArrayList(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 ArrayList<Integer> 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 #getIntegerArrayListExtra(String)
4273 */
4274 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4275 if (mExtras == null) {
4276 mExtras = new Bundle();
4277 }
4278 mExtras.putIntegerArrayList(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 ArrayList<String> 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 #getStringArrayListExtra(String)
4296 */
4297 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4298 if (mExtras == null) {
4299 mExtras = new Bundle();
4300 }
4301 mExtras.putStringArrayList(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 Serializable 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 #getSerializableExtra(String)
4319 */
4320 public Intent putExtra(String name, Serializable value) {
4321 if (mExtras == null) {
4322 mExtras = new Bundle();
4323 }
4324 mExtras.putSerializable(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 boolean array 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 #getBooleanArrayExtra(String)
4342 */
4343 public Intent putExtra(String name, boolean[] value) {
4344 if (mExtras == null) {
4345 mExtras = new Bundle();
4346 }
4347 mExtras.putBooleanArray(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 byte array 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 #getByteArrayExtra(String)
4365 */
4366 public Intent putExtra(String name, byte[] value) {
4367 if (mExtras == null) {
4368 mExtras = new Bundle();
4369 }
4370 mExtras.putByteArray(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 short array 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 #getShortArrayExtra(String)
4388 */
4389 public Intent putExtra(String name, short[] value) {
4390 if (mExtras == null) {
4391 mExtras = new Bundle();
4392 }
4393 mExtras.putShortArray(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 char array 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 #getCharArrayExtra(String)
4411 */
4412 public Intent putExtra(String name, char[] value) {
4413 if (mExtras == null) {
4414 mExtras = new Bundle();
4415 }
4416 mExtras.putCharArray(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 int array 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 #getIntArrayExtra(String)
4434 */
4435 public Intent putExtra(String name, int[] value) {
4436 if (mExtras == null) {
4437 mExtras = new Bundle();
4438 }
4439 mExtras.putIntArray(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 byte array 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 #getLongArrayExtra(String)
4457 */
4458 public Intent putExtra(String name, long[] value) {
4459 if (mExtras == null) {
4460 mExtras = new Bundle();
4461 }
4462 mExtras.putLongArray(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 float array 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 #getFloatArrayExtra(String)
4480 */
4481 public Intent putExtra(String name, float[] value) {
4482 if (mExtras == null) {
4483 mExtras = new Bundle();
4484 }
4485 mExtras.putFloatArray(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 double array 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 #getDoubleArrayExtra(String)
4503 */
4504 public Intent putExtra(String name, double[] value) {
4505 if (mExtras == null) {
4506 mExtras = new Bundle();
4507 }
4508 mExtras.putDoubleArray(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 String array 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 #getStringArrayExtra(String)
4526 */
4527 public Intent putExtra(String name, String[] value) {
4528 if (mExtras == null) {
4529 mExtras = new Bundle();
4530 }
4531 mExtras.putStringArray(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.
4541 * @param value The Bundle 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 #getBundleExtra(String)
4549 */
4550 public Intent putExtra(String name, Bundle value) {
4551 if (mExtras == null) {
4552 mExtras = new Bundle();
4553 }
4554 mExtras.putBundle(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.
4564 * @param value The IBinder 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 #getIBinderExtra(String)
4572 *
4573 * @deprecated
4574 * @hide
4575 */
4576 @Deprecated
4577 public Intent putExtra(String name, IBinder value) {
4578 if (mExtras == null) {
4579 mExtras = new Bundle();
4580 }
4581 mExtras.putIBinder(name, value);
4582 return this;
4583 }
4584
4585 /**
4586 * Copy all extras in 'src' in to this intent.
4587 *
4588 * @param src Contains the extras to copy.
4589 *
4590 * @see #putExtra
4591 */
4592 public Intent putExtras(Intent src) {
4593 if (src.mExtras != null) {
4594 if (mExtras == null) {
4595 mExtras = new Bundle(src.mExtras);
4596 } else {
4597 mExtras.putAll(src.mExtras);
4598 }
4599 }
4600 return this;
4601 }
4602
4603 /**
4604 * Add a set of extended data to the intent. The keys must include a package
4605 * prefix, for example the app com.android.contacts would use names
4606 * like "com.android.contacts.ShowAll".
4607 *
4608 * @param extras The Bundle of extras to add to this intent.
4609 *
4610 * @see #putExtra
4611 * @see #removeExtra
4612 */
4613 public Intent putExtras(Bundle extras) {
4614 if (mExtras == null) {
4615 mExtras = new Bundle();
4616 }
4617 mExtras.putAll(extras);
4618 return this;
4619 }
4620
4621 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004622 * Completely replace the extras in the Intent with the extras in the
4623 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07004624 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004625 * @param src The exact extras contained in this Intent are copied
4626 * into the target intent, replacing any that were previously there.
4627 */
4628 public Intent replaceExtras(Intent src) {
4629 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
4630 return this;
4631 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004632
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004633 /**
4634 * Completely replace the extras in the Intent with the given Bundle of
4635 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07004636 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004637 * @param extras The new set of extras in the Intent, or null to erase
4638 * all extras.
4639 */
4640 public Intent replaceExtras(Bundle extras) {
4641 mExtras = extras != null ? new Bundle(extras) : null;
4642 return this;
4643 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004644
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004645 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004646 * Remove extended data from the intent.
4647 *
4648 * @see #putExtra
4649 */
4650 public void removeExtra(String name) {
4651 if (mExtras != null) {
4652 mExtras.remove(name);
4653 if (mExtras.size() == 0) {
4654 mExtras = null;
4655 }
4656 }
4657 }
4658
4659 /**
4660 * Set special flags controlling how this intent is handled. Most values
4661 * here depend on the type of component being executed by the Intent,
4662 * specifically the FLAG_ACTIVITY_* flags are all for use with
4663 * {@link Context#startActivity Context.startActivity()} and the
4664 * FLAG_RECEIVER_* flags are all for use with
4665 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
4666 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004667 * <p>See the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
4668 * Activities and Tasks</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004669 * the behavior of your application.
4670 *
4671 * @param flags The desired flags.
4672 *
4673 * @return Returns the same Intent object, for chaining multiple calls
4674 * into a single statement.
4675 *
4676 * @see #getFlags
4677 * @see #addFlags
4678 *
4679 * @see #FLAG_GRANT_READ_URI_PERMISSION
4680 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
4681 * @see #FLAG_DEBUG_LOG_RESOLUTION
4682 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004683 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004684 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004685 * @see #FLAG_ACTIVITY_CLEAR_TOP
4686 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
4687 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004688 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004689 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4690 * @see #FLAG_ACTIVITY_NEW_TASK
4691 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004692 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004693 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
4694 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004695 * @see #FLAG_ACTIVITY_SINGLE_TOP
4696 * @see #FLAG_RECEIVER_REGISTERED_ONLY
4697 */
4698 public Intent setFlags(int flags) {
4699 mFlags = flags;
4700 return this;
4701 }
4702
4703 /**
4704 * Add additional flags to the intent (or with existing flags
4705 * value).
4706 *
4707 * @param flags The new flags to set.
4708 *
4709 * @return Returns the same Intent object, for chaining multiple calls
4710 * into a single statement.
4711 *
4712 * @see #setFlags
4713 */
4714 public Intent addFlags(int flags) {
4715 mFlags |= flags;
4716 return this;
4717 }
4718
4719 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004720 * (Usually optional) Set an explicit application package name that limits
4721 * the components this Intent will resolve to. If left to the default
4722 * value of null, all components in all applications will considered.
4723 * If non-null, the Intent can only match the components in the given
4724 * application package.
4725 *
4726 * @param packageName The name of the application package to handle the
4727 * intent, or null to allow any application package.
4728 *
4729 * @return Returns the same Intent object, for chaining multiple calls
4730 * into a single statement.
4731 *
4732 * @see #getPackage
4733 * @see #resolveActivity
4734 */
4735 public Intent setPackage(String packageName) {
4736 mPackage = packageName;
4737 return this;
4738 }
4739
4740 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 * (Usually optional) Explicitly set the component to handle the intent.
4742 * If left with the default value of null, the system will determine the
4743 * appropriate class to use based on the other fields (action, data,
4744 * type, categories) in the Intent. If this class is defined, the
4745 * specified class will always be used regardless of the other fields. You
4746 * should only set this value when you know you absolutely want a specific
4747 * class to be used; otherwise it is better to let the system find the
4748 * appropriate class so that you will respect the installed applications
4749 * and user preferences.
4750 *
4751 * @param component The name of the application component to handle the
4752 * intent, or null to let the system find one for you.
4753 *
4754 * @return Returns the same Intent object, for chaining multiple calls
4755 * into a single statement.
4756 *
4757 * @see #setClass
4758 * @see #setClassName(Context, String)
4759 * @see #setClassName(String, String)
4760 * @see #getComponent
4761 * @see #resolveActivity
4762 */
4763 public Intent setComponent(ComponentName component) {
4764 mComponent = component;
4765 return this;
4766 }
4767
4768 /**
4769 * Convenience for calling {@link #setComponent} with an
4770 * explicit class name.
4771 *
4772 * @param packageContext A Context of the application package implementing
4773 * this class.
4774 * @param className The name of a class inside of the application package
4775 * that will be used as the component for this Intent.
4776 *
4777 * @return Returns the same Intent object, for chaining multiple calls
4778 * into a single statement.
4779 *
4780 * @see #setComponent
4781 * @see #setClass
4782 */
4783 public Intent setClassName(Context packageContext, String className) {
4784 mComponent = new ComponentName(packageContext, className);
4785 return this;
4786 }
4787
4788 /**
4789 * Convenience for calling {@link #setComponent} with an
4790 * explicit application package name and class name.
4791 *
4792 * @param packageName The name of the package implementing the desired
4793 * component.
4794 * @param className The name of a class inside of the application package
4795 * that will be used as the component for this Intent.
4796 *
4797 * @return Returns the same Intent object, for chaining multiple calls
4798 * into a single statement.
4799 *
4800 * @see #setComponent
4801 * @see #setClass
4802 */
4803 public Intent setClassName(String packageName, String className) {
4804 mComponent = new ComponentName(packageName, className);
4805 return this;
4806 }
4807
4808 /**
4809 * Convenience for calling {@link #setComponent(ComponentName)} with the
4810 * name returned by a {@link Class} object.
4811 *
4812 * @param packageContext A Context of the application package implementing
4813 * this class.
4814 * @param cls The class name to set, equivalent to
4815 * <code>setClassName(context, cls.getName())</code>.
4816 *
4817 * @return Returns the same Intent object, for chaining multiple calls
4818 * into a single statement.
4819 *
4820 * @see #setComponent
4821 */
4822 public Intent setClass(Context packageContext, Class<?> cls) {
4823 mComponent = new ComponentName(packageContext, cls);
4824 return this;
4825 }
4826
4827 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004828 * Set the bounds of the sender of this intent, in screen coordinates. This can be
4829 * used as a hint to the receiver for animations and the like. Null means that there
4830 * is no source bounds.
4831 */
4832 public void setSourceBounds(Rect r) {
4833 if (r != null) {
4834 mSourceBounds = new Rect(r);
4835 } else {
4836 r = null;
4837 }
4838 }
4839
4840 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004841 * Use with {@link #fillIn} to allow the current action value to be
4842 * overwritten, even if it is already set.
4843 */
4844 public static final int FILL_IN_ACTION = 1<<0;
4845
4846 /**
4847 * Use with {@link #fillIn} to allow the current data or type value
4848 * overwritten, even if it is already set.
4849 */
4850 public static final int FILL_IN_DATA = 1<<1;
4851
4852 /**
4853 * Use with {@link #fillIn} to allow the current categories to be
4854 * overwritten, even if they are already set.
4855 */
4856 public static final int FILL_IN_CATEGORIES = 1<<2;
4857
4858 /**
4859 * Use with {@link #fillIn} to allow the current component value to be
4860 * overwritten, even if it is already set.
4861 */
4862 public static final int FILL_IN_COMPONENT = 1<<3;
4863
4864 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004865 * Use with {@link #fillIn} to allow the current package value to be
4866 * overwritten, even if it is already set.
4867 */
4868 public static final int FILL_IN_PACKAGE = 1<<4;
4869
4870 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004871 * Use with {@link #fillIn} to allow the current package value to be
4872 * overwritten, even if it is already set.
4873 */
4874 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
4875
4876 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004877 * Copy the contents of <var>other</var> in to this object, but only
4878 * where fields are not defined by this object. For purposes of a field
4879 * being defined, the following pieces of data in the Intent are
4880 * considered to be separate fields:
4881 *
4882 * <ul>
4883 * <li> action, as set by {@link #setAction}.
4884 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
4885 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
4886 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004887 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004888 * <li> component, as set by {@link #setComponent(ComponentName)} or
4889 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004890 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004891 * <li> each top-level name in the associated extras.
4892 * </ul>
4893 *
4894 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004895 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4896 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004897 * corresponding field will not be replaced if it is already set.
4898 *
Brett Chabot3e391752009-07-21 16:07:23 -07004899 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
4900 * specified.
4901 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004902 * <p>For example, consider Intent A with {data="foo", categories="bar"}
4903 * and Intent B with {action="gotit", data-type="some/thing",
4904 * categories="one","two"}.
4905 *
4906 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
4907 * containing: {action="gotit", data-type="some/thing",
4908 * categories="bar"}.
4909 *
4910 * @param other Another Intent whose values are to be used to fill in
4911 * the current one.
4912 * @param flags Options to control which fields can be filled in.
4913 *
4914 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004915 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4916 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004917 */
4918 public int fillIn(Intent other, int flags) {
4919 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004920 if (other.mAction != null
4921 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004922 mAction = other.mAction;
4923 changes |= FILL_IN_ACTION;
4924 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004925 if ((other.mData != null || other.mType != null)
4926 && ((mData == null && mType == null)
4927 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004928 mData = other.mData;
4929 mType = other.mType;
4930 changes |= FILL_IN_DATA;
4931 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004932 if (other.mCategories != null
4933 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004934 if (other.mCategories != null) {
4935 mCategories = new HashSet<String>(other.mCategories);
4936 }
4937 changes |= FILL_IN_CATEGORIES;
4938 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004939 if (other.mPackage != null
4940 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
4941 mPackage = other.mPackage;
4942 changes |= FILL_IN_PACKAGE;
4943 }
4944 // Component is special: it can -only- be set if explicitly allowed,
4945 // since otherwise the sender could force the intent somewhere the
4946 // originator didn't intend.
4947 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004948 mComponent = other.mComponent;
4949 changes |= FILL_IN_COMPONENT;
4950 }
4951 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004952 if (other.mSourceBounds != null
4953 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
4954 mSourceBounds = new Rect(other.mSourceBounds);
4955 changes |= FILL_IN_SOURCE_BOUNDS;
4956 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004957 if (mExtras == null) {
4958 if (other.mExtras != null) {
4959 mExtras = new Bundle(other.mExtras);
4960 }
4961 } else if (other.mExtras != null) {
4962 try {
4963 Bundle newb = new Bundle(other.mExtras);
4964 newb.putAll(mExtras);
4965 mExtras = newb;
4966 } catch (RuntimeException e) {
4967 // Modifying the extras can cause us to unparcel the contents
4968 // of the bundle, and if we do this in the system process that
4969 // may fail. We really should handle this (i.e., the Bundle
4970 // impl shouldn't be on top of a plain map), but for now just
4971 // ignore it and keep the original contents. :(
4972 Log.w("Intent", "Failure filling in extras", e);
4973 }
4974 }
4975 return changes;
4976 }
4977
4978 /**
4979 * Wrapper class holding an Intent and implementing comparisons on it for
4980 * the purpose of filtering. The class implements its
4981 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
4982 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
4983 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
4984 * on the wrapped Intent.
4985 */
4986 public static final class FilterComparison {
4987 private final Intent mIntent;
4988 private final int mHashCode;
4989
4990 public FilterComparison(Intent intent) {
4991 mIntent = intent;
4992 mHashCode = intent.filterHashCode();
4993 }
4994
4995 /**
4996 * Return the Intent that this FilterComparison represents.
4997 * @return Returns the Intent held by the FilterComparison. Do
4998 * not modify!
4999 */
5000 public Intent getIntent() {
5001 return mIntent;
5002 }
5003
5004 @Override
5005 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005006 if (obj instanceof FilterComparison) {
5007 Intent other = ((FilterComparison)obj).mIntent;
5008 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005009 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005010 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005011 }
5012
5013 @Override
5014 public int hashCode() {
5015 return mHashCode;
5016 }
5017 }
5018
5019 /**
5020 * Determine if two intents are the same for the purposes of intent
5021 * resolution (filtering). That is, if their action, data, type,
5022 * class, and categories are the same. This does <em>not</em> compare
5023 * any extra data included in the intents.
5024 *
5025 * @param other The other Intent to compare against.
5026 *
5027 * @return Returns true if action, data, type, class, and categories
5028 * are the same.
5029 */
5030 public boolean filterEquals(Intent other) {
5031 if (other == null) {
5032 return false;
5033 }
5034 if (mAction != other.mAction) {
5035 if (mAction != null) {
5036 if (!mAction.equals(other.mAction)) {
5037 return false;
5038 }
5039 } else {
5040 if (!other.mAction.equals(mAction)) {
5041 return false;
5042 }
5043 }
5044 }
5045 if (mData != other.mData) {
5046 if (mData != null) {
5047 if (!mData.equals(other.mData)) {
5048 return false;
5049 }
5050 } else {
5051 if (!other.mData.equals(mData)) {
5052 return false;
5053 }
5054 }
5055 }
5056 if (mType != other.mType) {
5057 if (mType != null) {
5058 if (!mType.equals(other.mType)) {
5059 return false;
5060 }
5061 } else {
5062 if (!other.mType.equals(mType)) {
5063 return false;
5064 }
5065 }
5066 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005067 if (mPackage != other.mPackage) {
5068 if (mPackage != null) {
5069 if (!mPackage.equals(other.mPackage)) {
5070 return false;
5071 }
5072 } else {
5073 if (!other.mPackage.equals(mPackage)) {
5074 return false;
5075 }
5076 }
5077 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005078 if (mComponent != other.mComponent) {
5079 if (mComponent != null) {
5080 if (!mComponent.equals(other.mComponent)) {
5081 return false;
5082 }
5083 } else {
5084 if (!other.mComponent.equals(mComponent)) {
5085 return false;
5086 }
5087 }
5088 }
5089 if (mCategories != other.mCategories) {
5090 if (mCategories != null) {
5091 if (!mCategories.equals(other.mCategories)) {
5092 return false;
5093 }
5094 } else {
5095 if (!other.mCategories.equals(mCategories)) {
5096 return false;
5097 }
5098 }
5099 }
5100
5101 return true;
5102 }
5103
5104 /**
5105 * Generate hash code that matches semantics of filterEquals().
5106 *
5107 * @return Returns the hash value of the action, data, type, class, and
5108 * categories.
5109 *
5110 * @see #filterEquals
5111 */
5112 public int filterHashCode() {
5113 int code = 0;
5114 if (mAction != null) {
5115 code += mAction.hashCode();
5116 }
5117 if (mData != null) {
5118 code += mData.hashCode();
5119 }
5120 if (mType != null) {
5121 code += mType.hashCode();
5122 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005123 if (mPackage != null) {
5124 code += mPackage.hashCode();
5125 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005126 if (mComponent != null) {
5127 code += mComponent.hashCode();
5128 }
5129 if (mCategories != null) {
5130 code += mCategories.hashCode();
5131 }
5132 return code;
5133 }
5134
5135 @Override
5136 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005137 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005138
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005139 b.append("Intent { ");
5140 toShortString(b, true, true);
5141 b.append(" }");
5142
5143 return b.toString();
5144 }
5145
5146 /** @hide */
5147 public String toShortString(boolean comp, boolean extras) {
5148 StringBuilder b = new StringBuilder(128);
5149 toShortString(b, comp, extras);
5150 return b.toString();
5151 }
Romain Guy4969af72009-06-17 10:53:19 -07005152
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005153 /** @hide */
5154 public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5155 boolean first = true;
5156 if (mAction != null) {
5157 b.append("act=").append(mAction);
5158 first = false;
5159 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005160 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005161 if (!first) {
5162 b.append(' ');
5163 }
5164 first = false;
5165 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005166 Iterator<String> i = mCategories.iterator();
5167 boolean didone = false;
5168 while (i.hasNext()) {
5169 if (didone) b.append(",");
5170 didone = true;
5171 b.append(i.next());
5172 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005173 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005174 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005175 if (mData != null) {
5176 if (!first) {
5177 b.append(' ');
5178 }
5179 first = false;
5180 b.append("dat=").append(mData);
5181 }
5182 if (mType != null) {
5183 if (!first) {
5184 b.append(' ');
5185 }
5186 first = false;
5187 b.append("typ=").append(mType);
5188 }
5189 if (mFlags != 0) {
5190 if (!first) {
5191 b.append(' ');
5192 }
5193 first = false;
5194 b.append("flg=0x").append(Integer.toHexString(mFlags));
5195 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005196 if (mPackage != null) {
5197 if (!first) {
5198 b.append(' ');
5199 }
5200 first = false;
5201 b.append("pkg=").append(mPackage);
5202 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005203 if (comp && mComponent != null) {
5204 if (!first) {
5205 b.append(' ');
5206 }
5207 first = false;
5208 b.append("cmp=").append(mComponent.flattenToShortString());
5209 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005210 if (mSourceBounds != null) {
5211 if (!first) {
5212 b.append(' ');
5213 }
5214 first = false;
5215 b.append("bnds=").append(mSourceBounds.toShortString());
5216 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005217 if (extras && mExtras != null) {
5218 if (!first) {
5219 b.append(' ');
5220 }
5221 first = false;
5222 b.append("(has extras)");
5223 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005224 }
5225
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005226 /**
5227 * Call {@link #toUri} with 0 flags.
5228 * @deprecated Use {@link #toUri} instead.
5229 */
5230 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005231 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005232 return toUri(0);
5233 }
5234
5235 /**
5236 * Convert this Intent into a String holding a URI representation of it.
5237 * The returned URI string has been properly URI encoded, so it can be
5238 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5239 * Intent's data as the base URI, with an additional fragment describing
5240 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005241 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005242 * <p>You can convert the returned string back to an Intent with
5243 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005244 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005245 * @param flags Additional operating flags. Either 0 or
5246 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005247 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005248 * @return Returns a URI encoding URI string describing the entire contents
5249 * of the Intent.
5250 */
5251 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005252 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005253 String scheme = null;
5254 if (mData != null) {
5255 String data = mData.toString();
5256 if ((flags&URI_INTENT_SCHEME) != 0) {
5257 final int N = data.length();
5258 for (int i=0; i<N; i++) {
5259 char c = data.charAt(i);
5260 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5261 || c == '.' || c == '-') {
5262 continue;
5263 }
5264 if (c == ':' && i > 0) {
5265 // Valid scheme.
5266 scheme = data.substring(0, i);
5267 uri.append("intent:");
5268 data = data.substring(i+1);
5269 break;
5270 }
Tom Taylord4a47292009-12-21 13:59:18 -08005271
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005272 // No scheme.
5273 break;
5274 }
5275 }
5276 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005277
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005278 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5279 uri.append("intent:");
5280 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005281
5282 uri.append("#Intent;");
5283
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005284 if (scheme != null) {
5285 uri.append("scheme=").append(scheme).append(';');
5286 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005287 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005288 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005289 }
5290 if (mCategories != null) {
5291 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005292 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005293 }
5294 }
5295 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005296 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 }
5298 if (mFlags != 0) {
5299 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5300 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005301 if (mPackage != null) {
5302 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5303 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005304 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005305 uri.append("component=").append(Uri.encode(
5306 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005307 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005308 if (mSourceBounds != null) {
5309 uri.append("sourceBounds=")
5310 .append(Uri.encode(mSourceBounds.flattenToString()))
5311 .append(';');
5312 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005313 if (mExtras != null) {
5314 for (String key : mExtras.keySet()) {
5315 final Object value = mExtras.get(key);
5316 char entryType =
5317 value instanceof String ? 'S' :
5318 value instanceof Boolean ? 'B' :
5319 value instanceof Byte ? 'b' :
5320 value instanceof Character ? 'c' :
5321 value instanceof Double ? 'd' :
5322 value instanceof Float ? 'f' :
5323 value instanceof Integer ? 'i' :
5324 value instanceof Long ? 'l' :
5325 value instanceof Short ? 's' :
5326 '\0';
5327
5328 if (entryType != '\0') {
5329 uri.append(entryType);
5330 uri.append('.');
5331 uri.append(Uri.encode(key));
5332 uri.append('=');
5333 uri.append(Uri.encode(value.toString()));
5334 uri.append(';');
5335 }
5336 }
5337 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005338
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005339 uri.append("end");
5340
5341 return uri.toString();
5342 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005343
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005344 public int describeContents() {
5345 return (mExtras != null) ? mExtras.describeContents() : 0;
5346 }
5347
5348 public void writeToParcel(Parcel out, int flags) {
5349 out.writeString(mAction);
5350 Uri.writeToParcel(out, mData);
5351 out.writeString(mType);
5352 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005353 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005354 ComponentName.writeToParcel(mComponent, out);
5355
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005356 if (mSourceBounds != null) {
5357 out.writeInt(1);
5358 mSourceBounds.writeToParcel(out, flags);
5359 } else {
5360 out.writeInt(0);
5361 }
5362
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005363 if (mCategories != null) {
5364 out.writeInt(mCategories.size());
5365 for (String category : mCategories) {
5366 out.writeString(category);
5367 }
5368 } else {
5369 out.writeInt(0);
5370 }
5371
5372 out.writeBundle(mExtras);
5373 }
5374
5375 public static final Parcelable.Creator<Intent> CREATOR
5376 = new Parcelable.Creator<Intent>() {
5377 public Intent createFromParcel(Parcel in) {
5378 return new Intent(in);
5379 }
5380 public Intent[] newArray(int size) {
5381 return new Intent[size];
5382 }
5383 };
5384
Dianne Hackborneb034652009-09-07 00:49:58 -07005385 /** @hide */
5386 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005387 readFromParcel(in);
5388 }
5389
5390 public void readFromParcel(Parcel in) {
5391 mAction = in.readString();
5392 mData = Uri.CREATOR.createFromParcel(in);
5393 mType = in.readString();
5394 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005395 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005396 mComponent = ComponentName.readFromParcel(in);
5397
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005398 if (in.readInt() != 0) {
5399 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5400 }
5401
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005402 int N = in.readInt();
5403 if (N > 0) {
5404 mCategories = new HashSet<String>();
5405 int i;
5406 for (i=0; i<N; i++) {
5407 mCategories.add(in.readString());
5408 }
5409 } else {
5410 mCategories = null;
5411 }
5412
5413 mExtras = in.readBundle();
5414 }
5415
5416 /**
5417 * Parses the "intent" element (and its children) from XML and instantiates
5418 * an Intent object. The given XML parser should be located at the tag
5419 * where parsing should start (often named "intent"), from which the
5420 * basic action, data, type, and package and class name will be
5421 * retrieved. The function will then parse in to any child elements,
5422 * looking for <category android:name="xxx"> tags to add categories and
5423 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5424 * to the intent.
5425 *
5426 * @param resources The Resources to use when inflating resources.
5427 * @param parser The XML parser pointing at an "intent" tag.
5428 * @param attrs The AttributeSet interface for retrieving extended
5429 * attribute data at the current <var>parser</var> location.
5430 * @return An Intent object matching the XML data.
5431 * @throws XmlPullParserException If there was an XML parsing error.
5432 * @throws IOException If there was an I/O error.
5433 */
5434 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5435 throws XmlPullParserException, IOException {
5436 Intent intent = new Intent();
5437
5438 TypedArray sa = resources.obtainAttributes(attrs,
5439 com.android.internal.R.styleable.Intent);
5440
5441 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5442
5443 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5444 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5445 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5446
5447 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5448 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5449 if (packageName != null && className != null) {
5450 intent.setComponent(new ComponentName(packageName, className));
5451 }
5452
5453 sa.recycle();
5454
5455 int outerDepth = parser.getDepth();
5456 int type;
5457 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5458 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5459 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5460 continue;
5461 }
5462
5463 String nodeName = parser.getName();
5464 if (nodeName.equals("category")) {
5465 sa = resources.obtainAttributes(attrs,
5466 com.android.internal.R.styleable.IntentCategory);
5467 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5468 sa.recycle();
5469
5470 if (cat != null) {
5471 intent.addCategory(cat);
5472 }
5473 XmlUtils.skipCurrentTag(parser);
5474
5475 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005476 if (intent.mExtras == null) {
5477 intent.mExtras = new Bundle();
5478 }
5479 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5480 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005481
5482 } else {
5483 XmlUtils.skipCurrentTag(parser);
5484 }
5485 }
5486
5487 return intent;
5488 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005489}