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