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