blob: 179b80780a114cee72be8a58f6e441e5c086b882 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import org.xmlpull.v1.XmlPullParser;
20import org.xmlpull.v1.XmlPullParserException;
21
22import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
24import android.content.pm.ActivityInfo;
25import android.content.pm.PackageManager;
26import android.content.pm.ResolveInfo;
27import android.content.res.Resources;
28import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080029import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.net.Uri;
31import android.os.Bundle;
32import android.os.IBinder;
33import android.os.Parcel;
34import android.os.Parcelable;
35import android.util.AttributeSet;
36import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080037
38import com.android.internal.util.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039
40import java.io.IOException;
41import java.io.Serializable;
42import java.net.URISyntaxException;
43import java.util.ArrayList;
44import java.util.HashSet;
45import java.util.Iterator;
46import java.util.Set;
47
48/**
49 * An intent is an abstract description of an operation to be performed. It
50 * can be used with {@link Context#startActivity(Intent) startActivity} to
51 * launch an {@link android.app.Activity},
52 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
53 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
54 * and {@link android.content.Context#startService} or
55 * {@link android.content.Context#bindService} to communicate with a
56 * background {@link android.app.Service}.
57 *
58 * <p>An Intent provides a facility for performing late runtime binding between
59 * the code in different applications. Its most significant use is in the
60 * launching of activities, where it can be thought of as the glue between
61 * activities. It is
62 * basically a passive data structure holding an abstract description of an
63 * action to be performed. The primary pieces of information in an intent
64 * are:</p>
65 *
66 * <ul>
67 * <li> <p><b>action</b> -- The general action to be performed, such as
68 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
69 * etc.</p>
70 * </li>
71 * <li> <p><b>data</b> -- The data to operate on, such as a person record
72 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
73 * </li>
74 * </ul>
75 *
76 *
77 * <p>Some examples of action/data pairs are:</p>
78 *
79 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070080 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070081 * information about the person whose identifier is "1".</p>
82 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070083 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070084 * the phone dialer with the person filled in.</p>
85 * </li>
86 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
87 * the phone dialer with the given number filled in. Note how the
88 * VIEW action does what what is considered the most reasonable thing for
89 * a particular URI.</p>
90 * </li>
91 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
92 * the phone dialer with the given number filled in.</p>
93 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070094 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 * information about the person whose identifier is "1".</p>
96 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070097 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 * a list of people, which the user can browse through. This example is a
99 * typical top-level entry into the Contacts application, showing you the
100 * list of people. Selecting a particular person to view would result in a
101 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
102 * being used to start an activity to display that person.</p>
103 * </li>
104 * </ul>
105 *
106 * <p>In addition to these primary attributes, there are a number of secondary
107 * attributes that you can also include with an intent:</p>
108 *
109 * <ul>
110 * <li> <p><b>category</b> -- Gives additional information about the action
111 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
112 * appear in the Launcher as a top-level application, while
113 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
114 * of alternative actions the user can perform on a piece of data.</p>
115 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
116 * intent data. Normally the type is inferred from the data itself.
117 * By setting this attribute, you disable that evaluation and force
118 * an explicit type.</p>
119 * <li> <p><b>component</b> -- Specifies an explicit name of a component
120 * class to use for the intent. Normally this is determined by looking
121 * at the other information in the intent (the action, data/type, and
122 * categories) and matching that with a component that can handle it.
123 * If this attribute is set then none of the evaluation is performed,
124 * and this component is used exactly as is. By specifying this attribute,
125 * all of the other Intent attributes become optional.</p>
126 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
127 * This can be used to provide extended information to the component.
128 * For example, if we have a action to send an e-mail message, we could
129 * also include extra pieces of data here to supply a subject, body,
130 * etc.</p>
131 * </ul>
132 *
133 * <p>Here are some examples of other operations you can specify as intents
134 * using these additional parameters:</p>
135 *
136 * <ul>
137 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
138 * Launch the home screen.</p>
139 * </li>
140 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
141 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
142 * vnd.android.cursor.item/phone}</i></b>
143 * -- Display the list of people's phone numbers, allowing the user to
144 * browse through them and pick one and return it to the parent activity.</p>
145 * </li>
146 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
147 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
148 * -- Display all pickers for data that can be opened with
149 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
150 * allowing the user to pick one of them and then some data inside of it
151 * and returning the resulting URI to the caller. This can be used,
152 * for example, in an e-mail application to allow the user to pick some
153 * data to include as an attachment.</p>
154 * </li>
155 * </ul>
156 *
157 * <p>There are a variety of standard Intent action and category constants
158 * defined in the Intent class, but applications can also define their own.
159 * These strings use java style scoping, to ensure they are unique -- for
160 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700161 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700162 *
163 * <p>Put together, the set of actions, data types, categories, and extra data
164 * defines a language for the system allowing for the expression of phrases
165 * such as "call john smith's cell". As applications are added to the system,
166 * they can extend this language by adding new actions, types, and categories, or
167 * they can modify the behavior of existing phrases by supplying their own
168 * activities that handle them.</p>
169 *
170 * <a name="IntentResolution"></a>
171 * <h3>Intent Resolution</h3>
172 *
173 * <p>There are two primary forms of intents you will use.
174 *
175 * <ul>
176 * <li> <p><b>Explicit Intents</b> have specified a component (via
177 * {@link #setComponent} or {@link #setClass}), which provides the exact
178 * class to be run. Often these will not include any other information,
179 * simply being a way for an application to launch various internal
180 * activities it has as the user interacts with the application.
181 *
182 * <li> <p><b>Implicit Intents</b> have not specified a component;
183 * instead, they must include enough information for the system to
184 * determine which of the available components is best to run for that
185 * intent.
186 * </ul>
187 *
188 * <p>When using implicit intents, given such an arbitrary intent we need to
189 * know what to do with it. This is handled by the process of <em>Intent
190 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
191 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
192 * more activities/receivers) that can handle it.</p>
193 *
194 * <p>The intent resolution mechanism basically revolves around matching an
195 * Intent against all of the &lt;intent-filter&gt; descriptions in the
196 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
197 * objects explicitly registered with {@link Context#registerReceiver}.) More
198 * details on this can be found in the documentation on the {@link
199 * IntentFilter} class.</p>
200 *
201 * <p>There are three pieces of information in the Intent that are used for
202 * resolution: the action, type, and category. Using this information, a query
203 * is done on the {@link PackageManager} for a component that can handle the
204 * intent. The appropriate component is determined based on the intent
205 * information supplied in the <code>AndroidManifest.xml</code> file as
206 * follows:</p>
207 *
208 * <ul>
209 * <li> <p>The <b>action</b>, if given, must be listed by the component as
210 * one it handles.</p>
211 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
212 * already supplied in the Intent. Like the action, if a type is
213 * included in the intent (either explicitly or implicitly in its
214 * data), then this must be listed by the component as one it handles.</p>
215 * <li> For data that is not a <code>content:</code> URI and where no explicit
216 * type is included in the Intent, instead the <b>scheme</b> of the
217 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
218 * considered. Again like the action, if we are matching a scheme it
219 * must be listed by the component as one it can handle.
220 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
221 * by the activity as categories it handles. That is, if you include
222 * the categories {@link #CATEGORY_LAUNCHER} and
223 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
224 * with an intent that lists <em>both</em> of those categories.
225 * Activities will very often need to support the
226 * {@link #CATEGORY_DEFAULT} so that they can be found by
227 * {@link Context#startActivity Context.startActivity()}.</p>
228 * </ul>
229 *
230 * <p>For example, consider the Note Pad sample application that
231 * allows user to browse through a list of notes data and view details about
232 * individual items. Text in italics indicate places were you would replace a
233 * name with one specific to your own package.</p>
234 *
235 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
236 * package="<i>com.android.notepad</i>"&gt;
237 * &lt;application android:icon="@drawable/app_notes"
238 * android:label="@string/app_name"&gt;
239 *
240 * &lt;provider class=".NotePadProvider"
241 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
242 *
243 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
244 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700245 * &lt;action android:name="android.intent.action.MAIN" /&gt;
246 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700247 * &lt;/intent-filter&gt;
248 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700249 * &lt;action android:name="android.intent.action.VIEW" /&gt;
250 * &lt;action android:name="android.intent.action.EDIT" /&gt;
251 * &lt;action android:name="android.intent.action.PICK" /&gt;
252 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
253 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700254 * &lt;/intent-filter&gt;
255 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700256 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
257 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
258 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700259 * &lt;/intent-filter&gt;
260 * &lt;/activity&gt;
261 *
262 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
263 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700264 * &lt;action android:name="android.intent.action.VIEW" /&gt;
265 * &lt;action android:name="android.intent.action.EDIT" /&gt;
266 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
267 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700268 * &lt;/intent-filter&gt;
269 *
270 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700271 * &lt;action android:name="android.intent.action.INSERT" /&gt;
272 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
273 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274 * &lt;/intent-filter&gt;
275 *
276 * &lt;/activity&gt;
277 *
278 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
279 * android:theme="@android:style/Theme.Dialog"&gt;
280 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
284 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;/activity&gt;
288 *
289 * &lt;/application&gt;
290 * &lt;/manifest&gt;</pre>
291 *
292 * <p>The first activity,
293 * <code>com.android.notepad.NotesList</code>, serves as our main
294 * entry into the app. It can do three things as described by its three intent
295 * templates:
296 * <ol>
297 * <li><pre>
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
300 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;</pre>
302 * <p>This provides a top-level entry into the NotePad application: the standard
303 * MAIN action is a main entry point (not requiring any other information in
304 * the Intent), and the LAUNCHER category says that this entry point should be
305 * listed in the application launcher.</p>
306 * <li><pre>
307 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700308 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
309 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
310 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
311 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
312 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700313 * &lt;/intent-filter&gt;</pre>
314 * <p>This declares the things that the activity can do on a directory of
315 * notes. The type being supported is given with the &lt;type&gt; tag, where
316 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
317 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
318 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
319 * The activity allows the user to view or edit the directory of data (via
320 * the VIEW and EDIT actions), or to pick a particular note and return it
321 * to the caller (via the PICK action). Note also the DEFAULT category
322 * supplied here: this is <em>required</em> for the
323 * {@link Context#startActivity Context.startActivity} method to resolve your
324 * activity when its component name is not explicitly specified.</p>
325 * <li><pre>
326 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700327 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
328 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
329 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700330 * &lt;/intent-filter&gt;</pre>
331 * <p>This filter describes the ability return to the caller a note selected by
332 * the user without needing to know where it came from. The data type
333 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
334 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
335 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
336 * The GET_CONTENT action is similar to the PICK action, where the activity
337 * will return to its caller a piece of data selected by the user. Here,
338 * however, the caller specifies the type of data they desire instead of
339 * the type of data the user will be picking from.</p>
340 * </ol>
341 *
342 * <p>Given these capabilities, the following intents will resolve to the
343 * NotesList activity:</p>
344 *
345 * <ul>
346 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
347 * activities that can be used as top-level entry points into an
348 * application.</p>
349 * <li> <p><b>{ action=android.app.action.MAIN,
350 * category=android.app.category.LAUNCHER }</b> is the actual intent
351 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700352 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * data=content://com.google.provider.NotePad/notes }</b>
354 * displays a list of all the notes under
355 * "content://com.google.provider.NotePad/notes", which
356 * the user can browse through and see the details on.</p>
357 * <li> <p><b>{ action=android.app.action.PICK
358 * data=content://com.google.provider.NotePad/notes }</b>
359 * provides a list of the notes under
360 * "content://com.google.provider.NotePad/notes", from which
361 * the user can pick a note whose data URL is returned back to the caller.</p>
362 * <li> <p><b>{ action=android.app.action.GET_CONTENT
363 * type=vnd.android.cursor.item/vnd.google.note }</b>
364 * is similar to the pick action, but allows the caller to specify the
365 * kind of data they want back so that the system can find the appropriate
366 * activity to pick something of that data type.</p>
367 * </ul>
368 *
369 * <p>The second activity,
370 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
371 * note entry and allows them to edit it. It can do two things as described
372 * by its two intent templates:
373 * <ol>
374 * <li><pre>
375 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700376 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
377 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
378 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
379 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700380 * &lt;/intent-filter&gt;</pre>
381 * <p>The first, primary, purpose of this activity is to let the user interact
382 * with a single note, as decribed by the MIME type
383 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
384 * either VIEW a note or allow the user to EDIT it. Again we support the
385 * DEFAULT category to allow the activity to be launched without explicitly
386 * specifying its component.</p>
387 * <li><pre>
388 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700389 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
390 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
391 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700392 * &lt;/intent-filter&gt;</pre>
393 * <p>The secondary use of this activity is to insert a new note entry into
394 * an existing directory of notes. This is used when the user creates a new
395 * note: the INSERT action is executed on the directory of notes, causing
396 * this activity to run and have the user create the new note data which
397 * it then adds to the content provider.</p>
398 * </ol>
399 *
400 * <p>Given these capabilities, the following intents will resolve to the
401 * NoteEditor activity:</p>
402 *
403 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700404 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700405 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
406 * shows the user the content of note <var>{ID}</var>.</p>
407 * <li> <p><b>{ action=android.app.action.EDIT
408 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
409 * allows the user to edit the content of note <var>{ID}</var>.</p>
410 * <li> <p><b>{ action=android.app.action.INSERT
411 * data=content://com.google.provider.NotePad/notes }</b>
412 * creates a new, empty note in the notes list at
413 * "content://com.google.provider.NotePad/notes"
414 * and allows the user to edit it. If they keep their changes, the URI
415 * of the newly created note is returned to the caller.</p>
416 * </ul>
417 *
418 * <p>The last activity,
419 * <code>com.android.notepad.TitleEditor</code>, allows the user to
420 * edit the title of a note. This could be implemented as a class that the
421 * application directly invokes (by explicitly setting its component in
422 * the Intent), but here we show a way you can publish alternative
423 * operations on existing data:</p>
424 *
425 * <pre>
426 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700427 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
428 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
429 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700432 * &lt;/intent-filter&gt;</pre>
433 *
434 * <p>In the single intent template here, we
435 * have created our own private action called
436 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
437 * edit the title of a note. It must be invoked on a specific note
438 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
439 * view and edit actions, but here displays and edits the title contained
440 * in the note data.
441 *
442 * <p>In addition to supporting the default category as usual, our title editor
443 * also supports two other standard categories: ALTERNATIVE and
444 * SELECTED_ALTERNATIVE. Implementing
445 * these categories allows others to find the special action it provides
446 * without directly knowing about it, through the
447 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
448 * more often to build dynamic menu items with
449 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
450 * template here was also supply an explicit name for the template
451 * (via <code>android:label="@string/resolve_title"</code>) to better control
452 * what the user sees when presented with this activity as an alternative
453 * action to the data they are viewing.
454 *
455 * <p>Given these capabilities, the following intent will resolve to the
456 * TitleEditor activity:</p>
457 *
458 * <ul>
459 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461 * displays and allows the user to edit the title associated
462 * with note <var>{ID}</var>.</p>
463 * </ul>
464 *
465 * <h3>Standard Activity Actions</h3>
466 *
467 * <p>These are the current standard actions that Intent defines for launching
468 * activities (usually through {@link Context#startActivity}. The most
469 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
470 * {@link #ACTION_EDIT}.
471 *
472 * <ul>
473 * <li> {@link #ACTION_MAIN}
474 * <li> {@link #ACTION_VIEW}
475 * <li> {@link #ACTION_ATTACH_DATA}
476 * <li> {@link #ACTION_EDIT}
477 * <li> {@link #ACTION_PICK}
478 * <li> {@link #ACTION_CHOOSER}
479 * <li> {@link #ACTION_GET_CONTENT}
480 * <li> {@link #ACTION_DIAL}
481 * <li> {@link #ACTION_CALL}
482 * <li> {@link #ACTION_SEND}
483 * <li> {@link #ACTION_SENDTO}
484 * <li> {@link #ACTION_ANSWER}
485 * <li> {@link #ACTION_INSERT}
486 * <li> {@link #ACTION_DELETE}
487 * <li> {@link #ACTION_RUN}
488 * <li> {@link #ACTION_SYNC}
489 * <li> {@link #ACTION_PICK_ACTIVITY}
490 * <li> {@link #ACTION_SEARCH}
491 * <li> {@link #ACTION_WEB_SEARCH}
492 * <li> {@link #ACTION_FACTORY_TEST}
493 * </ul>
494 *
495 * <h3>Standard Broadcast Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for receiving
498 * broadcasts (usually through {@link Context#registerReceiver} or a
499 * &lt;receiver&gt; tag in a manifest).
500 *
501 * <ul>
502 * <li> {@link #ACTION_TIME_TICK}
503 * <li> {@link #ACTION_TIME_CHANGED}
504 * <li> {@link #ACTION_TIMEZONE_CHANGED}
505 * <li> {@link #ACTION_BOOT_COMPLETED}
506 * <li> {@link #ACTION_PACKAGE_ADDED}
507 * <li> {@link #ACTION_PACKAGE_CHANGED}
508 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * <li> {@link #ACTION_PACKAGE_RESTARTED}
510 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700511 * <li> {@link #ACTION_UID_REMOVED}
512 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700513 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700514 * <li> {@link #ACTION_POWER_DISCONNECTED}
515 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700516 * </ul>
517 *
518 * <h3>Standard Categories</h3>
519 *
520 * <p>These are the current standard categories that can be used to further
521 * clarify an Intent via {@link #addCategory}.
522 *
523 * <ul>
524 * <li> {@link #CATEGORY_DEFAULT}
525 * <li> {@link #CATEGORY_BROWSABLE}
526 * <li> {@link #CATEGORY_TAB}
527 * <li> {@link #CATEGORY_ALTERNATIVE}
528 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
529 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700531 * <li> {@link #CATEGORY_HOME}
532 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700533 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400534 * <li> {@link #CATEGORY_CAR_DOCK}
535 * <li> {@link #CATEGORY_DESK_DOCK}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700536 * </ul>
537 *
538 * <h3>Standard Extra Data</h3>
539 *
540 * <p>These are the current standard fields that can be used as extra data via
541 * {@link #putExtra}.
542 *
543 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800544 * <li> {@link #EXTRA_ALARM_COUNT}
545 * <li> {@link #EXTRA_BCC}
546 * <li> {@link #EXTRA_CC}
547 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
548 * <li> {@link #EXTRA_DATA_REMOVED}
549 * <li> {@link #EXTRA_DOCK_STATE}
550 * <li> {@link #EXTRA_DOCK_STATE_CAR}
551 * <li> {@link #EXTRA_DOCK_STATE_DESK}
552 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
553 * <li> {@link #EXTRA_DONT_KILL_APP}
554 * <li> {@link #EXTRA_EMAIL}
555 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700556 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800557 * <li> {@link #EXTRA_KEY_EVENT}
558 * <li> {@link #EXTRA_PHONE_NUMBER}
559 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
560 * <li> {@link #EXTRA_REPLACING}
561 * <li> {@link #EXTRA_SHORTCUT_ICON}
562 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
563 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700564 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800565 * <li> {@link #EXTRA_SHORTCUT_NAME}
566 * <li> {@link #EXTRA_SUBJECT}
567 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700568 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800569 * <li> {@link #EXTRA_TITLE}
570 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700571 * </ul>
572 *
573 * <h3>Flags</h3>
574 *
575 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800576 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
577 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700578 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800579public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700580 // ---------------------------------------------------------------------
581 // ---------------------------------------------------------------------
582 // Standard intent activity actions (see action variable).
583
584 /**
585 * Activity Action: Start as a main entry point, does not expect to
586 * receive data.
587 * <p>Input: nothing
588 * <p>Output: nothing
589 */
590 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
591 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700593 /**
594 * Activity Action: Display the data to the user. This is the most common
595 * action performed on data -- it is the generic action you can use on
596 * a piece of data to get the most reasonable thing to occur. For example,
597 * when used on a contacts entry it will view the entry; when used on a
598 * mailto: URI it will bring up a compose window filled with the information
599 * supplied by the URI; when used with a tel: URI it will invoke the
600 * dialer.
601 * <p>Input: {@link #getData} is URI from which to retrieve data.
602 * <p>Output: nothing.
603 */
604 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
605 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800606
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 /**
608 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
609 * performed on a piece of data.
610 */
611 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800612
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 /**
614 * Used to indicate that some piece of data should be attached to some other
615 * place. For example, image data could be attached to a contact. It is up
616 * to the recipient to decide where the data should be attached; the intent
617 * does not specify the ultimate destination.
618 * <p>Input: {@link #getData} is URI of data to be attached.
619 * <p>Output: nothing.
620 */
621 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
622 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800623
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700624 /**
625 * Activity Action: Provide explicit editable access to the given data.
626 * <p>Input: {@link #getData} is URI of data to be edited.
627 * <p>Output: nothing.
628 */
629 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
630 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 /**
633 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
634 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
635 * The extras can contain type specific data to pass through to the editing/creating
636 * activity.
637 * <p>Output: The URI of the item that was picked. This must be a content:
638 * URI so that any receiver can access it.
639 */
640 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
641 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 /**
644 * Activity Action: Pick an item from the data, returning what was selected.
645 * <p>Input: {@link #getData} is URI containing a directory of data
646 * (vnd.android.cursor.dir/*) from which to pick an item.
647 * <p>Output: The URI of the item that was picked.
648 */
649 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
650 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800651
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700652 /**
653 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800654 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700655 * <p>Output: An Intent representing the shortcut. The intent must contain three
656 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
657 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658 * (value: ShortcutIconResource).</p>
659 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 * @see #EXTRA_SHORTCUT_INTENT
661 * @see #EXTRA_SHORTCUT_NAME
662 * @see #EXTRA_SHORTCUT_ICON
663 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
664 * @see android.content.Intent.ShortcutIconResource
665 */
666 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
667 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
668
669 /**
670 * The name of the extra used to define the Intent of a shortcut.
671 *
672 * @see #ACTION_CREATE_SHORTCUT
673 */
674 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
675 /**
676 * The name of the extra used to define the name of a shortcut.
677 *
678 * @see #ACTION_CREATE_SHORTCUT
679 */
680 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
681 /**
682 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
683 *
684 * @see #ACTION_CREATE_SHORTCUT
685 */
686 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
687 /**
688 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
689 *
690 * @see #ACTION_CREATE_SHORTCUT
691 * @see android.content.Intent.ShortcutIconResource
692 */
693 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
694 "android.intent.extra.shortcut.ICON_RESOURCE";
695
696 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800697 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700698 *
699 * @see Intent#ACTION_CREATE_SHORTCUT
700 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800701 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
702 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700703 */
704 public static class ShortcutIconResource implements Parcelable {
705 /**
706 * The package name of the application containing the icon.
707 */
708 public String packageName;
709
710 /**
711 * The resource name of the icon, including package, name and type.
712 */
713 public String resourceName;
714
715 /**
716 * Creates a new ShortcutIconResource for the specified context and resource
717 * identifier.
718 *
719 * @param context The context of the application.
720 * @param resourceId The resource idenfitier for the icon.
721 * @return A new ShortcutIconResource with the specified's context package name
722 * and icon resource idenfitier.
723 */
724 public static ShortcutIconResource fromContext(Context context, int resourceId) {
725 ShortcutIconResource icon = new ShortcutIconResource();
726 icon.packageName = context.getPackageName();
727 icon.resourceName = context.getResources().getResourceName(resourceId);
728 return icon;
729 }
730
731 /**
732 * Used to read a ShortcutIconResource from a Parcel.
733 */
734 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
735 new Parcelable.Creator<ShortcutIconResource>() {
736
737 public ShortcutIconResource createFromParcel(Parcel source) {
738 ShortcutIconResource icon = new ShortcutIconResource();
739 icon.packageName = source.readString();
740 icon.resourceName = source.readString();
741 return icon;
742 }
743
744 public ShortcutIconResource[] newArray(int size) {
745 return new ShortcutIconResource[size];
746 }
747 };
748
749 /**
750 * No special parcel contents.
751 */
752 public int describeContents() {
753 return 0;
754 }
755
756 public void writeToParcel(Parcel dest, int flags) {
757 dest.writeString(packageName);
758 dest.writeString(resourceName);
759 }
760
761 @Override
762 public String toString() {
763 return resourceName;
764 }
765 }
766
767 /**
768 * Activity Action: Display an activity chooser, allowing the user to pick
769 * what they want to before proceeding. This can be used as an alternative
770 * to the standard activity picker that is displayed by the system when
771 * you try to start an activity with multiple possible matches, with these
772 * differences in behavior:
773 * <ul>
774 * <li>You can specify the title that will appear in the activity chooser.
775 * <li>The user does not have the option to make one of the matching
776 * activities a preferred activity, and all possible activities will
777 * always be shown even if one of them is currently marked as the
778 * preferred activity.
779 * </ul>
780 * <p>
781 * This action should be used when the user will naturally expect to
782 * select an activity in order to proceed. An example if when not to use
783 * it is when the user clicks on a "mailto:" link. They would naturally
784 * expect to go directly to their mail app, so startActivity() should be
785 * called directly: it will
786 * either launch the current preferred app, or put up a dialog allowing the
787 * user to pick an app to use and optionally marking that as preferred.
788 * <p>
789 * In contrast, if the user is selecting a menu item to send a picture
790 * they are viewing to someone else, there are many different things they
791 * may want to do at this point: send it through e-mail, upload it to a
792 * web service, etc. In this case the CHOOSER action should be used, to
793 * always present to the user a list of the things they can do, with a
794 * nice title given by the caller such as "Send this photo with:".
795 * <p>
796 * As a convenience, an Intent of this form can be created with the
797 * {@link #createChooser} function.
798 * <p>Input: No data should be specified. get*Extra must have
799 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
800 * and can optionally have a {@link #EXTRA_TITLE} field containing the
801 * title text to display in the chooser.
802 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
803 */
804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
805 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
806
807 /**
808 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
809 *
810 * @param target The Intent that the user will be selecting an activity
811 * to perform.
812 * @param title Optional title that will be displayed in the chooser.
813 * @return Return a new Intent object that you can hand to
814 * {@link Context#startActivity(Intent) Context.startActivity()} and
815 * related methods.
816 */
817 public static Intent createChooser(Intent target, CharSequence title) {
818 Intent intent = new Intent(ACTION_CHOOSER);
819 intent.putExtra(EXTRA_INTENT, target);
820 if (title != null) {
821 intent.putExtra(EXTRA_TITLE, title);
822 }
823 return intent;
824 }
825 /**
826 * Activity Action: Allow the user to select a particular kind of data and
827 * return it. This is different than {@link #ACTION_PICK} in that here we
828 * just say what kind of data is desired, not a URI of existing data from
829 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
830 * create the data as it runs (for example taking a picture or recording a
831 * sound), let them browser over the web and download the desired data,
832 * etc.
833 * <p>
834 * There are two main ways to use this action: if you want an specific kind
835 * of data, such as a person contact, you set the MIME type to the kind of
836 * data you want and launch it with {@link Context#startActivity(Intent)}.
837 * The system will then launch the best application to select that kind
838 * of data for you.
839 * <p>
840 * You may also be interested in any of a set of types of content the user
841 * can pick. For example, an e-mail application that wants to allow the
842 * user to add an attachment to an e-mail message can use this action to
843 * bring up a list of all of the types of content the user can attach.
844 * <p>
845 * In this case, you should wrap the GET_CONTENT intent with a chooser
846 * (through {@link #createChooser}), which will give the proper interface
847 * for the user to pick how to send your data and allow you to specify
848 * a prompt indicating what they are doing. You will usually specify a
849 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
850 * broad range of content types the user can select from.
851 * <p>
852 * When using such a broad GET_CONTENT action, it is often desireable to
853 * only pick from data that can be represented as a stream. This is
854 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
855 * <p>
856 * Input: {@link #getType} is the desired MIME type to retrieve. Note
857 * that no URI is supplied in the intent, as there are no constraints on
858 * where the returned data originally comes from. You may also include the
859 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
860 * opened as a stream.
861 * <p>
862 * Output: The URI of the item that was picked. This must be a content:
863 * URI so that any receiver can access it.
864 */
865 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
866 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
867 /**
868 * Activity Action: Dial a number as specified by the data. This shows a
869 * UI with the number being dialed, allowing the user to explicitly
870 * initiate the call.
871 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
872 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
873 * number.
874 * <p>Output: nothing.
875 */
876 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
877 public static final String ACTION_DIAL = "android.intent.action.DIAL";
878 /**
879 * Activity Action: Perform a call to someone specified by the data.
880 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
881 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
882 * number.
883 * <p>Output: nothing.
884 *
885 * <p>Note: there will be restrictions on which applications can initiate a
886 * call; most applications should use the {@link #ACTION_DIAL}.
887 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
888 * numbers. Applications can <strong>dial</strong> emergency numbers using
889 * {@link #ACTION_DIAL}, however.
890 */
891 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
892 public static final String ACTION_CALL = "android.intent.action.CALL";
893 /**
894 * Activity Action: Perform a call to an emergency number specified by the
895 * data.
896 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
897 * tel: URI of an explicit phone number.
898 * <p>Output: nothing.
899 * @hide
900 */
901 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
902 /**
903 * Activity action: Perform a call to any number (emergency or not)
904 * specified by the data.
905 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
906 * tel: URI of an explicit phone number.
907 * <p>Output: nothing.
908 * @hide
909 */
910 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
911 /**
912 * Activity Action: Send a message to someone specified by the data.
913 * <p>Input: {@link #getData} is URI describing the target.
914 * <p>Output: nothing.
915 */
916 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
917 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
918 /**
919 * Activity Action: Deliver some data to someone else. Who the data is
920 * being delivered to is not specified; it is up to the receiver of this
921 * action to ask the user where the data should be sent.
922 * <p>
923 * When launching a SEND intent, you should usually wrap it in a chooser
924 * (through {@link #createChooser}), which will give the proper interface
925 * for the user to pick how to send your data and allow you to specify
926 * a prompt indicating what they are doing.
927 * <p>
928 * Input: {@link #getType} is the MIME type of the data being sent.
929 * get*Extra can have either a {@link #EXTRA_TEXT}
930 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
931 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
932 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
933 * if the MIME type is unknown (this will only allow senders that can
934 * handle generic data streams).
935 * <p>
936 * Optional standard extras, which may be interpreted by some recipients as
937 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
938 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
939 * <p>
940 * Output: nothing.
941 */
942 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
943 public static final String ACTION_SEND = "android.intent.action.SEND";
944 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800945 * Activity Action: Deliver multiple data to someone else.
946 * <p>
947 * Like ACTION_SEND, except the data is multiple.
948 * <p>
949 * Input: {@link #getType} is the MIME type of the data being sent.
950 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
951 * #EXTRA_STREAM} field, containing the data to be sent.
952 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800953 * Multiple types are supported, and receivers should handle mixed types
954 * whenever possible. The right way for the receiver to check them is to
955 * use the content resolver on each URI. The intent sender should try to
956 * put the most concrete mime type in the intent type, but it can fall
957 * back to {@literal <type>/*} or {@literal *}/* as needed.
958 * <p>
959 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
960 * be image/jpg, but if you are sending image/jpg and image/png, then the
961 * intent's type should be image/*.
962 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800963 * Optional standard extras, which may be interpreted by some recipients as
964 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
965 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
966 * <p>
967 * Output: nothing.
968 */
969 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
970 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
971 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700972 * Activity Action: Handle an incoming phone call.
973 * <p>Input: nothing.
974 * <p>Output: nothing.
975 */
976 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
977 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
978 /**
979 * Activity Action: Insert an empty item into the given container.
980 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
981 * in which to place the data.
982 * <p>Output: URI of the new data that was created.
983 */
984 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
985 public static final String ACTION_INSERT = "android.intent.action.INSERT";
986 /**
987 * Activity Action: Delete the given data from its container.
988 * <p>Input: {@link #getData} is URI of data to be deleted.
989 * <p>Output: nothing.
990 */
991 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
992 public static final String ACTION_DELETE = "android.intent.action.DELETE";
993 /**
994 * Activity Action: Run the data, whatever that means.
995 * <p>Input: ? (Note: this is currently specific to the test harness.)
996 * <p>Output: nothing.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_RUN = "android.intent.action.RUN";
1000 /**
1001 * Activity Action: Perform a data synchronization.
1002 * <p>Input: ?
1003 * <p>Output: ?
1004 */
1005 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1006 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1007 /**
1008 * Activity Action: Pick an activity given an intent, returning the class
1009 * selected.
1010 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1011 * used with {@link PackageManager#queryIntentActivities} to determine the
1012 * set of activities from which to pick.
1013 * <p>Output: Class name of the activity that was selected.
1014 */
1015 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1016 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1017 /**
1018 * Activity Action: Perform a search.
1019 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1020 * is the text to search for. If empty, simply
1021 * enter your search results Activity with the search UI activated.
1022 * <p>Output: nothing.
1023 */
1024 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1025 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1026 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001027 * Activity Action: Start the platform-defined tutorial
1028 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1029 * is the text to search for. If empty, simply
1030 * enter your search results Activity with the search UI activated.
1031 * <p>Output: nothing.
1032 */
1033 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1034 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1035 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001036 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001037 * <p>
1038 * Input: {@link android.app.SearchManager#QUERY
1039 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1040 * a url starts with http or https, the site will be opened. If it is plain
1041 * text, Google search will be applied.
1042 * <p>
1043 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001044 */
1045 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1046 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1047 /**
1048 * Activity Action: List all available applications
1049 * <p>Input: Nothing.
1050 * <p>Output: nothing.
1051 */
1052 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1053 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1054 /**
1055 * Activity Action: Show settings for choosing wallpaper
1056 * <p>Input: Nothing.
1057 * <p>Output: Nothing.
1058 */
1059 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1060 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1061
1062 /**
1063 * Activity Action: Show activity for reporting a bug.
1064 * <p>Input: Nothing.
1065 * <p>Output: Nothing.
1066 */
1067 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1068 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1069
1070 /**
1071 * Activity Action: Main entry point for factory tests. Only used when
1072 * the device is booting in factory test node. The implementing package
1073 * must be installed in the system image.
1074 * <p>Input: nothing
1075 * <p>Output: nothing
1076 */
1077 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1078
1079 /**
1080 * Activity Action: The user pressed the "call" button to go to the dialer
1081 * or other appropriate UI for placing a call.
1082 * <p>Input: Nothing.
1083 * <p>Output: Nothing.
1084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1087
1088 /**
1089 * Activity Action: Start Voice Command.
1090 * <p>Input: Nothing.
1091 * <p>Output: Nothing.
1092 */
1093 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1094 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001095
1096 /**
1097 * Activity Action: Start action associated with long pressing on the
1098 * search key.
1099 * <p>Input: Nothing.
1100 * <p>Output: Nothing.
1101 */
1102 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1103 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001104
Jacek Surazski86b6c532009-05-13 14:38:28 +02001105 /**
1106 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1107 * This intent is delivered to the package which installed the application, usually
1108 * the Market.
1109 * <p>Input: No data is specified. The bug report is passed in using
1110 * an {@link #EXTRA_BUG_REPORT} field.
1111 * <p>Output: Nothing.
1112 * @hide
1113 */
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1115 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001116
1117 /**
1118 * Activity Action: Show power usage information to the user.
1119 * <p>Input: Nothing.
1120 * <p>Output: Nothing.
1121 */
1122 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1123 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001124
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001125 /**
1126 * Activity Action: Setup wizard to launch after a platform update. This
1127 * activity should have a string meta-data field associated with it,
1128 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1129 * the platform for setup. The activity will be launched only if
1130 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1131 * same value.
1132 * <p>Input: Nothing.
1133 * <p>Output: Nothing.
1134 * @hide
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001138
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001139 /**
1140 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1141 * describing the last run version of the platform that was setup.
1142 * @hide
1143 */
1144 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1145
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001146 // ---------------------------------------------------------------------
1147 // ---------------------------------------------------------------------
1148 // Standard intent broadcast actions (see action variable).
1149
1150 /**
1151 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001152 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001153 * <p class="note">This is a protected intent that can only be sent
1154 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001155 */
1156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1157 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1158 /**
1159 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001160 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001161 * <p class="note">This is a protected intent that can only be sent
1162 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001163 */
1164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1165 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001166
1167 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001168 * 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 -07001169 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001170 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001171 * <p class="note">This is a protected intent that can only be sent
1172 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001173 */
1174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001175 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001176
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001177 /**
1178 * Broadcast Action: The current time has changed. Sent every
1179 * minute. You can <em>not</em> receive this through components declared
1180 * in manifests, only by exlicitly registering for it with
1181 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1182 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001183 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001184 * <p class="note">This is a protected intent that can only be sent
1185 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001186 */
1187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1188 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1189 /**
1190 * Broadcast Action: The time was set.
1191 */
1192 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1193 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1194 /**
1195 * Broadcast Action: The date has changed.
1196 */
1197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1198 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1199 /**
1200 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1201 * <ul>
1202 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1203 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001204 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001205 * <p class="note">This is a protected intent that can only be sent
1206 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001207 */
1208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1209 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1210 /**
1211 * Alarm Changed Action: This is broadcast when the AlarmClock
1212 * application's alarm is set or unset. It is used by the
1213 * AlarmClock application and the StatusBar service.
1214 * @hide
1215 */
1216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1217 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1218 /**
1219 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1220 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1221 * @hide
1222 */
1223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1224 public static final String ACTION_SYNC_STATE_CHANGED
1225 = "android.intent.action.SYNC_STATE_CHANGED";
1226 /**
1227 * Broadcast Action: This is broadcast once, after the system has finished
1228 * booting. It can be used to perform application-specific initialization,
1229 * such as installing alarms. You must hold the
1230 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1231 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001232 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001233 * <p class="note">This is a protected intent that can only be sent
1234 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001235 */
1236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1237 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1238 /**
1239 * Broadcast Action: This is broadcast when a user action should request a
1240 * temporary system dialog to dismiss. Some examples of temporary system
1241 * dialogs are the notification window-shade and the recent tasks dialog.
1242 */
1243 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1244 /**
1245 * Broadcast Action: Trigger the download and eventual installation
1246 * of a package.
1247 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001248 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001249 * <p class="note">This is a protected intent that can only be sent
1250 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001251 */
1252 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1253 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1254 /**
1255 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001256 * device. The data contains the name of the package. Note that the
1257 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001258 * <p>My include the following extras:
1259 * <ul>
1260 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1261 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1262 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1263 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001264 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001265 * <p class="note">This is a protected intent that can only be sent
1266 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001267 */
1268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1269 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1270 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001271 * Broadcast Action: A new version of an application package has been
1272 * installed, replacing an existing version that was previously installed.
1273 * The data contains the name of the package.
1274 * <p>My include the following extras:
1275 * <ul>
1276 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1277 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001278 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001279 * <p class="note">This is a protected intent that can only be sent
1280 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001281 */
1282 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1283 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1284 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001285 * Broadcast Action: An existing application package has been removed from
1286 * the device. The data contains the name of the package. The package
1287 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001288 * <ul>
1289 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1290 * to the package.
1291 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1292 * application -- data and code -- is being removed.
1293 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1294 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1295 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001296 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001297 * <p class="note">This is a protected intent that can only be sent
1298 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001299 */
1300 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1301 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1302 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001303 * Broadcast Action: An existing application package has been changed (e.g.
1304 * a component has been enabled or disabled). The data contains the name of
1305 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001306 * <ul>
1307 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001308 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1309 * of the changed components.
1310 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1311 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001312 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001313 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001314 * <p class="note">This is a protected intent that can only be sent
1315 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001316 */
1317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1318 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1319 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001320 * @hide
1321 * Broadcast Action: Ask system services if there is any reason to
1322 * restart the given package. The data contains the name of the
1323 * package.
1324 * <ul>
1325 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1326 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1327 * </ul>
1328 *
1329 * <p class="note">This is a protected intent that can only be sent
1330 * by the system.
1331 */
1332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1333 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1334 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001335 * Broadcast Action: The user has restarted a package, and all of its
1336 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001337 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001338 * be removed. Note that the restarted package does <em>not</em>
1339 * receive this broadcast.
1340 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001341 * <ul>
1342 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1343 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001344 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001345 * <p class="note">This is a protected intent that can only be sent
1346 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001347 */
1348 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1349 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1350 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001351 * Broadcast Action: The user has cleared the data of a package. This should
1352 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001353 * its persistent data is erased and this broadcast sent.
1354 * Note that the cleared package does <em>not</em>
1355 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001356 * <ul>
1357 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1358 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001359 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001360 * <p class="note">This is a protected intent that can only be sent
1361 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001362 */
1363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1364 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1365 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001366 * Broadcast Action: A user ID has been removed from the system. The user
1367 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001368 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001369 * <p class="note">This is a protected intent that can only be sent
1370 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001371 */
1372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1373 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001374
1375 /**
1376 * Broadcast Action: Resources for a set of packages (which were
1377 * previously unavailable) are currently
1378 * available since the media on which they exist is available.
1379 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1380 * list of packages whose availability changed.
1381 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1382 * list of uids of packages whose availability changed.
1383 * Note that the
1384 * packages in this list do <em>not</em> receive this broadcast.
1385 * The specified set of packages are now available on the system.
1386 * <p>Includes the following extras:
1387 * <ul>
1388 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1389 * whose resources(were previously unavailable) are currently available.
1390 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1391 * packages whose resources(were previously unavailable)
1392 * are currently available.
1393 * </ul>
1394 *
1395 * <p class="note">This is a protected intent that can only be sent
1396 * by the system.
1397 * @hide
1398 */
1399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001400 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1401 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001402
1403 /**
1404 * Broadcast Action: Resources for a set of packages are currently
1405 * unavailable since the media on which they exist is unavailable.
1406 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1407 * list of packages whose availability changed.
1408 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1409 * list of uids of packages whose availability changed.
1410 * The specified set of packages can no longer be
1411 * launched and are practically unavailable on the system.
1412 * <p>Inclues the following extras:
1413 * <ul>
1414 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1415 * whose resources are no longer available.
1416 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1417 * whose resources are no longer available.
1418 * </ul>
1419 *
1420 * <p class="note">This is a protected intent that can only be sent
1421 * by the system.
1422 * @hide
1423 */
1424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001425 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
1426 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABILE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001427
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001428 /**
1429 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001430 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001431 */
1432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1433 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1434 /**
1435 * Broadcast Action: The current device {@link android.content.res.Configuration}
1436 * (orientation, locale, etc) has changed. When such a change happens, the
1437 * UIs (view hierarchy) will need to be rebuilt based on this new
1438 * information; for the most part, applications don't need to worry about
1439 * this, because the system will take care of stopping and restarting the
1440 * application to make sure it sees the new changes. Some system code that
1441 * can not be restarted will need to watch for this action and handle it
1442 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001443 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001444 * <p class="note">
1445 * You can <em>not</em> receive this through components declared
1446 * in manifests, only by explicitly registering for it with
1447 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1448 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001449 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001450 * <p class="note">This is a protected intent that can only be sent
1451 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001452 *
1453 * @see android.content.res.Configuration
1454 */
1455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1456 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1457 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001458 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001459 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001460 * <p class="note">This is a protected intent that can only be sent
1461 * by the system.
1462 */
1463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1464 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1465 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001466 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1467 * charging state, level, and other information about the battery.
1468 * See {@link android.os.BatteryManager} for documentation on the
1469 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001470 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001471 * <p class="note">
1472 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001473 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001474 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001475 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1476 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1477 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1478 * broadcasts that are sent and can be received through manifest
1479 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001480 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001481 * <p class="note">This is a protected intent that can only be sent
1482 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001483 */
1484 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1485 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1486 /**
1487 * Broadcast Action: Indicates low battery condition on the device.
1488 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001489 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001490 * <p class="note">This is a protected intent that can only be sent
1491 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001492 */
1493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1494 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1495 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001496 * Broadcast Action: Indicates the battery is now okay after being low.
1497 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1498 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001499 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001500 * <p class="note">This is a protected intent that can only be sent
1501 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001502 */
1503 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1504 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1505 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001506 * Broadcast Action: External power has been connected to the device.
1507 * This is intended for applications that wish to register specifically to this notification.
1508 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1509 * stay active to receive this notification. This action can be used to implement actions
1510 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001511 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001512 * <p class="note">This is a protected intent that can only be sent
1513 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001514 */
1515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001516 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001517 /**
1518 * Broadcast Action: External power has been removed from the device.
1519 * This is intended for applications that wish to register specifically to this notification.
1520 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1521 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001522 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001523 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001524 * <p class="note">This is a protected intent that can only be sent
1525 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001526 */
1527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001528 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001529 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001530 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001531 * Broadcast Action: Device is shutting down.
1532 * This is broadcast when the device is being shut down (completely turned
1533 * off, not sleeping). Once the broadcast is complete, the final shutdown
1534 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001535 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001536 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001537 * <p class="note">This is a protected intent that can only be sent
1538 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001539 */
1540 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001541 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001542 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001543 * Activity Action: Start this activity to request system shutdown.
1544 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1545 * to request confirmation from the user before shutting down.
1546 *
1547 * <p class="note">This is a protected intent that can only be sent
1548 * by the system.
1549 *
1550 * {@hide}
1551 */
1552 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1553 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001554 * Broadcast Action: A sticky broadcast that indicates low memory
1555 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001556 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001557 * <p class="note">This is a protected intent that can only be sent
1558 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001559 */
1560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1561 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1562 /**
1563 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001564 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001565 * <p class="note">This is a protected intent that can only be sent
1566 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001567 */
1568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1569 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1570 /**
1571 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1572 * and package management should be started.
1573 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1574 * notification.
1575 */
1576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1577 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1578 /**
1579 * Broadcast Action: The device has entered USB Mass Storage mode.
1580 * This is used mainly for the USB Settings panel.
1581 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1582 * when the SD card file system is mounted or unmounted
1583 */
1584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1585 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1586
1587 /**
1588 * Broadcast Action: The device has exited USB Mass Storage mode.
1589 * This is used mainly for the USB Settings panel.
1590 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1591 * when the SD card file system is mounted or unmounted
1592 */
1593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1594 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1595
1596 /**
1597 * Broadcast Action: External media has been removed.
1598 * The path to the mount point for the removed media is contained in the Intent.mData field.
1599 */
1600 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1601 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1602
1603 /**
1604 * Broadcast Action: External media is present, but not mounted at its mount point.
1605 * The path to the mount point for the removed media is contained in the Intent.mData field.
1606 */
1607 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1608 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1609
1610 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001611 * Broadcast Action: External media is present, and being disk-checked
1612 * 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 -08001613 */
1614 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1615 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1616
1617 /**
1618 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1619 * 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 -08001620 */
1621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1622 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1623
1624 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001625 * Broadcast Action: External media is present and mounted at its mount point.
1626 * The path to the mount point for the removed media is contained in the Intent.mData field.
1627 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1628 * media was mounted read only.
1629 */
1630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1631 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1632
1633 /**
1634 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001635 * The path to the mount point for the shared media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001636 */
1637 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1638 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1639
1640 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001641 * Broadcast Action: External media is no longer being shared via USB mass storage.
1642 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1643 *
1644 * @hide
1645 */
1646 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1647
1648 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001649 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1650 * The path to the mount point for the removed media is contained in the Intent.mData field.
1651 */
1652 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1653 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1654
1655 /**
1656 * Broadcast Action: External media is present but cannot be mounted.
1657 * The path to the mount point for the removed media is contained in the Intent.mData field.
1658 */
1659 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1660 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1661
1662 /**
1663 * Broadcast Action: User has expressed the desire to remove the external storage media.
1664 * Applications should close all files they have open within the mount point when they receive this intent.
1665 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1666 */
1667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1668 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1669
1670 /**
1671 * Broadcast Action: The media scanner has started scanning a directory.
1672 * The path to the directory being scanned is contained in the Intent.mData field.
1673 */
1674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1675 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1676
1677 /**
1678 * Broadcast Action: The media scanner has finished scanning a directory.
1679 * The path to the scanned directory is contained in the Intent.mData field.
1680 */
1681 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1682 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1683
1684 /**
1685 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1686 * The path to the file is contained in the Intent.mData field.
1687 */
1688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1689 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1690
1691 /**
1692 * Broadcast Action: The "Media Button" was pressed. Includes a single
1693 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1694 * caused the broadcast.
1695 */
1696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1697 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1698
1699 /**
1700 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1701 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1702 * caused the broadcast.
1703 */
1704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1705 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1706
1707 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1708 // location; they are not general-purpose actions.
1709
1710 /**
1711 * Broadcast Action: An GTalk connection has been established.
1712 */
1713 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1714 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1715 "android.intent.action.GTALK_CONNECTED";
1716
1717 /**
1718 * Broadcast Action: An GTalk connection has been disconnected.
1719 */
1720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1721 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1722 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001723
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001724 /**
1725 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001726 */
1727 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1728 public static final String ACTION_INPUT_METHOD_CHANGED =
1729 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001730
1731 /**
1732 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1733 * more radios have been turned off or on. The intent will have the following extra value:</p>
1734 * <ul>
1735 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1736 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1737 * turned off</li>
1738 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001739 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001740 * <p class="note">This is a protected intent that can only be sent
1741 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001742 */
1743 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1744 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1745
1746 /**
1747 * Broadcast Action: Some content providers have parts of their namespace
1748 * where they publish new events or items that the user may be especially
1749 * interested in. For these things, they may broadcast this action when the
1750 * set of interesting items change.
1751 *
1752 * For example, GmailProvider sends this notification when the set of unread
1753 * mail in the inbox changes.
1754 *
1755 * <p>The data of the intent identifies which part of which provider
1756 * changed. When queried through the content resolver, the data URI will
1757 * return the data set in question.
1758 *
1759 * <p>The intent will have the following extra values:
1760 * <ul>
1761 * <li><em>count</em> - The number of items in the data set. This is the
1762 * same as the number of items in the cursor returned by querying the
1763 * data URI. </li>
1764 * </ul>
1765 *
1766 * This intent will be sent at boot (if the count is non-zero) and when the
1767 * data set changes. It is possible for the data set to change without the
1768 * count changing (for example, if a new unread message arrives in the same
1769 * sync operation in which a message is archived). The phone should still
1770 * ring/vibrate/etc as normal in this case.
1771 */
1772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1773 public static final String ACTION_PROVIDER_CHANGED =
1774 "android.intent.action.PROVIDER_CHANGED";
1775
1776 /**
1777 * Broadcast Action: Wired Headset plugged in or unplugged.
1778 *
1779 * <p>The intent will have the following extra values:
1780 * <ul>
1781 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1782 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001783 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001784 * </ul>
1785 * </ul>
1786 */
1787 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1788 public static final String ACTION_HEADSET_PLUG =
1789 "android.intent.action.HEADSET_PLUG";
1790
1791 /**
1792 * Broadcast Action: An outgoing call is about to be placed.
1793 *
1794 * <p>The Intent will have the following extra value:
1795 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07001796 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001797 * the phone number originally intended to be dialed.</li>
1798 * </ul>
1799 * <p>Once the broadcast is finished, the resultData is used as the actual
1800 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07001801 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001802 * outgoing call in turn: for example, a parental control application
1803 * might verify that the user is authorized to place the call at that
1804 * time, then a number-rewriting application might add an area code if
1805 * one was not specified.</p>
1806 * <p>For consistency, any receiver whose purpose is to prohibit phone
1807 * calls should have a priority of 0, to ensure it will see the final
1808 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07001809 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001810 * should have a positive priority.
1811 * Negative priorities are reserved for the system for this broadcast;
1812 * using them may cause problems.</p>
1813 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
1814 * abort the broadcast.</p>
1815 * <p>Emergency calls cannot be intercepted using this mechanism, and
1816 * other calls cannot be modified to call emergency numbers using this
1817 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07001818 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001819 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
1820 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08001821 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001822 * <p class="note">This is a protected intent that can only be sent
1823 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001824 */
1825 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1826 public static final String ACTION_NEW_OUTGOING_CALL =
1827 "android.intent.action.NEW_OUTGOING_CALL";
1828
1829 /**
1830 * Broadcast Action: Have the device reboot. This is only for use by
1831 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08001832 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001833 * <p class="note">This is a protected intent that can only be sent
1834 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001835 */
1836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1837 public static final String ACTION_REBOOT =
1838 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001839
Wei Huang97ecc9c2009-05-11 17:44:20 -07001840 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001841 * Broadcast Action: A sticky broadcast indicating the phone was docked
Tobias Haamel154f7a12010-02-17 11:56:39 -08001842 * or undocked.
1843 *
1844 * <p>The intent will have the following extra values:
1845 * <ul>
1846 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
1847 * state, which depends on the state of the car mode.</li>
1848 * <li><em>{@link #EXTRA_PHYSICAL_DOCK_STATE}</em> - the physical dock
1849 * state.</li>
1850 * <li><em>{@link #EXTRA_CAR_MODE_ENABLED}</em> - a boolean indicating the
1851 * state of the car mode.</li>
1852 * </ul>
1853 * <p>This is intended for monitoring the current dock state.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001854 * To launch an activity from a dock state change, use {@link #CATEGORY_CAR_DOCK}
1855 * or {@link #CATEGORY_DESK_DOCK} instead.
1856 */
1857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1858 public static final String ACTION_DOCK_EVENT =
1859 "android.intent.action.DOCK_EVENT";
1860
1861 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07001862 * Broadcast Action: a remote intent is to be broadcasted.
1863 *
1864 * A remote intent is used for remote RPC between devices. The remote intent
1865 * is serialized and sent from one device to another device. The receiving
1866 * device parses the remote intent and broadcasts it. Note that anyone can
1867 * broadcast a remote intent. However, if the intent receiver of the remote intent
1868 * does not trust intent broadcasts from arbitrary intent senders, it should require
1869 * the sender to hold certain permissions so only trusted sender's broadcast will be
1870 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001871 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07001872 */
1873 public static final String ACTION_REMOTE_INTENT =
Costin Manolache63cfebf2010-02-04 16:52:34 -08001874 "com.google.android.pushmessaging.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07001875
Dianne Hackborn9acc0302009-08-25 00:27:12 -07001876 /**
1877 * Broadcast Action: hook for permforming cleanup after a system update.
1878 *
1879 * The broadcast is sent when the system is booting, before the
1880 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
1881 * image. A receiver for this should do its work and then disable itself
1882 * so that it does not get run again at the next boot.
1883 * @hide
1884 */
1885 public static final String ACTION_PRE_BOOT_COMPLETED =
1886 "android.intent.action.PRE_BOOT_COMPLETED";
1887
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001888 // ---------------------------------------------------------------------
1889 // ---------------------------------------------------------------------
1890 // Standard intent categories (see addCategory()).
1891
1892 /**
1893 * Set if the activity should be an option for the default action
1894 * (center press) to perform on a piece of data. Setting this will
1895 * hide from the user any activities without it set when performing an
1896 * action on some data. Note that this is normal -not- set in the
1897 * Intent when initiating an action -- it is for use in intent filters
1898 * specified in packages.
1899 */
1900 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1901 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
1902 /**
1903 * Activities that can be safely invoked from a browser must support this
1904 * category. For example, if the user is viewing a web page or an e-mail
1905 * and clicks on a link in the text, the Intent generated execute that
1906 * link will require the BROWSABLE category, so that only activities
1907 * supporting this category will be considered as possible actions. By
1908 * supporting this category, you are promising that there is nothing
1909 * damaging (without user intervention) that can happen by invoking any
1910 * matching Intent.
1911 */
1912 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1913 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
1914 /**
1915 * Set if the activity should be considered as an alternative action to
1916 * the data the user is currently viewing. See also
1917 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
1918 * applies to the selection in a list of items.
1919 *
1920 * <p>Supporting this category means that you would like your activity to be
1921 * displayed in the set of alternative things the user can do, usually as
1922 * part of the current activity's options menu. You will usually want to
1923 * include a specific label in the &lt;intent-filter&gt; of this action
1924 * describing to the user what it does.
1925 *
1926 * <p>The action of IntentFilter with this category is important in that it
1927 * describes the specific action the target will perform. This generally
1928 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
1929 * a specific name such as "com.android.camera.action.CROP. Only one
1930 * alternative of any particular action will be shown to the user, so using
1931 * a specific action like this makes sure that your alternative will be
1932 * displayed while also allowing other applications to provide their own
1933 * overrides of that particular action.
1934 */
1935 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1936 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
1937 /**
1938 * Set if the activity should be considered as an alternative selection
1939 * action to the data the user has currently selected. This is like
1940 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
1941 * of items from which the user can select, giving them alternatives to the
1942 * default action that will be performed on it.
1943 */
1944 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1945 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
1946 /**
1947 * Intended to be used as a tab inside of an containing TabActivity.
1948 */
1949 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1950 public static final String CATEGORY_TAB = "android.intent.category.TAB";
1951 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001952 * Should be displayed in the top-level launcher.
1953 */
1954 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1955 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
1956 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001957 * Provides information about the package it is in; typically used if
1958 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
1959 * a front-door to the user without having to be shown in the all apps list.
1960 */
1961 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1962 public static final String CATEGORY_INFO = "android.intent.category.INFO";
1963 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 * This is the home activity, that is the first activity that is displayed
1965 * when the device boots.
1966 */
1967 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1968 public static final String CATEGORY_HOME = "android.intent.category.HOME";
1969 /**
1970 * This activity is a preference panel.
1971 */
1972 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1973 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
1974 /**
1975 * This activity is a development preference panel.
1976 */
1977 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1978 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
1979 /**
1980 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001981 */
1982 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1983 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
1984 /**
1985 * This activity may be exercised by the monkey or other automated test tools.
1986 */
1987 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1988 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
1989 /**
1990 * To be used as a test (not part of the normal user experience).
1991 */
1992 public static final String CATEGORY_TEST = "android.intent.category.TEST";
1993 /**
1994 * To be used as a unit test (run through the Test Harness).
1995 */
1996 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
1997 /**
1998 * To be used as an sample code example (not part of the normal user
1999 * experience).
2000 */
2001 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2002 /**
2003 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2004 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2005 * when queried, though it is allowable for those columns to be blank.
2006 */
2007 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2008 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2009
2010 /**
2011 * To be used as code under test for framework instrumentation tests.
2012 */
2013 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2014 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002015 /**
2016 * An activity to run when device is inserted into a car dock.
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002017 * Used with {@link #ACTION_MAIN} to launch an activity.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002018 * To monitor dock state, use {@link #ACTION_DOCK_EVENT} instead.
2019 */
2020 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2021 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2022 /**
2023 * An activity to run when device is inserted into a car dock.
2024 * Used with {@link #ACTION_MAIN} to launch an activity.
2025 * To monitor dock state, use {@link #ACTION_DOCK_EVENT} instead.
2026 */
2027 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2028 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002029
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002030 // ---------------------------------------------------------------------
2031 // ---------------------------------------------------------------------
2032 // Standard extra data keys.
2033
2034 /**
2035 * The initial data to place in a newly created record. Use with
2036 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2037 * fields as would be given to the underlying ContentProvider.insert()
2038 * call.
2039 */
2040 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2041
2042 /**
2043 * A constant CharSequence that is associated with the Intent, used with
2044 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2045 * this may be a styled CharSequence, so you must use
2046 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2047 * retrieve it.
2048 */
2049 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2050
2051 /**
2052 * A content: URI holding a stream of data associated with the Intent,
2053 * used with {@link #ACTION_SEND} to supply the data being sent.
2054 */
2055 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2056
2057 /**
2058 * A String[] holding e-mail addresses that should be delivered to.
2059 */
2060 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2061
2062 /**
2063 * A String[] holding e-mail addresses that should be carbon copied.
2064 */
2065 public static final String EXTRA_CC = "android.intent.extra.CC";
2066
2067 /**
2068 * A String[] holding e-mail addresses that should be blind carbon copied.
2069 */
2070 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2071
2072 /**
2073 * A constant string holding the desired subject line of a message.
2074 */
2075 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2076
2077 /**
2078 * An Intent describing the choices you would like shown with
2079 * {@link #ACTION_PICK_ACTIVITY}.
2080 */
2081 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2082
2083 /**
2084 * A CharSequence dialog title to provide to the user when used with a
2085 * {@link #ACTION_CHOOSER}.
2086 */
2087 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2088
2089 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002090 * A Parcelable[] of {@link Intent} or
2091 * {@link android.content.pm.LabeledIntent} objects as set with
2092 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2093 * a the front of the list of choices, when shown to the user with a
2094 * {@link #ACTION_CHOOSER}.
2095 */
2096 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2097
2098 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002099 * A {@link android.view.KeyEvent} object containing the event that
2100 * triggered the creation of the Intent it is in.
2101 */
2102 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2103
2104 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002105 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2106 * before shutting down.
2107 *
2108 * {@hide}
2109 */
2110 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2111
2112 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2114 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2115 * of restarting the application.
2116 */
2117 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2118
2119 /**
2120 * A String holding the phone number originally entered in
2121 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2122 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2123 */
2124 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002125
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002126 /**
2127 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2128 * intents to supply the uid the package had been assigned. Also an optional
2129 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2130 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2131 * purpose.
2132 */
2133 public static final String EXTRA_UID = "android.intent.extra.UID";
2134
2135 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002136 * @hide String array of package names.
2137 */
2138 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2139
2140 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002141 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2142 * intents to indicate whether this represents a full uninstall (removing
2143 * both the code and its data) or a partial uninstall (leaving its data,
2144 * implying that this is an update).
2145 */
2146 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002147
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002148 /**
2149 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2150 * intents to indicate that this is a replacement of the package, so this
2151 * broadcast will immediately be followed by an add broadcast for a
2152 * different version of the same package.
2153 */
2154 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002155
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002156 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002157 * Used as an int extra field in {@link android.app.AlarmManager} intents
2158 * to tell the application being invoked how many pending alarms are being
2159 * delievered with the intent. For one-shot alarms this will always be 1.
2160 * For recurring alarms, this might be greater than 1 if the device was
2161 * asleep or powered off at the time an earlier alarm would have been
2162 * delivered.
2163 */
2164 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002165
Jacek Surazski86b6c532009-05-13 14:38:28 +02002166 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002167 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2168 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002169 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2170 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2171 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002172 */
2173 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2174
2175 /**
2176 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2177 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002178 */
2179 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2180
2181 /**
2182 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2183 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002184 */
2185 public static final int EXTRA_DOCK_STATE_DESK = 1;
2186
2187 /**
2188 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2189 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002190 */
2191 public static final int EXTRA_DOCK_STATE_CAR = 2;
2192
2193 /**
Tobias Haamel154f7a12010-02-17 11:56:39 -08002194 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2195 * intents to request the physical dock state. Possible values are
2196 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2197 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2198 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
2199 */
2200 public static final String EXTRA_PHYSICAL_DOCK_STATE =
2201 "android.intent.extra.PHYSICAL_DOCK_STATE";
2202
2203 /**
Tobias Haamel27b28b32010-02-09 23:09:17 +01002204 * Used as an boolean extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2205 * intents to indicate that the car mode is enabled or not.
2206 */
2207 public static final String EXTRA_CAR_MODE_ENABLED = "android.intent.extra.CAR_MODE_ENABLED";
2208
2209 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002210 * Boolean that can be supplied as meta-data with a dock activity, to
2211 * indicate that the dock should take over the home key when it is active.
2212 */
2213 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002214
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002215 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002216 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2217 * the bug report.
Romain Guy4969af72009-06-17 10:53:19 -07002218 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002219 * @hide
2220 */
2221 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2222
2223 /**
Romain Guy4969af72009-06-17 10:53:19 -07002224 * Used as a string extra field when sending an intent to PackageInstaller to install a
Jacek Surazski86b6c532009-05-13 14:38:28 +02002225 * package. Specifies the installer package name; this package will receive the
2226 * {@link #ACTION_APP_ERROR} intent.
Romain Guy4969af72009-06-17 10:53:19 -07002227 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002228 * @hide
2229 */
Romain Guy4969af72009-06-17 10:53:19 -07002230 public static final String EXTRA_INSTALLER_PACKAGE_NAME
Jacek Surazski86b6c532009-05-13 14:38:28 +02002231 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002232
Wei Huang97ecc9c2009-05-11 17:44:20 -07002233 /**
2234 * Used in the extra field in the remote intent. It's astring token passed with the
2235 * remote intent.
2236 */
2237 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2238 "android.intent.extra.remote_intent_token";
2239
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002240 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002241 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002242 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002243 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002244 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002245 "android.intent.extra.changed_component_name";
2246
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002247 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002248 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002249 * and contains a string array of all of the components that have changed.
2250 */
2251 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2252 "android.intent.extra.changed_component_name_list";
2253
2254 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002255 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002256 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2257 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002258 * and contains a string array of all of the components that have changed.
2259 * @hide
2260 */
2261 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2262 "android.intent.extra.changed_package_list";
2263
2264 /**
2265 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002266 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2267 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002268 * and contains an integer array of uids of all of the components
2269 * that have changed.
2270 * @hide
2271 */
2272 public static final String EXTRA_CHANGED_UID_LIST =
2273 "android.intent.extra.changed_uid_list";
2274
2275 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002276 * @hide
2277 * Magic extra system code can use when binding, to give a label for
2278 * who it is that has bound to a service. This is an integer giving
2279 * a framework string resource that can be displayed to the user.
2280 */
2281 public static final String EXTRA_CLIENT_LABEL =
2282 "android.intent.extra.client_label";
2283
2284 /**
2285 * @hide
2286 * Magic extra system code can use when binding, to give a PendingIntent object
2287 * that can be launched for the user to disable the system's use of this
2288 * service.
2289 */
2290 public static final String EXTRA_CLIENT_INTENT =
2291 "android.intent.extra.client_intent";
2292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002293 // ---------------------------------------------------------------------
2294 // ---------------------------------------------------------------------
2295 // Intent flags (see mFlags variable).
2296
2297 /**
2298 * If set, the recipient of this Intent will be granted permission to
2299 * perform read operations on the Uri in the Intent's data.
2300 */
2301 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2302 /**
2303 * If set, the recipient of this Intent will be granted permission to
2304 * perform write operations on the Uri in the Intent's data.
2305 */
2306 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2307 /**
2308 * Can be set by the caller to indicate that this Intent is coming from
2309 * a background operation, not from direct user interaction.
2310 */
2311 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2312 /**
2313 * A flag you can enable for debugging: when set, log messages will be
2314 * printed during the resolution of this intent to show you what has
2315 * been found to create the final resolved list.
2316 */
2317 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
2318
2319 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002320 * If set, the new activity is not kept in the history stack. As soon as
2321 * the user navigates away from it, the activity is finished. This may also
2322 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2323 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 */
2325 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2326 /**
2327 * If set, the activity will not be launched if it is already running
2328 * at the top of the history stack.
2329 */
2330 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2331 /**
2332 * If set, this activity will become the start of a new task on this
2333 * history stack. A task (from the activity that started it to the
2334 * next task activity) defines an atomic group of activities that the
2335 * user can move to. Tasks can be moved to the foreground and background;
2336 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002337 * the same order. See
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002338 * <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2339 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002340 *
2341 * <p>This flag is generally used by activities that want
2342 * to present a "launcher" style behavior: they give the user a list of
2343 * separate things that can be done, which otherwise run completely
2344 * independently of the activity launching them.
2345 *
2346 * <p>When using this flag, if a task is already running for the activity
2347 * you are now starting, then a new activity will not be started; instead,
2348 * the current task will simply be brought to the front of the screen with
2349 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2350 * to disable this behavior.
2351 *
2352 * <p>This flag can not be used when the caller is requesting a result from
2353 * the activity being launched.
2354 */
2355 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2356 /**
2357 * <strong>Do not use this flag unless you are implementing your own
2358 * top-level application launcher.</strong> Used in conjunction with
2359 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2360 * behavior of bringing an existing task to the foreground. When set,
2361 * a new task is <em>always</em> started to host the Activity for the
2362 * Intent, regardless of whether there is already an existing task running
2363 * the same thing.
2364 *
2365 * <p><strong>Because the default system does not include graphical task management,
2366 * you should not use this flag unless you provide some way for a user to
2367 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002368 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 * <p>This flag is ignored if
2370 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2371 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002372 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2373 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002374 */
2375 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2376 /**
2377 * If set, and the activity being launched is already running in the
2378 * current task, then instead of launching a new instance of that activity,
2379 * all of the other activities on top of it will be closed and this Intent
2380 * will be delivered to the (now on top) old activity as a new Intent.
2381 *
2382 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2383 * If D calls startActivity() with an Intent that resolves to the component
2384 * of activity B, then C and D will be finished and B receive the given
2385 * Intent, resulting in the stack now being: A, B.
2386 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002387 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002388 * either receive the new intent you are starting here in its
2389 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002390 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002391 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2392 * the same intent, then it will be finished and re-created; for all other
2393 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2394 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002395 *
2396 * <p>This launch mode can also be used to good effect in conjunction with
2397 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2398 * of a task, it will bring any currently running instance of that task
2399 * to the foreground, and then clear it to its root state. This is
2400 * especially useful, for example, when launching an activity from the
2401 * notification manager.
2402 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002403 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2404 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002405 */
2406 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2407 /**
2408 * If set and this intent is being used to launch a new activity from an
2409 * existing one, then the reply target of the existing activity will be
2410 * transfered to the new activity. This way the new activity can call
2411 * {@link android.app.Activity#setResult} and have that result sent back to
2412 * the reply target of the original activity.
2413 */
2414 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2415 /**
2416 * If set and this intent is being used to launch a new activity from an
2417 * existing one, the current activity will not be counted as the top
2418 * activity for deciding whether the new intent should be delivered to
2419 * the top instead of starting a new one. The previous activity will
2420 * be used as the top, with the assumption being that the current activity
2421 * will finish itself immediately.
2422 */
2423 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2424 /**
2425 * If set, the new activity is not kept in the list of recently launched
2426 * activities.
2427 */
2428 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2429 /**
2430 * This flag is not normally set by application code, but set for you by
2431 * the system as described in the
2432 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2433 * launchMode} documentation for the singleTask mode.
2434 */
2435 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2436 /**
2437 * If set, and this activity is either being started in a new task or
2438 * bringing to the top an existing task, then it will be launched as
2439 * the front door of the task. This will result in the application of
2440 * any affinities needed to have that task in the proper state (either
2441 * moving activities to or from it), or simply resetting that task to
2442 * its initial state if needed.
2443 */
2444 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2445 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002446 * This flag is not normally set by application code, but set for you by
2447 * the system if this activity is being launched from history
2448 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002449 */
2450 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002451 /**
2452 * If set, this marks a point in the task's activity stack that should
2453 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002454 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002455 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2456 * the user re-launching it from home), this activity and all on top of
2457 * it will be finished so that the user does not return to them, but
2458 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002459 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002460 * <p>This is useful for cases where you have a logical break in your
2461 * application. For example, an e-mail application may have a command
2462 * to view an attachment, which launches an image view activity to
2463 * display it. This activity should be part of the e-mail application's
2464 * task, since it is a part of the task the user is involved in. However,
2465 * if the user leaves that task, and later selects the e-mail app from
2466 * home, we may like them to return to the conversation they were
2467 * viewing, not the picture attachment, since that is confusing. By
2468 * setting this flag when launching the image viewer, that viewer and
2469 * any activities it starts will be removed the next time the user returns
2470 * to mail.
2471 */
2472 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002473 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002474 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002475 * callback from occurring on the current frontmost activity before it is
2476 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002477 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002478 * <p>Typically, an activity can rely on that callback to indicate that an
2479 * explicit user action has caused their activity to be moved out of the
2480 * foreground. The callback marks an appropriate point in the activity's
2481 * lifecycle for it to dismiss any notifications that it intends to display
2482 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002483 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002484 * <p>If an activity is ever started via any non-user-driven events such as
2485 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2486 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002487 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002488 */
2489 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002490 /**
2491 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2492 * this flag will cause the launched activity to be brought to the front of its
2493 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002494 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002495 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2496 * If D calls startActivity() with an Intent that resolves to the component
2497 * of activity B, then B will be brought to the front of the history stack,
2498 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002499 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002500 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002501 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002502 */
2503 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002504 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002505 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2506 * this flag will prevent the system from applying an activity transition
2507 * animation to go to the next activity state. This doesn't mean an
2508 * animation will never run -- if another activity change happens that doesn't
2509 * specify this flag before the activity started here is displayed, then
2510 * that transition will be used. This this flag can be put to good use
2511 * when you are going to do a series of activity operations but the
2512 * animation seen by the user shouldn't be driven by the first activity
2513 * change but rather a later one.
2514 */
2515 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2516 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002517 * If set, when sending a broadcast only registered receivers will be
2518 * called -- no BroadcastReceiver components will be launched.
2519 */
2520 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002521 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002522 * If set, when sending a broadcast the new broadcast will replace
2523 * any existing pending broadcast that matches it. Matching is defined
2524 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2525 * true for the intents of the two broadcasts. When a match is found,
2526 * the new broadcast (and receivers associated with it) will replace the
2527 * existing one in the pending broadcast list, remaining at the same
2528 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002529 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002530 * <p>This flag is most typically used with sticky broadcasts, which
2531 * only care about delivering the most recent values of the broadcast
2532 * to their receivers.
2533 */
2534 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2535 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002536 * If set, when sending a broadcast <i>before boot has completed</i> only
2537 * registered receivers will be called -- no BroadcastReceiver components
2538 * will be launched. Sticky intent state will be recorded properly even
2539 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2540 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002541 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002542 * <p>This flag is only for use by system sevices as a convenience to
2543 * avoid having to implement a more complex mechanism around detection
2544 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002545 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002546 * @hide
2547 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002548 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002549 /**
2550 * Set when this broadcast is for a boot upgrade, a special mode that
2551 * allows the broadcast to be sent before the system is ready and launches
2552 * the app process with no providers running in it.
2553 * @hide
2554 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002555 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002556
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002557 /**
2558 * @hide Flags that can't be changed with PendingIntent.
2559 */
2560 public static final int IMMUTABLE_FLAGS =
2561 FLAG_GRANT_READ_URI_PERMISSION
2562 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002563
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002564 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002565 // ---------------------------------------------------------------------
2566 // toUri() and parseUri() options.
2567
2568 /**
2569 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2570 * always has the "intent:" scheme. This syntax can be used when you want
2571 * to later disambiguate between URIs that are intended to describe an
2572 * Intent vs. all others that should be treated as raw URIs. When used
2573 * with {@link #parseUri}, any other scheme will result in a generic
2574 * VIEW action for that raw URI.
2575 */
2576 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002577
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002578 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579
2580 private String mAction;
2581 private Uri mData;
2582 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002583 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002584 private ComponentName mComponent;
2585 private int mFlags;
2586 private HashSet<String> mCategories;
2587 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002588 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589
2590 // ---------------------------------------------------------------------
2591
2592 /**
2593 * Create an empty intent.
2594 */
2595 public Intent() {
2596 }
2597
2598 /**
2599 * Copy constructor.
2600 */
2601 public Intent(Intent o) {
2602 this.mAction = o.mAction;
2603 this.mData = o.mData;
2604 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002605 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002606 this.mComponent = o.mComponent;
2607 this.mFlags = o.mFlags;
2608 if (o.mCategories != null) {
2609 this.mCategories = new HashSet<String>(o.mCategories);
2610 }
2611 if (o.mExtras != null) {
2612 this.mExtras = new Bundle(o.mExtras);
2613 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002614 if (o.mSourceBounds != null) {
2615 this.mSourceBounds = new Rect(o.mSourceBounds);
2616 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002617 }
2618
2619 @Override
2620 public Object clone() {
2621 return new Intent(this);
2622 }
2623
2624 private Intent(Intent o, boolean all) {
2625 this.mAction = o.mAction;
2626 this.mData = o.mData;
2627 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002628 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002629 this.mComponent = o.mComponent;
2630 if (o.mCategories != null) {
2631 this.mCategories = new HashSet<String>(o.mCategories);
2632 }
2633 }
2634
2635 /**
2636 * Make a clone of only the parts of the Intent that are relevant for
2637 * filter matching: the action, data, type, component, and categories.
2638 */
2639 public Intent cloneFilter() {
2640 return new Intent(this, false);
2641 }
2642
2643 /**
2644 * Create an intent with a given action. All other fields (data, type,
2645 * class) are null. Note that the action <em>must</em> be in a
2646 * namespace because Intents are used globally in the system -- for
2647 * example the system VIEW action is android.intent.action.VIEW; an
2648 * application's custom action would be something like
2649 * com.google.app.myapp.CUSTOM_ACTION.
2650 *
2651 * @param action The Intent action, such as ACTION_VIEW.
2652 */
2653 public Intent(String action) {
2654 mAction = action;
2655 }
2656
2657 /**
2658 * Create an intent with a given action and for a given data url. Note
2659 * that the action <em>must</em> be in a namespace because Intents are
2660 * used globally in the system -- for example the system VIEW action is
2661 * android.intent.action.VIEW; an application's custom action would be
2662 * something like com.google.app.myapp.CUSTOM_ACTION.
2663 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002664 * <p><em>Note: scheme and host name matching in the Android framework is
2665 * case-sensitive, unlike the formal RFC. As a result,
2666 * you should always ensure that you write your Uri with these elements
2667 * using lower case letters, and normalize any Uris you receive from
2668 * outside of Android to ensure the scheme and host is lower case.</em></p>
2669 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002670 * @param action The Intent action, such as ACTION_VIEW.
2671 * @param uri The Intent data URI.
2672 */
2673 public Intent(String action, Uri uri) {
2674 mAction = action;
2675 mData = uri;
2676 }
2677
2678 /**
2679 * Create an intent for a specific component. All other fields (action, data,
2680 * type, class) are null, though they can be modified later with explicit
2681 * calls. This provides a convenient way to create an intent that is
2682 * intended to execute a hard-coded class name, rather than relying on the
2683 * system to find an appropriate class for you; see {@link #setComponent}
2684 * for more information on the repercussions of this.
2685 *
2686 * @param packageContext A Context of the application package implementing
2687 * this class.
2688 * @param cls The component class that is to be used for the intent.
2689 *
2690 * @see #setClass
2691 * @see #setComponent
2692 * @see #Intent(String, android.net.Uri , Context, Class)
2693 */
2694 public Intent(Context packageContext, Class<?> cls) {
2695 mComponent = new ComponentName(packageContext, cls);
2696 }
2697
2698 /**
2699 * Create an intent for a specific component with a specified action and data.
2700 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
2701 * construct the Intent and then calling {@link #setClass} to set its
2702 * class.
2703 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002704 * <p><em>Note: scheme and host name matching in the Android framework is
2705 * case-sensitive, unlike the formal RFC. As a result,
2706 * you should always ensure that you write your Uri with these elements
2707 * using lower case letters, and normalize any Uris you receive from
2708 * outside of Android to ensure the scheme and host is lower case.</em></p>
2709 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002710 * @param action The Intent action, such as ACTION_VIEW.
2711 * @param uri The Intent data URI.
2712 * @param packageContext A Context of the application package implementing
2713 * this class.
2714 * @param cls The component class that is to be used for the intent.
2715 *
2716 * @see #Intent(String, android.net.Uri)
2717 * @see #Intent(Context, Class)
2718 * @see #setClass
2719 * @see #setComponent
2720 */
2721 public Intent(String action, Uri uri,
2722 Context packageContext, Class<?> cls) {
2723 mAction = action;
2724 mData = uri;
2725 mComponent = new ComponentName(packageContext, cls);
2726 }
2727
2728 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002729 * Call {@link #parseUri} with 0 flags.
2730 * @deprecated Use {@link #parseUri} instead.
2731 */
2732 @Deprecated
2733 public static Intent getIntent(String uri) throws URISyntaxException {
2734 return parseUri(uri, 0);
2735 }
Tom Taylord4a47292009-12-21 13:59:18 -08002736
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002737 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002739 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07002740 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002741 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002742 *
2743 * <p>The URI given here must not be relative -- that is, it must include
2744 * the scheme and full path.
2745 *
2746 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002747 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002748 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002749 *
2750 * @return Intent The newly created Intent object.
2751 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002752 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
2753 * it bad (as parsed by the Uri class) or the Intent data within the
2754 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08002755 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002756 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002757 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002758 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002759 int i = 0;
2760 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002761 // Validate intent scheme for if requested.
2762 if ((flags&URI_INTENT_SCHEME) != 0) {
2763 if (!uri.startsWith("intent:")) {
2764 Intent intent = new Intent(ACTION_VIEW);
2765 try {
2766 intent.setData(Uri.parse(uri));
2767 } catch (IllegalArgumentException e) {
2768 throw new URISyntaxException(uri, e.getMessage());
2769 }
2770 return intent;
2771 }
2772 }
Tom Taylord4a47292009-12-21 13:59:18 -08002773
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002774 // simple case
2775 i = uri.lastIndexOf("#");
2776 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
2777
2778 // old format Intent URI
2779 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07002780
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002781 // new format
2782 Intent intent = new Intent(ACTION_VIEW);
2783
2784 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002785 String data = i >= 0 ? uri.substring(0, i) : null;
2786 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002787 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07002788
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002789 // loop over contents of Intent, all name=value;
2790 while (!uri.startsWith("end", i)) {
2791 int eq = uri.indexOf('=', i);
2792 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002793 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002794
2795 // action
2796 if (uri.startsWith("action=", i)) {
2797 intent.mAction = value;
2798 }
2799
2800 // categories
2801 else if (uri.startsWith("category=", i)) {
2802 intent.addCategory(value);
2803 }
2804
2805 // type
2806 else if (uri.startsWith("type=", i)) {
2807 intent.mType = value;
2808 }
2809
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002810 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002811 else if (uri.startsWith("launchFlags=", i)) {
2812 intent.mFlags = Integer.decode(value).intValue();
2813 }
2814
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002815 // package
2816 else if (uri.startsWith("package=", i)) {
2817 intent.mPackage = value;
2818 }
2819
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002820 // component
2821 else if (uri.startsWith("component=", i)) {
2822 intent.mComponent = ComponentName.unflattenFromString(value);
2823 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002824
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002825 // scheme
2826 else if (uri.startsWith("scheme=", i)) {
2827 scheme = value;
2828 }
2829
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002830 // source bounds
2831 else if (uri.startsWith("sourceBounds=", i)) {
2832 intent.mSourceBounds = Rect.unflattenFromString(value);
2833 }
2834
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002835 // extra
2836 else {
2837 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002838 // create Bundle if it doesn't already exist
2839 if (intent.mExtras == null) intent.mExtras = new Bundle();
2840 Bundle b = intent.mExtras;
2841 // add EXTRA
2842 if (uri.startsWith("S.", i)) b.putString(key, value);
2843 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
2844 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
2845 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
2846 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
2847 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
2848 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
2849 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
2850 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
2851 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
2852 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002853
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002854 // move to the next item
2855 i = semi + 1;
2856 }
2857
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002858 if (data != null) {
2859 if (data.startsWith("intent:")) {
2860 data = data.substring(7);
2861 if (scheme != null) {
2862 data = scheme + ':' + data;
2863 }
2864 }
Tom Taylord4a47292009-12-21 13:59:18 -08002865
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002866 if (data.length() > 0) {
2867 try {
2868 intent.mData = Uri.parse(data);
2869 } catch (IllegalArgumentException e) {
2870 throw new URISyntaxException(uri, e.getMessage());
2871 }
2872 }
2873 }
Tom Taylord4a47292009-12-21 13:59:18 -08002874
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002875 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07002876
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002877 } catch (IndexOutOfBoundsException e) {
2878 throw new URISyntaxException(uri, "illegal Intent URI format", i);
2879 }
2880 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002881
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002882 public static Intent getIntentOld(String uri) throws URISyntaxException {
2883 Intent intent;
2884
2885 int i = uri.lastIndexOf('#');
2886 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002887 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002888 final int intentFragmentStart = i;
2889 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002890
2891 i++;
2892
2893 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002894 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002895 i += 7;
2896 int j = uri.indexOf(')', i);
2897 action = uri.substring(i, j);
2898 i = j + 1;
2899 }
2900
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002901 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002902
2903 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002904 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002905 i += 11;
2906 int j = uri.indexOf(')', i);
2907 while (i < j) {
2908 int sep = uri.indexOf('!', i);
2909 if (sep < 0) sep = j;
2910 if (i < sep) {
2911 intent.addCategory(uri.substring(i, sep));
2912 }
2913 i = sep + 1;
2914 }
2915 i = j + 1;
2916 }
2917
2918 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002919 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002920 i += 5;
2921 int j = uri.indexOf(')', i);
2922 intent.mType = uri.substring(i, j);
2923 i = j + 1;
2924 }
2925
2926 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002927 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002928 i += 12;
2929 int j = uri.indexOf(')', i);
2930 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
2931 i = j + 1;
2932 }
2933
2934 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002935 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002936 i += 10;
2937 int j = uri.indexOf(')', i);
2938 int sep = uri.indexOf('!', i);
2939 if (sep >= 0 && sep < j) {
2940 String pkg = uri.substring(i, sep);
2941 String cls = uri.substring(sep + 1, j);
2942 intent.mComponent = new ComponentName(pkg, cls);
2943 }
2944 i = j + 1;
2945 }
2946
2947 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002948 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002949 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07002950
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002951 final int closeParen = uri.indexOf(')', i);
2952 if (closeParen == -1) throw new URISyntaxException(uri,
2953 "EXTRA missing trailing ')'", i);
2954
2955 while (i < closeParen) {
2956 // fetch the key value
2957 int j = uri.indexOf('=', i);
2958 if (j <= i + 1 || i >= closeParen) {
2959 throw new URISyntaxException(uri, "EXTRA missing '='", i);
2960 }
2961 char type = uri.charAt(i);
2962 i++;
2963 String key = uri.substring(i, j);
2964 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07002965
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002966 // get type-value
2967 j = uri.indexOf('!', i);
2968 if (j == -1 || j >= closeParen) j = closeParen;
2969 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
2970 String value = uri.substring(i, j);
2971 i = j;
2972
2973 // create Bundle if it doesn't already exist
2974 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07002975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002976 // add item to bundle
2977 try {
2978 switch (type) {
2979 case 'S':
2980 intent.mExtras.putString(key, Uri.decode(value));
2981 break;
2982 case 'B':
2983 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
2984 break;
2985 case 'b':
2986 intent.mExtras.putByte(key, Byte.parseByte(value));
2987 break;
2988 case 'c':
2989 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
2990 break;
2991 case 'd':
2992 intent.mExtras.putDouble(key, Double.parseDouble(value));
2993 break;
2994 case 'f':
2995 intent.mExtras.putFloat(key, Float.parseFloat(value));
2996 break;
2997 case 'i':
2998 intent.mExtras.putInt(key, Integer.parseInt(value));
2999 break;
3000 case 'l':
3001 intent.mExtras.putLong(key, Long.parseLong(value));
3002 break;
3003 case 's':
3004 intent.mExtras.putShort(key, Short.parseShort(value));
3005 break;
3006 default:
3007 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3008 }
3009 } catch (NumberFormatException e) {
3010 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3011 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003013 char ch = uri.charAt(i);
3014 if (ch == ')') break;
3015 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3016 i++;
3017 }
3018 }
3019
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003020 if (isIntentFragment) {
3021 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3022 } else {
3023 intent.mData = Uri.parse(uri);
3024 }
Tom Taylord4a47292009-12-21 13:59:18 -08003025
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003026 if (intent.mAction == null) {
3027 // By default, if no action is specified, then use VIEW.
3028 intent.mAction = ACTION_VIEW;
3029 }
3030
3031 } else {
3032 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3033 }
3034
3035 return intent;
3036 }
3037
3038 /**
3039 * Retrieve the general action to be performed, such as
3040 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3041 * the information in the intent should be interpreted -- most importantly,
3042 * what to do with the data returned by {@link #getData}.
3043 *
3044 * @return The action of this intent or null if none is specified.
3045 *
3046 * @see #setAction
3047 */
3048 public String getAction() {
3049 return mAction;
3050 }
3051
3052 /**
3053 * Retrieve data this intent is operating on. This URI specifies the name
3054 * of the data; often it uses the content: scheme, specifying data in a
3055 * content provider. Other schemes may be handled by specific activities,
3056 * such as http: by the web browser.
3057 *
3058 * @return The URI of the data this intent is targeting or null.
3059 *
3060 * @see #getScheme
3061 * @see #setData
3062 */
3063 public Uri getData() {
3064 return mData;
3065 }
3066
3067 /**
3068 * The same as {@link #getData()}, but returns the URI as an encoded
3069 * String.
3070 */
3071 public String getDataString() {
3072 return mData != null ? mData.toString() : null;
3073 }
3074
3075 /**
3076 * Return the scheme portion of the intent's data. If the data is null or
3077 * does not include a scheme, null is returned. Otherwise, the scheme
3078 * prefix without the final ':' is returned, i.e. "http".
3079 *
3080 * <p>This is the same as calling getData().getScheme() (and checking for
3081 * null data).
3082 *
3083 * @return The scheme of this intent.
3084 *
3085 * @see #getData
3086 */
3087 public String getScheme() {
3088 return mData != null ? mData.getScheme() : null;
3089 }
3090
3091 /**
3092 * Retrieve any explicit MIME type included in the intent. This is usually
3093 * null, as the type is determined by the intent data.
3094 *
3095 * @return If a type was manually set, it is returned; else null is
3096 * returned.
3097 *
3098 * @see #resolveType(ContentResolver)
3099 * @see #setType
3100 */
3101 public String getType() {
3102 return mType;
3103 }
3104
3105 /**
3106 * Return the MIME data type of this intent. If the type field is
3107 * explicitly set, that is simply returned. Otherwise, if the data is set,
3108 * the type of that data is returned. If neither fields are set, a null is
3109 * returned.
3110 *
3111 * @return The MIME type of this intent.
3112 *
3113 * @see #getType
3114 * @see #resolveType(ContentResolver)
3115 */
3116 public String resolveType(Context context) {
3117 return resolveType(context.getContentResolver());
3118 }
3119
3120 /**
3121 * Return the MIME data type of this intent. If the type field is
3122 * explicitly set, that is simply returned. Otherwise, if the data is set,
3123 * the type of that data is returned. If neither fields are set, a null is
3124 * returned.
3125 *
3126 * @param resolver A ContentResolver that can be used to determine the MIME
3127 * type of the intent's data.
3128 *
3129 * @return The MIME type of this intent.
3130 *
3131 * @see #getType
3132 * @see #resolveType(Context)
3133 */
3134 public String resolveType(ContentResolver resolver) {
3135 if (mType != null) {
3136 return mType;
3137 }
3138 if (mData != null) {
3139 if ("content".equals(mData.getScheme())) {
3140 return resolver.getType(mData);
3141 }
3142 }
3143 return null;
3144 }
3145
3146 /**
3147 * Return the MIME data type of this intent, only if it will be needed for
3148 * intent resolution. This is not generally useful for application code;
3149 * it is used by the frameworks for communicating with back-end system
3150 * services.
3151 *
3152 * @param resolver A ContentResolver that can be used to determine the MIME
3153 * type of the intent's data.
3154 *
3155 * @return The MIME type of this intent, or null if it is unknown or not
3156 * needed.
3157 */
3158 public String resolveTypeIfNeeded(ContentResolver resolver) {
3159 if (mComponent != null) {
3160 return mType;
3161 }
3162 return resolveType(resolver);
3163 }
3164
3165 /**
3166 * Check if an category exists in the intent.
3167 *
3168 * @param category The category to check.
3169 *
3170 * @return boolean True if the intent contains the category, else false.
3171 *
3172 * @see #getCategories
3173 * @see #addCategory
3174 */
3175 public boolean hasCategory(String category) {
3176 return mCategories != null && mCategories.contains(category);
3177 }
3178
3179 /**
3180 * Return the set of all categories in the intent. If there are no categories,
3181 * returns NULL.
3182 *
3183 * @return Set The set of categories you can examine. Do not modify!
3184 *
3185 * @see #hasCategory
3186 * @see #addCategory
3187 */
3188 public Set<String> getCategories() {
3189 return mCategories;
3190 }
3191
3192 /**
3193 * Sets the ClassLoader that will be used when unmarshalling
3194 * any Parcelable values from the extras of this Intent.
3195 *
3196 * @param loader a ClassLoader, or null to use the default loader
3197 * at the time of unmarshalling.
3198 */
3199 public void setExtrasClassLoader(ClassLoader loader) {
3200 if (mExtras != null) {
3201 mExtras.setClassLoader(loader);
3202 }
3203 }
3204
3205 /**
3206 * Returns true if an extra value is associated with the given name.
3207 * @param name the extra's name
3208 * @return true if the given extra is present.
3209 */
3210 public boolean hasExtra(String name) {
3211 return mExtras != null && mExtras.containsKey(name);
3212 }
3213
3214 /**
3215 * Returns true if the Intent's extras contain a parcelled file descriptor.
3216 * @return true if the Intent contains a parcelled file descriptor.
3217 */
3218 public boolean hasFileDescriptors() {
3219 return mExtras != null && mExtras.hasFileDescriptors();
3220 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003221
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003222 /**
3223 * Retrieve extended data from the intent.
3224 *
3225 * @param name The name of the desired item.
3226 *
3227 * @return the value of an item that previously added with putExtra()
3228 * or null if none was found.
3229 *
3230 * @deprecated
3231 * @hide
3232 */
3233 @Deprecated
3234 public Object getExtra(String name) {
3235 return getExtra(name, null);
3236 }
3237
3238 /**
3239 * Retrieve extended data from the intent.
3240 *
3241 * @param name The name of the desired item.
3242 * @param defaultValue the value to be returned if no value of the desired
3243 * type is stored with the given name.
3244 *
3245 * @return the value of an item that previously added with putExtra()
3246 * or the default value if none was found.
3247 *
3248 * @see #putExtra(String, boolean)
3249 */
3250 public boolean getBooleanExtra(String name, boolean defaultValue) {
3251 return mExtras == null ? defaultValue :
3252 mExtras.getBoolean(name, defaultValue);
3253 }
3254
3255 /**
3256 * Retrieve extended data from the intent.
3257 *
3258 * @param name The name of the desired item.
3259 * @param defaultValue the value to be returned if no value of the desired
3260 * type is stored with the given name.
3261 *
3262 * @return the value of an item that previously added with putExtra()
3263 * or the default value if none was found.
3264 *
3265 * @see #putExtra(String, byte)
3266 */
3267 public byte getByteExtra(String name, byte defaultValue) {
3268 return mExtras == null ? defaultValue :
3269 mExtras.getByte(name, defaultValue);
3270 }
3271
3272 /**
3273 * Retrieve extended data from the intent.
3274 *
3275 * @param name The name of the desired item.
3276 * @param defaultValue the value to be returned if no value of the desired
3277 * type is stored with the given name.
3278 *
3279 * @return the value of an item that previously added with putExtra()
3280 * or the default value if none was found.
3281 *
3282 * @see #putExtra(String, short)
3283 */
3284 public short getShortExtra(String name, short defaultValue) {
3285 return mExtras == null ? defaultValue :
3286 mExtras.getShort(name, defaultValue);
3287 }
3288
3289 /**
3290 * Retrieve extended data from the intent.
3291 *
3292 * @param name The name of the desired item.
3293 * @param defaultValue the value to be returned if no value of the desired
3294 * type is stored with the given name.
3295 *
3296 * @return the value of an item that previously added with putExtra()
3297 * or the default value if none was found.
3298 *
3299 * @see #putExtra(String, char)
3300 */
3301 public char getCharExtra(String name, char defaultValue) {
3302 return mExtras == null ? defaultValue :
3303 mExtras.getChar(name, defaultValue);
3304 }
3305
3306 /**
3307 * Retrieve extended data from the intent.
3308 *
3309 * @param name The name of the desired item.
3310 * @param defaultValue the value to be returned if no value of the desired
3311 * type is stored with the given name.
3312 *
3313 * @return the value of an item that previously added with putExtra()
3314 * or the default value if none was found.
3315 *
3316 * @see #putExtra(String, int)
3317 */
3318 public int getIntExtra(String name, int defaultValue) {
3319 return mExtras == null ? defaultValue :
3320 mExtras.getInt(name, defaultValue);
3321 }
3322
3323 /**
3324 * Retrieve extended data from the intent.
3325 *
3326 * @param name The name of the desired item.
3327 * @param defaultValue the value to be returned if no value of the desired
3328 * type is stored with the given name.
3329 *
3330 * @return the value of an item that previously added with putExtra()
3331 * or the default value if none was found.
3332 *
3333 * @see #putExtra(String, long)
3334 */
3335 public long getLongExtra(String name, long defaultValue) {
3336 return mExtras == null ? defaultValue :
3337 mExtras.getLong(name, defaultValue);
3338 }
3339
3340 /**
3341 * Retrieve extended data from the intent.
3342 *
3343 * @param name The name of the desired item.
3344 * @param defaultValue the value to be returned if no value of the desired
3345 * type is stored with the given name.
3346 *
3347 * @return the value of an item that previously added with putExtra(),
3348 * or the default value if no such item is present
3349 *
3350 * @see #putExtra(String, float)
3351 */
3352 public float getFloatExtra(String name, float defaultValue) {
3353 return mExtras == null ? defaultValue :
3354 mExtras.getFloat(name, defaultValue);
3355 }
3356
3357 /**
3358 * Retrieve extended data from the intent.
3359 *
3360 * @param name The name of the desired item.
3361 * @param defaultValue the value to be returned if no value of the desired
3362 * type is stored with the given name.
3363 *
3364 * @return the value of an item that previously added with putExtra()
3365 * or the default value if none was found.
3366 *
3367 * @see #putExtra(String, double)
3368 */
3369 public double getDoubleExtra(String name, double defaultValue) {
3370 return mExtras == null ? defaultValue :
3371 mExtras.getDouble(name, defaultValue);
3372 }
3373
3374 /**
3375 * Retrieve extended data from the intent.
3376 *
3377 * @param name The name of the desired item.
3378 *
3379 * @return the value of an item that previously added with putExtra()
3380 * or null if no String value was found.
3381 *
3382 * @see #putExtra(String, String)
3383 */
3384 public String getStringExtra(String name) {
3385 return mExtras == null ? null : mExtras.getString(name);
3386 }
3387
3388 /**
3389 * Retrieve extended data from the intent.
3390 *
3391 * @param name The name of the desired item.
3392 *
3393 * @return the value of an item that previously added with putExtra()
3394 * or null if no CharSequence value was found.
3395 *
3396 * @see #putExtra(String, CharSequence)
3397 */
3398 public CharSequence getCharSequenceExtra(String name) {
3399 return mExtras == null ? null : mExtras.getCharSequence(name);
3400 }
3401
3402 /**
3403 * Retrieve extended data from the intent.
3404 *
3405 * @param name The name of the desired item.
3406 *
3407 * @return the value of an item that previously added with putExtra()
3408 * or null if no Parcelable value was found.
3409 *
3410 * @see #putExtra(String, Parcelable)
3411 */
3412 public <T extends Parcelable> T getParcelableExtra(String name) {
3413 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3414 }
3415
3416 /**
3417 * Retrieve extended data from the intent.
3418 *
3419 * @param name The name of the desired item.
3420 *
3421 * @return the value of an item that previously added with putExtra()
3422 * or null if no Parcelable[] value was found.
3423 *
3424 * @see #putExtra(String, Parcelable[])
3425 */
3426 public Parcelable[] getParcelableArrayExtra(String name) {
3427 return mExtras == null ? null : mExtras.getParcelableArray(name);
3428 }
3429
3430 /**
3431 * Retrieve extended data from the intent.
3432 *
3433 * @param name The name of the desired item.
3434 *
3435 * @return the value of an item that previously added with putExtra()
3436 * or null if no ArrayList<Parcelable> value was found.
3437 *
3438 * @see #putParcelableArrayListExtra(String, ArrayList)
3439 */
3440 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3441 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3442 }
3443
3444 /**
3445 * Retrieve extended data from the intent.
3446 *
3447 * @param name The name of the desired item.
3448 *
3449 * @return the value of an item that previously added with putExtra()
3450 * or null if no Serializable value was found.
3451 *
3452 * @see #putExtra(String, Serializable)
3453 */
3454 public Serializable getSerializableExtra(String name) {
3455 return mExtras == null ? null : mExtras.getSerializable(name);
3456 }
3457
3458 /**
3459 * Retrieve extended data from the intent.
3460 *
3461 * @param name The name of the desired item.
3462 *
3463 * @return the value of an item that previously added with putExtra()
3464 * or null if no ArrayList<Integer> value was found.
3465 *
3466 * @see #putIntegerArrayListExtra(String, ArrayList)
3467 */
3468 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3469 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3470 }
3471
3472 /**
3473 * Retrieve extended data from the intent.
3474 *
3475 * @param name The name of the desired item.
3476 *
3477 * @return the value of an item that previously added with putExtra()
3478 * or null if no ArrayList<String> value was found.
3479 *
3480 * @see #putStringArrayListExtra(String, ArrayList)
3481 */
3482 public ArrayList<String> getStringArrayListExtra(String name) {
3483 return mExtras == null ? null : mExtras.getStringArrayList(name);
3484 }
3485
3486 /**
3487 * Retrieve extended data from the intent.
3488 *
3489 * @param name The name of the desired item.
3490 *
3491 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003492 * or null if no ArrayList<CharSequence> value was found.
3493 *
3494 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3495 */
3496 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3497 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3498 }
3499
3500 /**
3501 * Retrieve extended data from the intent.
3502 *
3503 * @param name The name of the desired item.
3504 *
3505 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003506 * or null if no boolean array value was found.
3507 *
3508 * @see #putExtra(String, boolean[])
3509 */
3510 public boolean[] getBooleanArrayExtra(String name) {
3511 return mExtras == null ? null : mExtras.getBooleanArray(name);
3512 }
3513
3514 /**
3515 * Retrieve extended data from the intent.
3516 *
3517 * @param name The name of the desired item.
3518 *
3519 * @return the value of an item that previously added with putExtra()
3520 * or null if no byte array value was found.
3521 *
3522 * @see #putExtra(String, byte[])
3523 */
3524 public byte[] getByteArrayExtra(String name) {
3525 return mExtras == null ? null : mExtras.getByteArray(name);
3526 }
3527
3528 /**
3529 * Retrieve extended data from the intent.
3530 *
3531 * @param name The name of the desired item.
3532 *
3533 * @return the value of an item that previously added with putExtra()
3534 * or null if no short array value was found.
3535 *
3536 * @see #putExtra(String, short[])
3537 */
3538 public short[] getShortArrayExtra(String name) {
3539 return mExtras == null ? null : mExtras.getShortArray(name);
3540 }
3541
3542 /**
3543 * Retrieve extended data from the intent.
3544 *
3545 * @param name The name of the desired item.
3546 *
3547 * @return the value of an item that previously added with putExtra()
3548 * or null if no char array value was found.
3549 *
3550 * @see #putExtra(String, char[])
3551 */
3552 public char[] getCharArrayExtra(String name) {
3553 return mExtras == null ? null : mExtras.getCharArray(name);
3554 }
3555
3556 /**
3557 * Retrieve extended data from the intent.
3558 *
3559 * @param name The name of the desired item.
3560 *
3561 * @return the value of an item that previously added with putExtra()
3562 * or null if no int array value was found.
3563 *
3564 * @see #putExtra(String, int[])
3565 */
3566 public int[] getIntArrayExtra(String name) {
3567 return mExtras == null ? null : mExtras.getIntArray(name);
3568 }
3569
3570 /**
3571 * Retrieve extended data from the intent.
3572 *
3573 * @param name The name of the desired item.
3574 *
3575 * @return the value of an item that previously added with putExtra()
3576 * or null if no long array value was found.
3577 *
3578 * @see #putExtra(String, long[])
3579 */
3580 public long[] getLongArrayExtra(String name) {
3581 return mExtras == null ? null : mExtras.getLongArray(name);
3582 }
3583
3584 /**
3585 * Retrieve extended data from the intent.
3586 *
3587 * @param name The name of the desired item.
3588 *
3589 * @return the value of an item that previously added with putExtra()
3590 * or null if no float array value was found.
3591 *
3592 * @see #putExtra(String, float[])
3593 */
3594 public float[] getFloatArrayExtra(String name) {
3595 return mExtras == null ? null : mExtras.getFloatArray(name);
3596 }
3597
3598 /**
3599 * Retrieve extended data from the intent.
3600 *
3601 * @param name The name of the desired item.
3602 *
3603 * @return the value of an item that previously added with putExtra()
3604 * or null if no double array value was found.
3605 *
3606 * @see #putExtra(String, double[])
3607 */
3608 public double[] getDoubleArrayExtra(String name) {
3609 return mExtras == null ? null : mExtras.getDoubleArray(name);
3610 }
3611
3612 /**
3613 * Retrieve extended data from the intent.
3614 *
3615 * @param name The name of the desired item.
3616 *
3617 * @return the value of an item that previously added with putExtra()
3618 * or null if no String array value was found.
3619 *
3620 * @see #putExtra(String, String[])
3621 */
3622 public String[] getStringArrayExtra(String name) {
3623 return mExtras == null ? null : mExtras.getStringArray(name);
3624 }
3625
3626 /**
3627 * Retrieve extended data from the intent.
3628 *
3629 * @param name The name of the desired item.
3630 *
3631 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003632 * or null if no CharSequence array value was found.
3633 *
3634 * @see #putExtra(String, CharSequence[])
3635 */
3636 public CharSequence[] getCharSequenceArrayExtra(String name) {
3637 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3638 }
3639
3640 /**
3641 * Retrieve extended data from the intent.
3642 *
3643 * @param name The name of the desired item.
3644 *
3645 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003646 * or null if no Bundle value was found.
3647 *
3648 * @see #putExtra(String, Bundle)
3649 */
3650 public Bundle getBundleExtra(String name) {
3651 return mExtras == null ? null : mExtras.getBundle(name);
3652 }
3653
3654 /**
3655 * Retrieve extended data from the intent.
3656 *
3657 * @param name The name of the desired item.
3658 *
3659 * @return the value of an item that previously added with putExtra()
3660 * or null if no IBinder value was found.
3661 *
3662 * @see #putExtra(String, IBinder)
3663 *
3664 * @deprecated
3665 * @hide
3666 */
3667 @Deprecated
3668 public IBinder getIBinderExtra(String name) {
3669 return mExtras == null ? null : mExtras.getIBinder(name);
3670 }
3671
3672 /**
3673 * Retrieve extended data from the intent.
3674 *
3675 * @param name The name of the desired item.
3676 * @param defaultValue The default value to return in case no item is
3677 * associated with the key 'name'
3678 *
3679 * @return the value of an item that previously added with putExtra()
3680 * or defaultValue if none was found.
3681 *
3682 * @see #putExtra
3683 *
3684 * @deprecated
3685 * @hide
3686 */
3687 @Deprecated
3688 public Object getExtra(String name, Object defaultValue) {
3689 Object result = defaultValue;
3690 if (mExtras != null) {
3691 Object result2 = mExtras.get(name);
3692 if (result2 != null) {
3693 result = result2;
3694 }
3695 }
3696
3697 return result;
3698 }
3699
3700 /**
3701 * Retrieves a map of extended data from the intent.
3702 *
3703 * @return the map of all extras previously added with putExtra(),
3704 * or null if none have been added.
3705 */
3706 public Bundle getExtras() {
3707 return (mExtras != null)
3708 ? new Bundle(mExtras)
3709 : null;
3710 }
3711
3712 /**
3713 * Retrieve any special flags associated with this intent. You will
3714 * normally just set them with {@link #setFlags} and let the system
3715 * take the appropriate action with them.
3716 *
3717 * @return int The currently set flags.
3718 *
3719 * @see #setFlags
3720 */
3721 public int getFlags() {
3722 return mFlags;
3723 }
3724
3725 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003726 * Retrieve the application package name this Intent is limited to. When
3727 * resolving an Intent, if non-null this limits the resolution to only
3728 * components in the given application package.
3729 *
3730 * @return The name of the application package for the Intent.
3731 *
3732 * @see #resolveActivity
3733 * @see #setPackage
3734 */
3735 public String getPackage() {
3736 return mPackage;
3737 }
3738
3739 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003740 * Retrieve the concrete component associated with the intent. When receiving
3741 * an intent, this is the component that was found to best handle it (that is,
3742 * yourself) and will always be non-null; in all other cases it will be
3743 * null unless explicitly set.
3744 *
3745 * @return The name of the application component to handle the intent.
3746 *
3747 * @see #resolveActivity
3748 * @see #setComponent
3749 */
3750 public ComponentName getComponent() {
3751 return mComponent;
3752 }
3753
3754 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003755 * Get the bounds of the sender of this intent, in screen coordinates. This can be
3756 * used as a hint to the receiver for animations and the like. Null means that there
3757 * is no source bounds.
3758 */
3759 public Rect getSourceBounds() {
3760 return mSourceBounds;
3761 }
3762
3763 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003764 * Return the Activity component that should be used to handle this intent.
3765 * The appropriate component is determined based on the information in the
3766 * intent, evaluated as follows:
3767 *
3768 * <p>If {@link #getComponent} returns an explicit class, that is returned
3769 * without any further consideration.
3770 *
3771 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
3772 * category to be considered.
3773 *
3774 * <p>If {@link #getAction} is non-NULL, the activity must handle this
3775 * action.
3776 *
3777 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
3778 * this type.
3779 *
3780 * <p>If {@link #addCategory} has added any categories, the activity must
3781 * handle ALL of the categories specified.
3782 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003783 * <p>If {@link #getPackage} is non-NULL, only activity components in
3784 * that application package will be considered.
3785 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003786 * <p>If there are no activities that satisfy all of these conditions, a
3787 * null string is returned.
3788 *
3789 * <p>If multiple activities are found to satisfy the intent, the one with
3790 * the highest priority will be used. If there are multiple activities
3791 * with the same priority, the system will either pick the best activity
3792 * based on user preference, or resolve to a system class that will allow
3793 * the user to pick an activity and forward from there.
3794 *
3795 * <p>This method is implemented simply by calling
3796 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
3797 * true.</p>
3798 * <p> This API is called for you as part of starting an activity from an
3799 * intent. You do not normally need to call it yourself.</p>
3800 *
3801 * @param pm The package manager with which to resolve the Intent.
3802 *
3803 * @return Name of the component implementing an activity that can
3804 * display the intent.
3805 *
3806 * @see #setComponent
3807 * @see #getComponent
3808 * @see #resolveActivityInfo
3809 */
3810 public ComponentName resolveActivity(PackageManager pm) {
3811 if (mComponent != null) {
3812 return mComponent;
3813 }
3814
3815 ResolveInfo info = pm.resolveActivity(
3816 this, PackageManager.MATCH_DEFAULT_ONLY);
3817 if (info != null) {
3818 return new ComponentName(
3819 info.activityInfo.applicationInfo.packageName,
3820 info.activityInfo.name);
3821 }
3822
3823 return null;
3824 }
3825
3826 /**
3827 * Resolve the Intent into an {@link ActivityInfo}
3828 * describing the activity that should execute the intent. Resolution
3829 * follows the same rules as described for {@link #resolveActivity}, but
3830 * you get back the completely information about the resolved activity
3831 * instead of just its class name.
3832 *
3833 * @param pm The package manager with which to resolve the Intent.
3834 * @param flags Addition information to retrieve as per
3835 * {@link PackageManager#getActivityInfo(ComponentName, int)
3836 * PackageManager.getActivityInfo()}.
3837 *
3838 * @return PackageManager.ActivityInfo
3839 *
3840 * @see #resolveActivity
3841 */
3842 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
3843 ActivityInfo ai = null;
3844 if (mComponent != null) {
3845 try {
3846 ai = pm.getActivityInfo(mComponent, flags);
3847 } catch (PackageManager.NameNotFoundException e) {
3848 // ignore
3849 }
3850 } else {
3851 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003852 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003853 if (info != null) {
3854 ai = info.activityInfo;
3855 }
3856 }
3857
3858 return ai;
3859 }
3860
3861 /**
3862 * Set the general action to be performed.
3863 *
3864 * @param action An action name, such as ACTION_VIEW. Application-specific
3865 * actions should be prefixed with the vendor's package name.
3866 *
3867 * @return Returns the same Intent object, for chaining multiple calls
3868 * into a single statement.
3869 *
3870 * @see #getAction
3871 */
3872 public Intent setAction(String action) {
3873 mAction = action;
3874 return this;
3875 }
3876
3877 /**
3878 * Set the data this intent is operating on. This method automatically
3879 * clears any type that was previously set by {@link #setType}.
3880 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003881 * <p><em>Note: scheme and host name matching in the Android framework is
3882 * case-sensitive, unlike the formal RFC. As a result,
3883 * you should always ensure that you write your Uri with these elements
3884 * using lower case letters, and normalize any Uris you receive from
3885 * outside of Android to ensure the scheme and host is lower case.</em></p>
3886 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003887 * @param data The URI of the data this intent is now targeting.
3888 *
3889 * @return Returns the same Intent object, for chaining multiple calls
3890 * into a single statement.
3891 *
3892 * @see #getData
3893 * @see #setType
3894 * @see #setDataAndType
3895 */
3896 public Intent setData(Uri data) {
3897 mData = data;
3898 mType = null;
3899 return this;
3900 }
3901
3902 /**
3903 * Set an explicit MIME data type. This is used to create intents that
3904 * only specify a type and not data, for example to indicate the type of
3905 * data to return. This method automatically clears any data that was
3906 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07003907 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003908 * <p><em>Note: MIME type matching in the Android framework is
3909 * case-sensitive, unlike formal RFC MIME types. As a result,
3910 * you should always write your MIME types with lower case letters,
3911 * and any MIME types you receive from outside of Android should be
3912 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003913 *
3914 * @param type The MIME type of the data being handled by this intent.
3915 *
3916 * @return Returns the same Intent object, for chaining multiple calls
3917 * into a single statement.
3918 *
3919 * @see #getType
3920 * @see #setData
3921 * @see #setDataAndType
3922 */
3923 public Intent setType(String type) {
3924 mData = null;
3925 mType = type;
3926 return this;
3927 }
3928
3929 /**
3930 * (Usually optional) Set the data for the intent along with an explicit
3931 * MIME data type. This method should very rarely be used -- it allows you
3932 * to override the MIME type that would ordinarily be inferred from the
3933 * data with your own type given here.
3934 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003935 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
3936 * Android framework is case-sensitive, unlike the formal RFC definitions.
3937 * As a result, you should always write these elements with lower case letters,
3938 * and normalize any MIME types or Uris you receive from
3939 * outside of Android to ensure these elements are lower case before
3940 * supplying them here.</em></p>
3941 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003942 * @param data The URI of the data this intent is now targeting.
3943 * @param type The MIME type of the data being handled by this intent.
3944 *
3945 * @return Returns the same Intent object, for chaining multiple calls
3946 * into a single statement.
3947 *
3948 * @see #setData
3949 * @see #setType
3950 */
3951 public Intent setDataAndType(Uri data, String type) {
3952 mData = data;
3953 mType = type;
3954 return this;
3955 }
3956
3957 /**
3958 * Add a new category to the intent. Categories provide additional detail
3959 * about the action the intent is perform. When resolving an intent, only
3960 * activities that provide <em>all</em> of the requested categories will be
3961 * used.
3962 *
3963 * @param category The desired category. This can be either one of the
3964 * predefined Intent categories, or a custom category in your own
3965 * namespace.
3966 *
3967 * @return Returns the same Intent object, for chaining multiple calls
3968 * into a single statement.
3969 *
3970 * @see #hasCategory
3971 * @see #removeCategory
3972 */
3973 public Intent addCategory(String category) {
3974 if (mCategories == null) {
3975 mCategories = new HashSet<String>();
3976 }
3977 mCategories.add(category);
3978 return this;
3979 }
3980
3981 /**
3982 * Remove an category from an intent.
3983 *
3984 * @param category The category to remove.
3985 *
3986 * @see #addCategory
3987 */
3988 public void removeCategory(String category) {
3989 if (mCategories != null) {
3990 mCategories.remove(category);
3991 if (mCategories.size() == 0) {
3992 mCategories = null;
3993 }
3994 }
3995 }
3996
3997 /**
3998 * Add extended data to the intent. The name must include a package
3999 * prefix, for example the app com.android.contacts would use names
4000 * like "com.android.contacts.ShowAll".
4001 *
4002 * @param name The name of the extra data, with package prefix.
4003 * @param value The boolean data value.
4004 *
4005 * @return Returns the same Intent object, for chaining multiple calls
4006 * into a single statement.
4007 *
4008 * @see #putExtras
4009 * @see #removeExtra
4010 * @see #getBooleanExtra(String, boolean)
4011 */
4012 public Intent putExtra(String name, boolean value) {
4013 if (mExtras == null) {
4014 mExtras = new Bundle();
4015 }
4016 mExtras.putBoolean(name, value);
4017 return this;
4018 }
4019
4020 /**
4021 * Add extended data to the intent. The name must include a package
4022 * prefix, for example the app com.android.contacts would use names
4023 * like "com.android.contacts.ShowAll".
4024 *
4025 * @param name The name of the extra data, with package prefix.
4026 * @param value The byte data value.
4027 *
4028 * @return Returns the same Intent object, for chaining multiple calls
4029 * into a single statement.
4030 *
4031 * @see #putExtras
4032 * @see #removeExtra
4033 * @see #getByteExtra(String, byte)
4034 */
4035 public Intent putExtra(String name, byte value) {
4036 if (mExtras == null) {
4037 mExtras = new Bundle();
4038 }
4039 mExtras.putByte(name, value);
4040 return this;
4041 }
4042
4043 /**
4044 * Add extended data to the intent. The name must include a package
4045 * prefix, for example the app com.android.contacts would use names
4046 * like "com.android.contacts.ShowAll".
4047 *
4048 * @param name The name of the extra data, with package prefix.
4049 * @param value The char data value.
4050 *
4051 * @return Returns the same Intent object, for chaining multiple calls
4052 * into a single statement.
4053 *
4054 * @see #putExtras
4055 * @see #removeExtra
4056 * @see #getCharExtra(String, char)
4057 */
4058 public Intent putExtra(String name, char value) {
4059 if (mExtras == null) {
4060 mExtras = new Bundle();
4061 }
4062 mExtras.putChar(name, value);
4063 return this;
4064 }
4065
4066 /**
4067 * Add extended data to the intent. The name must include a package
4068 * prefix, for example the app com.android.contacts would use names
4069 * like "com.android.contacts.ShowAll".
4070 *
4071 * @param name The name of the extra data, with package prefix.
4072 * @param value The short data value.
4073 *
4074 * @return Returns the same Intent object, for chaining multiple calls
4075 * into a single statement.
4076 *
4077 * @see #putExtras
4078 * @see #removeExtra
4079 * @see #getShortExtra(String, short)
4080 */
4081 public Intent putExtra(String name, short value) {
4082 if (mExtras == null) {
4083 mExtras = new Bundle();
4084 }
4085 mExtras.putShort(name, value);
4086 return this;
4087 }
4088
4089 /**
4090 * Add extended data to the intent. The name must include a package
4091 * prefix, for example the app com.android.contacts would use names
4092 * like "com.android.contacts.ShowAll".
4093 *
4094 * @param name The name of the extra data, with package prefix.
4095 * @param value The integer data value.
4096 *
4097 * @return Returns the same Intent object, for chaining multiple calls
4098 * into a single statement.
4099 *
4100 * @see #putExtras
4101 * @see #removeExtra
4102 * @see #getIntExtra(String, int)
4103 */
4104 public Intent putExtra(String name, int value) {
4105 if (mExtras == null) {
4106 mExtras = new Bundle();
4107 }
4108 mExtras.putInt(name, value);
4109 return this;
4110 }
4111
4112 /**
4113 * Add extended data to the intent. The name must include a package
4114 * prefix, for example the app com.android.contacts would use names
4115 * like "com.android.contacts.ShowAll".
4116 *
4117 * @param name The name of the extra data, with package prefix.
4118 * @param value The long data value.
4119 *
4120 * @return Returns the same Intent object, for chaining multiple calls
4121 * into a single statement.
4122 *
4123 * @see #putExtras
4124 * @see #removeExtra
4125 * @see #getLongExtra(String, long)
4126 */
4127 public Intent putExtra(String name, long value) {
4128 if (mExtras == null) {
4129 mExtras = new Bundle();
4130 }
4131 mExtras.putLong(name, value);
4132 return this;
4133 }
4134
4135 /**
4136 * Add extended data to the intent. The name must include a package
4137 * prefix, for example the app com.android.contacts would use names
4138 * like "com.android.contacts.ShowAll".
4139 *
4140 * @param name The name of the extra data, with package prefix.
4141 * @param value The float data value.
4142 *
4143 * @return Returns the same Intent object, for chaining multiple calls
4144 * into a single statement.
4145 *
4146 * @see #putExtras
4147 * @see #removeExtra
4148 * @see #getFloatExtra(String, float)
4149 */
4150 public Intent putExtra(String name, float value) {
4151 if (mExtras == null) {
4152 mExtras = new Bundle();
4153 }
4154 mExtras.putFloat(name, value);
4155 return this;
4156 }
4157
4158 /**
4159 * Add extended data to the intent. The name must include a package
4160 * prefix, for example the app com.android.contacts would use names
4161 * like "com.android.contacts.ShowAll".
4162 *
4163 * @param name The name of the extra data, with package prefix.
4164 * @param value The double data value.
4165 *
4166 * @return Returns the same Intent object, for chaining multiple calls
4167 * into a single statement.
4168 *
4169 * @see #putExtras
4170 * @see #removeExtra
4171 * @see #getDoubleExtra(String, double)
4172 */
4173 public Intent putExtra(String name, double value) {
4174 if (mExtras == null) {
4175 mExtras = new Bundle();
4176 }
4177 mExtras.putDouble(name, value);
4178 return this;
4179 }
4180
4181 /**
4182 * Add extended data to the intent. The name must include a package
4183 * prefix, for example the app com.android.contacts would use names
4184 * like "com.android.contacts.ShowAll".
4185 *
4186 * @param name The name of the extra data, with package prefix.
4187 * @param value The String data value.
4188 *
4189 * @return Returns the same Intent object, for chaining multiple calls
4190 * into a single statement.
4191 *
4192 * @see #putExtras
4193 * @see #removeExtra
4194 * @see #getStringExtra(String)
4195 */
4196 public Intent putExtra(String name, String value) {
4197 if (mExtras == null) {
4198 mExtras = new Bundle();
4199 }
4200 mExtras.putString(name, value);
4201 return this;
4202 }
4203
4204 /**
4205 * Add extended data to the intent. The name must include a package
4206 * prefix, for example the app com.android.contacts would use names
4207 * like "com.android.contacts.ShowAll".
4208 *
4209 * @param name The name of the extra data, with package prefix.
4210 * @param value The CharSequence data value.
4211 *
4212 * @return Returns the same Intent object, for chaining multiple calls
4213 * into a single statement.
4214 *
4215 * @see #putExtras
4216 * @see #removeExtra
4217 * @see #getCharSequenceExtra(String)
4218 */
4219 public Intent putExtra(String name, CharSequence value) {
4220 if (mExtras == null) {
4221 mExtras = new Bundle();
4222 }
4223 mExtras.putCharSequence(name, value);
4224 return this;
4225 }
4226
4227 /**
4228 * Add extended data to the intent. The name must include a package
4229 * prefix, for example the app com.android.contacts would use names
4230 * like "com.android.contacts.ShowAll".
4231 *
4232 * @param name The name of the extra data, with package prefix.
4233 * @param value The Parcelable data value.
4234 *
4235 * @return Returns the same Intent object, for chaining multiple calls
4236 * into a single statement.
4237 *
4238 * @see #putExtras
4239 * @see #removeExtra
4240 * @see #getParcelableExtra(String)
4241 */
4242 public Intent putExtra(String name, Parcelable value) {
4243 if (mExtras == null) {
4244 mExtras = new Bundle();
4245 }
4246 mExtras.putParcelable(name, value);
4247 return this;
4248 }
4249
4250 /**
4251 * Add extended data to the intent. The name must include a package
4252 * prefix, for example the app com.android.contacts would use names
4253 * like "com.android.contacts.ShowAll".
4254 *
4255 * @param name The name of the extra data, with package prefix.
4256 * @param value The Parcelable[] data value.
4257 *
4258 * @return Returns the same Intent object, for chaining multiple calls
4259 * into a single statement.
4260 *
4261 * @see #putExtras
4262 * @see #removeExtra
4263 * @see #getParcelableArrayExtra(String)
4264 */
4265 public Intent putExtra(String name, Parcelable[] value) {
4266 if (mExtras == null) {
4267 mExtras = new Bundle();
4268 }
4269 mExtras.putParcelableArray(name, value);
4270 return this;
4271 }
4272
4273 /**
4274 * Add extended data to the intent. The name must include a package
4275 * prefix, for example the app com.android.contacts would use names
4276 * like "com.android.contacts.ShowAll".
4277 *
4278 * @param name The name of the extra data, with package prefix.
4279 * @param value The ArrayList<Parcelable> data value.
4280 *
4281 * @return Returns the same Intent object, for chaining multiple calls
4282 * into a single statement.
4283 *
4284 * @see #putExtras
4285 * @see #removeExtra
4286 * @see #getParcelableArrayListExtra(String)
4287 */
4288 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4289 if (mExtras == null) {
4290 mExtras = new Bundle();
4291 }
4292 mExtras.putParcelableArrayList(name, value);
4293 return this;
4294 }
4295
4296 /**
4297 * Add extended data to the intent. The name must include a package
4298 * prefix, for example the app com.android.contacts would use names
4299 * like "com.android.contacts.ShowAll".
4300 *
4301 * @param name The name of the extra data, with package prefix.
4302 * @param value The ArrayList<Integer> data value.
4303 *
4304 * @return Returns the same Intent object, for chaining multiple calls
4305 * into a single statement.
4306 *
4307 * @see #putExtras
4308 * @see #removeExtra
4309 * @see #getIntegerArrayListExtra(String)
4310 */
4311 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4312 if (mExtras == null) {
4313 mExtras = new Bundle();
4314 }
4315 mExtras.putIntegerArrayList(name, value);
4316 return this;
4317 }
4318
4319 /**
4320 * Add extended data to the intent. The name must include a package
4321 * prefix, for example the app com.android.contacts would use names
4322 * like "com.android.contacts.ShowAll".
4323 *
4324 * @param name The name of the extra data, with package prefix.
4325 * @param value The ArrayList<String> data value.
4326 *
4327 * @return Returns the same Intent object, for chaining multiple calls
4328 * into a single statement.
4329 *
4330 * @see #putExtras
4331 * @see #removeExtra
4332 * @see #getStringArrayListExtra(String)
4333 */
4334 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4335 if (mExtras == null) {
4336 mExtras = new Bundle();
4337 }
4338 mExtras.putStringArrayList(name, value);
4339 return this;
4340 }
4341
4342 /**
4343 * Add extended data to the intent. The name must include a package
4344 * prefix, for example the app com.android.contacts would use names
4345 * like "com.android.contacts.ShowAll".
4346 *
4347 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004348 * @param value The ArrayList<CharSequence> data value.
4349 *
4350 * @return Returns the same Intent object, for chaining multiple calls
4351 * into a single statement.
4352 *
4353 * @see #putExtras
4354 * @see #removeExtra
4355 * @see #getCharSequenceArrayListExtra(String)
4356 */
4357 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4358 if (mExtras == null) {
4359 mExtras = new Bundle();
4360 }
4361 mExtras.putCharSequenceArrayList(name, value);
4362 return this;
4363 }
4364
4365 /**
4366 * Add extended data to the intent. The name must include a package
4367 * prefix, for example the app com.android.contacts would use names
4368 * like "com.android.contacts.ShowAll".
4369 *
4370 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004371 * @param value The Serializable data value.
4372 *
4373 * @return Returns the same Intent object, for chaining multiple calls
4374 * into a single statement.
4375 *
4376 * @see #putExtras
4377 * @see #removeExtra
4378 * @see #getSerializableExtra(String)
4379 */
4380 public Intent putExtra(String name, Serializable value) {
4381 if (mExtras == null) {
4382 mExtras = new Bundle();
4383 }
4384 mExtras.putSerializable(name, value);
4385 return this;
4386 }
4387
4388 /**
4389 * Add extended data to the intent. The name must include a package
4390 * prefix, for example the app com.android.contacts would use names
4391 * like "com.android.contacts.ShowAll".
4392 *
4393 * @param name The name of the extra data, with package prefix.
4394 * @param value The boolean array data value.
4395 *
4396 * @return Returns the same Intent object, for chaining multiple calls
4397 * into a single statement.
4398 *
4399 * @see #putExtras
4400 * @see #removeExtra
4401 * @see #getBooleanArrayExtra(String)
4402 */
4403 public Intent putExtra(String name, boolean[] value) {
4404 if (mExtras == null) {
4405 mExtras = new Bundle();
4406 }
4407 mExtras.putBooleanArray(name, value);
4408 return this;
4409 }
4410
4411 /**
4412 * Add extended data to the intent. The name must include a package
4413 * prefix, for example the app com.android.contacts would use names
4414 * like "com.android.contacts.ShowAll".
4415 *
4416 * @param name The name of the extra data, with package prefix.
4417 * @param value The byte array data value.
4418 *
4419 * @return Returns the same Intent object, for chaining multiple calls
4420 * into a single statement.
4421 *
4422 * @see #putExtras
4423 * @see #removeExtra
4424 * @see #getByteArrayExtra(String)
4425 */
4426 public Intent putExtra(String name, byte[] value) {
4427 if (mExtras == null) {
4428 mExtras = new Bundle();
4429 }
4430 mExtras.putByteArray(name, value);
4431 return this;
4432 }
4433
4434 /**
4435 * Add extended data to the intent. The name must include a package
4436 * prefix, for example the app com.android.contacts would use names
4437 * like "com.android.contacts.ShowAll".
4438 *
4439 * @param name The name of the extra data, with package prefix.
4440 * @param value The short array data value.
4441 *
4442 * @return Returns the same Intent object, for chaining multiple calls
4443 * into a single statement.
4444 *
4445 * @see #putExtras
4446 * @see #removeExtra
4447 * @see #getShortArrayExtra(String)
4448 */
4449 public Intent putExtra(String name, short[] value) {
4450 if (mExtras == null) {
4451 mExtras = new Bundle();
4452 }
4453 mExtras.putShortArray(name, value);
4454 return this;
4455 }
4456
4457 /**
4458 * Add extended data to the intent. The name must include a package
4459 * prefix, for example the app com.android.contacts would use names
4460 * like "com.android.contacts.ShowAll".
4461 *
4462 * @param name The name of the extra data, with package prefix.
4463 * @param value The char array data value.
4464 *
4465 * @return Returns the same Intent object, for chaining multiple calls
4466 * into a single statement.
4467 *
4468 * @see #putExtras
4469 * @see #removeExtra
4470 * @see #getCharArrayExtra(String)
4471 */
4472 public Intent putExtra(String name, char[] value) {
4473 if (mExtras == null) {
4474 mExtras = new Bundle();
4475 }
4476 mExtras.putCharArray(name, value);
4477 return this;
4478 }
4479
4480 /**
4481 * Add extended data to the intent. The name must include a package
4482 * prefix, for example the app com.android.contacts would use names
4483 * like "com.android.contacts.ShowAll".
4484 *
4485 * @param name The name of the extra data, with package prefix.
4486 * @param value The int array data value.
4487 *
4488 * @return Returns the same Intent object, for chaining multiple calls
4489 * into a single statement.
4490 *
4491 * @see #putExtras
4492 * @see #removeExtra
4493 * @see #getIntArrayExtra(String)
4494 */
4495 public Intent putExtra(String name, int[] value) {
4496 if (mExtras == null) {
4497 mExtras = new Bundle();
4498 }
4499 mExtras.putIntArray(name, value);
4500 return this;
4501 }
4502
4503 /**
4504 * Add extended data to the intent. The name must include a package
4505 * prefix, for example the app com.android.contacts would use names
4506 * like "com.android.contacts.ShowAll".
4507 *
4508 * @param name The name of the extra data, with package prefix.
4509 * @param value The byte array data value.
4510 *
4511 * @return Returns the same Intent object, for chaining multiple calls
4512 * into a single statement.
4513 *
4514 * @see #putExtras
4515 * @see #removeExtra
4516 * @see #getLongArrayExtra(String)
4517 */
4518 public Intent putExtra(String name, long[] value) {
4519 if (mExtras == null) {
4520 mExtras = new Bundle();
4521 }
4522 mExtras.putLongArray(name, value);
4523 return this;
4524 }
4525
4526 /**
4527 * Add extended data to the intent. The name must include a package
4528 * prefix, for example the app com.android.contacts would use names
4529 * like "com.android.contacts.ShowAll".
4530 *
4531 * @param name The name of the extra data, with package prefix.
4532 * @param value The float array data value.
4533 *
4534 * @return Returns the same Intent object, for chaining multiple calls
4535 * into a single statement.
4536 *
4537 * @see #putExtras
4538 * @see #removeExtra
4539 * @see #getFloatArrayExtra(String)
4540 */
4541 public Intent putExtra(String name, float[] value) {
4542 if (mExtras == null) {
4543 mExtras = new Bundle();
4544 }
4545 mExtras.putFloatArray(name, value);
4546 return this;
4547 }
4548
4549 /**
4550 * Add extended data to the intent. The name must include a package
4551 * prefix, for example the app com.android.contacts would use names
4552 * like "com.android.contacts.ShowAll".
4553 *
4554 * @param name The name of the extra data, with package prefix.
4555 * @param value The double array data value.
4556 *
4557 * @return Returns the same Intent object, for chaining multiple calls
4558 * into a single statement.
4559 *
4560 * @see #putExtras
4561 * @see #removeExtra
4562 * @see #getDoubleArrayExtra(String)
4563 */
4564 public Intent putExtra(String name, double[] value) {
4565 if (mExtras == null) {
4566 mExtras = new Bundle();
4567 }
4568 mExtras.putDoubleArray(name, value);
4569 return this;
4570 }
4571
4572 /**
4573 * Add extended data to the intent. The name must include a package
4574 * prefix, for example the app com.android.contacts would use names
4575 * like "com.android.contacts.ShowAll".
4576 *
4577 * @param name The name of the extra data, with package prefix.
4578 * @param value The String array data value.
4579 *
4580 * @return Returns the same Intent object, for chaining multiple calls
4581 * into a single statement.
4582 *
4583 * @see #putExtras
4584 * @see #removeExtra
4585 * @see #getStringArrayExtra(String)
4586 */
4587 public Intent putExtra(String name, String[] value) {
4588 if (mExtras == null) {
4589 mExtras = new Bundle();
4590 }
4591 mExtras.putStringArray(name, value);
4592 return this;
4593 }
4594
4595 /**
4596 * Add extended data to the intent. The name must include a package
4597 * prefix, for example the app com.android.contacts would use names
4598 * like "com.android.contacts.ShowAll".
4599 *
4600 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004601 * @param value The CharSequence array data value.
4602 *
4603 * @return Returns the same Intent object, for chaining multiple calls
4604 * into a single statement.
4605 *
4606 * @see #putExtras
4607 * @see #removeExtra
4608 * @see #getCharSequenceArrayExtra(String)
4609 */
4610 public Intent putExtra(String name, CharSequence[] value) {
4611 if (mExtras == null) {
4612 mExtras = new Bundle();
4613 }
4614 mExtras.putCharSequenceArray(name, value);
4615 return this;
4616 }
4617
4618 /**
4619 * Add extended data to the intent. The name must include a package
4620 * prefix, for example the app com.android.contacts would use names
4621 * like "com.android.contacts.ShowAll".
4622 *
4623 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004624 * @param value The Bundle data value.
4625 *
4626 * @return Returns the same Intent object, for chaining multiple calls
4627 * into a single statement.
4628 *
4629 * @see #putExtras
4630 * @see #removeExtra
4631 * @see #getBundleExtra(String)
4632 */
4633 public Intent putExtra(String name, Bundle value) {
4634 if (mExtras == null) {
4635 mExtras = new Bundle();
4636 }
4637 mExtras.putBundle(name, value);
4638 return this;
4639 }
4640
4641 /**
4642 * Add extended data to the intent. The name must include a package
4643 * prefix, for example the app com.android.contacts would use names
4644 * like "com.android.contacts.ShowAll".
4645 *
4646 * @param name The name of the extra data, with package prefix.
4647 * @param value The IBinder data value.
4648 *
4649 * @return Returns the same Intent object, for chaining multiple calls
4650 * into a single statement.
4651 *
4652 * @see #putExtras
4653 * @see #removeExtra
4654 * @see #getIBinderExtra(String)
4655 *
4656 * @deprecated
4657 * @hide
4658 */
4659 @Deprecated
4660 public Intent putExtra(String name, IBinder value) {
4661 if (mExtras == null) {
4662 mExtras = new Bundle();
4663 }
4664 mExtras.putIBinder(name, value);
4665 return this;
4666 }
4667
4668 /**
4669 * Copy all extras in 'src' in to this intent.
4670 *
4671 * @param src Contains the extras to copy.
4672 *
4673 * @see #putExtra
4674 */
4675 public Intent putExtras(Intent src) {
4676 if (src.mExtras != null) {
4677 if (mExtras == null) {
4678 mExtras = new Bundle(src.mExtras);
4679 } else {
4680 mExtras.putAll(src.mExtras);
4681 }
4682 }
4683 return this;
4684 }
4685
4686 /**
4687 * Add a set of extended data to the intent. The keys must include a package
4688 * prefix, for example the app com.android.contacts would use names
4689 * like "com.android.contacts.ShowAll".
4690 *
4691 * @param extras The Bundle of extras to add to this intent.
4692 *
4693 * @see #putExtra
4694 * @see #removeExtra
4695 */
4696 public Intent putExtras(Bundle extras) {
4697 if (mExtras == null) {
4698 mExtras = new Bundle();
4699 }
4700 mExtras.putAll(extras);
4701 return this;
4702 }
4703
4704 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004705 * Completely replace the extras in the Intent with the extras in the
4706 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07004707 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004708 * @param src The exact extras contained in this Intent are copied
4709 * into the target intent, replacing any that were previously there.
4710 */
4711 public Intent replaceExtras(Intent src) {
4712 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
4713 return this;
4714 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004715
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004716 /**
4717 * Completely replace the extras in the Intent with the given Bundle of
4718 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07004719 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004720 * @param extras The new set of extras in the Intent, or null to erase
4721 * all extras.
4722 */
4723 public Intent replaceExtras(Bundle extras) {
4724 mExtras = extras != null ? new Bundle(extras) : null;
4725 return this;
4726 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004727
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004728 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004729 * Remove extended data from the intent.
4730 *
4731 * @see #putExtra
4732 */
4733 public void removeExtra(String name) {
4734 if (mExtras != null) {
4735 mExtras.remove(name);
4736 if (mExtras.size() == 0) {
4737 mExtras = null;
4738 }
4739 }
4740 }
4741
4742 /**
4743 * Set special flags controlling how this intent is handled. Most values
4744 * here depend on the type of component being executed by the Intent,
4745 * specifically the FLAG_ACTIVITY_* flags are all for use with
4746 * {@link Context#startActivity Context.startActivity()} and the
4747 * FLAG_RECEIVER_* flags are all for use with
4748 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
4749 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004750 * <p>See the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
4751 * 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 -07004752 * the behavior of your application.
4753 *
4754 * @param flags The desired flags.
4755 *
4756 * @return Returns the same Intent object, for chaining multiple calls
4757 * into a single statement.
4758 *
4759 * @see #getFlags
4760 * @see #addFlags
4761 *
4762 * @see #FLAG_GRANT_READ_URI_PERMISSION
4763 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
4764 * @see #FLAG_DEBUG_LOG_RESOLUTION
4765 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004766 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004767 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004768 * @see #FLAG_ACTIVITY_CLEAR_TOP
4769 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
4770 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004771 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004772 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4773 * @see #FLAG_ACTIVITY_NEW_TASK
4774 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004775 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004776 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
4777 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 * @see #FLAG_ACTIVITY_SINGLE_TOP
4779 * @see #FLAG_RECEIVER_REGISTERED_ONLY
4780 */
4781 public Intent setFlags(int flags) {
4782 mFlags = flags;
4783 return this;
4784 }
4785
4786 /**
4787 * Add additional flags to the intent (or with existing flags
4788 * value).
4789 *
4790 * @param flags The new flags to set.
4791 *
4792 * @return Returns the same Intent object, for chaining multiple calls
4793 * into a single statement.
4794 *
4795 * @see #setFlags
4796 */
4797 public Intent addFlags(int flags) {
4798 mFlags |= flags;
4799 return this;
4800 }
4801
4802 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004803 * (Usually optional) Set an explicit application package name that limits
4804 * the components this Intent will resolve to. If left to the default
4805 * value of null, all components in all applications will considered.
4806 * If non-null, the Intent can only match the components in the given
4807 * application package.
4808 *
4809 * @param packageName The name of the application package to handle the
4810 * intent, or null to allow any application package.
4811 *
4812 * @return Returns the same Intent object, for chaining multiple calls
4813 * into a single statement.
4814 *
4815 * @see #getPackage
4816 * @see #resolveActivity
4817 */
4818 public Intent setPackage(String packageName) {
4819 mPackage = packageName;
4820 return this;
4821 }
4822
4823 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004824 * (Usually optional) Explicitly set the component to handle the intent.
4825 * If left with the default value of null, the system will determine the
4826 * appropriate class to use based on the other fields (action, data,
4827 * type, categories) in the Intent. If this class is defined, the
4828 * specified class will always be used regardless of the other fields. You
4829 * should only set this value when you know you absolutely want a specific
4830 * class to be used; otherwise it is better to let the system find the
4831 * appropriate class so that you will respect the installed applications
4832 * and user preferences.
4833 *
4834 * @param component The name of the application component to handle the
4835 * intent, or null to let the system find one for you.
4836 *
4837 * @return Returns the same Intent object, for chaining multiple calls
4838 * into a single statement.
4839 *
4840 * @see #setClass
4841 * @see #setClassName(Context, String)
4842 * @see #setClassName(String, String)
4843 * @see #getComponent
4844 * @see #resolveActivity
4845 */
4846 public Intent setComponent(ComponentName component) {
4847 mComponent = component;
4848 return this;
4849 }
4850
4851 /**
4852 * Convenience for calling {@link #setComponent} with an
4853 * explicit class name.
4854 *
4855 * @param packageContext A Context of the application package implementing
4856 * this class.
4857 * @param className The name of a class inside of the application package
4858 * that will be used as the component for this Intent.
4859 *
4860 * @return Returns the same Intent object, for chaining multiple calls
4861 * into a single statement.
4862 *
4863 * @see #setComponent
4864 * @see #setClass
4865 */
4866 public Intent setClassName(Context packageContext, String className) {
4867 mComponent = new ComponentName(packageContext, className);
4868 return this;
4869 }
4870
4871 /**
4872 * Convenience for calling {@link #setComponent} with an
4873 * explicit application package name and class name.
4874 *
4875 * @param packageName The name of the package implementing the desired
4876 * component.
4877 * @param className The name of a class inside of the application package
4878 * that will be used as the component for this Intent.
4879 *
4880 * @return Returns the same Intent object, for chaining multiple calls
4881 * into a single statement.
4882 *
4883 * @see #setComponent
4884 * @see #setClass
4885 */
4886 public Intent setClassName(String packageName, String className) {
4887 mComponent = new ComponentName(packageName, className);
4888 return this;
4889 }
4890
4891 /**
4892 * Convenience for calling {@link #setComponent(ComponentName)} with the
4893 * name returned by a {@link Class} object.
4894 *
4895 * @param packageContext A Context of the application package implementing
4896 * this class.
4897 * @param cls The class name to set, equivalent to
4898 * <code>setClassName(context, cls.getName())</code>.
4899 *
4900 * @return Returns the same Intent object, for chaining multiple calls
4901 * into a single statement.
4902 *
4903 * @see #setComponent
4904 */
4905 public Intent setClass(Context packageContext, Class<?> cls) {
4906 mComponent = new ComponentName(packageContext, cls);
4907 return this;
4908 }
4909
4910 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004911 * Set the bounds of the sender of this intent, in screen coordinates. This can be
4912 * used as a hint to the receiver for animations and the like. Null means that there
4913 * is no source bounds.
4914 */
4915 public void setSourceBounds(Rect r) {
4916 if (r != null) {
4917 mSourceBounds = new Rect(r);
4918 } else {
4919 r = null;
4920 }
4921 }
4922
4923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004924 * Use with {@link #fillIn} to allow the current action value to be
4925 * overwritten, even if it is already set.
4926 */
4927 public static final int FILL_IN_ACTION = 1<<0;
4928
4929 /**
4930 * Use with {@link #fillIn} to allow the current data or type value
4931 * overwritten, even if it is already set.
4932 */
4933 public static final int FILL_IN_DATA = 1<<1;
4934
4935 /**
4936 * Use with {@link #fillIn} to allow the current categories to be
4937 * overwritten, even if they are already set.
4938 */
4939 public static final int FILL_IN_CATEGORIES = 1<<2;
4940
4941 /**
4942 * Use with {@link #fillIn} to allow the current component value to be
4943 * overwritten, even if it is already set.
4944 */
4945 public static final int FILL_IN_COMPONENT = 1<<3;
4946
4947 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004948 * Use with {@link #fillIn} to allow the current package value to be
4949 * overwritten, even if it is already set.
4950 */
4951 public static final int FILL_IN_PACKAGE = 1<<4;
4952
4953 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004954 * Use with {@link #fillIn} to allow the current package value to be
4955 * overwritten, even if it is already set.
4956 */
4957 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
4958
4959 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004960 * Copy the contents of <var>other</var> in to this object, but only
4961 * where fields are not defined by this object. For purposes of a field
4962 * being defined, the following pieces of data in the Intent are
4963 * considered to be separate fields:
4964 *
4965 * <ul>
4966 * <li> action, as set by {@link #setAction}.
4967 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
4968 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
4969 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004970 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004971 * <li> component, as set by {@link #setComponent(ComponentName)} or
4972 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004973 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004974 * <li> each top-level name in the associated extras.
4975 * </ul>
4976 *
4977 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004978 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4979 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004980 * corresponding field will not be replaced if it is already set.
4981 *
Brett Chabot3e391752009-07-21 16:07:23 -07004982 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
4983 * specified.
4984 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004985 * <p>For example, consider Intent A with {data="foo", categories="bar"}
4986 * and Intent B with {action="gotit", data-type="some/thing",
4987 * categories="one","two"}.
4988 *
4989 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
4990 * containing: {action="gotit", data-type="some/thing",
4991 * categories="bar"}.
4992 *
4993 * @param other Another Intent whose values are to be used to fill in
4994 * the current one.
4995 * @param flags Options to control which fields can be filled in.
4996 *
4997 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004998 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4999 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005000 */
5001 public int fillIn(Intent other, int flags) {
5002 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005003 if (other.mAction != null
5004 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005005 mAction = other.mAction;
5006 changes |= FILL_IN_ACTION;
5007 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005008 if ((other.mData != null || other.mType != null)
5009 && ((mData == null && mType == null)
5010 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005011 mData = other.mData;
5012 mType = other.mType;
5013 changes |= FILL_IN_DATA;
5014 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005015 if (other.mCategories != null
5016 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005017 if (other.mCategories != null) {
5018 mCategories = new HashSet<String>(other.mCategories);
5019 }
5020 changes |= FILL_IN_CATEGORIES;
5021 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005022 if (other.mPackage != null
5023 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5024 mPackage = other.mPackage;
5025 changes |= FILL_IN_PACKAGE;
5026 }
5027 // Component is special: it can -only- be set if explicitly allowed,
5028 // since otherwise the sender could force the intent somewhere the
5029 // originator didn't intend.
5030 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005031 mComponent = other.mComponent;
5032 changes |= FILL_IN_COMPONENT;
5033 }
5034 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005035 if (other.mSourceBounds != null
5036 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5037 mSourceBounds = new Rect(other.mSourceBounds);
5038 changes |= FILL_IN_SOURCE_BOUNDS;
5039 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 if (mExtras == null) {
5041 if (other.mExtras != null) {
5042 mExtras = new Bundle(other.mExtras);
5043 }
5044 } else if (other.mExtras != null) {
5045 try {
5046 Bundle newb = new Bundle(other.mExtras);
5047 newb.putAll(mExtras);
5048 mExtras = newb;
5049 } catch (RuntimeException e) {
5050 // Modifying the extras can cause us to unparcel the contents
5051 // of the bundle, and if we do this in the system process that
5052 // may fail. We really should handle this (i.e., the Bundle
5053 // impl shouldn't be on top of a plain map), but for now just
5054 // ignore it and keep the original contents. :(
5055 Log.w("Intent", "Failure filling in extras", e);
5056 }
5057 }
5058 return changes;
5059 }
5060
5061 /**
5062 * Wrapper class holding an Intent and implementing comparisons on it for
5063 * the purpose of filtering. The class implements its
5064 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5065 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5066 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5067 * on the wrapped Intent.
5068 */
5069 public static final class FilterComparison {
5070 private final Intent mIntent;
5071 private final int mHashCode;
5072
5073 public FilterComparison(Intent intent) {
5074 mIntent = intent;
5075 mHashCode = intent.filterHashCode();
5076 }
5077
5078 /**
5079 * Return the Intent that this FilterComparison represents.
5080 * @return Returns the Intent held by the FilterComparison. Do
5081 * not modify!
5082 */
5083 public Intent getIntent() {
5084 return mIntent;
5085 }
5086
5087 @Override
5088 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005089 if (obj instanceof FilterComparison) {
5090 Intent other = ((FilterComparison)obj).mIntent;
5091 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005092 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005093 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005094 }
5095
5096 @Override
5097 public int hashCode() {
5098 return mHashCode;
5099 }
5100 }
5101
5102 /**
5103 * Determine if two intents are the same for the purposes of intent
5104 * resolution (filtering). That is, if their action, data, type,
5105 * class, and categories are the same. This does <em>not</em> compare
5106 * any extra data included in the intents.
5107 *
5108 * @param other The other Intent to compare against.
5109 *
5110 * @return Returns true if action, data, type, class, and categories
5111 * are the same.
5112 */
5113 public boolean filterEquals(Intent other) {
5114 if (other == null) {
5115 return false;
5116 }
5117 if (mAction != other.mAction) {
5118 if (mAction != null) {
5119 if (!mAction.equals(other.mAction)) {
5120 return false;
5121 }
5122 } else {
5123 if (!other.mAction.equals(mAction)) {
5124 return false;
5125 }
5126 }
5127 }
5128 if (mData != other.mData) {
5129 if (mData != null) {
5130 if (!mData.equals(other.mData)) {
5131 return false;
5132 }
5133 } else {
5134 if (!other.mData.equals(mData)) {
5135 return false;
5136 }
5137 }
5138 }
5139 if (mType != other.mType) {
5140 if (mType != null) {
5141 if (!mType.equals(other.mType)) {
5142 return false;
5143 }
5144 } else {
5145 if (!other.mType.equals(mType)) {
5146 return false;
5147 }
5148 }
5149 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005150 if (mPackage != other.mPackage) {
5151 if (mPackage != null) {
5152 if (!mPackage.equals(other.mPackage)) {
5153 return false;
5154 }
5155 } else {
5156 if (!other.mPackage.equals(mPackage)) {
5157 return false;
5158 }
5159 }
5160 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005161 if (mComponent != other.mComponent) {
5162 if (mComponent != null) {
5163 if (!mComponent.equals(other.mComponent)) {
5164 return false;
5165 }
5166 } else {
5167 if (!other.mComponent.equals(mComponent)) {
5168 return false;
5169 }
5170 }
5171 }
5172 if (mCategories != other.mCategories) {
5173 if (mCategories != null) {
5174 if (!mCategories.equals(other.mCategories)) {
5175 return false;
5176 }
5177 } else {
5178 if (!other.mCategories.equals(mCategories)) {
5179 return false;
5180 }
5181 }
5182 }
5183
5184 return true;
5185 }
5186
5187 /**
5188 * Generate hash code that matches semantics of filterEquals().
5189 *
5190 * @return Returns the hash value of the action, data, type, class, and
5191 * categories.
5192 *
5193 * @see #filterEquals
5194 */
5195 public int filterHashCode() {
5196 int code = 0;
5197 if (mAction != null) {
5198 code += mAction.hashCode();
5199 }
5200 if (mData != null) {
5201 code += mData.hashCode();
5202 }
5203 if (mType != null) {
5204 code += mType.hashCode();
5205 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005206 if (mPackage != null) {
5207 code += mPackage.hashCode();
5208 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005209 if (mComponent != null) {
5210 code += mComponent.hashCode();
5211 }
5212 if (mCategories != null) {
5213 code += mCategories.hashCode();
5214 }
5215 return code;
5216 }
5217
5218 @Override
5219 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005220 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005221
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005222 b.append("Intent { ");
5223 toShortString(b, true, true);
5224 b.append(" }");
5225
5226 return b.toString();
5227 }
5228
5229 /** @hide */
5230 public String toShortString(boolean comp, boolean extras) {
5231 StringBuilder b = new StringBuilder(128);
5232 toShortString(b, comp, extras);
5233 return b.toString();
5234 }
Romain Guy4969af72009-06-17 10:53:19 -07005235
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005236 /** @hide */
5237 public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5238 boolean first = true;
5239 if (mAction != null) {
5240 b.append("act=").append(mAction);
5241 first = false;
5242 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005243 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005244 if (!first) {
5245 b.append(' ');
5246 }
5247 first = false;
5248 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005249 Iterator<String> i = mCategories.iterator();
5250 boolean didone = false;
5251 while (i.hasNext()) {
5252 if (didone) b.append(",");
5253 didone = true;
5254 b.append(i.next());
5255 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005256 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005257 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005258 if (mData != null) {
5259 if (!first) {
5260 b.append(' ');
5261 }
5262 first = false;
5263 b.append("dat=").append(mData);
5264 }
5265 if (mType != null) {
5266 if (!first) {
5267 b.append(' ');
5268 }
5269 first = false;
5270 b.append("typ=").append(mType);
5271 }
5272 if (mFlags != 0) {
5273 if (!first) {
5274 b.append(' ');
5275 }
5276 first = false;
5277 b.append("flg=0x").append(Integer.toHexString(mFlags));
5278 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005279 if (mPackage != null) {
5280 if (!first) {
5281 b.append(' ');
5282 }
5283 first = false;
5284 b.append("pkg=").append(mPackage);
5285 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005286 if (comp && mComponent != null) {
5287 if (!first) {
5288 b.append(' ');
5289 }
5290 first = false;
5291 b.append("cmp=").append(mComponent.flattenToShortString());
5292 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005293 if (mSourceBounds != null) {
5294 if (!first) {
5295 b.append(' ');
5296 }
5297 first = false;
5298 b.append("bnds=").append(mSourceBounds.toShortString());
5299 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005300 if (extras && mExtras != null) {
5301 if (!first) {
5302 b.append(' ');
5303 }
5304 first = false;
5305 b.append("(has extras)");
5306 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005307 }
5308
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005309 /**
5310 * Call {@link #toUri} with 0 flags.
5311 * @deprecated Use {@link #toUri} instead.
5312 */
5313 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005314 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005315 return toUri(0);
5316 }
5317
5318 /**
5319 * Convert this Intent into a String holding a URI representation of it.
5320 * The returned URI string has been properly URI encoded, so it can be
5321 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5322 * Intent's data as the base URI, with an additional fragment describing
5323 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005324 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005325 * <p>You can convert the returned string back to an Intent with
5326 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005327 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005328 * @param flags Additional operating flags. Either 0 or
5329 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005330 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005331 * @return Returns a URI encoding URI string describing the entire contents
5332 * of the Intent.
5333 */
5334 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005335 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005336 String scheme = null;
5337 if (mData != null) {
5338 String data = mData.toString();
5339 if ((flags&URI_INTENT_SCHEME) != 0) {
5340 final int N = data.length();
5341 for (int i=0; i<N; i++) {
5342 char c = data.charAt(i);
5343 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5344 || c == '.' || c == '-') {
5345 continue;
5346 }
5347 if (c == ':' && i > 0) {
5348 // Valid scheme.
5349 scheme = data.substring(0, i);
5350 uri.append("intent:");
5351 data = data.substring(i+1);
5352 break;
5353 }
Tom Taylord4a47292009-12-21 13:59:18 -08005354
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005355 // No scheme.
5356 break;
5357 }
5358 }
5359 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005360
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005361 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5362 uri.append("intent:");
5363 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005364
5365 uri.append("#Intent;");
5366
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005367 if (scheme != null) {
5368 uri.append("scheme=").append(scheme).append(';');
5369 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005370 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005371 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005372 }
5373 if (mCategories != null) {
5374 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005375 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005376 }
5377 }
5378 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005379 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380 }
5381 if (mFlags != 0) {
5382 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5383 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005384 if (mPackage != null) {
5385 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5386 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005387 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005388 uri.append("component=").append(Uri.encode(
5389 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005390 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005391 if (mSourceBounds != null) {
5392 uri.append("sourceBounds=")
5393 .append(Uri.encode(mSourceBounds.flattenToString()))
5394 .append(';');
5395 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005396 if (mExtras != null) {
5397 for (String key : mExtras.keySet()) {
5398 final Object value = mExtras.get(key);
5399 char entryType =
5400 value instanceof String ? 'S' :
5401 value instanceof Boolean ? 'B' :
5402 value instanceof Byte ? 'b' :
5403 value instanceof Character ? 'c' :
5404 value instanceof Double ? 'd' :
5405 value instanceof Float ? 'f' :
5406 value instanceof Integer ? 'i' :
5407 value instanceof Long ? 'l' :
5408 value instanceof Short ? 's' :
5409 '\0';
5410
5411 if (entryType != '\0') {
5412 uri.append(entryType);
5413 uri.append('.');
5414 uri.append(Uri.encode(key));
5415 uri.append('=');
5416 uri.append(Uri.encode(value.toString()));
5417 uri.append(';');
5418 }
5419 }
5420 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005421
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005422 uri.append("end");
5423
5424 return uri.toString();
5425 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005426
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005427 public int describeContents() {
5428 return (mExtras != null) ? mExtras.describeContents() : 0;
5429 }
5430
5431 public void writeToParcel(Parcel out, int flags) {
5432 out.writeString(mAction);
5433 Uri.writeToParcel(out, mData);
5434 out.writeString(mType);
5435 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005436 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005437 ComponentName.writeToParcel(mComponent, out);
5438
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005439 if (mSourceBounds != null) {
5440 out.writeInt(1);
5441 mSourceBounds.writeToParcel(out, flags);
5442 } else {
5443 out.writeInt(0);
5444 }
5445
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005446 if (mCategories != null) {
5447 out.writeInt(mCategories.size());
5448 for (String category : mCategories) {
5449 out.writeString(category);
5450 }
5451 } else {
5452 out.writeInt(0);
5453 }
5454
5455 out.writeBundle(mExtras);
5456 }
5457
5458 public static final Parcelable.Creator<Intent> CREATOR
5459 = new Parcelable.Creator<Intent>() {
5460 public Intent createFromParcel(Parcel in) {
5461 return new Intent(in);
5462 }
5463 public Intent[] newArray(int size) {
5464 return new Intent[size];
5465 }
5466 };
5467
Dianne Hackborneb034652009-09-07 00:49:58 -07005468 /** @hide */
5469 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005470 readFromParcel(in);
5471 }
5472
5473 public void readFromParcel(Parcel in) {
5474 mAction = in.readString();
5475 mData = Uri.CREATOR.createFromParcel(in);
5476 mType = in.readString();
5477 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005478 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005479 mComponent = ComponentName.readFromParcel(in);
5480
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005481 if (in.readInt() != 0) {
5482 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5483 }
5484
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005485 int N = in.readInt();
5486 if (N > 0) {
5487 mCategories = new HashSet<String>();
5488 int i;
5489 for (i=0; i<N; i++) {
5490 mCategories.add(in.readString());
5491 }
5492 } else {
5493 mCategories = null;
5494 }
5495
5496 mExtras = in.readBundle();
5497 }
5498
5499 /**
5500 * Parses the "intent" element (and its children) from XML and instantiates
5501 * an Intent object. The given XML parser should be located at the tag
5502 * where parsing should start (often named "intent"), from which the
5503 * basic action, data, type, and package and class name will be
5504 * retrieved. The function will then parse in to any child elements,
5505 * looking for <category android:name="xxx"> tags to add categories and
5506 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5507 * to the intent.
5508 *
5509 * @param resources The Resources to use when inflating resources.
5510 * @param parser The XML parser pointing at an "intent" tag.
5511 * @param attrs The AttributeSet interface for retrieving extended
5512 * attribute data at the current <var>parser</var> location.
5513 * @return An Intent object matching the XML data.
5514 * @throws XmlPullParserException If there was an XML parsing error.
5515 * @throws IOException If there was an I/O error.
5516 */
5517 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5518 throws XmlPullParserException, IOException {
5519 Intent intent = new Intent();
5520
5521 TypedArray sa = resources.obtainAttributes(attrs,
5522 com.android.internal.R.styleable.Intent);
5523
5524 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5525
5526 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5527 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5528 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5529
5530 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5531 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5532 if (packageName != null && className != null) {
5533 intent.setComponent(new ComponentName(packageName, className));
5534 }
5535
5536 sa.recycle();
5537
5538 int outerDepth = parser.getDepth();
5539 int type;
5540 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5541 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5542 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5543 continue;
5544 }
5545
5546 String nodeName = parser.getName();
5547 if (nodeName.equals("category")) {
5548 sa = resources.obtainAttributes(attrs,
5549 com.android.internal.R.styleable.IntentCategory);
5550 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5551 sa.recycle();
5552
5553 if (cat != null) {
5554 intent.addCategory(cat);
5555 }
5556 XmlUtils.skipCurrentTag(parser);
5557
5558 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005559 if (intent.mExtras == null) {
5560 intent.mExtras = new Bundle();
5561 }
5562 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5563 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005564
5565 } else {
5566 XmlUtils.skipCurrentTag(parser);
5567 }
5568 }
5569
5570 return intent;
5571 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005572}