blob: 2f9627a4403d64a9135d41acbb925a5411b55d09 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import org.xmlpull.v1.XmlPullParser;
20import org.xmlpull.v1.XmlPullParserException;
21
22import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
24import android.content.pm.ActivityInfo;
25import android.content.pm.PackageManager;
26import android.content.pm.ResolveInfo;
27import android.content.res.Resources;
28import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080029import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.net.Uri;
31import android.os.Bundle;
32import android.os.IBinder;
33import android.os.Parcel;
34import android.os.Parcelable;
35import android.util.AttributeSet;
36import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080037
38import com.android.internal.util.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039
40import java.io.IOException;
41import java.io.Serializable;
42import java.net.URISyntaxException;
43import java.util.ArrayList;
44import java.util.HashSet;
45import java.util.Iterator;
46import java.util.Set;
47
48/**
49 * An intent is an abstract description of an operation to be performed. It
50 * can be used with {@link Context#startActivity(Intent) startActivity} to
51 * launch an {@link android.app.Activity},
52 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
53 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
54 * and {@link android.content.Context#startService} or
55 * {@link android.content.Context#bindService} to communicate with a
56 * background {@link android.app.Service}.
57 *
58 * <p>An Intent provides a facility for performing late runtime binding between
59 * the code in different applications. Its most significant use is in the
60 * launching of activities, where it can be thought of as the glue between
61 * activities. It is
62 * basically a passive data structure holding an abstract description of an
63 * action to be performed. The primary pieces of information in an intent
64 * are:</p>
65 *
66 * <ul>
67 * <li> <p><b>action</b> -- The general action to be performed, such as
68 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
69 * etc.</p>
70 * </li>
71 * <li> <p><b>data</b> -- The data to operate on, such as a person record
72 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
73 * </li>
74 * </ul>
75 *
76 *
77 * <p>Some examples of action/data pairs are:</p>
78 *
79 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070080 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070081 * information about the person whose identifier is "1".</p>
82 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070083 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070084 * the phone dialer with the person filled in.</p>
85 * </li>
86 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
87 * the phone dialer with the given number filled in. Note how the
88 * VIEW action does what what is considered the most reasonable thing for
89 * a particular URI.</p>
90 * </li>
91 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
92 * the phone dialer with the given number filled in.</p>
93 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070094 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 * information about the person whose identifier is "1".</p>
96 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070097 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 * a list of people, which the user can browse through. This example is a
99 * typical top-level entry into the Contacts application, showing you the
100 * list of people. Selecting a particular person to view would result in a
101 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
102 * being used to start an activity to display that person.</p>
103 * </li>
104 * </ul>
105 *
106 * <p>In addition to these primary attributes, there are a number of secondary
107 * attributes that you can also include with an intent:</p>
108 *
109 * <ul>
110 * <li> <p><b>category</b> -- Gives additional information about the action
111 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
112 * appear in the Launcher as a top-level application, while
113 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
114 * of alternative actions the user can perform on a piece of data.</p>
115 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
116 * intent data. Normally the type is inferred from the data itself.
117 * By setting this attribute, you disable that evaluation and force
118 * an explicit type.</p>
119 * <li> <p><b>component</b> -- Specifies an explicit name of a component
120 * class to use for the intent. Normally this is determined by looking
121 * at the other information in the intent (the action, data/type, and
122 * categories) and matching that with a component that can handle it.
123 * If this attribute is set then none of the evaluation is performed,
124 * and this component is used exactly as is. By specifying this attribute,
125 * all of the other Intent attributes become optional.</p>
126 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
127 * This can be used to provide extended information to the component.
128 * For example, if we have a action to send an e-mail message, we could
129 * also include extra pieces of data here to supply a subject, body,
130 * etc.</p>
131 * </ul>
132 *
133 * <p>Here are some examples of other operations you can specify as intents
134 * using these additional parameters:</p>
135 *
136 * <ul>
137 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
138 * Launch the home screen.</p>
139 * </li>
140 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
141 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
142 * vnd.android.cursor.item/phone}</i></b>
143 * -- Display the list of people's phone numbers, allowing the user to
144 * browse through them and pick one and return it to the parent activity.</p>
145 * </li>
146 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
147 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
148 * -- Display all pickers for data that can be opened with
149 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
150 * allowing the user to pick one of them and then some data inside of it
151 * and returning the resulting URI to the caller. This can be used,
152 * for example, in an e-mail application to allow the user to pick some
153 * data to include as an attachment.</p>
154 * </li>
155 * </ul>
156 *
157 * <p>There are a variety of standard Intent action and category constants
158 * defined in the Intent class, but applications can also define their own.
159 * These strings use java style scoping, to ensure they are unique -- for
160 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700161 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700162 *
163 * <p>Put together, the set of actions, data types, categories, and extra data
164 * defines a language for the system allowing for the expression of phrases
165 * such as "call john smith's cell". As applications are added to the system,
166 * they can extend this language by adding new actions, types, and categories, or
167 * they can modify the behavior of existing phrases by supplying their own
168 * activities that handle them.</p>
169 *
170 * <a name="IntentResolution"></a>
171 * <h3>Intent Resolution</h3>
172 *
173 * <p>There are two primary forms of intents you will use.
174 *
175 * <ul>
176 * <li> <p><b>Explicit Intents</b> have specified a component (via
177 * {@link #setComponent} or {@link #setClass}), which provides the exact
178 * class to be run. Often these will not include any other information,
179 * simply being a way for an application to launch various internal
180 * activities it has as the user interacts with the application.
181 *
182 * <li> <p><b>Implicit Intents</b> have not specified a component;
183 * instead, they must include enough information for the system to
184 * determine which of the available components is best to run for that
185 * intent.
186 * </ul>
187 *
188 * <p>When using implicit intents, given such an arbitrary intent we need to
189 * know what to do with it. This is handled by the process of <em>Intent
190 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
191 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
192 * more activities/receivers) that can handle it.</p>
193 *
194 * <p>The intent resolution mechanism basically revolves around matching an
195 * Intent against all of the &lt;intent-filter&gt; descriptions in the
196 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
197 * objects explicitly registered with {@link Context#registerReceiver}.) More
198 * details on this can be found in the documentation on the {@link
199 * IntentFilter} class.</p>
200 *
201 * <p>There are three pieces of information in the Intent that are used for
202 * resolution: the action, type, and category. Using this information, a query
203 * is done on the {@link PackageManager} for a component that can handle the
204 * intent. The appropriate component is determined based on the intent
205 * information supplied in the <code>AndroidManifest.xml</code> file as
206 * follows:</p>
207 *
208 * <ul>
209 * <li> <p>The <b>action</b>, if given, must be listed by the component as
210 * one it handles.</p>
211 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
212 * already supplied in the Intent. Like the action, if a type is
213 * included in the intent (either explicitly or implicitly in its
214 * data), then this must be listed by the component as one it handles.</p>
215 * <li> For data that is not a <code>content:</code> URI and where no explicit
216 * type is included in the Intent, instead the <b>scheme</b> of the
217 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
218 * considered. Again like the action, if we are matching a scheme it
219 * must be listed by the component as one it can handle.
220 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
221 * by the activity as categories it handles. That is, if you include
222 * the categories {@link #CATEGORY_LAUNCHER} and
223 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
224 * with an intent that lists <em>both</em> of those categories.
225 * Activities will very often need to support the
226 * {@link #CATEGORY_DEFAULT} so that they can be found by
227 * {@link Context#startActivity Context.startActivity()}.</p>
228 * </ul>
229 *
230 * <p>For example, consider the Note Pad sample application that
231 * allows user to browse through a list of notes data and view details about
232 * individual items. Text in italics indicate places were you would replace a
233 * name with one specific to your own package.</p>
234 *
235 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
236 * package="<i>com.android.notepad</i>"&gt;
237 * &lt;application android:icon="@drawable/app_notes"
238 * android:label="@string/app_name"&gt;
239 *
240 * &lt;provider class=".NotePadProvider"
241 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
242 *
243 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
244 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700245 * &lt;action android:name="android.intent.action.MAIN" /&gt;
246 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700247 * &lt;/intent-filter&gt;
248 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700249 * &lt;action android:name="android.intent.action.VIEW" /&gt;
250 * &lt;action android:name="android.intent.action.EDIT" /&gt;
251 * &lt;action android:name="android.intent.action.PICK" /&gt;
252 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
253 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700254 * &lt;/intent-filter&gt;
255 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700256 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
257 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
258 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700259 * &lt;/intent-filter&gt;
260 * &lt;/activity&gt;
261 *
262 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
263 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700264 * &lt;action android:name="android.intent.action.VIEW" /&gt;
265 * &lt;action android:name="android.intent.action.EDIT" /&gt;
266 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
267 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700268 * &lt;/intent-filter&gt;
269 *
270 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700271 * &lt;action android:name="android.intent.action.INSERT" /&gt;
272 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
273 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274 * &lt;/intent-filter&gt;
275 *
276 * &lt;/activity&gt;
277 *
278 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
279 * android:theme="@android:style/Theme.Dialog"&gt;
280 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
284 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;/activity&gt;
288 *
289 * &lt;/application&gt;
290 * &lt;/manifest&gt;</pre>
291 *
292 * <p>The first activity,
293 * <code>com.android.notepad.NotesList</code>, serves as our main
294 * entry into the app. It can do three things as described by its three intent
295 * templates:
296 * <ol>
297 * <li><pre>
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
300 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;</pre>
302 * <p>This provides a top-level entry into the NotePad application: the standard
303 * MAIN action is a main entry point (not requiring any other information in
304 * the Intent), and the LAUNCHER category says that this entry point should be
305 * listed in the application launcher.</p>
306 * <li><pre>
307 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700308 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
309 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
310 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
311 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
312 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700313 * &lt;/intent-filter&gt;</pre>
314 * <p>This declares the things that the activity can do on a directory of
315 * notes. The type being supported is given with the &lt;type&gt; tag, where
316 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
317 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
318 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
319 * The activity allows the user to view or edit the directory of data (via
320 * the VIEW and EDIT actions), or to pick a particular note and return it
321 * to the caller (via the PICK action). Note also the DEFAULT category
322 * supplied here: this is <em>required</em> for the
323 * {@link Context#startActivity Context.startActivity} method to resolve your
324 * activity when its component name is not explicitly specified.</p>
325 * <li><pre>
326 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700327 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
328 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
329 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700330 * &lt;/intent-filter&gt;</pre>
331 * <p>This filter describes the ability return to the caller a note selected by
332 * the user without needing to know where it came from. The data type
333 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
334 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
335 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
336 * The GET_CONTENT action is similar to the PICK action, where the activity
337 * will return to its caller a piece of data selected by the user. Here,
338 * however, the caller specifies the type of data they desire instead of
339 * the type of data the user will be picking from.</p>
340 * </ol>
341 *
342 * <p>Given these capabilities, the following intents will resolve to the
343 * NotesList activity:</p>
344 *
345 * <ul>
346 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
347 * activities that can be used as top-level entry points into an
348 * application.</p>
349 * <li> <p><b>{ action=android.app.action.MAIN,
350 * category=android.app.category.LAUNCHER }</b> is the actual intent
351 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700352 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * data=content://com.google.provider.NotePad/notes }</b>
354 * displays a list of all the notes under
355 * "content://com.google.provider.NotePad/notes", which
356 * the user can browse through and see the details on.</p>
357 * <li> <p><b>{ action=android.app.action.PICK
358 * data=content://com.google.provider.NotePad/notes }</b>
359 * provides a list of the notes under
360 * "content://com.google.provider.NotePad/notes", from which
361 * the user can pick a note whose data URL is returned back to the caller.</p>
362 * <li> <p><b>{ action=android.app.action.GET_CONTENT
363 * type=vnd.android.cursor.item/vnd.google.note }</b>
364 * is similar to the pick action, but allows the caller to specify the
365 * kind of data they want back so that the system can find the appropriate
366 * activity to pick something of that data type.</p>
367 * </ul>
368 *
369 * <p>The second activity,
370 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
371 * note entry and allows them to edit it. It can do two things as described
372 * by its two intent templates:
373 * <ol>
374 * <li><pre>
375 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700376 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
377 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
378 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
379 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700380 * &lt;/intent-filter&gt;</pre>
381 * <p>The first, primary, purpose of this activity is to let the user interact
382 * with a single note, as decribed by the MIME type
383 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
384 * either VIEW a note or allow the user to EDIT it. Again we support the
385 * DEFAULT category to allow the activity to be launched without explicitly
386 * specifying its component.</p>
387 * <li><pre>
388 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700389 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
390 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
391 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700392 * &lt;/intent-filter&gt;</pre>
393 * <p>The secondary use of this activity is to insert a new note entry into
394 * an existing directory of notes. This is used when the user creates a new
395 * note: the INSERT action is executed on the directory of notes, causing
396 * this activity to run and have the user create the new note data which
397 * it then adds to the content provider.</p>
398 * </ol>
399 *
400 * <p>Given these capabilities, the following intents will resolve to the
401 * NoteEditor activity:</p>
402 *
403 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700404 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700405 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
406 * shows the user the content of note <var>{ID}</var>.</p>
407 * <li> <p><b>{ action=android.app.action.EDIT
408 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
409 * allows the user to edit the content of note <var>{ID}</var>.</p>
410 * <li> <p><b>{ action=android.app.action.INSERT
411 * data=content://com.google.provider.NotePad/notes }</b>
412 * creates a new, empty note in the notes list at
413 * "content://com.google.provider.NotePad/notes"
414 * and allows the user to edit it. If they keep their changes, the URI
415 * of the newly created note is returned to the caller.</p>
416 * </ul>
417 *
418 * <p>The last activity,
419 * <code>com.android.notepad.TitleEditor</code>, allows the user to
420 * edit the title of a note. This could be implemented as a class that the
421 * application directly invokes (by explicitly setting its component in
422 * the Intent), but here we show a way you can publish alternative
423 * operations on existing data:</p>
424 *
425 * <pre>
426 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700427 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
428 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
429 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700432 * &lt;/intent-filter&gt;</pre>
433 *
434 * <p>In the single intent template here, we
435 * have created our own private action called
436 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
437 * edit the title of a note. It must be invoked on a specific note
438 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
439 * view and edit actions, but here displays and edits the title contained
440 * in the note data.
441 *
442 * <p>In addition to supporting the default category as usual, our title editor
443 * also supports two other standard categories: ALTERNATIVE and
444 * SELECTED_ALTERNATIVE. Implementing
445 * these categories allows others to find the special action it provides
446 * without directly knowing about it, through the
447 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
448 * more often to build dynamic menu items with
449 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
450 * template here was also supply an explicit name for the template
451 * (via <code>android:label="@string/resolve_title"</code>) to better control
452 * what the user sees when presented with this activity as an alternative
453 * action to the data they are viewing.
454 *
455 * <p>Given these capabilities, the following intent will resolve to the
456 * TitleEditor activity:</p>
457 *
458 * <ul>
459 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461 * displays and allows the user to edit the title associated
462 * with note <var>{ID}</var>.</p>
463 * </ul>
464 *
465 * <h3>Standard Activity Actions</h3>
466 *
467 * <p>These are the current standard actions that Intent defines for launching
468 * activities (usually through {@link Context#startActivity}. The most
469 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
470 * {@link #ACTION_EDIT}.
471 *
472 * <ul>
473 * <li> {@link #ACTION_MAIN}
474 * <li> {@link #ACTION_VIEW}
475 * <li> {@link #ACTION_ATTACH_DATA}
476 * <li> {@link #ACTION_EDIT}
477 * <li> {@link #ACTION_PICK}
478 * <li> {@link #ACTION_CHOOSER}
479 * <li> {@link #ACTION_GET_CONTENT}
480 * <li> {@link #ACTION_DIAL}
481 * <li> {@link #ACTION_CALL}
482 * <li> {@link #ACTION_SEND}
483 * <li> {@link #ACTION_SENDTO}
484 * <li> {@link #ACTION_ANSWER}
485 * <li> {@link #ACTION_INSERT}
486 * <li> {@link #ACTION_DELETE}
487 * <li> {@link #ACTION_RUN}
488 * <li> {@link #ACTION_SYNC}
489 * <li> {@link #ACTION_PICK_ACTIVITY}
490 * <li> {@link #ACTION_SEARCH}
491 * <li> {@link #ACTION_WEB_SEARCH}
492 * <li> {@link #ACTION_FACTORY_TEST}
493 * </ul>
494 *
495 * <h3>Standard Broadcast Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for receiving
498 * broadcasts (usually through {@link Context#registerReceiver} or a
499 * &lt;receiver&gt; tag in a manifest).
500 *
501 * <ul>
502 * <li> {@link #ACTION_TIME_TICK}
503 * <li> {@link #ACTION_TIME_CHANGED}
504 * <li> {@link #ACTION_TIMEZONE_CHANGED}
505 * <li> {@link #ACTION_BOOT_COMPLETED}
506 * <li> {@link #ACTION_PACKAGE_ADDED}
507 * <li> {@link #ACTION_PACKAGE_CHANGED}
508 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * <li> {@link #ACTION_PACKAGE_RESTARTED}
510 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700511 * <li> {@link #ACTION_UID_REMOVED}
512 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700513 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700514 * <li> {@link #ACTION_POWER_DISCONNECTED}
515 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700516 * </ul>
517 *
518 * <h3>Standard Categories</h3>
519 *
520 * <p>These are the current standard categories that can be used to further
521 * clarify an Intent via {@link #addCategory}.
522 *
523 * <ul>
524 * <li> {@link #CATEGORY_DEFAULT}
525 * <li> {@link #CATEGORY_BROWSABLE}
526 * <li> {@link #CATEGORY_TAB}
527 * <li> {@link #CATEGORY_ALTERNATIVE}
528 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
529 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700531 * <li> {@link #CATEGORY_HOME}
532 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700533 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400534 * <li> {@link #CATEGORY_CAR_DOCK}
535 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500536 * <li> {@link #CATEGORY_LE_DESK_DOCK}
537 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200538 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700539 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700540 * </ul>
541 *
542 * <h3>Standard Extra Data</h3>
543 *
544 * <p>These are the current standard fields that can be used as extra data via
545 * {@link #putExtra}.
546 *
547 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800548 * <li> {@link #EXTRA_ALARM_COUNT}
549 * <li> {@link #EXTRA_BCC}
550 * <li> {@link #EXTRA_CC}
551 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
552 * <li> {@link #EXTRA_DATA_REMOVED}
553 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500554 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
555 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800556 * <li> {@link #EXTRA_DOCK_STATE_CAR}
557 * <li> {@link #EXTRA_DOCK_STATE_DESK}
558 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
559 * <li> {@link #EXTRA_DONT_KILL_APP}
560 * <li> {@link #EXTRA_EMAIL}
561 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700562 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800563 * <li> {@link #EXTRA_KEY_EVENT}
564 * <li> {@link #EXTRA_PHONE_NUMBER}
565 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
566 * <li> {@link #EXTRA_REPLACING}
567 * <li> {@link #EXTRA_SHORTCUT_ICON}
568 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
569 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800571 * <li> {@link #EXTRA_SHORTCUT_NAME}
572 * <li> {@link #EXTRA_SUBJECT}
573 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800575 * <li> {@link #EXTRA_TITLE}
576 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700577 * </ul>
578 *
579 * <h3>Flags</h3>
580 *
581 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800582 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
583 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700584 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800585public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700586 // ---------------------------------------------------------------------
587 // ---------------------------------------------------------------------
588 // Standard intent activity actions (see action variable).
589
590 /**
591 * Activity Action: Start as a main entry point, does not expect to
592 * receive data.
593 * <p>Input: nothing
594 * <p>Output: nothing
595 */
596 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
597 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800598
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700599 /**
600 * Activity Action: Display the data to the user. This is the most common
601 * action performed on data -- it is the generic action you can use on
602 * a piece of data to get the most reasonable thing to occur. For example,
603 * when used on a contacts entry it will view the entry; when used on a
604 * mailto: URI it will bring up a compose window filled with the information
605 * supplied by the URI; when used with a tel: URI it will invoke the
606 * dialer.
607 * <p>Input: {@link #getData} is URI from which to retrieve data.
608 * <p>Output: nothing.
609 */
610 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
611 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800612
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 /**
614 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
615 * performed on a piece of data.
616 */
617 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800618
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 /**
620 * Used to indicate that some piece of data should be attached to some other
621 * place. For example, image data could be attached to a contact. It is up
622 * to the recipient to decide where the data should be attached; the intent
623 * does not specify the ultimate destination.
624 * <p>Input: {@link #getData} is URI of data to be attached.
625 * <p>Output: nothing.
626 */
627 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
628 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 /**
631 * Activity Action: Provide explicit editable access to the given data.
632 * <p>Input: {@link #getData} is URI of data to be edited.
633 * <p>Output: nothing.
634 */
635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
636 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800637
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700638 /**
639 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
640 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
641 * The extras can contain type specific data to pass through to the editing/creating
642 * activity.
643 * <p>Output: The URI of the item that was picked. This must be a content:
644 * URI so that any receiver can access it.
645 */
646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
647 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800648
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700649 /**
650 * Activity Action: Pick an item from the data, returning what was selected.
651 * <p>Input: {@link #getData} is URI containing a directory of data
652 * (vnd.android.cursor.dir/*) from which to pick an item.
653 * <p>Output: The URI of the item that was picked.
654 */
655 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
656 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700658 /**
659 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800660 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700661 * <p>Output: An Intent representing the shortcut. The intent must contain three
662 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
663 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664 * (value: ShortcutIconResource).</p>
665 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 * @see #EXTRA_SHORTCUT_INTENT
667 * @see #EXTRA_SHORTCUT_NAME
668 * @see #EXTRA_SHORTCUT_ICON
669 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
670 * @see android.content.Intent.ShortcutIconResource
671 */
672 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
673 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
674
675 /**
676 * The name of the extra used to define the Intent of a shortcut.
677 *
678 * @see #ACTION_CREATE_SHORTCUT
679 */
680 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
681 /**
682 * The name of the extra used to define the name of a shortcut.
683 *
684 * @see #ACTION_CREATE_SHORTCUT
685 */
686 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
687 /**
688 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
689 *
690 * @see #ACTION_CREATE_SHORTCUT
691 */
692 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
693 /**
694 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
695 *
696 * @see #ACTION_CREATE_SHORTCUT
697 * @see android.content.Intent.ShortcutIconResource
698 */
699 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
700 "android.intent.extra.shortcut.ICON_RESOURCE";
701
702 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 *
705 * @see Intent#ACTION_CREATE_SHORTCUT
706 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800707 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
708 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700709 */
710 public static class ShortcutIconResource implements Parcelable {
711 /**
712 * The package name of the application containing the icon.
713 */
714 public String packageName;
715
716 /**
717 * The resource name of the icon, including package, name and type.
718 */
719 public String resourceName;
720
721 /**
722 * Creates a new ShortcutIconResource for the specified context and resource
723 * identifier.
724 *
725 * @param context The context of the application.
726 * @param resourceId The resource idenfitier for the icon.
727 * @return A new ShortcutIconResource with the specified's context package name
728 * and icon resource idenfitier.
729 */
730 public static ShortcutIconResource fromContext(Context context, int resourceId) {
731 ShortcutIconResource icon = new ShortcutIconResource();
732 icon.packageName = context.getPackageName();
733 icon.resourceName = context.getResources().getResourceName(resourceId);
734 return icon;
735 }
736
737 /**
738 * Used to read a ShortcutIconResource from a Parcel.
739 */
740 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
741 new Parcelable.Creator<ShortcutIconResource>() {
742
743 public ShortcutIconResource createFromParcel(Parcel source) {
744 ShortcutIconResource icon = new ShortcutIconResource();
745 icon.packageName = source.readString();
746 icon.resourceName = source.readString();
747 return icon;
748 }
749
750 public ShortcutIconResource[] newArray(int size) {
751 return new ShortcutIconResource[size];
752 }
753 };
754
755 /**
756 * No special parcel contents.
757 */
758 public int describeContents() {
759 return 0;
760 }
761
762 public void writeToParcel(Parcel dest, int flags) {
763 dest.writeString(packageName);
764 dest.writeString(resourceName);
765 }
766
767 @Override
768 public String toString() {
769 return resourceName;
770 }
771 }
772
773 /**
774 * Activity Action: Display an activity chooser, allowing the user to pick
775 * what they want to before proceeding. This can be used as an alternative
776 * to the standard activity picker that is displayed by the system when
777 * you try to start an activity with multiple possible matches, with these
778 * differences in behavior:
779 * <ul>
780 * <li>You can specify the title that will appear in the activity chooser.
781 * <li>The user does not have the option to make one of the matching
782 * activities a preferred activity, and all possible activities will
783 * always be shown even if one of them is currently marked as the
784 * preferred activity.
785 * </ul>
786 * <p>
787 * This action should be used when the user will naturally expect to
788 * select an activity in order to proceed. An example if when not to use
789 * it is when the user clicks on a "mailto:" link. They would naturally
790 * expect to go directly to their mail app, so startActivity() should be
791 * called directly: it will
792 * either launch the current preferred app, or put up a dialog allowing the
793 * user to pick an app to use and optionally marking that as preferred.
794 * <p>
795 * In contrast, if the user is selecting a menu item to send a picture
796 * they are viewing to someone else, there are many different things they
797 * may want to do at this point: send it through e-mail, upload it to a
798 * web service, etc. In this case the CHOOSER action should be used, to
799 * always present to the user a list of the things they can do, with a
800 * nice title given by the caller such as "Send this photo with:".
801 * <p>
802 * As a convenience, an Intent of this form can be created with the
803 * {@link #createChooser} function.
804 * <p>Input: No data should be specified. get*Extra must have
805 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
806 * and can optionally have a {@link #EXTRA_TITLE} field containing the
807 * title text to display in the chooser.
808 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
809 */
810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
811 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
812
813 /**
814 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
815 *
816 * @param target The Intent that the user will be selecting an activity
817 * to perform.
818 * @param title Optional title that will be displayed in the chooser.
819 * @return Return a new Intent object that you can hand to
820 * {@link Context#startActivity(Intent) Context.startActivity()} and
821 * related methods.
822 */
823 public static Intent createChooser(Intent target, CharSequence title) {
824 Intent intent = new Intent(ACTION_CHOOSER);
825 intent.putExtra(EXTRA_INTENT, target);
826 if (title != null) {
827 intent.putExtra(EXTRA_TITLE, title);
828 }
829 return intent;
830 }
831 /**
832 * Activity Action: Allow the user to select a particular kind of data and
833 * return it. This is different than {@link #ACTION_PICK} in that here we
834 * just say what kind of data is desired, not a URI of existing data from
835 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
836 * create the data as it runs (for example taking a picture or recording a
837 * sound), let them browser over the web and download the desired data,
838 * etc.
839 * <p>
840 * There are two main ways to use this action: if you want an specific kind
841 * of data, such as a person contact, you set the MIME type to the kind of
842 * data you want and launch it with {@link Context#startActivity(Intent)}.
843 * The system will then launch the best application to select that kind
844 * of data for you.
845 * <p>
846 * You may also be interested in any of a set of types of content the user
847 * can pick. For example, an e-mail application that wants to allow the
848 * user to add an attachment to an e-mail message can use this action to
849 * bring up a list of all of the types of content the user can attach.
850 * <p>
851 * In this case, you should wrap the GET_CONTENT intent with a chooser
852 * (through {@link #createChooser}), which will give the proper interface
853 * for the user to pick how to send your data and allow you to specify
854 * a prompt indicating what they are doing. You will usually specify a
855 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
856 * broad range of content types the user can select from.
857 * <p>
858 * When using such a broad GET_CONTENT action, it is often desireable to
859 * only pick from data that can be represented as a stream. This is
860 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
861 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800862 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
863 * the launched content chooser only return results representing data that
864 * is locally available on the device. For example, if this extra is set
865 * to true then an image picker should not show any pictures that are available
866 * from a remote server but not already on the local device (thus requiring
867 * they be downloaded when opened).
868 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700869 * Input: {@link #getType} is the desired MIME type to retrieve. Note
870 * that no URI is supplied in the intent, as there are no constraints on
871 * where the returned data originally comes from. You may also include the
872 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800873 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
874 * selection to local data.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700875 * <p>
876 * Output: The URI of the item that was picked. This must be a content:
877 * URI so that any receiver can access it.
878 */
879 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
880 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
881 /**
882 * Activity Action: Dial a number as specified by the data. This shows a
883 * UI with the number being dialed, allowing the user to explicitly
884 * initiate the call.
885 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
886 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
887 * number.
888 * <p>Output: nothing.
889 */
890 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
891 public static final String ACTION_DIAL = "android.intent.action.DIAL";
892 /**
893 * Activity Action: Perform a call to someone specified by the data.
894 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
895 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
896 * number.
897 * <p>Output: nothing.
898 *
899 * <p>Note: there will be restrictions on which applications can initiate a
900 * call; most applications should use the {@link #ACTION_DIAL}.
901 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
902 * numbers. Applications can <strong>dial</strong> emergency numbers using
903 * {@link #ACTION_DIAL}, however.
904 */
905 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
906 public static final String ACTION_CALL = "android.intent.action.CALL";
907 /**
908 * Activity Action: Perform a call to an emergency number specified by the
909 * data.
910 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
911 * tel: URI of an explicit phone number.
912 * <p>Output: nothing.
913 * @hide
914 */
915 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
916 /**
917 * Activity action: Perform a call to any number (emergency or not)
918 * specified by the data.
919 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
920 * tel: URI of an explicit phone number.
921 * <p>Output: nothing.
922 * @hide
923 */
924 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
925 /**
926 * Activity Action: Send a message to someone specified by the data.
927 * <p>Input: {@link #getData} is URI describing the target.
928 * <p>Output: nothing.
929 */
930 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
931 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
932 /**
933 * Activity Action: Deliver some data to someone else. Who the data is
934 * being delivered to is not specified; it is up to the receiver of this
935 * action to ask the user where the data should be sent.
936 * <p>
937 * When launching a SEND intent, you should usually wrap it in a chooser
938 * (through {@link #createChooser}), which will give the proper interface
939 * for the user to pick how to send your data and allow you to specify
940 * a prompt indicating what they are doing.
941 * <p>
942 * Input: {@link #getType} is the MIME type of the data being sent.
943 * get*Extra can have either a {@link #EXTRA_TEXT}
944 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
945 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
946 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
947 * if the MIME type is unknown (this will only allow senders that can
948 * handle generic data streams).
949 * <p>
950 * Optional standard extras, which may be interpreted by some recipients as
951 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
952 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
953 * <p>
954 * Output: nothing.
955 */
956 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
957 public static final String ACTION_SEND = "android.intent.action.SEND";
958 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800959 * Activity Action: Deliver multiple data to someone else.
960 * <p>
961 * Like ACTION_SEND, except the data is multiple.
962 * <p>
963 * Input: {@link #getType} is the MIME type of the data being sent.
964 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
965 * #EXTRA_STREAM} field, containing the data to be sent.
966 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800967 * Multiple types are supported, and receivers should handle mixed types
968 * whenever possible. The right way for the receiver to check them is to
969 * use the content resolver on each URI. The intent sender should try to
970 * put the most concrete mime type in the intent type, but it can fall
971 * back to {@literal <type>/*} or {@literal *}/* as needed.
972 * <p>
973 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
974 * be image/jpg, but if you are sending image/jpg and image/png, then the
975 * intent's type should be image/*.
976 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800977 * Optional standard extras, which may be interpreted by some recipients as
978 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
979 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
980 * <p>
981 * Output: nothing.
982 */
983 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
984 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
985 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700986 * Activity Action: Handle an incoming phone call.
987 * <p>Input: nothing.
988 * <p>Output: nothing.
989 */
990 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
991 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
992 /**
993 * Activity Action: Insert an empty item into the given container.
994 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
995 * in which to place the data.
996 * <p>Output: URI of the new data that was created.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1000 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001001 * Activity Action: Create a new item in the given container, initializing it
1002 * from the current contents of the clipboard.
1003 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1004 * in which to place the data.
1005 * <p>Output: URI of the new data that was created.
1006 */
1007 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1008 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1009 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001010 * Activity Action: Delete the given data from its container.
1011 * <p>Input: {@link #getData} is URI of data to be deleted.
1012 * <p>Output: nothing.
1013 */
1014 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1015 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1016 /**
1017 * Activity Action: Run the data, whatever that means.
1018 * <p>Input: ? (Note: this is currently specific to the test harness.)
1019 * <p>Output: nothing.
1020 */
1021 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1022 public static final String ACTION_RUN = "android.intent.action.RUN";
1023 /**
1024 * Activity Action: Perform a data synchronization.
1025 * <p>Input: ?
1026 * <p>Output: ?
1027 */
1028 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1029 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1030 /**
1031 * Activity Action: Pick an activity given an intent, returning the class
1032 * selected.
1033 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1034 * used with {@link PackageManager#queryIntentActivities} to determine the
1035 * set of activities from which to pick.
1036 * <p>Output: Class name of the activity that was selected.
1037 */
1038 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1039 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1040 /**
1041 * Activity Action: Perform a search.
1042 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1043 * is the text to search for. If empty, simply
1044 * enter your search results Activity with the search UI activated.
1045 * <p>Output: nothing.
1046 */
1047 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1048 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1049 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001050 * Activity Action: Start the platform-defined tutorial
1051 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1052 * is the text to search for. If empty, simply
1053 * enter your search results Activity with the search UI activated.
1054 * <p>Output: nothing.
1055 */
1056 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1057 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1058 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001059 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001060 * <p>
1061 * Input: {@link android.app.SearchManager#QUERY
1062 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1063 * a url starts with http or https, the site will be opened. If it is plain
1064 * text, Google search will be applied.
1065 * <p>
1066 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001067 */
1068 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1069 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1070 /**
1071 * Activity Action: List all available applications
1072 * <p>Input: Nothing.
1073 * <p>Output: nothing.
1074 */
1075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1076 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1077 /**
1078 * Activity Action: Show settings for choosing wallpaper
1079 * <p>Input: Nothing.
1080 * <p>Output: Nothing.
1081 */
1082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1083 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1084
1085 /**
1086 * Activity Action: Show activity for reporting a bug.
1087 * <p>Input: Nothing.
1088 * <p>Output: Nothing.
1089 */
1090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1091 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1092
1093 /**
1094 * Activity Action: Main entry point for factory tests. Only used when
1095 * the device is booting in factory test node. The implementing package
1096 * must be installed in the system image.
1097 * <p>Input: nothing
1098 * <p>Output: nothing
1099 */
1100 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1101
1102 /**
1103 * Activity Action: The user pressed the "call" button to go to the dialer
1104 * or other appropriate UI for placing a call.
1105 * <p>Input: Nothing.
1106 * <p>Output: Nothing.
1107 */
1108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1109 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1110
1111 /**
1112 * Activity Action: Start Voice Command.
1113 * <p>Input: Nothing.
1114 * <p>Output: Nothing.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001118
1119 /**
1120 * Activity Action: Start action associated with long pressing on the
1121 * search key.
1122 * <p>Input: Nothing.
1123 * <p>Output: Nothing.
1124 */
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001127
Jacek Surazski86b6c532009-05-13 14:38:28 +02001128 /**
1129 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1130 * This intent is delivered to the package which installed the application, usually
1131 * the Market.
1132 * <p>Input: No data is specified. The bug report is passed in using
1133 * an {@link #EXTRA_BUG_REPORT} field.
1134 * <p>Output: Nothing.
1135 * @hide
1136 */
1137 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1138 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001139
1140 /**
1141 * Activity Action: Show power usage information to the user.
1142 * <p>Input: Nothing.
1143 * <p>Output: Nothing.
1144 */
1145 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1146 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001147
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001148 /**
1149 * Activity Action: Setup wizard to launch after a platform update. This
1150 * activity should have a string meta-data field associated with it,
1151 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1152 * the platform for setup. The activity will be launched only if
1153 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1154 * same value.
1155 * <p>Input: Nothing.
1156 * <p>Output: Nothing.
1157 * @hide
1158 */
1159 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1160 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001161
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001162 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001163 * Activity Action: Show settings for managing network data usage of a
1164 * specific application. Applications should define an activity that offers
1165 * options to control data usage.
1166 */
1167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1168 public static final String ACTION_MANAGE_NETWORK_USAGE =
1169 "android.intent.action.MANAGE_NETWORK_USAGE";
1170
1171 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001172 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1173 * describing the last run version of the platform that was setup.
1174 * @hide
1175 */
1176 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1177
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001178 // ---------------------------------------------------------------------
1179 // ---------------------------------------------------------------------
1180 // Standard intent broadcast actions (see action variable).
1181
1182 /**
1183 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001185 * <p class="note">This is a protected intent that can only be sent
1186 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001187 */
1188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1189 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1190 /**
1191 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001192 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001193 * <p class="note">This is a protected intent that can only be sent
1194 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001195 */
1196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1197 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001198
1199 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001200 * 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 -07001201 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001202 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001203 * <p class="note">This is a protected intent that can only be sent
1204 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001205 */
1206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001207 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001208
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001209 /**
1210 * Broadcast Action: The current time has changed. Sent every
1211 * minute. You can <em>not</em> receive this through components declared
1212 * in manifests, only by exlicitly registering for it with
1213 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1214 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001215 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001216 * <p class="note">This is a protected intent that can only be sent
1217 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001218 */
1219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1220 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1221 /**
1222 * Broadcast Action: The time was set.
1223 */
1224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1225 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1226 /**
1227 * Broadcast Action: The date has changed.
1228 */
1229 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1230 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1231 /**
1232 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1233 * <ul>
1234 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1235 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001236 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001237 * <p class="note">This is a protected intent that can only be sent
1238 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001239 */
1240 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1241 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1242 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001243 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1244 * DNS entries should be tossed.
1245 * @hide
1246 */
1247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1248 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1249 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001250 * Alarm Changed Action: This is broadcast when the AlarmClock
1251 * application's alarm is set or unset. It is used by the
1252 * AlarmClock application and the StatusBar service.
1253 * @hide
1254 */
1255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1256 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1257 /**
1258 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1259 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1260 * @hide
1261 */
1262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1263 public static final String ACTION_SYNC_STATE_CHANGED
1264 = "android.intent.action.SYNC_STATE_CHANGED";
1265 /**
1266 * Broadcast Action: This is broadcast once, after the system has finished
1267 * booting. It can be used to perform application-specific initialization,
1268 * such as installing alarms. You must hold the
1269 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1270 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001271 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001272 * <p class="note">This is a protected intent that can only be sent
1273 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001274 */
1275 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1276 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1277 /**
1278 * Broadcast Action: This is broadcast when a user action should request a
1279 * temporary system dialog to dismiss. Some examples of temporary system
1280 * dialogs are the notification window-shade and the recent tasks dialog.
1281 */
1282 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1283 /**
1284 * Broadcast Action: Trigger the download and eventual installation
1285 * of a package.
1286 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001287 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001288 * <p class="note">This is a protected intent that can only be sent
1289 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001290 */
1291 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1292 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1293 /**
1294 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001295 * device. The data contains the name of the package. Note that the
1296 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001297 * <p>My include the following extras:
1298 * <ul>
1299 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1300 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1301 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1302 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001303 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001304 * <p class="note">This is a protected intent that can only be sent
1305 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 */
1307 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1308 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1309 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001310 * Broadcast Action: A new version of an application package has been
1311 * installed, replacing an existing version that was previously installed.
1312 * The data contains the name of the package.
1313 * <p>My include the following extras:
1314 * <ul>
1315 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1316 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001317 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001318 * <p class="note">This is a protected intent that can only be sent
1319 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001320 */
1321 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1322 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1323 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001324 * Broadcast Action: A new version of your application has been installed
1325 * over an existing one. This is only sent to the application that was
1326 * replaced. It does not contain any additional data; to receive it, just
1327 * use an intent filter for this action.
1328 *
1329 * <p class="note">This is a protected intent that can only be sent
1330 * by the system.
1331 */
1332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1333 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1334 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001335 * Broadcast Action: An existing application package has been removed from
1336 * the device. The data contains the name of the package. The package
1337 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001338 * <ul>
1339 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1340 * to the package.
1341 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1342 * application -- data and code -- is being removed.
1343 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1344 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1345 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001346 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001347 * <p class="note">This is a protected intent that can only be sent
1348 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001349 */
1350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1351 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1352 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001353 * Broadcast Action: An existing application package has been changed (e.g.
1354 * a component has been enabled or disabled). The data contains the name of
1355 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001356 * <ul>
1357 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001358 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1359 * of the changed components.
1360 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1361 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001362 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001363 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001364 * <p class="note">This is a protected intent that can only be sent
1365 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001366 */
1367 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1368 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1369 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001370 * @hide
1371 * Broadcast Action: Ask system services if there is any reason to
1372 * restart the given package. The data contains the name of the
1373 * package.
1374 * <ul>
1375 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1376 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1377 * </ul>
1378 *
1379 * <p class="note">This is a protected intent that can only be sent
1380 * by the system.
1381 */
1382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1383 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1384 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001385 * Broadcast Action: The user has restarted a package, and all of its
1386 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001387 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001388 * be removed. Note that the restarted package does <em>not</em>
1389 * receive this broadcast.
1390 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001391 * <ul>
1392 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1393 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001394 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001395 * <p class="note">This is a protected intent that can only be sent
1396 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001397 */
1398 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1399 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1400 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001401 * Broadcast Action: The user has cleared the data of a package. This should
1402 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001403 * its persistent data is erased and this broadcast sent.
1404 * Note that the cleared package does <em>not</em>
1405 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001406 * <ul>
1407 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1408 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001409 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001410 * <p class="note">This is a protected intent that can only be sent
1411 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001412 */
1413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1414 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1415 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001416 * Broadcast Action: A user ID has been removed from the system. The user
1417 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001418 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001419 * <p class="note">This is a protected intent that can only be sent
1420 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001421 */
1422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1423 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001424
1425 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001426 * Broadcast Action: Sent to the installer package of an application
1427 * when that application is first launched (that is the first time it
1428 * is moved out of the stopped state). The data contains the name of the package.
1429 *
1430 * <p class="note">This is a protected intent that can only be sent
1431 * by the system.
1432 */
1433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1434 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1435
1436 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001437 * Broadcast Action: Resources for a set of packages (which were
1438 * previously unavailable) are currently
1439 * available since the media on which they exist is available.
1440 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1441 * list of packages whose availability changed.
1442 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1443 * list of uids of packages whose availability changed.
1444 * Note that the
1445 * packages in this list do <em>not</em> receive this broadcast.
1446 * The specified set of packages are now available on the system.
1447 * <p>Includes the following extras:
1448 * <ul>
1449 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1450 * whose resources(were previously unavailable) are currently available.
1451 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1452 * packages whose resources(were previously unavailable)
1453 * are currently available.
1454 * </ul>
1455 *
1456 * <p class="note">This is a protected intent that can only be sent
1457 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001458 */
1459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001460 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1461 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001462
1463 /**
1464 * Broadcast Action: Resources for a set of packages are currently
1465 * unavailable since the media on which they exist is unavailable.
1466 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1467 * list of packages whose availability changed.
1468 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1469 * list of uids of packages whose availability changed.
1470 * The specified set of packages can no longer be
1471 * launched and are practically unavailable on the system.
1472 * <p>Inclues the following extras:
1473 * <ul>
1474 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1475 * whose resources are no longer available.
1476 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1477 * whose resources are no longer available.
1478 * </ul>
1479 *
1480 * <p class="note">This is a protected intent that can only be sent
1481 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001482 */
1483 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001484 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001485 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001486
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001487 /**
1488 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001489 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001490 */
1491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1492 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1493 /**
1494 * Broadcast Action: The current device {@link android.content.res.Configuration}
1495 * (orientation, locale, etc) has changed. When such a change happens, the
1496 * UIs (view hierarchy) will need to be rebuilt based on this new
1497 * information; for the most part, applications don't need to worry about
1498 * this, because the system will take care of stopping and restarting the
1499 * application to make sure it sees the new changes. Some system code that
1500 * can not be restarted will need to watch for this action and handle it
1501 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001502 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001503 * <p class="note">
1504 * You can <em>not</em> receive this through components declared
1505 * in manifests, only by explicitly registering for it with
1506 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1507 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001508 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001509 * <p class="note">This is a protected intent that can only be sent
1510 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001511 *
1512 * @see android.content.res.Configuration
1513 */
1514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1515 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1516 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001517 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001518 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001519 * <p class="note">This is a protected intent that can only be sent
1520 * by the system.
1521 */
1522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1523 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1524 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001525 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1526 * charging state, level, and other information about the battery.
1527 * See {@link android.os.BatteryManager} for documentation on the
1528 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001529 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001530 * <p class="note">
1531 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001532 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001533 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001534 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1535 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1536 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1537 * broadcasts that are sent and can be received through manifest
1538 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001539 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001540 * <p class="note">This is a protected intent that can only be sent
1541 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001542 */
1543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1544 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1545 /**
1546 * Broadcast Action: Indicates low battery condition on the device.
1547 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001548 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001549 * <p class="note">This is a protected intent that can only be sent
1550 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001551 */
1552 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1553 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1554 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001555 * Broadcast Action: Indicates the battery is now okay after being low.
1556 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1557 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001558 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001559 * <p class="note">This is a protected intent that can only be sent
1560 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001561 */
1562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1563 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1564 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001565 * Broadcast Action: External power has been connected to the device.
1566 * This is intended for applications that wish to register specifically to this notification.
1567 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1568 * stay active to receive this notification. This action can be used to implement actions
1569 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001570 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001571 * <p class="note">This is a protected intent that can only be sent
1572 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001573 */
1574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001575 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001576 /**
1577 * Broadcast Action: External power has been removed from the device.
1578 * This is intended for applications that wish to register specifically to this notification.
1579 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1580 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001581 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001582 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001583 * <p class="note">This is a protected intent that can only be sent
1584 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001585 */
1586 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001587 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001588 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001589 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001590 * Broadcast Action: Device is shutting down.
1591 * This is broadcast when the device is being shut down (completely turned
1592 * off, not sleeping). Once the broadcast is complete, the final shutdown
1593 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001594 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001595 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001596 * <p class="note">This is a protected intent that can only be sent
1597 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001598 */
1599 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001600 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001601 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001602 * Activity Action: Start this activity to request system shutdown.
1603 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1604 * to request confirmation from the user before shutting down.
1605 *
1606 * <p class="note">This is a protected intent that can only be sent
1607 * by the system.
1608 *
1609 * {@hide}
1610 */
1611 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1612 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001613 * Broadcast Action: A sticky broadcast that indicates low memory
1614 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001615 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001616 * <p class="note">This is a protected intent that can only be sent
1617 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001618 */
1619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1620 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1621 /**
1622 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001623 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001624 * <p class="note">This is a protected intent that can only be sent
1625 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001626 */
1627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1628 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1629 /**
Jake Hambybb371632010-08-23 18:16:48 -07001630 * Broadcast Action: A sticky broadcast that indicates a memory full
1631 * condition on the device. This is intended for activities that want
1632 * to be able to fill the data partition completely, leaving only
1633 * enough free space to prevent system-wide SQLite failures.
1634 *
1635 * <p class="note">This is a protected intent that can only be sent
1636 * by the system.
1637 *
1638 * {@hide}
1639 */
1640 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1641 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1642 /**
1643 * Broadcast Action: Indicates memory full condition on the device
1644 * no longer exists.
1645 *
1646 * <p class="note">This is a protected intent that can only be sent
1647 * by the system.
1648 *
1649 * {@hide}
1650 */
1651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1652 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
1653 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001654 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1655 * and package management should be started.
1656 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1657 * notification.
1658 */
1659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1660 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1661 /**
1662 * Broadcast Action: The device has entered USB Mass Storage mode.
1663 * This is used mainly for the USB Settings panel.
1664 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1665 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001666 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001667 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001668 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001669 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1670
1671 /**
1672 * Broadcast Action: The device has exited USB Mass Storage mode.
1673 * This is used mainly for the USB Settings panel.
1674 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1675 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001676 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001677 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001678 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001679 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1680
1681 /**
1682 * Broadcast Action: External media has been removed.
1683 * The path to the mount point for the removed media is contained in the Intent.mData field.
1684 */
1685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1686 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1687
1688 /**
1689 * Broadcast Action: External media is present, but not mounted at its mount point.
1690 * The path to the mount point for the removed media is contained in the Intent.mData field.
1691 */
1692 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1693 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1694
1695 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001696 * Broadcast Action: External media is present, and being disk-checked
1697 * 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 -08001698 */
1699 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1700 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1701
1702 /**
1703 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1704 * 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 -08001705 */
1706 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1707 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1708
1709 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001710 * Broadcast Action: External media is present and mounted at its mount point.
1711 * The path to the mount point for the removed media is contained in the Intent.mData field.
1712 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1713 * media was mounted read only.
1714 */
1715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1716 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1717
1718 /**
1719 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001720 * 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 -07001721 */
1722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1723 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1724
1725 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001726 * Broadcast Action: External media is no longer being shared via USB mass storage.
1727 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1728 *
1729 * @hide
1730 */
1731 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1732
1733 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001734 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1735 * The path to the mount point for the removed media is contained in the Intent.mData field.
1736 */
1737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1738 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1739
1740 /**
1741 * Broadcast Action: External media is present but cannot be mounted.
1742 * The path to the mount point for the removed media is contained in the Intent.mData field.
1743 */
1744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1745 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1746
1747 /**
1748 * Broadcast Action: User has expressed the desire to remove the external storage media.
1749 * Applications should close all files they have open within the mount point when they receive this intent.
1750 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1751 */
1752 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1753 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1754
1755 /**
1756 * Broadcast Action: The media scanner has started scanning a directory.
1757 * The path to the directory being scanned is contained in the Intent.mData field.
1758 */
1759 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1760 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1761
1762 /**
1763 * Broadcast Action: The media scanner has finished scanning a directory.
1764 * The path to the scanned directory is contained in the Intent.mData field.
1765 */
1766 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1767 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1768
1769 /**
1770 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1771 * The path to the file is contained in the Intent.mData field.
1772 */
1773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1774 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1775
1776 /**
1777 * Broadcast Action: The "Media Button" was pressed. Includes a single
1778 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1779 * caused the broadcast.
1780 */
1781 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1782 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1783
1784 /**
1785 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1786 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1787 * caused the broadcast.
1788 */
1789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1790 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1791
1792 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1793 // location; they are not general-purpose actions.
1794
1795 /**
1796 * Broadcast Action: An GTalk connection has been established.
1797 */
1798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1799 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1800 "android.intent.action.GTALK_CONNECTED";
1801
1802 /**
1803 * Broadcast Action: An GTalk connection has been disconnected.
1804 */
1805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1806 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1807 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001808
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001809 /**
1810 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001811 */
1812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1813 public static final String ACTION_INPUT_METHOD_CHANGED =
1814 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001815
1816 /**
1817 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1818 * more radios have been turned off or on. The intent will have the following extra value:</p>
1819 * <ul>
1820 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1821 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1822 * turned off</li>
1823 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001824 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001825 * <p class="note">This is a protected intent that can only be sent
1826 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001827 */
1828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1829 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1830
1831 /**
1832 * Broadcast Action: Some content providers have parts of their namespace
1833 * where they publish new events or items that the user may be especially
1834 * interested in. For these things, they may broadcast this action when the
1835 * set of interesting items change.
1836 *
1837 * For example, GmailProvider sends this notification when the set of unread
1838 * mail in the inbox changes.
1839 *
1840 * <p>The data of the intent identifies which part of which provider
1841 * changed. When queried through the content resolver, the data URI will
1842 * return the data set in question.
1843 *
1844 * <p>The intent will have the following extra values:
1845 * <ul>
1846 * <li><em>count</em> - The number of items in the data set. This is the
1847 * same as the number of items in the cursor returned by querying the
1848 * data URI. </li>
1849 * </ul>
1850 *
1851 * This intent will be sent at boot (if the count is non-zero) and when the
1852 * data set changes. It is possible for the data set to change without the
1853 * count changing (for example, if a new unread message arrives in the same
1854 * sync operation in which a message is archived). The phone should still
1855 * ring/vibrate/etc as normal in this case.
1856 */
1857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1858 public static final String ACTION_PROVIDER_CHANGED =
1859 "android.intent.action.PROVIDER_CHANGED";
1860
1861 /**
1862 * Broadcast Action: Wired Headset plugged in or unplugged.
1863 *
1864 * <p>The intent will have the following extra values:
1865 * <ul>
1866 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1867 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001868 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001869 * </ul>
1870 * </ul>
1871 */
1872 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1873 public static final String ACTION_HEADSET_PLUG =
1874 "android.intent.action.HEADSET_PLUG";
1875
1876 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001877 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
1878 *
1879 * <p>The intent will have the following extra values:
1880 * <ul>
1881 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1882 * <li><em>name</em> - Headset type, human readable string </li>
1883 * </ul>
1884 * </ul>
1885 * @hide
1886 */
1887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1888 public static final String ACTION_USB_ANLG_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08001889 "android.intent.action.USB_ANLG_HEADSET_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001890
1891 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07001892 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001893 *
1894 * <p>The intent will have the following extra values:
1895 * <ul>
1896 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1897 * <li><em>name</em> - Headset type, human readable string </li>
1898 * </ul>
1899 * </ul>
1900 * @hide
1901 */
1902 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1903 public static final String ACTION_USB_DGTL_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08001904 "android.intent.action.USB_DGTL_HEADSET_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07001905
1906 /**
1907 * Broadcast Action: A HMDI cable was plugged or unplugged
1908 *
1909 * <p>The intent will have the following extra values:
1910 * <ul>
1911 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1912 * <li><em>name</em> - HDMI cable, human readable string </li>
1913 * </ul>
1914 * </ul>
1915 * @hide
1916 */
1917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1918 public static final String ACTION_HDMI_AUDIO_PLUG =
1919 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001920
1921 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07001922 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
1923 * <ul>
1924 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
1925 * </ul>
1926 *
1927 * <p class="note">This is a protected intent that can only be sent
1928 * by the system.
1929 *
1930 * @hide
1931 */
1932 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1933 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
1934 = "android.intent.action.ADVANCED_SETTINGS";
1935
1936 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001937 * Broadcast Action: An outgoing call is about to be placed.
1938 *
1939 * <p>The Intent will have the following extra value:
1940 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07001941 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001942 * the phone number originally intended to be dialed.</li>
1943 * </ul>
1944 * <p>Once the broadcast is finished, the resultData is used as the actual
1945 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07001946 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001947 * outgoing call in turn: for example, a parental control application
1948 * might verify that the user is authorized to place the call at that
1949 * time, then a number-rewriting application might add an area code if
1950 * one was not specified.</p>
1951 * <p>For consistency, any receiver whose purpose is to prohibit phone
1952 * calls should have a priority of 0, to ensure it will see the final
1953 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07001954 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001955 * should have a positive priority.
1956 * Negative priorities are reserved for the system for this broadcast;
1957 * using them may cause problems.</p>
1958 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
1959 * abort the broadcast.</p>
1960 * <p>Emergency calls cannot be intercepted using this mechanism, and
1961 * other calls cannot be modified to call emergency numbers using this
1962 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07001963 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
1965 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08001966 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001967 * <p class="note">This is a protected intent that can only be sent
1968 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001969 */
1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1971 public static final String ACTION_NEW_OUTGOING_CALL =
1972 "android.intent.action.NEW_OUTGOING_CALL";
1973
1974 /**
1975 * Broadcast Action: Have the device reboot. This is only for use by
1976 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08001977 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001978 * <p class="note">This is a protected intent that can only be sent
1979 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001980 */
1981 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1982 public static final String ACTION_REBOOT =
1983 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001984
Wei Huang97ecc9c2009-05-11 17:44:20 -07001985 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08001986 * Broadcast Action: A sticky broadcast for changes in the physical
1987 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08001988 *
1989 * <p>The intent will have the following extra values:
1990 * <ul>
1991 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08001992 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08001993 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08001994 * <p>This is intended for monitoring the current physical dock state.
1995 * See {@link android.app.UiModeManager} for the normal API dealing with
1996 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001997 */
1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1999 public static final String ACTION_DOCK_EVENT =
2000 "android.intent.action.DOCK_EVENT";
2001
2002 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002003 * Broadcast Action: a remote intent is to be broadcasted.
2004 *
2005 * A remote intent is used for remote RPC between devices. The remote intent
2006 * is serialized and sent from one device to another device. The receiving
2007 * device parses the remote intent and broadcasts it. Note that anyone can
2008 * broadcast a remote intent. However, if the intent receiver of the remote intent
2009 * does not trust intent broadcasts from arbitrary intent senders, it should require
2010 * the sender to hold certain permissions so only trusted sender's broadcast will be
2011 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002012 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002013 */
2014 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002015 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002016
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002017 /**
2018 * Broadcast Action: hook for permforming cleanup after a system update.
2019 *
2020 * The broadcast is sent when the system is booting, before the
2021 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2022 * image. A receiver for this should do its work and then disable itself
2023 * so that it does not get run again at the next boot.
2024 * @hide
2025 */
2026 public static final String ACTION_PRE_BOOT_COMPLETED =
2027 "android.intent.action.PRE_BOOT_COMPLETED";
2028
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002029 // ---------------------------------------------------------------------
2030 // ---------------------------------------------------------------------
2031 // Standard intent categories (see addCategory()).
2032
2033 /**
2034 * Set if the activity should be an option for the default action
2035 * (center press) to perform on a piece of data. Setting this will
2036 * hide from the user any activities without it set when performing an
2037 * action on some data. Note that this is normal -not- set in the
2038 * Intent when initiating an action -- it is for use in intent filters
2039 * specified in packages.
2040 */
2041 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2042 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2043 /**
2044 * Activities that can be safely invoked from a browser must support this
2045 * category. For example, if the user is viewing a web page or an e-mail
2046 * and clicks on a link in the text, the Intent generated execute that
2047 * link will require the BROWSABLE category, so that only activities
2048 * supporting this category will be considered as possible actions. By
2049 * supporting this category, you are promising that there is nothing
2050 * damaging (without user intervention) that can happen by invoking any
2051 * matching Intent.
2052 */
2053 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2054 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2055 /**
2056 * Set if the activity should be considered as an alternative action to
2057 * the data the user is currently viewing. See also
2058 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2059 * applies to the selection in a list of items.
2060 *
2061 * <p>Supporting this category means that you would like your activity to be
2062 * displayed in the set of alternative things the user can do, usually as
2063 * part of the current activity's options menu. You will usually want to
2064 * include a specific label in the &lt;intent-filter&gt; of this action
2065 * describing to the user what it does.
2066 *
2067 * <p>The action of IntentFilter with this category is important in that it
2068 * describes the specific action the target will perform. This generally
2069 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2070 * a specific name such as "com.android.camera.action.CROP. Only one
2071 * alternative of any particular action will be shown to the user, so using
2072 * a specific action like this makes sure that your alternative will be
2073 * displayed while also allowing other applications to provide their own
2074 * overrides of that particular action.
2075 */
2076 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2077 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2078 /**
2079 * Set if the activity should be considered as an alternative selection
2080 * action to the data the user has currently selected. This is like
2081 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2082 * of items from which the user can select, giving them alternatives to the
2083 * default action that will be performed on it.
2084 */
2085 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2086 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2087 /**
2088 * Intended to be used as a tab inside of an containing TabActivity.
2089 */
2090 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2091 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2092 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002093 * Should be displayed in the top-level launcher.
2094 */
2095 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2096 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2097 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098 * Provides information about the package it is in; typically used if
2099 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2100 * a front-door to the user without having to be shown in the all apps list.
2101 */
2102 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2103 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2104 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002105 * This is the home activity, that is the first activity that is displayed
2106 * when the device boots.
2107 */
2108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2109 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2110 /**
2111 * This activity is a preference panel.
2112 */
2113 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2114 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2115 /**
2116 * This activity is a development preference panel.
2117 */
2118 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2119 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2120 /**
2121 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002122 */
2123 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2124 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2125 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002126 * This activity allows the user to browse and download new applications.
2127 */
2128 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2129 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2130 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002131 * This activity may be exercised by the monkey or other automated test tools.
2132 */
2133 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2134 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2135 /**
2136 * To be used as a test (not part of the normal user experience).
2137 */
2138 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2139 /**
2140 * To be used as a unit test (run through the Test Harness).
2141 */
2142 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2143 /**
2144 * To be used as an sample code example (not part of the normal user
2145 * experience).
2146 */
2147 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2148 /**
2149 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2150 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2151 * when queried, though it is allowable for those columns to be blank.
2152 */
2153 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2154 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2155
2156 /**
2157 * To be used as code under test for framework instrumentation tests.
2158 */
2159 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2160 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002161 /**
2162 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002163 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2164 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002165 */
2166 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2167 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2168 /**
2169 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002170 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2171 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002172 */
2173 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2174 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002175 /**
2176 * An activity to run when device is inserted into a analog (low end) dock.
2177 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2178 * information, see {@link android.app.UiModeManager}.
2179 */
2180 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2181 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2182
2183 /**
2184 * An activity to run when device is inserted into a digital (high end) dock.
2185 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2186 * information, see {@link android.app.UiModeManager}.
2187 */
2188 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2189 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002190
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002191 /**
2192 * Used to indicate that the activity can be used in a car environment.
2193 */
2194 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2195 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2196
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002197 // ---------------------------------------------------------------------
2198 // ---------------------------------------------------------------------
2199 // Standard extra data keys.
2200
2201 /**
2202 * The initial data to place in a newly created record. Use with
2203 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2204 * fields as would be given to the underlying ContentProvider.insert()
2205 * call.
2206 */
2207 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2208
2209 /**
2210 * A constant CharSequence that is associated with the Intent, used with
2211 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2212 * this may be a styled CharSequence, so you must use
2213 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2214 * retrieve it.
2215 */
2216 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2217
2218 /**
2219 * A content: URI holding a stream of data associated with the Intent,
2220 * used with {@link #ACTION_SEND} to supply the data being sent.
2221 */
2222 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2223
2224 /**
2225 * A String[] holding e-mail addresses that should be delivered to.
2226 */
2227 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2228
2229 /**
2230 * A String[] holding e-mail addresses that should be carbon copied.
2231 */
2232 public static final String EXTRA_CC = "android.intent.extra.CC";
2233
2234 /**
2235 * A String[] holding e-mail addresses that should be blind carbon copied.
2236 */
2237 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2238
2239 /**
2240 * A constant string holding the desired subject line of a message.
2241 */
2242 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2243
2244 /**
2245 * An Intent describing the choices you would like shown with
2246 * {@link #ACTION_PICK_ACTIVITY}.
2247 */
2248 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2249
2250 /**
2251 * A CharSequence dialog title to provide to the user when used with a
2252 * {@link #ACTION_CHOOSER}.
2253 */
2254 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2255
2256 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002257 * A Parcelable[] of {@link Intent} or
2258 * {@link android.content.pm.LabeledIntent} objects as set with
2259 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2260 * a the front of the list of choices, when shown to the user with a
2261 * {@link #ACTION_CHOOSER}.
2262 */
2263 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2264
2265 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002266 * A {@link android.view.KeyEvent} object containing the event that
2267 * triggered the creation of the Intent it is in.
2268 */
2269 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2270
2271 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002272 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2273 * before shutting down.
2274 *
2275 * {@hide}
2276 */
2277 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2278
2279 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002280 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2281 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2282 * of restarting the application.
2283 */
2284 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2285
2286 /**
2287 * A String holding the phone number originally entered in
2288 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2289 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2290 */
2291 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002293 /**
2294 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2295 * intents to supply the uid the package had been assigned. Also an optional
2296 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2297 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2298 * purpose.
2299 */
2300 public static final String EXTRA_UID = "android.intent.extra.UID";
2301
2302 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002303 * @hide String array of package names.
2304 */
2305 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2306
2307 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002308 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2309 * intents to indicate whether this represents a full uninstall (removing
2310 * both the code and its data) or a partial uninstall (leaving its data,
2311 * implying that this is an update).
2312 */
2313 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002314
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002315 /**
2316 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2317 * intents to indicate that this is a replacement of the package, so this
2318 * broadcast will immediately be followed by an add broadcast for a
2319 * different version of the same package.
2320 */
2321 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002322
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002323 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 * Used as an int extra field in {@link android.app.AlarmManager} intents
2325 * to tell the application being invoked how many pending alarms are being
2326 * delievered with the intent. For one-shot alarms this will always be 1.
2327 * For recurring alarms, this might be greater than 1 if the device was
2328 * asleep or powered off at the time an earlier alarm would have been
2329 * delivered.
2330 */
2331 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002332
Jacek Surazski86b6c532009-05-13 14:38:28 +02002333 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002334 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2335 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002336 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2337 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002338 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
2339 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
2340 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002341 */
2342 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2343
2344 /**
2345 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2346 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002347 */
2348 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2349
2350 /**
2351 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2352 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002353 */
2354 public static final int EXTRA_DOCK_STATE_DESK = 1;
2355
2356 /**
2357 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2358 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002359 */
2360 public static final int EXTRA_DOCK_STATE_CAR = 2;
2361
2362 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002363 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2364 * to represent that the phone is in a analog (low end) dock.
2365 */
2366 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
2367
2368 /**
2369 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2370 * to represent that the phone is in a digital (high end) dock.
2371 */
2372 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
2373
2374 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002375 * Boolean that can be supplied as meta-data with a dock activity, to
2376 * indicate that the dock should take over the home key when it is active.
2377 */
2378 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002379
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002380 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002381 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2382 * the bug report.
Romain Guy4969af72009-06-17 10:53:19 -07002383 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002384 * @hide
2385 */
2386 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2387
2388 /**
Romain Guy4969af72009-06-17 10:53:19 -07002389 * Used as a string extra field when sending an intent to PackageInstaller to install a
Jacek Surazski86b6c532009-05-13 14:38:28 +02002390 * package. Specifies the installer package name; this package will receive the
2391 * {@link #ACTION_APP_ERROR} intent.
Romain Guy4969af72009-06-17 10:53:19 -07002392 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002393 * @hide
2394 */
Romain Guy4969af72009-06-17 10:53:19 -07002395 public static final String EXTRA_INSTALLER_PACKAGE_NAME
Jacek Surazski86b6c532009-05-13 14:38:28 +02002396 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002397
Wei Huang97ecc9c2009-05-11 17:44:20 -07002398 /**
2399 * Used in the extra field in the remote intent. It's astring token passed with the
2400 * remote intent.
2401 */
2402 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2403 "android.intent.extra.remote_intent_token";
2404
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002405 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002406 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002407 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002408 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002409 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002410 "android.intent.extra.changed_component_name";
2411
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002412 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002413 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002414 * and contains a string array of all of the components that have changed.
2415 */
2416 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2417 "android.intent.extra.changed_component_name_list";
2418
2419 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002420 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002421 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2422 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002423 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002424 */
2425 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2426 "android.intent.extra.changed_package_list";
2427
2428 /**
2429 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002430 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2431 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002432 * and contains an integer array of uids of all of the components
2433 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002434 */
2435 public static final String EXTRA_CHANGED_UID_LIST =
2436 "android.intent.extra.changed_uid_list";
2437
2438 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002439 * @hide
2440 * Magic extra system code can use when binding, to give a label for
2441 * who it is that has bound to a service. This is an integer giving
2442 * a framework string resource that can be displayed to the user.
2443 */
2444 public static final String EXTRA_CLIENT_LABEL =
2445 "android.intent.extra.client_label";
2446
2447 /**
2448 * @hide
2449 * Magic extra system code can use when binding, to give a PendingIntent object
2450 * that can be launched for the user to disable the system's use of this
2451 * service.
2452 */
2453 public static final String EXTRA_CLIENT_INTENT =
2454 "android.intent.extra.client_intent";
2455
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08002456 /**
2457 * Used to indicate that a {@link #ACTION_GET_CONTENT} intent should only return
2458 * data that is on the local device. This is a boolean extra; the default
2459 * is false. If true, an implementation of ACTION_GET_CONTENT should only allow
2460 * the user to select media that is already on the device, not requiring it
2461 * be downloaded from a remote service when opened. Another way to look
2462 * at it is that such content should generally have a "_data" column to the
2463 * path of the content on local external storage.
2464 */
2465 public static final String EXTRA_LOCAL_ONLY =
2466 "android.intent.extra.LOCAL_ONLY";
2467
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002468 // ---------------------------------------------------------------------
2469 // ---------------------------------------------------------------------
2470 // Intent flags (see mFlags variable).
2471
2472 /**
2473 * If set, the recipient of this Intent will be granted permission to
2474 * perform read operations on the Uri in the Intent's data.
2475 */
2476 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2477 /**
2478 * If set, the recipient of this Intent will be granted permission to
2479 * perform write operations on the Uri in the Intent's data.
2480 */
2481 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2482 /**
2483 * Can be set by the caller to indicate that this Intent is coming from
2484 * a background operation, not from direct user interaction.
2485 */
2486 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2487 /**
2488 * A flag you can enable for debugging: when set, log messages will be
2489 * printed during the resolution of this intent to show you what has
2490 * been found to create the final resolved list.
2491 */
2492 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08002493 /**
2494 * If set, this intent will not match any components in packages that
2495 * are currently stopped. If this is not set, then the default behavior
2496 * is to include such applications in the result.
2497 */
2498 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
2499 /**
2500 * If set, this intent will always match any components in packages that
2501 * are currently stopped. This is the default behavior when
2502 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
2503 * flags are set, this one wins (it allows overriding of exclude for
2504 * places where the framework may automatically set the exclude flag).
2505 */
2506 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002507
2508 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002509 * If set, the new activity is not kept in the history stack. As soon as
2510 * the user navigates away from it, the activity is finished. This may also
2511 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2512 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002513 */
2514 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2515 /**
2516 * If set, the activity will not be launched if it is already running
2517 * at the top of the history stack.
2518 */
2519 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2520 /**
2521 * If set, this activity will become the start of a new task on this
2522 * history stack. A task (from the activity that started it to the
2523 * next task activity) defines an atomic group of activities that the
2524 * user can move to. Tasks can be moved to the foreground and background;
2525 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002526 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08002527 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2528 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002529 *
2530 * <p>This flag is generally used by activities that want
2531 * to present a "launcher" style behavior: they give the user a list of
2532 * separate things that can be done, which otherwise run completely
2533 * independently of the activity launching them.
2534 *
2535 * <p>When using this flag, if a task is already running for the activity
2536 * you are now starting, then a new activity will not be started; instead,
2537 * the current task will simply be brought to the front of the screen with
2538 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2539 * to disable this behavior.
2540 *
2541 * <p>This flag can not be used when the caller is requesting a result from
2542 * the activity being launched.
2543 */
2544 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2545 /**
2546 * <strong>Do not use this flag unless you are implementing your own
2547 * top-level application launcher.</strong> Used in conjunction with
2548 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2549 * behavior of bringing an existing task to the foreground. When set,
2550 * a new task is <em>always</em> started to host the Activity for the
2551 * Intent, regardless of whether there is already an existing task running
2552 * the same thing.
2553 *
2554 * <p><strong>Because the default system does not include graphical task management,
2555 * you should not use this flag unless you provide some way for a user to
2556 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002557 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002558 * <p>This flag is ignored if
2559 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2560 *
Scott Main7aee61f2011-02-08 11:25:01 -08002561 * <p>See
2562 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2563 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002564 */
2565 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2566 /**
2567 * If set, and the activity being launched is already running in the
2568 * current task, then instead of launching a new instance of that activity,
2569 * all of the other activities on top of it will be closed and this Intent
2570 * will be delivered to the (now on top) old activity as a new Intent.
2571 *
2572 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2573 * If D calls startActivity() with an Intent that resolves to the component
2574 * of activity B, then C and D will be finished and B receive the given
2575 * Intent, resulting in the stack now being: A, B.
2576 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002577 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002578 * either receive the new intent you are starting here in its
2579 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002580 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002581 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2582 * the same intent, then it will be finished and re-created; for all other
2583 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2584 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002585 *
2586 * <p>This launch mode can also be used to good effect in conjunction with
2587 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2588 * of a task, it will bring any currently running instance of that task
2589 * to the foreground, and then clear it to its root state. This is
2590 * especially useful, for example, when launching an activity from the
2591 * notification manager.
2592 *
Scott Main7aee61f2011-02-08 11:25:01 -08002593 * <p>See
2594 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2595 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002596 */
2597 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2598 /**
2599 * If set and this intent is being used to launch a new activity from an
2600 * existing one, then the reply target of the existing activity will be
2601 * transfered to the new activity. This way the new activity can call
2602 * {@link android.app.Activity#setResult} and have that result sent back to
2603 * the reply target of the original activity.
2604 */
2605 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2606 /**
2607 * If set and this intent is being used to launch a new activity from an
2608 * existing one, the current activity will not be counted as the top
2609 * activity for deciding whether the new intent should be delivered to
2610 * the top instead of starting a new one. The previous activity will
2611 * be used as the top, with the assumption being that the current activity
2612 * will finish itself immediately.
2613 */
2614 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2615 /**
2616 * If set, the new activity is not kept in the list of recently launched
2617 * activities.
2618 */
2619 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2620 /**
2621 * This flag is not normally set by application code, but set for you by
2622 * the system as described in the
2623 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2624 * launchMode} documentation for the singleTask mode.
2625 */
2626 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2627 /**
2628 * If set, and this activity is either being started in a new task or
2629 * bringing to the top an existing task, then it will be launched as
2630 * the front door of the task. This will result in the application of
2631 * any affinities needed to have that task in the proper state (either
2632 * moving activities to or from it), or simply resetting that task to
2633 * its initial state if needed.
2634 */
2635 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2636 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002637 * This flag is not normally set by application code, but set for you by
2638 * the system if this activity is being launched from history
2639 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002640 */
2641 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002642 /**
2643 * If set, this marks a point in the task's activity stack that should
2644 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002645 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002646 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2647 * the user re-launching it from home), this activity and all on top of
2648 * it will be finished so that the user does not return to them, but
2649 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002650 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002651 * <p>This is useful for cases where you have a logical break in your
2652 * application. For example, an e-mail application may have a command
2653 * to view an attachment, which launches an image view activity to
2654 * display it. This activity should be part of the e-mail application's
2655 * task, since it is a part of the task the user is involved in. However,
2656 * if the user leaves that task, and later selects the e-mail app from
2657 * home, we may like them to return to the conversation they were
2658 * viewing, not the picture attachment, since that is confusing. By
2659 * setting this flag when launching the image viewer, that viewer and
2660 * any activities it starts will be removed the next time the user returns
2661 * to mail.
2662 */
2663 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002664 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002665 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002666 * callback from occurring on the current frontmost activity before it is
2667 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002668 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002669 * <p>Typically, an activity can rely on that callback to indicate that an
2670 * explicit user action has caused their activity to be moved out of the
2671 * foreground. The callback marks an appropriate point in the activity's
2672 * lifecycle for it to dismiss any notifications that it intends to display
2673 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002674 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002675 * <p>If an activity is ever started via any non-user-driven events such as
2676 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2677 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002678 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002679 */
2680 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002681 /**
2682 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2683 * this flag will cause the launched activity to be brought to the front of its
2684 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002685 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002686 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2687 * If D calls startActivity() with an Intent that resolves to the component
2688 * of activity B, then B will be brought to the front of the history stack,
2689 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002690 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002691 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002692 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002693 */
2694 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002695 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002696 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2697 * this flag will prevent the system from applying an activity transition
2698 * animation to go to the next activity state. This doesn't mean an
2699 * animation will never run -- if another activity change happens that doesn't
2700 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002701 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002702 * when you are going to do a series of activity operations but the
2703 * animation seen by the user shouldn't be driven by the first activity
2704 * change but rather a later one.
2705 */
2706 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2707 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002708 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2709 * this flag will cause any existing task that would be associated with the
2710 * activity to be cleared before the activity is started. That is, the activity
2711 * becomes the new root of an otherwise empty task, and any old activities
2712 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2713 */
2714 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
2715 /**
2716 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2717 * this flag will cause a newly launching task to be placed on top of the current
2718 * home activity task (if there is one). That is, pressing back from the task
2719 * will always return the user to home even if that was not the last activity they
2720 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2721 */
2722 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
2723 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002724 * If set, when sending a broadcast only registered receivers will be
2725 * called -- no BroadcastReceiver components will be launched.
2726 */
2727 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002728 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002729 * If set, when sending a broadcast the new broadcast will replace
2730 * any existing pending broadcast that matches it. Matching is defined
2731 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2732 * true for the intents of the two broadcasts. When a match is found,
2733 * the new broadcast (and receivers associated with it) will replace the
2734 * existing one in the pending broadcast list, remaining at the same
2735 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002736 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002737 * <p>This flag is most typically used with sticky broadcasts, which
2738 * only care about delivering the most recent values of the broadcast
2739 * to their receivers.
2740 */
2741 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2742 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002743 * If set, when sending a broadcast <i>before boot has completed</i> only
2744 * registered receivers will be called -- no BroadcastReceiver components
2745 * will be launched. Sticky intent state will be recorded properly even
2746 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2747 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002748 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002749 * <p>This flag is only for use by system sevices as a convenience to
2750 * avoid having to implement a more complex mechanism around detection
2751 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002752 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002753 * @hide
2754 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002755 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002756 /**
2757 * Set when this broadcast is for a boot upgrade, a special mode that
2758 * allows the broadcast to be sent before the system is ready and launches
2759 * the app process with no providers running in it.
2760 * @hide
2761 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002762 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002763
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002764 /**
2765 * @hide Flags that can't be changed with PendingIntent.
2766 */
2767 public static final int IMMUTABLE_FLAGS =
2768 FLAG_GRANT_READ_URI_PERMISSION
2769 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002770
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002771 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002772 // ---------------------------------------------------------------------
2773 // toUri() and parseUri() options.
2774
2775 /**
2776 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2777 * always has the "intent:" scheme. This syntax can be used when you want
2778 * to later disambiguate between URIs that are intended to describe an
2779 * Intent vs. all others that should be treated as raw URIs. When used
2780 * with {@link #parseUri}, any other scheme will result in a generic
2781 * VIEW action for that raw URI.
2782 */
2783 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002784
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002785 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002786
2787 private String mAction;
2788 private Uri mData;
2789 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002790 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002791 private ComponentName mComponent;
2792 private int mFlags;
2793 private HashSet<String> mCategories;
2794 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002795 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002796
2797 // ---------------------------------------------------------------------
2798
2799 /**
2800 * Create an empty intent.
2801 */
2802 public Intent() {
2803 }
2804
2805 /**
2806 * Copy constructor.
2807 */
2808 public Intent(Intent o) {
2809 this.mAction = o.mAction;
2810 this.mData = o.mData;
2811 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002812 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 this.mComponent = o.mComponent;
2814 this.mFlags = o.mFlags;
2815 if (o.mCategories != null) {
2816 this.mCategories = new HashSet<String>(o.mCategories);
2817 }
2818 if (o.mExtras != null) {
2819 this.mExtras = new Bundle(o.mExtras);
2820 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002821 if (o.mSourceBounds != null) {
2822 this.mSourceBounds = new Rect(o.mSourceBounds);
2823 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002824 }
2825
2826 @Override
2827 public Object clone() {
2828 return new Intent(this);
2829 }
2830
2831 private Intent(Intent o, boolean all) {
2832 this.mAction = o.mAction;
2833 this.mData = o.mData;
2834 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002835 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002836 this.mComponent = o.mComponent;
2837 if (o.mCategories != null) {
2838 this.mCategories = new HashSet<String>(o.mCategories);
2839 }
2840 }
2841
2842 /**
2843 * Make a clone of only the parts of the Intent that are relevant for
2844 * filter matching: the action, data, type, component, and categories.
2845 */
2846 public Intent cloneFilter() {
2847 return new Intent(this, false);
2848 }
2849
2850 /**
2851 * Create an intent with a given action. All other fields (data, type,
2852 * class) are null. Note that the action <em>must</em> be in a
2853 * namespace because Intents are used globally in the system -- for
2854 * example the system VIEW action is android.intent.action.VIEW; an
2855 * application's custom action would be something like
2856 * com.google.app.myapp.CUSTOM_ACTION.
2857 *
2858 * @param action The Intent action, such as ACTION_VIEW.
2859 */
2860 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002861 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002862 }
2863
2864 /**
2865 * Create an intent with a given action and for a given data url. Note
2866 * that the action <em>must</em> be in a namespace because Intents are
2867 * used globally in the system -- for example the system VIEW action is
2868 * android.intent.action.VIEW; an application's custom action would be
2869 * something like com.google.app.myapp.CUSTOM_ACTION.
2870 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002871 * <p><em>Note: scheme and host name matching in the Android framework is
2872 * case-sensitive, unlike the formal RFC. As a result,
2873 * you should always ensure that you write your Uri with these elements
2874 * using lower case letters, and normalize any Uris you receive from
2875 * outside of Android to ensure the scheme and host is lower case.</em></p>
2876 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002877 * @param action The Intent action, such as ACTION_VIEW.
2878 * @param uri The Intent data URI.
2879 */
2880 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002881 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002882 mData = uri;
2883 }
2884
2885 /**
2886 * Create an intent for a specific component. All other fields (action, data,
2887 * type, class) are null, though they can be modified later with explicit
2888 * calls. This provides a convenient way to create an intent that is
2889 * intended to execute a hard-coded class name, rather than relying on the
2890 * system to find an appropriate class for you; see {@link #setComponent}
2891 * for more information on the repercussions of this.
2892 *
2893 * @param packageContext A Context of the application package implementing
2894 * this class.
2895 * @param cls The component class that is to be used for the intent.
2896 *
2897 * @see #setClass
2898 * @see #setComponent
2899 * @see #Intent(String, android.net.Uri , Context, Class)
2900 */
2901 public Intent(Context packageContext, Class<?> cls) {
2902 mComponent = new ComponentName(packageContext, cls);
2903 }
2904
2905 /**
2906 * Create an intent for a specific component with a specified action and data.
2907 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
2908 * construct the Intent and then calling {@link #setClass} to set its
2909 * class.
2910 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002911 * <p><em>Note: scheme and host name matching in the Android framework is
2912 * case-sensitive, unlike the formal RFC. As a result,
2913 * you should always ensure that you write your Uri with these elements
2914 * using lower case letters, and normalize any Uris you receive from
2915 * outside of Android to ensure the scheme and host is lower case.</em></p>
2916 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002917 * @param action The Intent action, such as ACTION_VIEW.
2918 * @param uri The Intent data URI.
2919 * @param packageContext A Context of the application package implementing
2920 * this class.
2921 * @param cls The component class that is to be used for the intent.
2922 *
2923 * @see #Intent(String, android.net.Uri)
2924 * @see #Intent(Context, Class)
2925 * @see #setClass
2926 * @see #setComponent
2927 */
2928 public Intent(String action, Uri uri,
2929 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002930 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002931 mData = uri;
2932 mComponent = new ComponentName(packageContext, cls);
2933 }
2934
2935 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08002936 * Create an intent to launch the main (root) activity of a task. This
2937 * is the Intent that is started when the application's is launched from
2938 * Home. For anything else that wants to launch an application in the
2939 * same way, it is important that they use an Intent structured the same
2940 * way, and can use this function to ensure this is the case.
2941 *
2942 * <p>The returned Intent has the given Activity component as its explicit
2943 * component, {@link #ACTION_MAIN} as its action, and includes the
2944 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
2945 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
2946 * to do that through {@link #addFlags(int)} on the returned Intent.
2947 *
2948 * @param mainActivity The main activity component that this Intent will
2949 * launch.
2950 * @return Returns a newly created Intent that can be used to launch the
2951 * activity as a main application entry.
2952 *
2953 * @see #setClass
2954 * @see #setComponent
2955 */
2956 public static Intent makeMainActivity(ComponentName mainActivity) {
2957 Intent intent = new Intent(ACTION_MAIN);
2958 intent.setComponent(mainActivity);
2959 intent.addCategory(CATEGORY_LAUNCHER);
2960 return intent;
2961 }
2962
2963 /**
2964 * Make an Intent that can be used to re-launch an application's task
2965 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
2966 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
2967 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
2968 *
2969 * @param mainActivity The activity component that is the root of the
2970 * task; this is the activity that has been published in the application's
2971 * manifest as the main launcher icon.
2972 *
2973 * @return Returns a newly created Intent that can be used to relaunch the
2974 * activity's task in its root state.
2975 */
2976 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
2977 Intent intent = makeMainActivity(mainActivity);
2978 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
2979 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
2980 return intent;
2981 }
2982
2983 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002984 * Call {@link #parseUri} with 0 flags.
2985 * @deprecated Use {@link #parseUri} instead.
2986 */
2987 @Deprecated
2988 public static Intent getIntent(String uri) throws URISyntaxException {
2989 return parseUri(uri, 0);
2990 }
Tom Taylord4a47292009-12-21 13:59:18 -08002991
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002992 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002993 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002994 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07002995 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002996 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002997 *
2998 * <p>The URI given here must not be relative -- that is, it must include
2999 * the scheme and full path.
3000 *
3001 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003002 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003003 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003004 *
3005 * @return Intent The newly created Intent object.
3006 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003007 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
3008 * it bad (as parsed by the Uri class) or the Intent data within the
3009 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08003010 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003011 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003012 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003013 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003014 int i = 0;
3015 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003016 // Validate intent scheme for if requested.
3017 if ((flags&URI_INTENT_SCHEME) != 0) {
3018 if (!uri.startsWith("intent:")) {
3019 Intent intent = new Intent(ACTION_VIEW);
3020 try {
3021 intent.setData(Uri.parse(uri));
3022 } catch (IllegalArgumentException e) {
3023 throw new URISyntaxException(uri, e.getMessage());
3024 }
3025 return intent;
3026 }
3027 }
Tom Taylord4a47292009-12-21 13:59:18 -08003028
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003029 // simple case
3030 i = uri.lastIndexOf("#");
3031 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
3032
3033 // old format Intent URI
3034 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07003035
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003036 // new format
3037 Intent intent = new Intent(ACTION_VIEW);
3038
3039 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003040 String data = i >= 0 ? uri.substring(0, i) : null;
3041 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003042 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07003043
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003044 // loop over contents of Intent, all name=value;
3045 while (!uri.startsWith("end", i)) {
3046 int eq = uri.indexOf('=', i);
3047 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003048 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003049
3050 // action
3051 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003052 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003053 }
3054
3055 // categories
3056 else if (uri.startsWith("category=", i)) {
3057 intent.addCategory(value);
3058 }
3059
3060 // type
3061 else if (uri.startsWith("type=", i)) {
3062 intent.mType = value;
3063 }
3064
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003065 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003066 else if (uri.startsWith("launchFlags=", i)) {
3067 intent.mFlags = Integer.decode(value).intValue();
3068 }
3069
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003070 // package
3071 else if (uri.startsWith("package=", i)) {
3072 intent.mPackage = value;
3073 }
3074
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003075 // component
3076 else if (uri.startsWith("component=", i)) {
3077 intent.mComponent = ComponentName.unflattenFromString(value);
3078 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003079
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003080 // scheme
3081 else if (uri.startsWith("scheme=", i)) {
3082 scheme = value;
3083 }
3084
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003085 // source bounds
3086 else if (uri.startsWith("sourceBounds=", i)) {
3087 intent.mSourceBounds = Rect.unflattenFromString(value);
3088 }
3089
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003090 // extra
3091 else {
3092 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003093 // create Bundle if it doesn't already exist
3094 if (intent.mExtras == null) intent.mExtras = new Bundle();
3095 Bundle b = intent.mExtras;
3096 // add EXTRA
3097 if (uri.startsWith("S.", i)) b.putString(key, value);
3098 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
3099 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
3100 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
3101 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
3102 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
3103 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
3104 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
3105 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
3106 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
3107 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003108
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003109 // move to the next item
3110 i = semi + 1;
3111 }
3112
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003113 if (data != null) {
3114 if (data.startsWith("intent:")) {
3115 data = data.substring(7);
3116 if (scheme != null) {
3117 data = scheme + ':' + data;
3118 }
3119 }
Tom Taylord4a47292009-12-21 13:59:18 -08003120
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003121 if (data.length() > 0) {
3122 try {
3123 intent.mData = Uri.parse(data);
3124 } catch (IllegalArgumentException e) {
3125 throw new URISyntaxException(uri, e.getMessage());
3126 }
3127 }
3128 }
Tom Taylord4a47292009-12-21 13:59:18 -08003129
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003130 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07003131
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003132 } catch (IndexOutOfBoundsException e) {
3133 throw new URISyntaxException(uri, "illegal Intent URI format", i);
3134 }
3135 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003136
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003137 public static Intent getIntentOld(String uri) throws URISyntaxException {
3138 Intent intent;
3139
3140 int i = uri.lastIndexOf('#');
3141 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003142 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003143 final int intentFragmentStart = i;
3144 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003145
3146 i++;
3147
3148 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003149 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003150 i += 7;
3151 int j = uri.indexOf(')', i);
3152 action = uri.substring(i, j);
3153 i = j + 1;
3154 }
3155
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003156 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003157
3158 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003159 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003160 i += 11;
3161 int j = uri.indexOf(')', i);
3162 while (i < j) {
3163 int sep = uri.indexOf('!', i);
3164 if (sep < 0) sep = j;
3165 if (i < sep) {
3166 intent.addCategory(uri.substring(i, sep));
3167 }
3168 i = sep + 1;
3169 }
3170 i = j + 1;
3171 }
3172
3173 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003174 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003175 i += 5;
3176 int j = uri.indexOf(')', i);
3177 intent.mType = uri.substring(i, j);
3178 i = j + 1;
3179 }
3180
3181 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003182 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003183 i += 12;
3184 int j = uri.indexOf(')', i);
3185 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
3186 i = j + 1;
3187 }
3188
3189 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003190 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003191 i += 10;
3192 int j = uri.indexOf(')', i);
3193 int sep = uri.indexOf('!', i);
3194 if (sep >= 0 && sep < j) {
3195 String pkg = uri.substring(i, sep);
3196 String cls = uri.substring(sep + 1, j);
3197 intent.mComponent = new ComponentName(pkg, cls);
3198 }
3199 i = j + 1;
3200 }
3201
3202 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003203 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003204 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07003205
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003206 final int closeParen = uri.indexOf(')', i);
3207 if (closeParen == -1) throw new URISyntaxException(uri,
3208 "EXTRA missing trailing ')'", i);
3209
3210 while (i < closeParen) {
3211 // fetch the key value
3212 int j = uri.indexOf('=', i);
3213 if (j <= i + 1 || i >= closeParen) {
3214 throw new URISyntaxException(uri, "EXTRA missing '='", i);
3215 }
3216 char type = uri.charAt(i);
3217 i++;
3218 String key = uri.substring(i, j);
3219 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07003220
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003221 // get type-value
3222 j = uri.indexOf('!', i);
3223 if (j == -1 || j >= closeParen) j = closeParen;
3224 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3225 String value = uri.substring(i, j);
3226 i = j;
3227
3228 // create Bundle if it doesn't already exist
3229 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07003230
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003231 // add item to bundle
3232 try {
3233 switch (type) {
3234 case 'S':
3235 intent.mExtras.putString(key, Uri.decode(value));
3236 break;
3237 case 'B':
3238 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
3239 break;
3240 case 'b':
3241 intent.mExtras.putByte(key, Byte.parseByte(value));
3242 break;
3243 case 'c':
3244 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
3245 break;
3246 case 'd':
3247 intent.mExtras.putDouble(key, Double.parseDouble(value));
3248 break;
3249 case 'f':
3250 intent.mExtras.putFloat(key, Float.parseFloat(value));
3251 break;
3252 case 'i':
3253 intent.mExtras.putInt(key, Integer.parseInt(value));
3254 break;
3255 case 'l':
3256 intent.mExtras.putLong(key, Long.parseLong(value));
3257 break;
3258 case 's':
3259 intent.mExtras.putShort(key, Short.parseShort(value));
3260 break;
3261 default:
3262 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3263 }
3264 } catch (NumberFormatException e) {
3265 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3266 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003267
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003268 char ch = uri.charAt(i);
3269 if (ch == ')') break;
3270 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3271 i++;
3272 }
3273 }
3274
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003275 if (isIntentFragment) {
3276 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3277 } else {
3278 intent.mData = Uri.parse(uri);
3279 }
Tom Taylord4a47292009-12-21 13:59:18 -08003280
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003281 if (intent.mAction == null) {
3282 // By default, if no action is specified, then use VIEW.
3283 intent.mAction = ACTION_VIEW;
3284 }
3285
3286 } else {
3287 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3288 }
3289
3290 return intent;
3291 }
3292
3293 /**
3294 * Retrieve the general action to be performed, such as
3295 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3296 * the information in the intent should be interpreted -- most importantly,
3297 * what to do with the data returned by {@link #getData}.
3298 *
3299 * @return The action of this intent or null if none is specified.
3300 *
3301 * @see #setAction
3302 */
3303 public String getAction() {
3304 return mAction;
3305 }
3306
3307 /**
3308 * Retrieve data this intent is operating on. This URI specifies the name
3309 * of the data; often it uses the content: scheme, specifying data in a
3310 * content provider. Other schemes may be handled by specific activities,
3311 * such as http: by the web browser.
3312 *
3313 * @return The URI of the data this intent is targeting or null.
3314 *
3315 * @see #getScheme
3316 * @see #setData
3317 */
3318 public Uri getData() {
3319 return mData;
3320 }
3321
3322 /**
3323 * The same as {@link #getData()}, but returns the URI as an encoded
3324 * String.
3325 */
3326 public String getDataString() {
3327 return mData != null ? mData.toString() : null;
3328 }
3329
3330 /**
3331 * Return the scheme portion of the intent's data. If the data is null or
3332 * does not include a scheme, null is returned. Otherwise, the scheme
3333 * prefix without the final ':' is returned, i.e. "http".
3334 *
3335 * <p>This is the same as calling getData().getScheme() (and checking for
3336 * null data).
3337 *
3338 * @return The scheme of this intent.
3339 *
3340 * @see #getData
3341 */
3342 public String getScheme() {
3343 return mData != null ? mData.getScheme() : null;
3344 }
3345
3346 /**
3347 * Retrieve any explicit MIME type included in the intent. This is usually
3348 * null, as the type is determined by the intent data.
3349 *
3350 * @return If a type was manually set, it is returned; else null is
3351 * returned.
3352 *
3353 * @see #resolveType(ContentResolver)
3354 * @see #setType
3355 */
3356 public String getType() {
3357 return mType;
3358 }
3359
3360 /**
3361 * Return the MIME data type of this intent. If the type field is
3362 * explicitly set, that is simply returned. Otherwise, if the data is set,
3363 * the type of that data is returned. If neither fields are set, a null is
3364 * returned.
3365 *
3366 * @return The MIME type of this intent.
3367 *
3368 * @see #getType
3369 * @see #resolveType(ContentResolver)
3370 */
3371 public String resolveType(Context context) {
3372 return resolveType(context.getContentResolver());
3373 }
3374
3375 /**
3376 * Return the MIME data type of this intent. If the type field is
3377 * explicitly set, that is simply returned. Otherwise, if the data is set,
3378 * the type of that data is returned. If neither fields are set, a null is
3379 * returned.
3380 *
3381 * @param resolver A ContentResolver that can be used to determine the MIME
3382 * type of the intent's data.
3383 *
3384 * @return The MIME type of this intent.
3385 *
3386 * @see #getType
3387 * @see #resolveType(Context)
3388 */
3389 public String resolveType(ContentResolver resolver) {
3390 if (mType != null) {
3391 return mType;
3392 }
3393 if (mData != null) {
3394 if ("content".equals(mData.getScheme())) {
3395 return resolver.getType(mData);
3396 }
3397 }
3398 return null;
3399 }
3400
3401 /**
3402 * Return the MIME data type of this intent, only if it will be needed for
3403 * intent resolution. This is not generally useful for application code;
3404 * it is used by the frameworks for communicating with back-end system
3405 * services.
3406 *
3407 * @param resolver A ContentResolver that can be used to determine the MIME
3408 * type of the intent's data.
3409 *
3410 * @return The MIME type of this intent, or null if it is unknown or not
3411 * needed.
3412 */
3413 public String resolveTypeIfNeeded(ContentResolver resolver) {
3414 if (mComponent != null) {
3415 return mType;
3416 }
3417 return resolveType(resolver);
3418 }
3419
3420 /**
3421 * Check if an category exists in the intent.
3422 *
3423 * @param category The category to check.
3424 *
3425 * @return boolean True if the intent contains the category, else false.
3426 *
3427 * @see #getCategories
3428 * @see #addCategory
3429 */
3430 public boolean hasCategory(String category) {
3431 return mCategories != null && mCategories.contains(category);
3432 }
3433
3434 /**
3435 * Return the set of all categories in the intent. If there are no categories,
3436 * returns NULL.
3437 *
3438 * @return Set The set of categories you can examine. Do not modify!
3439 *
3440 * @see #hasCategory
3441 * @see #addCategory
3442 */
3443 public Set<String> getCategories() {
3444 return mCategories;
3445 }
3446
3447 /**
3448 * Sets the ClassLoader that will be used when unmarshalling
3449 * any Parcelable values from the extras of this Intent.
3450 *
3451 * @param loader a ClassLoader, or null to use the default loader
3452 * at the time of unmarshalling.
3453 */
3454 public void setExtrasClassLoader(ClassLoader loader) {
3455 if (mExtras != null) {
3456 mExtras.setClassLoader(loader);
3457 }
3458 }
3459
3460 /**
3461 * Returns true if an extra value is associated with the given name.
3462 * @param name the extra's name
3463 * @return true if the given extra is present.
3464 */
3465 public boolean hasExtra(String name) {
3466 return mExtras != null && mExtras.containsKey(name);
3467 }
3468
3469 /**
3470 * Returns true if the Intent's extras contain a parcelled file descriptor.
3471 * @return true if the Intent contains a parcelled file descriptor.
3472 */
3473 public boolean hasFileDescriptors() {
3474 return mExtras != null && mExtras.hasFileDescriptors();
3475 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003476
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003477 /**
3478 * Retrieve extended data from the intent.
3479 *
3480 * @param name The name of the desired item.
3481 *
3482 * @return the value of an item that previously added with putExtra()
3483 * or null if none was found.
3484 *
3485 * @deprecated
3486 * @hide
3487 */
3488 @Deprecated
3489 public Object getExtra(String name) {
3490 return getExtra(name, null);
3491 }
3492
3493 /**
3494 * Retrieve extended data from the intent.
3495 *
3496 * @param name The name of the desired item.
3497 * @param defaultValue the value to be returned if no value of the desired
3498 * type is stored with the given name.
3499 *
3500 * @return the value of an item that previously added with putExtra()
3501 * or the default value if none was found.
3502 *
3503 * @see #putExtra(String, boolean)
3504 */
3505 public boolean getBooleanExtra(String name, boolean defaultValue) {
3506 return mExtras == null ? defaultValue :
3507 mExtras.getBoolean(name, defaultValue);
3508 }
3509
3510 /**
3511 * Retrieve extended data from the intent.
3512 *
3513 * @param name The name of the desired item.
3514 * @param defaultValue the value to be returned if no value of the desired
3515 * type is stored with the given name.
3516 *
3517 * @return the value of an item that previously added with putExtra()
3518 * or the default value if none was found.
3519 *
3520 * @see #putExtra(String, byte)
3521 */
3522 public byte getByteExtra(String name, byte defaultValue) {
3523 return mExtras == null ? defaultValue :
3524 mExtras.getByte(name, defaultValue);
3525 }
3526
3527 /**
3528 * Retrieve extended data from the intent.
3529 *
3530 * @param name The name of the desired item.
3531 * @param defaultValue the value to be returned if no value of the desired
3532 * type is stored with the given name.
3533 *
3534 * @return the value of an item that previously added with putExtra()
3535 * or the default value if none was found.
3536 *
3537 * @see #putExtra(String, short)
3538 */
3539 public short getShortExtra(String name, short defaultValue) {
3540 return mExtras == null ? defaultValue :
3541 mExtras.getShort(name, defaultValue);
3542 }
3543
3544 /**
3545 * Retrieve extended data from the intent.
3546 *
3547 * @param name The name of the desired item.
3548 * @param defaultValue the value to be returned if no value of the desired
3549 * type is stored with the given name.
3550 *
3551 * @return the value of an item that previously added with putExtra()
3552 * or the default value if none was found.
3553 *
3554 * @see #putExtra(String, char)
3555 */
3556 public char getCharExtra(String name, char defaultValue) {
3557 return mExtras == null ? defaultValue :
3558 mExtras.getChar(name, defaultValue);
3559 }
3560
3561 /**
3562 * Retrieve extended data from the intent.
3563 *
3564 * @param name The name of the desired item.
3565 * @param defaultValue the value to be returned if no value of the desired
3566 * type is stored with the given name.
3567 *
3568 * @return the value of an item that previously added with putExtra()
3569 * or the default value if none was found.
3570 *
3571 * @see #putExtra(String, int)
3572 */
3573 public int getIntExtra(String name, int defaultValue) {
3574 return mExtras == null ? defaultValue :
3575 mExtras.getInt(name, defaultValue);
3576 }
3577
3578 /**
3579 * Retrieve extended data from the intent.
3580 *
3581 * @param name The name of the desired item.
3582 * @param defaultValue the value to be returned if no value of the desired
3583 * type is stored with the given name.
3584 *
3585 * @return the value of an item that previously added with putExtra()
3586 * or the default value if none was found.
3587 *
3588 * @see #putExtra(String, long)
3589 */
3590 public long getLongExtra(String name, long defaultValue) {
3591 return mExtras == null ? defaultValue :
3592 mExtras.getLong(name, defaultValue);
3593 }
3594
3595 /**
3596 * Retrieve extended data from the intent.
3597 *
3598 * @param name The name of the desired item.
3599 * @param defaultValue the value to be returned if no value of the desired
3600 * type is stored with the given name.
3601 *
3602 * @return the value of an item that previously added with putExtra(),
3603 * or the default value if no such item is present
3604 *
3605 * @see #putExtra(String, float)
3606 */
3607 public float getFloatExtra(String name, float defaultValue) {
3608 return mExtras == null ? defaultValue :
3609 mExtras.getFloat(name, defaultValue);
3610 }
3611
3612 /**
3613 * Retrieve extended data from the intent.
3614 *
3615 * @param name The name of the desired item.
3616 * @param defaultValue the value to be returned if no value of the desired
3617 * type is stored with the given name.
3618 *
3619 * @return the value of an item that previously added with putExtra()
3620 * or the default value if none was found.
3621 *
3622 * @see #putExtra(String, double)
3623 */
3624 public double getDoubleExtra(String name, double defaultValue) {
3625 return mExtras == null ? defaultValue :
3626 mExtras.getDouble(name, defaultValue);
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 String value was found.
3636 *
3637 * @see #putExtra(String, String)
3638 */
3639 public String getStringExtra(String name) {
3640 return mExtras == null ? null : mExtras.getString(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 CharSequence value was found.
3650 *
3651 * @see #putExtra(String, CharSequence)
3652 */
3653 public CharSequence getCharSequenceExtra(String name) {
3654 return mExtras == null ? null : mExtras.getCharSequence(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()
3663 * or null if no Parcelable value was found.
3664 *
3665 * @see #putExtra(String, Parcelable)
3666 */
3667 public <T extends Parcelable> T getParcelableExtra(String name) {
3668 return mExtras == null ? null : mExtras.<T>getParcelable(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()
3677 * or null if no Parcelable[] value was found.
3678 *
3679 * @see #putExtra(String, Parcelable[])
3680 */
3681 public Parcelable[] getParcelableArrayExtra(String name) {
3682 return mExtras == null ? null : mExtras.getParcelableArray(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 ArrayList<Parcelable> value was found.
3692 *
3693 * @see #putParcelableArrayListExtra(String, ArrayList)
3694 */
3695 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3696 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(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 Serializable value was found.
3706 *
3707 * @see #putExtra(String, Serializable)
3708 */
3709 public Serializable getSerializableExtra(String name) {
3710 return mExtras == null ? null : mExtras.getSerializable(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 ArrayList<Integer> value was found.
3720 *
3721 * @see #putIntegerArrayListExtra(String, ArrayList)
3722 */
3723 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3724 return mExtras == null ? null : mExtras.getIntegerArrayList(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 ArrayList<String> value was found.
3734 *
3735 * @see #putStringArrayListExtra(String, ArrayList)
3736 */
3737 public ArrayList<String> getStringArrayListExtra(String name) {
3738 return mExtras == null ? null : mExtras.getStringArrayList(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()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003747 * or null if no ArrayList<CharSequence> value was found.
3748 *
3749 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3750 */
3751 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3752 return mExtras == null ? null : mExtras.getCharSequenceArrayList(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()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003761 * or null if no boolean array value was found.
3762 *
3763 * @see #putExtra(String, boolean[])
3764 */
3765 public boolean[] getBooleanArrayExtra(String name) {
3766 return mExtras == null ? null : mExtras.getBooleanArray(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 byte array value was found.
3776 *
3777 * @see #putExtra(String, byte[])
3778 */
3779 public byte[] getByteArrayExtra(String name) {
3780 return mExtras == null ? null : mExtras.getByteArray(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 short array value was found.
3790 *
3791 * @see #putExtra(String, short[])
3792 */
3793 public short[] getShortArrayExtra(String name) {
3794 return mExtras == null ? null : mExtras.getShortArray(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()
3803 * or null if no char array value was found.
3804 *
3805 * @see #putExtra(String, char[])
3806 */
3807 public char[] getCharArrayExtra(String name) {
3808 return mExtras == null ? null : mExtras.getCharArray(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()
3817 * or null if no int array value was found.
3818 *
3819 * @see #putExtra(String, int[])
3820 */
3821 public int[] getIntArrayExtra(String name) {
3822 return mExtras == null ? null : mExtras.getIntArray(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 long array value was found.
3832 *
3833 * @see #putExtra(String, long[])
3834 */
3835 public long[] getLongArrayExtra(String name) {
3836 return mExtras == null ? null : mExtras.getLongArray(name);
3837 }
3838
3839 /**
3840 * Retrieve extended data from the intent.
3841 *
3842 * @param name The name of the desired item.
3843 *
3844 * @return the value of an item that previously added with putExtra()
3845 * or null if no float array value was found.
3846 *
3847 * @see #putExtra(String, float[])
3848 */
3849 public float[] getFloatArrayExtra(String name) {
3850 return mExtras == null ? null : mExtras.getFloatArray(name);
3851 }
3852
3853 /**
3854 * Retrieve extended data from the intent.
3855 *
3856 * @param name The name of the desired item.
3857 *
3858 * @return the value of an item that previously added with putExtra()
3859 * or null if no double array value was found.
3860 *
3861 * @see #putExtra(String, double[])
3862 */
3863 public double[] getDoubleArrayExtra(String name) {
3864 return mExtras == null ? null : mExtras.getDoubleArray(name);
3865 }
3866
3867 /**
3868 * Retrieve extended data from the intent.
3869 *
3870 * @param name The name of the desired item.
3871 *
3872 * @return the value of an item that previously added with putExtra()
3873 * or null if no String array value was found.
3874 *
3875 * @see #putExtra(String, String[])
3876 */
3877 public String[] getStringArrayExtra(String name) {
3878 return mExtras == null ? null : mExtras.getStringArray(name);
3879 }
3880
3881 /**
3882 * Retrieve extended data from the intent.
3883 *
3884 * @param name The name of the desired item.
3885 *
3886 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003887 * or null if no CharSequence array value was found.
3888 *
3889 * @see #putExtra(String, CharSequence[])
3890 */
3891 public CharSequence[] getCharSequenceArrayExtra(String name) {
3892 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3893 }
3894
3895 /**
3896 * Retrieve extended data from the intent.
3897 *
3898 * @param name The name of the desired item.
3899 *
3900 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003901 * or null if no Bundle value was found.
3902 *
3903 * @see #putExtra(String, Bundle)
3904 */
3905 public Bundle getBundleExtra(String name) {
3906 return mExtras == null ? null : mExtras.getBundle(name);
3907 }
3908
3909 /**
3910 * Retrieve extended data from the intent.
3911 *
3912 * @param name The name of the desired item.
3913 *
3914 * @return the value of an item that previously added with putExtra()
3915 * or null if no IBinder value was found.
3916 *
3917 * @see #putExtra(String, IBinder)
3918 *
3919 * @deprecated
3920 * @hide
3921 */
3922 @Deprecated
3923 public IBinder getIBinderExtra(String name) {
3924 return mExtras == null ? null : mExtras.getIBinder(name);
3925 }
3926
3927 /**
3928 * Retrieve extended data from the intent.
3929 *
3930 * @param name The name of the desired item.
3931 * @param defaultValue The default value to return in case no item is
3932 * associated with the key 'name'
3933 *
3934 * @return the value of an item that previously added with putExtra()
3935 * or defaultValue if none was found.
3936 *
3937 * @see #putExtra
3938 *
3939 * @deprecated
3940 * @hide
3941 */
3942 @Deprecated
3943 public Object getExtra(String name, Object defaultValue) {
3944 Object result = defaultValue;
3945 if (mExtras != null) {
3946 Object result2 = mExtras.get(name);
3947 if (result2 != null) {
3948 result = result2;
3949 }
3950 }
3951
3952 return result;
3953 }
3954
3955 /**
3956 * Retrieves a map of extended data from the intent.
3957 *
3958 * @return the map of all extras previously added with putExtra(),
3959 * or null if none have been added.
3960 */
3961 public Bundle getExtras() {
3962 return (mExtras != null)
3963 ? new Bundle(mExtras)
3964 : null;
3965 }
3966
3967 /**
3968 * Retrieve any special flags associated with this intent. You will
3969 * normally just set them with {@link #setFlags} and let the system
3970 * take the appropriate action with them.
3971 *
3972 * @return int The currently set flags.
3973 *
3974 * @see #setFlags
3975 */
3976 public int getFlags() {
3977 return mFlags;
3978 }
3979
Dianne Hackborne7f97212011-02-24 14:40:20 -08003980 /** @hide */
3981 public boolean isExcludingStopped() {
3982 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
3983 == FLAG_EXCLUDE_STOPPED_PACKAGES;
3984 }
3985
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003986 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003987 * Retrieve the application package name this Intent is limited to. When
3988 * resolving an Intent, if non-null this limits the resolution to only
3989 * components in the given application package.
3990 *
3991 * @return The name of the application package for the Intent.
3992 *
3993 * @see #resolveActivity
3994 * @see #setPackage
3995 */
3996 public String getPackage() {
3997 return mPackage;
3998 }
3999
4000 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004001 * Retrieve the concrete component associated with the intent. When receiving
4002 * an intent, this is the component that was found to best handle it (that is,
4003 * yourself) and will always be non-null; in all other cases it will be
4004 * null unless explicitly set.
4005 *
4006 * @return The name of the application component to handle the intent.
4007 *
4008 * @see #resolveActivity
4009 * @see #setComponent
4010 */
4011 public ComponentName getComponent() {
4012 return mComponent;
4013 }
4014
4015 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004016 * Get the bounds of the sender of this intent, in screen coordinates. This can be
4017 * used as a hint to the receiver for animations and the like. Null means that there
4018 * is no source bounds.
4019 */
4020 public Rect getSourceBounds() {
4021 return mSourceBounds;
4022 }
4023
4024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004025 * Return the Activity component that should be used to handle this intent.
4026 * The appropriate component is determined based on the information in the
4027 * intent, evaluated as follows:
4028 *
4029 * <p>If {@link #getComponent} returns an explicit class, that is returned
4030 * without any further consideration.
4031 *
4032 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
4033 * category to be considered.
4034 *
4035 * <p>If {@link #getAction} is non-NULL, the activity must handle this
4036 * action.
4037 *
4038 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
4039 * this type.
4040 *
4041 * <p>If {@link #addCategory} has added any categories, the activity must
4042 * handle ALL of the categories specified.
4043 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004044 * <p>If {@link #getPackage} is non-NULL, only activity components in
4045 * that application package will be considered.
4046 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004047 * <p>If there are no activities that satisfy all of these conditions, a
4048 * null string is returned.
4049 *
4050 * <p>If multiple activities are found to satisfy the intent, the one with
4051 * the highest priority will be used. If there are multiple activities
4052 * with the same priority, the system will either pick the best activity
4053 * based on user preference, or resolve to a system class that will allow
4054 * the user to pick an activity and forward from there.
4055 *
4056 * <p>This method is implemented simply by calling
4057 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
4058 * true.</p>
4059 * <p> This API is called for you as part of starting an activity from an
4060 * intent. You do not normally need to call it yourself.</p>
4061 *
4062 * @param pm The package manager with which to resolve the Intent.
4063 *
4064 * @return Name of the component implementing an activity that can
4065 * display the intent.
4066 *
4067 * @see #setComponent
4068 * @see #getComponent
4069 * @see #resolveActivityInfo
4070 */
4071 public ComponentName resolveActivity(PackageManager pm) {
4072 if (mComponent != null) {
4073 return mComponent;
4074 }
4075
4076 ResolveInfo info = pm.resolveActivity(
4077 this, PackageManager.MATCH_DEFAULT_ONLY);
4078 if (info != null) {
4079 return new ComponentName(
4080 info.activityInfo.applicationInfo.packageName,
4081 info.activityInfo.name);
4082 }
4083
4084 return null;
4085 }
4086
4087 /**
4088 * Resolve the Intent into an {@link ActivityInfo}
4089 * describing the activity that should execute the intent. Resolution
4090 * follows the same rules as described for {@link #resolveActivity}, but
4091 * you get back the completely information about the resolved activity
4092 * instead of just its class name.
4093 *
4094 * @param pm The package manager with which to resolve the Intent.
4095 * @param flags Addition information to retrieve as per
4096 * {@link PackageManager#getActivityInfo(ComponentName, int)
4097 * PackageManager.getActivityInfo()}.
4098 *
4099 * @return PackageManager.ActivityInfo
4100 *
4101 * @see #resolveActivity
4102 */
4103 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
4104 ActivityInfo ai = null;
4105 if (mComponent != null) {
4106 try {
4107 ai = pm.getActivityInfo(mComponent, flags);
4108 } catch (PackageManager.NameNotFoundException e) {
4109 // ignore
4110 }
4111 } else {
4112 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004113 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004114 if (info != null) {
4115 ai = info.activityInfo;
4116 }
4117 }
4118
4119 return ai;
4120 }
4121
4122 /**
4123 * Set the general action to be performed.
4124 *
4125 * @param action An action name, such as ACTION_VIEW. Application-specific
4126 * actions should be prefixed with the vendor's package name.
4127 *
4128 * @return Returns the same Intent object, for chaining multiple calls
4129 * into a single statement.
4130 *
4131 * @see #getAction
4132 */
4133 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004134 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004135 return this;
4136 }
4137
4138 /**
4139 * Set the data this intent is operating on. This method automatically
4140 * clears any type that was previously set by {@link #setType}.
4141 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004142 * <p><em>Note: scheme and host name matching in the Android framework is
4143 * case-sensitive, unlike the formal RFC. As a result,
4144 * you should always ensure that you write your Uri with these elements
4145 * using lower case letters, and normalize any Uris you receive from
4146 * outside of Android to ensure the scheme and host is lower case.</em></p>
4147 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004148 * @param data The URI of the data this intent is now targeting.
4149 *
4150 * @return Returns the same Intent object, for chaining multiple calls
4151 * into a single statement.
4152 *
4153 * @see #getData
4154 * @see #setType
4155 * @see #setDataAndType
4156 */
4157 public Intent setData(Uri data) {
4158 mData = data;
4159 mType = null;
4160 return this;
4161 }
4162
4163 /**
4164 * Set an explicit MIME data type. This is used to create intents that
4165 * only specify a type and not data, for example to indicate the type of
4166 * data to return. This method automatically clears any data that was
4167 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07004168 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004169 * <p><em>Note: MIME type matching in the Android framework is
4170 * case-sensitive, unlike formal RFC MIME types. As a result,
4171 * you should always write your MIME types with lower case letters,
4172 * and any MIME types you receive from outside of Android should be
4173 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004174 *
4175 * @param type The MIME type of the data being handled by this intent.
4176 *
4177 * @return Returns the same Intent object, for chaining multiple calls
4178 * into a single statement.
4179 *
4180 * @see #getType
4181 * @see #setData
4182 * @see #setDataAndType
4183 */
4184 public Intent setType(String type) {
4185 mData = null;
4186 mType = type;
4187 return this;
4188 }
4189
4190 /**
4191 * (Usually optional) Set the data for the intent along with an explicit
4192 * MIME data type. This method should very rarely be used -- it allows you
4193 * to override the MIME type that would ordinarily be inferred from the
4194 * data with your own type given here.
4195 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004196 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
4197 * Android framework is case-sensitive, unlike the formal RFC definitions.
4198 * As a result, you should always write these elements with lower case letters,
4199 * and normalize any MIME types or Uris you receive from
4200 * outside of Android to ensure these elements are lower case before
4201 * supplying them here.</em></p>
4202 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004203 * @param data The URI of the data this intent is now targeting.
4204 * @param type The MIME type of the data being handled by this intent.
4205 *
4206 * @return Returns the same Intent object, for chaining multiple calls
4207 * into a single statement.
4208 *
4209 * @see #setData
4210 * @see #setType
4211 */
4212 public Intent setDataAndType(Uri data, String type) {
4213 mData = data;
4214 mType = type;
4215 return this;
4216 }
4217
4218 /**
4219 * Add a new category to the intent. Categories provide additional detail
4220 * about the action the intent is perform. When resolving an intent, only
4221 * activities that provide <em>all</em> of the requested categories will be
4222 * used.
4223 *
4224 * @param category The desired category. This can be either one of the
4225 * predefined Intent categories, or a custom category in your own
4226 * namespace.
4227 *
4228 * @return Returns the same Intent object, for chaining multiple calls
4229 * into a single statement.
4230 *
4231 * @see #hasCategory
4232 * @see #removeCategory
4233 */
4234 public Intent addCategory(String category) {
4235 if (mCategories == null) {
4236 mCategories = new HashSet<String>();
4237 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08004238 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004239 return this;
4240 }
4241
4242 /**
4243 * Remove an category from an intent.
4244 *
4245 * @param category The category to remove.
4246 *
4247 * @see #addCategory
4248 */
4249 public void removeCategory(String category) {
4250 if (mCategories != null) {
4251 mCategories.remove(category);
4252 if (mCategories.size() == 0) {
4253 mCategories = null;
4254 }
4255 }
4256 }
4257
4258 /**
4259 * Add extended data to the intent. The name must include a package
4260 * prefix, for example the app com.android.contacts would use names
4261 * like "com.android.contacts.ShowAll".
4262 *
4263 * @param name The name of the extra data, with package prefix.
4264 * @param value The boolean data value.
4265 *
4266 * @return Returns the same Intent object, for chaining multiple calls
4267 * into a single statement.
4268 *
4269 * @see #putExtras
4270 * @see #removeExtra
4271 * @see #getBooleanExtra(String, boolean)
4272 */
4273 public Intent putExtra(String name, boolean value) {
4274 if (mExtras == null) {
4275 mExtras = new Bundle();
4276 }
4277 mExtras.putBoolean(name, value);
4278 return this;
4279 }
4280
4281 /**
4282 * Add extended data to the intent. The name must include a package
4283 * prefix, for example the app com.android.contacts would use names
4284 * like "com.android.contacts.ShowAll".
4285 *
4286 * @param name The name of the extra data, with package prefix.
4287 * @param value The byte data value.
4288 *
4289 * @return Returns the same Intent object, for chaining multiple calls
4290 * into a single statement.
4291 *
4292 * @see #putExtras
4293 * @see #removeExtra
4294 * @see #getByteExtra(String, byte)
4295 */
4296 public Intent putExtra(String name, byte value) {
4297 if (mExtras == null) {
4298 mExtras = new Bundle();
4299 }
4300 mExtras.putByte(name, value);
4301 return this;
4302 }
4303
4304 /**
4305 * Add extended data to the intent. The name must include a package
4306 * prefix, for example the app com.android.contacts would use names
4307 * like "com.android.contacts.ShowAll".
4308 *
4309 * @param name The name of the extra data, with package prefix.
4310 * @param value The char data value.
4311 *
4312 * @return Returns the same Intent object, for chaining multiple calls
4313 * into a single statement.
4314 *
4315 * @see #putExtras
4316 * @see #removeExtra
4317 * @see #getCharExtra(String, char)
4318 */
4319 public Intent putExtra(String name, char value) {
4320 if (mExtras == null) {
4321 mExtras = new Bundle();
4322 }
4323 mExtras.putChar(name, value);
4324 return this;
4325 }
4326
4327 /**
4328 * Add extended data to the intent. The name must include a package
4329 * prefix, for example the app com.android.contacts would use names
4330 * like "com.android.contacts.ShowAll".
4331 *
4332 * @param name The name of the extra data, with package prefix.
4333 * @param value The short data value.
4334 *
4335 * @return Returns the same Intent object, for chaining multiple calls
4336 * into a single statement.
4337 *
4338 * @see #putExtras
4339 * @see #removeExtra
4340 * @see #getShortExtra(String, short)
4341 */
4342 public Intent putExtra(String name, short value) {
4343 if (mExtras == null) {
4344 mExtras = new Bundle();
4345 }
4346 mExtras.putShort(name, value);
4347 return this;
4348 }
4349
4350 /**
4351 * Add extended data to the intent. The name must include a package
4352 * prefix, for example the app com.android.contacts would use names
4353 * like "com.android.contacts.ShowAll".
4354 *
4355 * @param name The name of the extra data, with package prefix.
4356 * @param value The integer data value.
4357 *
4358 * @return Returns the same Intent object, for chaining multiple calls
4359 * into a single statement.
4360 *
4361 * @see #putExtras
4362 * @see #removeExtra
4363 * @see #getIntExtra(String, int)
4364 */
4365 public Intent putExtra(String name, int value) {
4366 if (mExtras == null) {
4367 mExtras = new Bundle();
4368 }
4369 mExtras.putInt(name, value);
4370 return this;
4371 }
4372
4373 /**
4374 * Add extended data to the intent. The name must include a package
4375 * prefix, for example the app com.android.contacts would use names
4376 * like "com.android.contacts.ShowAll".
4377 *
4378 * @param name The name of the extra data, with package prefix.
4379 * @param value The long data value.
4380 *
4381 * @return Returns the same Intent object, for chaining multiple calls
4382 * into a single statement.
4383 *
4384 * @see #putExtras
4385 * @see #removeExtra
4386 * @see #getLongExtra(String, long)
4387 */
4388 public Intent putExtra(String name, long value) {
4389 if (mExtras == null) {
4390 mExtras = new Bundle();
4391 }
4392 mExtras.putLong(name, value);
4393 return this;
4394 }
4395
4396 /**
4397 * Add extended data to the intent. The name must include a package
4398 * prefix, for example the app com.android.contacts would use names
4399 * like "com.android.contacts.ShowAll".
4400 *
4401 * @param name The name of the extra data, with package prefix.
4402 * @param value The float data value.
4403 *
4404 * @return Returns the same Intent object, for chaining multiple calls
4405 * into a single statement.
4406 *
4407 * @see #putExtras
4408 * @see #removeExtra
4409 * @see #getFloatExtra(String, float)
4410 */
4411 public Intent putExtra(String name, float value) {
4412 if (mExtras == null) {
4413 mExtras = new Bundle();
4414 }
4415 mExtras.putFloat(name, value);
4416 return this;
4417 }
4418
4419 /**
4420 * Add extended data to the intent. The name must include a package
4421 * prefix, for example the app com.android.contacts would use names
4422 * like "com.android.contacts.ShowAll".
4423 *
4424 * @param name The name of the extra data, with package prefix.
4425 * @param value The double data value.
4426 *
4427 * @return Returns the same Intent object, for chaining multiple calls
4428 * into a single statement.
4429 *
4430 * @see #putExtras
4431 * @see #removeExtra
4432 * @see #getDoubleExtra(String, double)
4433 */
4434 public Intent putExtra(String name, double value) {
4435 if (mExtras == null) {
4436 mExtras = new Bundle();
4437 }
4438 mExtras.putDouble(name, value);
4439 return this;
4440 }
4441
4442 /**
4443 * Add extended data to the intent. The name must include a package
4444 * prefix, for example the app com.android.contacts would use names
4445 * like "com.android.contacts.ShowAll".
4446 *
4447 * @param name The name of the extra data, with package prefix.
4448 * @param value The String data value.
4449 *
4450 * @return Returns the same Intent object, for chaining multiple calls
4451 * into a single statement.
4452 *
4453 * @see #putExtras
4454 * @see #removeExtra
4455 * @see #getStringExtra(String)
4456 */
4457 public Intent putExtra(String name, String value) {
4458 if (mExtras == null) {
4459 mExtras = new Bundle();
4460 }
4461 mExtras.putString(name, value);
4462 return this;
4463 }
4464
4465 /**
4466 * Add extended data to the intent. The name must include a package
4467 * prefix, for example the app com.android.contacts would use names
4468 * like "com.android.contacts.ShowAll".
4469 *
4470 * @param name The name of the extra data, with package prefix.
4471 * @param value The CharSequence data value.
4472 *
4473 * @return Returns the same Intent object, for chaining multiple calls
4474 * into a single statement.
4475 *
4476 * @see #putExtras
4477 * @see #removeExtra
4478 * @see #getCharSequenceExtra(String)
4479 */
4480 public Intent putExtra(String name, CharSequence value) {
4481 if (mExtras == null) {
4482 mExtras = new Bundle();
4483 }
4484 mExtras.putCharSequence(name, value);
4485 return this;
4486 }
4487
4488 /**
4489 * Add extended data to the intent. The name must include a package
4490 * prefix, for example the app com.android.contacts would use names
4491 * like "com.android.contacts.ShowAll".
4492 *
4493 * @param name The name of the extra data, with package prefix.
4494 * @param value The Parcelable data value.
4495 *
4496 * @return Returns the same Intent object, for chaining multiple calls
4497 * into a single statement.
4498 *
4499 * @see #putExtras
4500 * @see #removeExtra
4501 * @see #getParcelableExtra(String)
4502 */
4503 public Intent putExtra(String name, Parcelable value) {
4504 if (mExtras == null) {
4505 mExtras = new Bundle();
4506 }
4507 mExtras.putParcelable(name, value);
4508 return this;
4509 }
4510
4511 /**
4512 * Add extended data to the intent. The name must include a package
4513 * prefix, for example the app com.android.contacts would use names
4514 * like "com.android.contacts.ShowAll".
4515 *
4516 * @param name The name of the extra data, with package prefix.
4517 * @param value The Parcelable[] data value.
4518 *
4519 * @return Returns the same Intent object, for chaining multiple calls
4520 * into a single statement.
4521 *
4522 * @see #putExtras
4523 * @see #removeExtra
4524 * @see #getParcelableArrayExtra(String)
4525 */
4526 public Intent putExtra(String name, Parcelable[] value) {
4527 if (mExtras == null) {
4528 mExtras = new Bundle();
4529 }
4530 mExtras.putParcelableArray(name, value);
4531 return this;
4532 }
4533
4534 /**
4535 * Add extended data to the intent. The name must include a package
4536 * prefix, for example the app com.android.contacts would use names
4537 * like "com.android.contacts.ShowAll".
4538 *
4539 * @param name The name of the extra data, with package prefix.
4540 * @param value The ArrayList<Parcelable> data value.
4541 *
4542 * @return Returns the same Intent object, for chaining multiple calls
4543 * into a single statement.
4544 *
4545 * @see #putExtras
4546 * @see #removeExtra
4547 * @see #getParcelableArrayListExtra(String)
4548 */
4549 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4550 if (mExtras == null) {
4551 mExtras = new Bundle();
4552 }
4553 mExtras.putParcelableArrayList(name, value);
4554 return this;
4555 }
4556
4557 /**
4558 * Add extended data to the intent. The name must include a package
4559 * prefix, for example the app com.android.contacts would use names
4560 * like "com.android.contacts.ShowAll".
4561 *
4562 * @param name The name of the extra data, with package prefix.
4563 * @param value The ArrayList<Integer> data value.
4564 *
4565 * @return Returns the same Intent object, for chaining multiple calls
4566 * into a single statement.
4567 *
4568 * @see #putExtras
4569 * @see #removeExtra
4570 * @see #getIntegerArrayListExtra(String)
4571 */
4572 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4573 if (mExtras == null) {
4574 mExtras = new Bundle();
4575 }
4576 mExtras.putIntegerArrayList(name, value);
4577 return this;
4578 }
4579
4580 /**
4581 * Add extended data to the intent. The name must include a package
4582 * prefix, for example the app com.android.contacts would use names
4583 * like "com.android.contacts.ShowAll".
4584 *
4585 * @param name The name of the extra data, with package prefix.
4586 * @param value The ArrayList<String> data value.
4587 *
4588 * @return Returns the same Intent object, for chaining multiple calls
4589 * into a single statement.
4590 *
4591 * @see #putExtras
4592 * @see #removeExtra
4593 * @see #getStringArrayListExtra(String)
4594 */
4595 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4596 if (mExtras == null) {
4597 mExtras = new Bundle();
4598 }
4599 mExtras.putStringArrayList(name, value);
4600 return this;
4601 }
4602
4603 /**
4604 * Add extended data to the intent. The name must include a package
4605 * prefix, for example the app com.android.contacts would use names
4606 * like "com.android.contacts.ShowAll".
4607 *
4608 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004609 * @param value The ArrayList<CharSequence> data value.
4610 *
4611 * @return Returns the same Intent object, for chaining multiple calls
4612 * into a single statement.
4613 *
4614 * @see #putExtras
4615 * @see #removeExtra
4616 * @see #getCharSequenceArrayListExtra(String)
4617 */
4618 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4619 if (mExtras == null) {
4620 mExtras = new Bundle();
4621 }
4622 mExtras.putCharSequenceArrayList(name, value);
4623 return this;
4624 }
4625
4626 /**
4627 * Add extended data to the intent. The name must include a package
4628 * prefix, for example the app com.android.contacts would use names
4629 * like "com.android.contacts.ShowAll".
4630 *
4631 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004632 * @param value The Serializable data value.
4633 *
4634 * @return Returns the same Intent object, for chaining multiple calls
4635 * into a single statement.
4636 *
4637 * @see #putExtras
4638 * @see #removeExtra
4639 * @see #getSerializableExtra(String)
4640 */
4641 public Intent putExtra(String name, Serializable value) {
4642 if (mExtras == null) {
4643 mExtras = new Bundle();
4644 }
4645 mExtras.putSerializable(name, value);
4646 return this;
4647 }
4648
4649 /**
4650 * Add extended data to the intent. The name must include a package
4651 * prefix, for example the app com.android.contacts would use names
4652 * like "com.android.contacts.ShowAll".
4653 *
4654 * @param name The name of the extra data, with package prefix.
4655 * @param value The boolean array data value.
4656 *
4657 * @return Returns the same Intent object, for chaining multiple calls
4658 * into a single statement.
4659 *
4660 * @see #putExtras
4661 * @see #removeExtra
4662 * @see #getBooleanArrayExtra(String)
4663 */
4664 public Intent putExtra(String name, boolean[] value) {
4665 if (mExtras == null) {
4666 mExtras = new Bundle();
4667 }
4668 mExtras.putBooleanArray(name, value);
4669 return this;
4670 }
4671
4672 /**
4673 * Add extended data to the intent. The name must include a package
4674 * prefix, for example the app com.android.contacts would use names
4675 * like "com.android.contacts.ShowAll".
4676 *
4677 * @param name The name of the extra data, with package prefix.
4678 * @param value The byte array data value.
4679 *
4680 * @return Returns the same Intent object, for chaining multiple calls
4681 * into a single statement.
4682 *
4683 * @see #putExtras
4684 * @see #removeExtra
4685 * @see #getByteArrayExtra(String)
4686 */
4687 public Intent putExtra(String name, byte[] value) {
4688 if (mExtras == null) {
4689 mExtras = new Bundle();
4690 }
4691 mExtras.putByteArray(name, value);
4692 return this;
4693 }
4694
4695 /**
4696 * Add extended data to the intent. The name must include a package
4697 * prefix, for example the app com.android.contacts would use names
4698 * like "com.android.contacts.ShowAll".
4699 *
4700 * @param name The name of the extra data, with package prefix.
4701 * @param value The short array data value.
4702 *
4703 * @return Returns the same Intent object, for chaining multiple calls
4704 * into a single statement.
4705 *
4706 * @see #putExtras
4707 * @see #removeExtra
4708 * @see #getShortArrayExtra(String)
4709 */
4710 public Intent putExtra(String name, short[] value) {
4711 if (mExtras == null) {
4712 mExtras = new Bundle();
4713 }
4714 mExtras.putShortArray(name, value);
4715 return this;
4716 }
4717
4718 /**
4719 * Add extended data to the intent. The name must include a package
4720 * prefix, for example the app com.android.contacts would use names
4721 * like "com.android.contacts.ShowAll".
4722 *
4723 * @param name The name of the extra data, with package prefix.
4724 * @param value The char array data value.
4725 *
4726 * @return Returns the same Intent object, for chaining multiple calls
4727 * into a single statement.
4728 *
4729 * @see #putExtras
4730 * @see #removeExtra
4731 * @see #getCharArrayExtra(String)
4732 */
4733 public Intent putExtra(String name, char[] value) {
4734 if (mExtras == null) {
4735 mExtras = new Bundle();
4736 }
4737 mExtras.putCharArray(name, value);
4738 return this;
4739 }
4740
4741 /**
4742 * Add extended data to the intent. The name must include a package
4743 * prefix, for example the app com.android.contacts would use names
4744 * like "com.android.contacts.ShowAll".
4745 *
4746 * @param name The name of the extra data, with package prefix.
4747 * @param value The int array data value.
4748 *
4749 * @return Returns the same Intent object, for chaining multiple calls
4750 * into a single statement.
4751 *
4752 * @see #putExtras
4753 * @see #removeExtra
4754 * @see #getIntArrayExtra(String)
4755 */
4756 public Intent putExtra(String name, int[] value) {
4757 if (mExtras == null) {
4758 mExtras = new Bundle();
4759 }
4760 mExtras.putIntArray(name, value);
4761 return this;
4762 }
4763
4764 /**
4765 * Add extended data to the intent. The name must include a package
4766 * prefix, for example the app com.android.contacts would use names
4767 * like "com.android.contacts.ShowAll".
4768 *
4769 * @param name The name of the extra data, with package prefix.
4770 * @param value The byte array data value.
4771 *
4772 * @return Returns the same Intent object, for chaining multiple calls
4773 * into a single statement.
4774 *
4775 * @see #putExtras
4776 * @see #removeExtra
4777 * @see #getLongArrayExtra(String)
4778 */
4779 public Intent putExtra(String name, long[] value) {
4780 if (mExtras == null) {
4781 mExtras = new Bundle();
4782 }
4783 mExtras.putLongArray(name, value);
4784 return this;
4785 }
4786
4787 /**
4788 * Add extended data to the intent. The name must include a package
4789 * prefix, for example the app com.android.contacts would use names
4790 * like "com.android.contacts.ShowAll".
4791 *
4792 * @param name The name of the extra data, with package prefix.
4793 * @param value The float array data value.
4794 *
4795 * @return Returns the same Intent object, for chaining multiple calls
4796 * into a single statement.
4797 *
4798 * @see #putExtras
4799 * @see #removeExtra
4800 * @see #getFloatArrayExtra(String)
4801 */
4802 public Intent putExtra(String name, float[] value) {
4803 if (mExtras == null) {
4804 mExtras = new Bundle();
4805 }
4806 mExtras.putFloatArray(name, value);
4807 return this;
4808 }
4809
4810 /**
4811 * Add extended data to the intent. The name must include a package
4812 * prefix, for example the app com.android.contacts would use names
4813 * like "com.android.contacts.ShowAll".
4814 *
4815 * @param name The name of the extra data, with package prefix.
4816 * @param value The double array data value.
4817 *
4818 * @return Returns the same Intent object, for chaining multiple calls
4819 * into a single statement.
4820 *
4821 * @see #putExtras
4822 * @see #removeExtra
4823 * @see #getDoubleArrayExtra(String)
4824 */
4825 public Intent putExtra(String name, double[] value) {
4826 if (mExtras == null) {
4827 mExtras = new Bundle();
4828 }
4829 mExtras.putDoubleArray(name, value);
4830 return this;
4831 }
4832
4833 /**
4834 * Add extended data to the intent. The name must include a package
4835 * prefix, for example the app com.android.contacts would use names
4836 * like "com.android.contacts.ShowAll".
4837 *
4838 * @param name The name of the extra data, with package prefix.
4839 * @param value The String array data value.
4840 *
4841 * @return Returns the same Intent object, for chaining multiple calls
4842 * into a single statement.
4843 *
4844 * @see #putExtras
4845 * @see #removeExtra
4846 * @see #getStringArrayExtra(String)
4847 */
4848 public Intent putExtra(String name, String[] value) {
4849 if (mExtras == null) {
4850 mExtras = new Bundle();
4851 }
4852 mExtras.putStringArray(name, value);
4853 return this;
4854 }
4855
4856 /**
4857 * Add extended data to the intent. The name must include a package
4858 * prefix, for example the app com.android.contacts would use names
4859 * like "com.android.contacts.ShowAll".
4860 *
4861 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004862 * @param value The CharSequence array data value.
4863 *
4864 * @return Returns the same Intent object, for chaining multiple calls
4865 * into a single statement.
4866 *
4867 * @see #putExtras
4868 * @see #removeExtra
4869 * @see #getCharSequenceArrayExtra(String)
4870 */
4871 public Intent putExtra(String name, CharSequence[] value) {
4872 if (mExtras == null) {
4873 mExtras = new Bundle();
4874 }
4875 mExtras.putCharSequenceArray(name, value);
4876 return this;
4877 }
4878
4879 /**
4880 * Add extended data to the intent. The name must include a package
4881 * prefix, for example the app com.android.contacts would use names
4882 * like "com.android.contacts.ShowAll".
4883 *
4884 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004885 * @param value The Bundle data value.
4886 *
4887 * @return Returns the same Intent object, for chaining multiple calls
4888 * into a single statement.
4889 *
4890 * @see #putExtras
4891 * @see #removeExtra
4892 * @see #getBundleExtra(String)
4893 */
4894 public Intent putExtra(String name, Bundle value) {
4895 if (mExtras == null) {
4896 mExtras = new Bundle();
4897 }
4898 mExtras.putBundle(name, value);
4899 return this;
4900 }
4901
4902 /**
4903 * Add extended data to the intent. The name must include a package
4904 * prefix, for example the app com.android.contacts would use names
4905 * like "com.android.contacts.ShowAll".
4906 *
4907 * @param name The name of the extra data, with package prefix.
4908 * @param value The IBinder data value.
4909 *
4910 * @return Returns the same Intent object, for chaining multiple calls
4911 * into a single statement.
4912 *
4913 * @see #putExtras
4914 * @see #removeExtra
4915 * @see #getIBinderExtra(String)
4916 *
4917 * @deprecated
4918 * @hide
4919 */
4920 @Deprecated
4921 public Intent putExtra(String name, IBinder value) {
4922 if (mExtras == null) {
4923 mExtras = new Bundle();
4924 }
4925 mExtras.putIBinder(name, value);
4926 return this;
4927 }
4928
4929 /**
4930 * Copy all extras in 'src' in to this intent.
4931 *
4932 * @param src Contains the extras to copy.
4933 *
4934 * @see #putExtra
4935 */
4936 public Intent putExtras(Intent src) {
4937 if (src.mExtras != null) {
4938 if (mExtras == null) {
4939 mExtras = new Bundle(src.mExtras);
4940 } else {
4941 mExtras.putAll(src.mExtras);
4942 }
4943 }
4944 return this;
4945 }
4946
4947 /**
4948 * Add a set of extended data to the intent. The keys must include a package
4949 * prefix, for example the app com.android.contacts would use names
4950 * like "com.android.contacts.ShowAll".
4951 *
4952 * @param extras The Bundle of extras to add to this intent.
4953 *
4954 * @see #putExtra
4955 * @see #removeExtra
4956 */
4957 public Intent putExtras(Bundle extras) {
4958 if (mExtras == null) {
4959 mExtras = new Bundle();
4960 }
4961 mExtras.putAll(extras);
4962 return this;
4963 }
4964
4965 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004966 * Completely replace the extras in the Intent with the extras in the
4967 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07004968 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004969 * @param src The exact extras contained in this Intent are copied
4970 * into the target intent, replacing any that were previously there.
4971 */
4972 public Intent replaceExtras(Intent src) {
4973 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
4974 return this;
4975 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004976
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004977 /**
4978 * Completely replace the extras in the Intent with the given Bundle of
4979 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07004980 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004981 * @param extras The new set of extras in the Intent, or null to erase
4982 * all extras.
4983 */
4984 public Intent replaceExtras(Bundle extras) {
4985 mExtras = extras != null ? new Bundle(extras) : null;
4986 return this;
4987 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004988
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004989 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004990 * Remove extended data from the intent.
4991 *
4992 * @see #putExtra
4993 */
4994 public void removeExtra(String name) {
4995 if (mExtras != null) {
4996 mExtras.remove(name);
4997 if (mExtras.size() == 0) {
4998 mExtras = null;
4999 }
5000 }
5001 }
5002
5003 /**
5004 * Set special flags controlling how this intent is handled. Most values
5005 * here depend on the type of component being executed by the Intent,
5006 * specifically the FLAG_ACTIVITY_* flags are all for use with
5007 * {@link Context#startActivity Context.startActivity()} and the
5008 * FLAG_RECEIVER_* flags are all for use with
5009 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
5010 *
Scott Main7aee61f2011-02-08 11:25:01 -08005011 * <p>See the
5012 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5013 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 * the behavior of your application.
5015 *
5016 * @param flags The desired flags.
5017 *
5018 * @return Returns the same Intent object, for chaining multiple calls
5019 * into a single statement.
5020 *
5021 * @see #getFlags
5022 * @see #addFlags
5023 *
5024 * @see #FLAG_GRANT_READ_URI_PERMISSION
5025 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
5026 * @see #FLAG_DEBUG_LOG_RESOLUTION
5027 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005028 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005029 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005030 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005031 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005032 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
5033 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005034 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005035 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5036 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005037 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005038 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005039 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005040 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
5041 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005042 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005043 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005044 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005045 * @see #FLAG_RECEIVER_REGISTERED_ONLY
5046 */
5047 public Intent setFlags(int flags) {
5048 mFlags = flags;
5049 return this;
5050 }
5051
5052 /**
5053 * Add additional flags to the intent (or with existing flags
5054 * value).
5055 *
5056 * @param flags The new flags to set.
5057 *
5058 * @return Returns the same Intent object, for chaining multiple calls
5059 * into a single statement.
5060 *
5061 * @see #setFlags
5062 */
5063 public Intent addFlags(int flags) {
5064 mFlags |= flags;
5065 return this;
5066 }
5067
5068 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005069 * (Usually optional) Set an explicit application package name that limits
5070 * the components this Intent will resolve to. If left to the default
5071 * value of null, all components in all applications will considered.
5072 * If non-null, the Intent can only match the components in the given
5073 * application package.
5074 *
5075 * @param packageName The name of the application package to handle the
5076 * intent, or null to allow any application package.
5077 *
5078 * @return Returns the same Intent object, for chaining multiple calls
5079 * into a single statement.
5080 *
5081 * @see #getPackage
5082 * @see #resolveActivity
5083 */
5084 public Intent setPackage(String packageName) {
5085 mPackage = packageName;
5086 return this;
5087 }
5088
5089 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005090 * (Usually optional) Explicitly set the component to handle the intent.
5091 * If left with the default value of null, the system will determine the
5092 * appropriate class to use based on the other fields (action, data,
5093 * type, categories) in the Intent. If this class is defined, the
5094 * specified class will always be used regardless of the other fields. You
5095 * should only set this value when you know you absolutely want a specific
5096 * class to be used; otherwise it is better to let the system find the
5097 * appropriate class so that you will respect the installed applications
5098 * and user preferences.
5099 *
5100 * @param component The name of the application component to handle the
5101 * intent, or null to let the system find one for you.
5102 *
5103 * @return Returns the same Intent object, for chaining multiple calls
5104 * into a single statement.
5105 *
5106 * @see #setClass
5107 * @see #setClassName(Context, String)
5108 * @see #setClassName(String, String)
5109 * @see #getComponent
5110 * @see #resolveActivity
5111 */
5112 public Intent setComponent(ComponentName component) {
5113 mComponent = component;
5114 return this;
5115 }
5116
5117 /**
5118 * Convenience for calling {@link #setComponent} with an
5119 * explicit class name.
5120 *
5121 * @param packageContext A Context of the application package implementing
5122 * this class.
5123 * @param className The name of a class inside of the application package
5124 * that will be used as the component for this Intent.
5125 *
5126 * @return Returns the same Intent object, for chaining multiple calls
5127 * into a single statement.
5128 *
5129 * @see #setComponent
5130 * @see #setClass
5131 */
5132 public Intent setClassName(Context packageContext, String className) {
5133 mComponent = new ComponentName(packageContext, className);
5134 return this;
5135 }
5136
5137 /**
5138 * Convenience for calling {@link #setComponent} with an
5139 * explicit application package name and class name.
5140 *
5141 * @param packageName The name of the package implementing the desired
5142 * component.
5143 * @param className The name of a class inside of the application package
5144 * that will be used as the component for this Intent.
5145 *
5146 * @return Returns the same Intent object, for chaining multiple calls
5147 * into a single statement.
5148 *
5149 * @see #setComponent
5150 * @see #setClass
5151 */
5152 public Intent setClassName(String packageName, String className) {
5153 mComponent = new ComponentName(packageName, className);
5154 return this;
5155 }
5156
5157 /**
5158 * Convenience for calling {@link #setComponent(ComponentName)} with the
5159 * name returned by a {@link Class} object.
5160 *
5161 * @param packageContext A Context of the application package implementing
5162 * this class.
5163 * @param cls The class name to set, equivalent to
5164 * <code>setClassName(context, cls.getName())</code>.
5165 *
5166 * @return Returns the same Intent object, for chaining multiple calls
5167 * into a single statement.
5168 *
5169 * @see #setComponent
5170 */
5171 public Intent setClass(Context packageContext, Class<?> cls) {
5172 mComponent = new ComponentName(packageContext, cls);
5173 return this;
5174 }
5175
5176 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005177 * Set the bounds of the sender of this intent, in screen coordinates. This can be
5178 * used as a hint to the receiver for animations and the like. Null means that there
5179 * is no source bounds.
5180 */
5181 public void setSourceBounds(Rect r) {
5182 if (r != null) {
5183 mSourceBounds = new Rect(r);
5184 } else {
5185 r = null;
5186 }
5187 }
5188
5189 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005190 * Use with {@link #fillIn} to allow the current action value to be
5191 * overwritten, even if it is already set.
5192 */
5193 public static final int FILL_IN_ACTION = 1<<0;
5194
5195 /**
5196 * Use with {@link #fillIn} to allow the current data or type value
5197 * overwritten, even if it is already set.
5198 */
5199 public static final int FILL_IN_DATA = 1<<1;
5200
5201 /**
5202 * Use with {@link #fillIn} to allow the current categories to be
5203 * overwritten, even if they are already set.
5204 */
5205 public static final int FILL_IN_CATEGORIES = 1<<2;
5206
5207 /**
5208 * Use with {@link #fillIn} to allow the current component value to be
5209 * overwritten, even if it is already set.
5210 */
5211 public static final int FILL_IN_COMPONENT = 1<<3;
5212
5213 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005214 * Use with {@link #fillIn} to allow the current package value to be
5215 * overwritten, even if it is already set.
5216 */
5217 public static final int FILL_IN_PACKAGE = 1<<4;
5218
5219 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005220 * Use with {@link #fillIn} to allow the current package value to be
5221 * overwritten, even if it is already set.
5222 */
5223 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
5224
5225 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005226 * Copy the contents of <var>other</var> in to this object, but only
5227 * where fields are not defined by this object. For purposes of a field
5228 * being defined, the following pieces of data in the Intent are
5229 * considered to be separate fields:
5230 *
5231 * <ul>
5232 * <li> action, as set by {@link #setAction}.
5233 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
5234 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
5235 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005236 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005237 * <li> component, as set by {@link #setComponent(ComponentName)} or
5238 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005239 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005240 * <li> each top-level name in the associated extras.
5241 * </ul>
5242 *
5243 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005244 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5245 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005246 * corresponding field will not be replaced if it is already set.
5247 *
Brett Chabot3e391752009-07-21 16:07:23 -07005248 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
5249 * specified.
5250 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005251 * <p>For example, consider Intent A with {data="foo", categories="bar"}
5252 * and Intent B with {action="gotit", data-type="some/thing",
5253 * categories="one","two"}.
5254 *
5255 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
5256 * containing: {action="gotit", data-type="some/thing",
5257 * categories="bar"}.
5258 *
5259 * @param other Another Intent whose values are to be used to fill in
5260 * the current one.
5261 * @param flags Options to control which fields can be filled in.
5262 *
5263 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005264 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5265 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005266 */
5267 public int fillIn(Intent other, int flags) {
5268 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005269 if (other.mAction != null
5270 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005271 mAction = other.mAction;
5272 changes |= FILL_IN_ACTION;
5273 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005274 if ((other.mData != null || other.mType != null)
5275 && ((mData == null && mType == null)
5276 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005277 mData = other.mData;
5278 mType = other.mType;
5279 changes |= FILL_IN_DATA;
5280 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005281 if (other.mCategories != null
5282 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005283 if (other.mCategories != null) {
5284 mCategories = new HashSet<String>(other.mCategories);
5285 }
5286 changes |= FILL_IN_CATEGORIES;
5287 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005288 if (other.mPackage != null
5289 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5290 mPackage = other.mPackage;
5291 changes |= FILL_IN_PACKAGE;
5292 }
5293 // Component is special: it can -only- be set if explicitly allowed,
5294 // since otherwise the sender could force the intent somewhere the
5295 // originator didn't intend.
5296 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 mComponent = other.mComponent;
5298 changes |= FILL_IN_COMPONENT;
5299 }
5300 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005301 if (other.mSourceBounds != null
5302 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5303 mSourceBounds = new Rect(other.mSourceBounds);
5304 changes |= FILL_IN_SOURCE_BOUNDS;
5305 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005306 if (mExtras == null) {
5307 if (other.mExtras != null) {
5308 mExtras = new Bundle(other.mExtras);
5309 }
5310 } else if (other.mExtras != null) {
5311 try {
5312 Bundle newb = new Bundle(other.mExtras);
5313 newb.putAll(mExtras);
5314 mExtras = newb;
5315 } catch (RuntimeException e) {
5316 // Modifying the extras can cause us to unparcel the contents
5317 // of the bundle, and if we do this in the system process that
5318 // may fail. We really should handle this (i.e., the Bundle
5319 // impl shouldn't be on top of a plain map), but for now just
5320 // ignore it and keep the original contents. :(
5321 Log.w("Intent", "Failure filling in extras", e);
5322 }
5323 }
5324 return changes;
5325 }
5326
5327 /**
5328 * Wrapper class holding an Intent and implementing comparisons on it for
5329 * the purpose of filtering. The class implements its
5330 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5331 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5332 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5333 * on the wrapped Intent.
5334 */
5335 public static final class FilterComparison {
5336 private final Intent mIntent;
5337 private final int mHashCode;
5338
5339 public FilterComparison(Intent intent) {
5340 mIntent = intent;
5341 mHashCode = intent.filterHashCode();
5342 }
5343
5344 /**
5345 * Return the Intent that this FilterComparison represents.
5346 * @return Returns the Intent held by the FilterComparison. Do
5347 * not modify!
5348 */
5349 public Intent getIntent() {
5350 return mIntent;
5351 }
5352
5353 @Override
5354 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005355 if (obj instanceof FilterComparison) {
5356 Intent other = ((FilterComparison)obj).mIntent;
5357 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005358 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005359 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005360 }
5361
5362 @Override
5363 public int hashCode() {
5364 return mHashCode;
5365 }
5366 }
5367
5368 /**
5369 * Determine if two intents are the same for the purposes of intent
5370 * resolution (filtering). That is, if their action, data, type,
5371 * class, and categories are the same. This does <em>not</em> compare
5372 * any extra data included in the intents.
5373 *
5374 * @param other The other Intent to compare against.
5375 *
5376 * @return Returns true if action, data, type, class, and categories
5377 * are the same.
5378 */
5379 public boolean filterEquals(Intent other) {
5380 if (other == null) {
5381 return false;
5382 }
5383 if (mAction != other.mAction) {
5384 if (mAction != null) {
5385 if (!mAction.equals(other.mAction)) {
5386 return false;
5387 }
5388 } else {
5389 if (!other.mAction.equals(mAction)) {
5390 return false;
5391 }
5392 }
5393 }
5394 if (mData != other.mData) {
5395 if (mData != null) {
5396 if (!mData.equals(other.mData)) {
5397 return false;
5398 }
5399 } else {
5400 if (!other.mData.equals(mData)) {
5401 return false;
5402 }
5403 }
5404 }
5405 if (mType != other.mType) {
5406 if (mType != null) {
5407 if (!mType.equals(other.mType)) {
5408 return false;
5409 }
5410 } else {
5411 if (!other.mType.equals(mType)) {
5412 return false;
5413 }
5414 }
5415 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005416 if (mPackage != other.mPackage) {
5417 if (mPackage != null) {
5418 if (!mPackage.equals(other.mPackage)) {
5419 return false;
5420 }
5421 } else {
5422 if (!other.mPackage.equals(mPackage)) {
5423 return false;
5424 }
5425 }
5426 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005427 if (mComponent != other.mComponent) {
5428 if (mComponent != null) {
5429 if (!mComponent.equals(other.mComponent)) {
5430 return false;
5431 }
5432 } else {
5433 if (!other.mComponent.equals(mComponent)) {
5434 return false;
5435 }
5436 }
5437 }
5438 if (mCategories != other.mCategories) {
5439 if (mCategories != null) {
5440 if (!mCategories.equals(other.mCategories)) {
5441 return false;
5442 }
5443 } else {
5444 if (!other.mCategories.equals(mCategories)) {
5445 return false;
5446 }
5447 }
5448 }
5449
5450 return true;
5451 }
5452
5453 /**
5454 * Generate hash code that matches semantics of filterEquals().
5455 *
5456 * @return Returns the hash value of the action, data, type, class, and
5457 * categories.
5458 *
5459 * @see #filterEquals
5460 */
5461 public int filterHashCode() {
5462 int code = 0;
5463 if (mAction != null) {
5464 code += mAction.hashCode();
5465 }
5466 if (mData != null) {
5467 code += mData.hashCode();
5468 }
5469 if (mType != null) {
5470 code += mType.hashCode();
5471 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005472 if (mPackage != null) {
5473 code += mPackage.hashCode();
5474 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005475 if (mComponent != null) {
5476 code += mComponent.hashCode();
5477 }
5478 if (mCategories != null) {
5479 code += mCategories.hashCode();
5480 }
5481 return code;
5482 }
5483
5484 @Override
5485 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005486 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005487
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005488 b.append("Intent { ");
5489 toShortString(b, true, true);
5490 b.append(" }");
5491
5492 return b.toString();
5493 }
5494
5495 /** @hide */
5496 public String toShortString(boolean comp, boolean extras) {
5497 StringBuilder b = new StringBuilder(128);
5498 toShortString(b, comp, extras);
5499 return b.toString();
5500 }
Romain Guy4969af72009-06-17 10:53:19 -07005501
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005502 /** @hide */
5503 public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5504 boolean first = true;
5505 if (mAction != null) {
5506 b.append("act=").append(mAction);
5507 first = false;
5508 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005510 if (!first) {
5511 b.append(' ');
5512 }
5513 first = false;
5514 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005515 Iterator<String> i = mCategories.iterator();
5516 boolean didone = false;
5517 while (i.hasNext()) {
5518 if (didone) b.append(",");
5519 didone = true;
5520 b.append(i.next());
5521 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005522 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005523 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005524 if (mData != null) {
5525 if (!first) {
5526 b.append(' ');
5527 }
5528 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07005529 b.append("dat=");
Wink Savillec491ee02010-10-13 11:40:10 -07005530 String scheme = mData.getScheme();
5531 if (scheme != null) {
5532 if (scheme.equalsIgnoreCase("tel")) {
5533 b.append("tel:xxx-xxx-xxxx");
5534 } else if (scheme.equalsIgnoreCase("smsto")) {
5535 b.append("smsto:xxx-xxx-xxxx");
5536 } else {
5537 b.append(mData);
5538 }
Wink Savillea4288072010-10-12 12:36:38 -07005539 } else {
5540 b.append(mData);
5541 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005542 }
5543 if (mType != null) {
5544 if (!first) {
5545 b.append(' ');
5546 }
5547 first = false;
5548 b.append("typ=").append(mType);
5549 }
5550 if (mFlags != 0) {
5551 if (!first) {
5552 b.append(' ');
5553 }
5554 first = false;
5555 b.append("flg=0x").append(Integer.toHexString(mFlags));
5556 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005557 if (mPackage != null) {
5558 if (!first) {
5559 b.append(' ');
5560 }
5561 first = false;
5562 b.append("pkg=").append(mPackage);
5563 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005564 if (comp && mComponent != null) {
5565 if (!first) {
5566 b.append(' ');
5567 }
5568 first = false;
5569 b.append("cmp=").append(mComponent.flattenToShortString());
5570 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005571 if (mSourceBounds != null) {
5572 if (!first) {
5573 b.append(' ');
5574 }
5575 first = false;
5576 b.append("bnds=").append(mSourceBounds.toShortString());
5577 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005578 if (extras && mExtras != null) {
5579 if (!first) {
5580 b.append(' ');
5581 }
5582 first = false;
5583 b.append("(has extras)");
5584 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005585 }
5586
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005587 /**
5588 * Call {@link #toUri} with 0 flags.
5589 * @deprecated Use {@link #toUri} instead.
5590 */
5591 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005592 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005593 return toUri(0);
5594 }
5595
5596 /**
5597 * Convert this Intent into a String holding a URI representation of it.
5598 * The returned URI string has been properly URI encoded, so it can be
5599 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5600 * Intent's data as the base URI, with an additional fragment describing
5601 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005602 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005603 * <p>You can convert the returned string back to an Intent with
5604 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005605 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005606 * @param flags Additional operating flags. Either 0 or
5607 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005608 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005609 * @return Returns a URI encoding URI string describing the entire contents
5610 * of the Intent.
5611 */
5612 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005613 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005614 String scheme = null;
5615 if (mData != null) {
5616 String data = mData.toString();
5617 if ((flags&URI_INTENT_SCHEME) != 0) {
5618 final int N = data.length();
5619 for (int i=0; i<N; i++) {
5620 char c = data.charAt(i);
5621 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5622 || c == '.' || c == '-') {
5623 continue;
5624 }
5625 if (c == ':' && i > 0) {
5626 // Valid scheme.
5627 scheme = data.substring(0, i);
5628 uri.append("intent:");
5629 data = data.substring(i+1);
5630 break;
5631 }
Tom Taylord4a47292009-12-21 13:59:18 -08005632
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005633 // No scheme.
5634 break;
5635 }
5636 }
5637 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005638
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005639 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5640 uri.append("intent:");
5641 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005642
5643 uri.append("#Intent;");
5644
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005645 if (scheme != null) {
5646 uri.append("scheme=").append(scheme).append(';');
5647 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005648 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005649 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005650 }
5651 if (mCategories != null) {
5652 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005653 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005654 }
5655 }
5656 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005657 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005658 }
5659 if (mFlags != 0) {
5660 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5661 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005662 if (mPackage != null) {
5663 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5664 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005665 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005666 uri.append("component=").append(Uri.encode(
5667 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005668 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005669 if (mSourceBounds != null) {
5670 uri.append("sourceBounds=")
5671 .append(Uri.encode(mSourceBounds.flattenToString()))
5672 .append(';');
5673 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005674 if (mExtras != null) {
5675 for (String key : mExtras.keySet()) {
5676 final Object value = mExtras.get(key);
5677 char entryType =
5678 value instanceof String ? 'S' :
5679 value instanceof Boolean ? 'B' :
5680 value instanceof Byte ? 'b' :
5681 value instanceof Character ? 'c' :
5682 value instanceof Double ? 'd' :
5683 value instanceof Float ? 'f' :
5684 value instanceof Integer ? 'i' :
5685 value instanceof Long ? 'l' :
5686 value instanceof Short ? 's' :
5687 '\0';
5688
5689 if (entryType != '\0') {
5690 uri.append(entryType);
5691 uri.append('.');
5692 uri.append(Uri.encode(key));
5693 uri.append('=');
5694 uri.append(Uri.encode(value.toString()));
5695 uri.append(';');
5696 }
5697 }
5698 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005699
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005700 uri.append("end");
5701
5702 return uri.toString();
5703 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005704
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005705 public int describeContents() {
5706 return (mExtras != null) ? mExtras.describeContents() : 0;
5707 }
5708
5709 public void writeToParcel(Parcel out, int flags) {
5710 out.writeString(mAction);
5711 Uri.writeToParcel(out, mData);
5712 out.writeString(mType);
5713 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005714 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005715 ComponentName.writeToParcel(mComponent, out);
5716
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005717 if (mSourceBounds != null) {
5718 out.writeInt(1);
5719 mSourceBounds.writeToParcel(out, flags);
5720 } else {
5721 out.writeInt(0);
5722 }
5723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005724 if (mCategories != null) {
5725 out.writeInt(mCategories.size());
5726 for (String category : mCategories) {
5727 out.writeString(category);
5728 }
5729 } else {
5730 out.writeInt(0);
5731 }
5732
5733 out.writeBundle(mExtras);
5734 }
5735
5736 public static final Parcelable.Creator<Intent> CREATOR
5737 = new Parcelable.Creator<Intent>() {
5738 public Intent createFromParcel(Parcel in) {
5739 return new Intent(in);
5740 }
5741 public Intent[] newArray(int size) {
5742 return new Intent[size];
5743 }
5744 };
5745
Dianne Hackborneb034652009-09-07 00:49:58 -07005746 /** @hide */
5747 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005748 readFromParcel(in);
5749 }
5750
5751 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005752 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005753 mData = Uri.CREATOR.createFromParcel(in);
5754 mType = in.readString();
5755 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005756 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005757 mComponent = ComponentName.readFromParcel(in);
5758
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005759 if (in.readInt() != 0) {
5760 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5761 }
5762
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 int N = in.readInt();
5764 if (N > 0) {
5765 mCategories = new HashSet<String>();
5766 int i;
5767 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005768 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005769 }
5770 } else {
5771 mCategories = null;
5772 }
5773
5774 mExtras = in.readBundle();
5775 }
5776
5777 /**
5778 * Parses the "intent" element (and its children) from XML and instantiates
5779 * an Intent object. The given XML parser should be located at the tag
5780 * where parsing should start (often named "intent"), from which the
5781 * basic action, data, type, and package and class name will be
5782 * retrieved. The function will then parse in to any child elements,
5783 * looking for <category android:name="xxx"> tags to add categories and
5784 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5785 * to the intent.
5786 *
5787 * @param resources The Resources to use when inflating resources.
5788 * @param parser The XML parser pointing at an "intent" tag.
5789 * @param attrs The AttributeSet interface for retrieving extended
5790 * attribute data at the current <var>parser</var> location.
5791 * @return An Intent object matching the XML data.
5792 * @throws XmlPullParserException If there was an XML parsing error.
5793 * @throws IOException If there was an I/O error.
5794 */
5795 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5796 throws XmlPullParserException, IOException {
5797 Intent intent = new Intent();
5798
5799 TypedArray sa = resources.obtainAttributes(attrs,
5800 com.android.internal.R.styleable.Intent);
5801
5802 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5803
5804 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5805 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5806 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5807
5808 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5809 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5810 if (packageName != null && className != null) {
5811 intent.setComponent(new ComponentName(packageName, className));
5812 }
5813
5814 sa.recycle();
5815
5816 int outerDepth = parser.getDepth();
5817 int type;
5818 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5819 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5820 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5821 continue;
5822 }
5823
5824 String nodeName = parser.getName();
5825 if (nodeName.equals("category")) {
5826 sa = resources.obtainAttributes(attrs,
5827 com.android.internal.R.styleable.IntentCategory);
5828 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5829 sa.recycle();
5830
5831 if (cat != null) {
5832 intent.addCategory(cat);
5833 }
5834 XmlUtils.skipCurrentTag(parser);
5835
5836 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005837 if (intent.mExtras == null) {
5838 intent.mExtras = new Bundle();
5839 }
5840 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5841 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005842
5843 } else {
5844 XmlUtils.skipCurrentTag(parser);
5845 }
5846 }
5847
5848 return intent;
5849 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005850}