blob: 13494f820a89842751566fc011af9faa961dfcb2 [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}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200536 * <li> {@link #CATEGORY_CAR_MODE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700537 * </ul>
538 *
539 * <h3>Standard Extra Data</h3>
540 *
541 * <p>These are the current standard fields that can be used as extra data via
542 * {@link #putExtra}.
543 *
544 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800545 * <li> {@link #EXTRA_ALARM_COUNT}
546 * <li> {@link #EXTRA_BCC}
547 * <li> {@link #EXTRA_CC}
548 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
549 * <li> {@link #EXTRA_DATA_REMOVED}
550 * <li> {@link #EXTRA_DOCK_STATE}
551 * <li> {@link #EXTRA_DOCK_STATE_CAR}
552 * <li> {@link #EXTRA_DOCK_STATE_DESK}
553 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
554 * <li> {@link #EXTRA_DONT_KILL_APP}
555 * <li> {@link #EXTRA_EMAIL}
556 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700557 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800558 * <li> {@link #EXTRA_KEY_EVENT}
559 * <li> {@link #EXTRA_PHONE_NUMBER}
560 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
561 * <li> {@link #EXTRA_REPLACING}
562 * <li> {@link #EXTRA_SHORTCUT_ICON}
563 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
564 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700565 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800566 * <li> {@link #EXTRA_SHORTCUT_NAME}
567 * <li> {@link #EXTRA_SUBJECT}
568 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700569 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800570 * <li> {@link #EXTRA_TITLE}
571 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * </ul>
573 *
574 * <h3>Flags</h3>
575 *
576 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800577 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
578 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700579 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800580public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700581 // ---------------------------------------------------------------------
582 // ---------------------------------------------------------------------
583 // Standard intent activity actions (see action variable).
584
585 /**
586 * Activity Action: Start as a main entry point, does not expect to
587 * receive data.
588 * <p>Input: nothing
589 * <p>Output: nothing
590 */
591 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
592 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800593
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700594 /**
595 * Activity Action: Display the data to the user. This is the most common
596 * action performed on data -- it is the generic action you can use on
597 * a piece of data to get the most reasonable thing to occur. For example,
598 * when used on a contacts entry it will view the entry; when used on a
599 * mailto: URI it will bring up a compose window filled with the information
600 * supplied by the URI; when used with a tel: URI it will invoke the
601 * dialer.
602 * <p>Input: {@link #getData} is URI from which to retrieve data.
603 * <p>Output: nothing.
604 */
605 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
606 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800607
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 /**
609 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
610 * performed on a piece of data.
611 */
612 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800613
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 /**
615 * Used to indicate that some piece of data should be attached to some other
616 * place. For example, image data could be attached to a contact. It is up
617 * to the recipient to decide where the data should be attached; the intent
618 * does not specify the ultimate destination.
619 * <p>Input: {@link #getData} is URI of data to be attached.
620 * <p>Output: nothing.
621 */
622 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
623 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800624
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700625 /**
626 * Activity Action: Provide explicit editable access to the given data.
627 * <p>Input: {@link #getData} is URI of data to be edited.
628 * <p>Output: nothing.
629 */
630 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
631 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700633 /**
634 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
635 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
636 * The extras can contain type specific data to pass through to the editing/creating
637 * activity.
638 * <p>Output: The URI of the item that was picked. This must be a content:
639 * URI so that any receiver can access it.
640 */
641 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
642 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800643
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700644 /**
645 * Activity Action: Pick an item from the data, returning what was selected.
646 * <p>Input: {@link #getData} is URI containing a directory of data
647 * (vnd.android.cursor.dir/*) from which to pick an item.
648 * <p>Output: The URI of the item that was picked.
649 */
650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
651 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700653 /**
654 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800655 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700656 * <p>Output: An Intent representing the shortcut. The intent must contain three
657 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
658 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659 * (value: ShortcutIconResource).</p>
660 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700661 * @see #EXTRA_SHORTCUT_INTENT
662 * @see #EXTRA_SHORTCUT_NAME
663 * @see #EXTRA_SHORTCUT_ICON
664 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
665 * @see android.content.Intent.ShortcutIconResource
666 */
667 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
668 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
669
670 /**
671 * The name of the extra used to define the Intent of a shortcut.
672 *
673 * @see #ACTION_CREATE_SHORTCUT
674 */
675 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
676 /**
677 * The name of the extra used to define the name of a shortcut.
678 *
679 * @see #ACTION_CREATE_SHORTCUT
680 */
681 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
682 /**
683 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
684 *
685 * @see #ACTION_CREATE_SHORTCUT
686 */
687 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
688 /**
689 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
690 *
691 * @see #ACTION_CREATE_SHORTCUT
692 * @see android.content.Intent.ShortcutIconResource
693 */
694 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
695 "android.intent.extra.shortcut.ICON_RESOURCE";
696
697 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800698 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700699 *
700 * @see Intent#ACTION_CREATE_SHORTCUT
701 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800702 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
703 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 */
705 public static class ShortcutIconResource implements Parcelable {
706 /**
707 * The package name of the application containing the icon.
708 */
709 public String packageName;
710
711 /**
712 * The resource name of the icon, including package, name and type.
713 */
714 public String resourceName;
715
716 /**
717 * Creates a new ShortcutIconResource for the specified context and resource
718 * identifier.
719 *
720 * @param context The context of the application.
721 * @param resourceId The resource idenfitier for the icon.
722 * @return A new ShortcutIconResource with the specified's context package name
723 * and icon resource idenfitier.
724 */
725 public static ShortcutIconResource fromContext(Context context, int resourceId) {
726 ShortcutIconResource icon = new ShortcutIconResource();
727 icon.packageName = context.getPackageName();
728 icon.resourceName = context.getResources().getResourceName(resourceId);
729 return icon;
730 }
731
732 /**
733 * Used to read a ShortcutIconResource from a Parcel.
734 */
735 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
736 new Parcelable.Creator<ShortcutIconResource>() {
737
738 public ShortcutIconResource createFromParcel(Parcel source) {
739 ShortcutIconResource icon = new ShortcutIconResource();
740 icon.packageName = source.readString();
741 icon.resourceName = source.readString();
742 return icon;
743 }
744
745 public ShortcutIconResource[] newArray(int size) {
746 return new ShortcutIconResource[size];
747 }
748 };
749
750 /**
751 * No special parcel contents.
752 */
753 public int describeContents() {
754 return 0;
755 }
756
757 public void writeToParcel(Parcel dest, int flags) {
758 dest.writeString(packageName);
759 dest.writeString(resourceName);
760 }
761
762 @Override
763 public String toString() {
764 return resourceName;
765 }
766 }
767
768 /**
769 * Activity Action: Display an activity chooser, allowing the user to pick
770 * what they want to before proceeding. This can be used as an alternative
771 * to the standard activity picker that is displayed by the system when
772 * you try to start an activity with multiple possible matches, with these
773 * differences in behavior:
774 * <ul>
775 * <li>You can specify the title that will appear in the activity chooser.
776 * <li>The user does not have the option to make one of the matching
777 * activities a preferred activity, and all possible activities will
778 * always be shown even if one of them is currently marked as the
779 * preferred activity.
780 * </ul>
781 * <p>
782 * This action should be used when the user will naturally expect to
783 * select an activity in order to proceed. An example if when not to use
784 * it is when the user clicks on a "mailto:" link. They would naturally
785 * expect to go directly to their mail app, so startActivity() should be
786 * called directly: it will
787 * either launch the current preferred app, or put up a dialog allowing the
788 * user to pick an app to use and optionally marking that as preferred.
789 * <p>
790 * In contrast, if the user is selecting a menu item to send a picture
791 * they are viewing to someone else, there are many different things they
792 * may want to do at this point: send it through e-mail, upload it to a
793 * web service, etc. In this case the CHOOSER action should be used, to
794 * always present to the user a list of the things they can do, with a
795 * nice title given by the caller such as "Send this photo with:".
796 * <p>
797 * As a convenience, an Intent of this form can be created with the
798 * {@link #createChooser} function.
799 * <p>Input: No data should be specified. get*Extra must have
800 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
801 * and can optionally have a {@link #EXTRA_TITLE} field containing the
802 * title text to display in the chooser.
803 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
804 */
805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
806 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
807
808 /**
809 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
810 *
811 * @param target The Intent that the user will be selecting an activity
812 * to perform.
813 * @param title Optional title that will be displayed in the chooser.
814 * @return Return a new Intent object that you can hand to
815 * {@link Context#startActivity(Intent) Context.startActivity()} and
816 * related methods.
817 */
818 public static Intent createChooser(Intent target, CharSequence title) {
819 Intent intent = new Intent(ACTION_CHOOSER);
820 intent.putExtra(EXTRA_INTENT, target);
821 if (title != null) {
822 intent.putExtra(EXTRA_TITLE, title);
823 }
824 return intent;
825 }
826 /**
827 * Activity Action: Allow the user to select a particular kind of data and
828 * return it. This is different than {@link #ACTION_PICK} in that here we
829 * just say what kind of data is desired, not a URI of existing data from
830 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
831 * create the data as it runs (for example taking a picture or recording a
832 * sound), let them browser over the web and download the desired data,
833 * etc.
834 * <p>
835 * There are two main ways to use this action: if you want an specific kind
836 * of data, such as a person contact, you set the MIME type to the kind of
837 * data you want and launch it with {@link Context#startActivity(Intent)}.
838 * The system will then launch the best application to select that kind
839 * of data for you.
840 * <p>
841 * You may also be interested in any of a set of types of content the user
842 * can pick. For example, an e-mail application that wants to allow the
843 * user to add an attachment to an e-mail message can use this action to
844 * bring up a list of all of the types of content the user can attach.
845 * <p>
846 * In this case, you should wrap the GET_CONTENT intent with a chooser
847 * (through {@link #createChooser}), which will give the proper interface
848 * for the user to pick how to send your data and allow you to specify
849 * a prompt indicating what they are doing. You will usually specify a
850 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
851 * broad range of content types the user can select from.
852 * <p>
853 * When using such a broad GET_CONTENT action, it is often desireable to
854 * only pick from data that can be represented as a stream. This is
855 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
856 * <p>
857 * Input: {@link #getType} is the desired MIME type to retrieve. Note
858 * that no URI is supplied in the intent, as there are no constraints on
859 * where the returned data originally comes from. You may also include the
860 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
861 * opened as a stream.
862 * <p>
863 * Output: The URI of the item that was picked. This must be a content:
864 * URI so that any receiver can access it.
865 */
866 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
867 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
868 /**
869 * Activity Action: Dial a number as specified by the data. This shows a
870 * UI with the number being dialed, allowing the user to explicitly
871 * initiate the call.
872 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
873 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
874 * number.
875 * <p>Output: nothing.
876 */
877 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
878 public static final String ACTION_DIAL = "android.intent.action.DIAL";
879 /**
880 * Activity Action: Perform a call to someone specified by the data.
881 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
882 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
883 * number.
884 * <p>Output: nothing.
885 *
886 * <p>Note: there will be restrictions on which applications can initiate a
887 * call; most applications should use the {@link #ACTION_DIAL}.
888 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
889 * numbers. Applications can <strong>dial</strong> emergency numbers using
890 * {@link #ACTION_DIAL}, however.
891 */
892 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
893 public static final String ACTION_CALL = "android.intent.action.CALL";
894 /**
895 * Activity Action: Perform a call to an emergency number specified by the
896 * data.
897 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
898 * tel: URI of an explicit phone number.
899 * <p>Output: nothing.
900 * @hide
901 */
902 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
903 /**
904 * Activity action: Perform a call to any number (emergency or not)
905 * specified by the data.
906 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
907 * tel: URI of an explicit phone number.
908 * <p>Output: nothing.
909 * @hide
910 */
911 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
912 /**
913 * Activity Action: Send a message to someone specified by the data.
914 * <p>Input: {@link #getData} is URI describing the target.
915 * <p>Output: nothing.
916 */
917 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
918 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
919 /**
920 * Activity Action: Deliver some data to someone else. Who the data is
921 * being delivered to is not specified; it is up to the receiver of this
922 * action to ask the user where the data should be sent.
923 * <p>
924 * When launching a SEND intent, you should usually wrap it in a chooser
925 * (through {@link #createChooser}), which will give the proper interface
926 * for the user to pick how to send your data and allow you to specify
927 * a prompt indicating what they are doing.
928 * <p>
929 * Input: {@link #getType} is the MIME type of the data being sent.
930 * get*Extra can have either a {@link #EXTRA_TEXT}
931 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
932 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
933 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
934 * if the MIME type is unknown (this will only allow senders that can
935 * handle generic data streams).
936 * <p>
937 * Optional standard extras, which may be interpreted by some recipients as
938 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
939 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
940 * <p>
941 * Output: nothing.
942 */
943 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
944 public static final String ACTION_SEND = "android.intent.action.SEND";
945 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800946 * Activity Action: Deliver multiple data to someone else.
947 * <p>
948 * Like ACTION_SEND, except the data is multiple.
949 * <p>
950 * Input: {@link #getType} is the MIME type of the data being sent.
951 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
952 * #EXTRA_STREAM} field, containing the data to be sent.
953 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800954 * Multiple types are supported, and receivers should handle mixed types
955 * whenever possible. The right way for the receiver to check them is to
956 * use the content resolver on each URI. The intent sender should try to
957 * put the most concrete mime type in the intent type, but it can fall
958 * back to {@literal <type>/*} or {@literal *}/* as needed.
959 * <p>
960 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
961 * be image/jpg, but if you are sending image/jpg and image/png, then the
962 * intent's type should be image/*.
963 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800964 * Optional standard extras, which may be interpreted by some recipients as
965 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
966 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
967 * <p>
968 * Output: nothing.
969 */
970 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
971 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
972 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700973 * Activity Action: Handle an incoming phone call.
974 * <p>Input: nothing.
975 * <p>Output: nothing.
976 */
977 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
978 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
979 /**
980 * Activity Action: Insert an empty item into the given container.
981 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
982 * in which to place the data.
983 * <p>Output: URI of the new data that was created.
984 */
985 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
986 public static final String ACTION_INSERT = "android.intent.action.INSERT";
987 /**
988 * Activity Action: Delete the given data from its container.
989 * <p>Input: {@link #getData} is URI of data to be deleted.
990 * <p>Output: nothing.
991 */
992 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
993 public static final String ACTION_DELETE = "android.intent.action.DELETE";
994 /**
995 * Activity Action: Run the data, whatever that means.
996 * <p>Input: ? (Note: this is currently specific to the test harness.)
997 * <p>Output: nothing.
998 */
999 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1000 public static final String ACTION_RUN = "android.intent.action.RUN";
1001 /**
1002 * Activity Action: Perform a data synchronization.
1003 * <p>Input: ?
1004 * <p>Output: ?
1005 */
1006 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1007 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1008 /**
1009 * Activity Action: Pick an activity given an intent, returning the class
1010 * selected.
1011 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1012 * used with {@link PackageManager#queryIntentActivities} to determine the
1013 * set of activities from which to pick.
1014 * <p>Output: Class name of the activity that was selected.
1015 */
1016 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1017 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1018 /**
1019 * Activity Action: Perform a search.
1020 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1021 * is the text to search for. If empty, simply
1022 * enter your search results Activity with the search UI activated.
1023 * <p>Output: nothing.
1024 */
1025 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1026 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1027 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001028 * Activity Action: Start the platform-defined tutorial
1029 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1030 * is the text to search for. If empty, simply
1031 * enter your search results Activity with the search UI activated.
1032 * <p>Output: nothing.
1033 */
1034 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1035 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1036 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001037 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001038 * <p>
1039 * Input: {@link android.app.SearchManager#QUERY
1040 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1041 * a url starts with http or https, the site will be opened. If it is plain
1042 * text, Google search will be applied.
1043 * <p>
1044 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001045 */
1046 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1047 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1048 /**
1049 * Activity Action: List all available applications
1050 * <p>Input: Nothing.
1051 * <p>Output: nothing.
1052 */
1053 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1054 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1055 /**
1056 * Activity Action: Show settings for choosing wallpaper
1057 * <p>Input: Nothing.
1058 * <p>Output: Nothing.
1059 */
1060 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1061 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1062
1063 /**
1064 * Activity Action: Show activity for reporting a bug.
1065 * <p>Input: Nothing.
1066 * <p>Output: Nothing.
1067 */
1068 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1069 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1070
1071 /**
1072 * Activity Action: Main entry point for factory tests. Only used when
1073 * the device is booting in factory test node. The implementing package
1074 * must be installed in the system image.
1075 * <p>Input: nothing
1076 * <p>Output: nothing
1077 */
1078 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1079
1080 /**
1081 * Activity Action: The user pressed the "call" button to go to the dialer
1082 * or other appropriate UI for placing a call.
1083 * <p>Input: Nothing.
1084 * <p>Output: Nothing.
1085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1088
1089 /**
1090 * Activity Action: Start Voice Command.
1091 * <p>Input: Nothing.
1092 * <p>Output: Nothing.
1093 */
1094 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1095 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001096
1097 /**
1098 * Activity Action: Start action associated with long pressing on the
1099 * search key.
1100 * <p>Input: Nothing.
1101 * <p>Output: Nothing.
1102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001105
Jacek Surazski86b6c532009-05-13 14:38:28 +02001106 /**
1107 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1108 * This intent is delivered to the package which installed the application, usually
1109 * the Market.
1110 * <p>Input: No data is specified. The bug report is passed in using
1111 * an {@link #EXTRA_BUG_REPORT} field.
1112 * <p>Output: Nothing.
1113 * @hide
1114 */
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1116 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001117
1118 /**
1119 * Activity Action: Show power usage information to the user.
1120 * <p>Input: Nothing.
1121 * <p>Output: Nothing.
1122 */
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1124 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001125
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001126 /**
1127 * Activity Action: Setup wizard to launch after a platform update. This
1128 * activity should have a string meta-data field associated with it,
1129 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1130 * the platform for setup. The activity will be launched only if
1131 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1132 * same value.
1133 * <p>Input: Nothing.
1134 * <p>Output: Nothing.
1135 * @hide
1136 */
1137 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1138 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001139
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001140 /**
1141 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1142 * describing the last run version of the platform that was setup.
1143 * @hide
1144 */
1145 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1146
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001147 // ---------------------------------------------------------------------
1148 // ---------------------------------------------------------------------
1149 // Standard intent broadcast actions (see action variable).
1150
1151 /**
1152 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001153 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001154 * <p class="note">This is a protected intent that can only be sent
1155 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001156 */
1157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1158 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1159 /**
1160 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001161 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001162 * <p class="note">This is a protected intent that can only be sent
1163 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001164 */
1165 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1166 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001167
1168 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001169 * 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 -07001170 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001171 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001172 * <p class="note">This is a protected intent that can only be sent
1173 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001174 */
1175 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001176 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001177
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001178 /**
1179 * Broadcast Action: The current time has changed. Sent every
1180 * minute. You can <em>not</em> receive this through components declared
1181 * in manifests, only by exlicitly registering for it with
1182 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1183 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001184 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001185 * <p class="note">This is a protected intent that can only be sent
1186 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001187 */
1188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1189 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1190 /**
1191 * Broadcast Action: The time was set.
1192 */
1193 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1194 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1195 /**
1196 * Broadcast Action: The date has changed.
1197 */
1198 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1199 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1200 /**
1201 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1202 * <ul>
1203 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1204 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001205 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001206 * <p class="note">This is a protected intent that can only be sent
1207 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001208 */
1209 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1210 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1211 /**
1212 * Alarm Changed Action: This is broadcast when the AlarmClock
1213 * application's alarm is set or unset. It is used by the
1214 * AlarmClock application and the StatusBar service.
1215 * @hide
1216 */
1217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1218 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1219 /**
1220 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1221 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1222 * @hide
1223 */
1224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1225 public static final String ACTION_SYNC_STATE_CHANGED
1226 = "android.intent.action.SYNC_STATE_CHANGED";
1227 /**
1228 * Broadcast Action: This is broadcast once, after the system has finished
1229 * booting. It can be used to perform application-specific initialization,
1230 * such as installing alarms. You must hold the
1231 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1232 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001233 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001234 * <p class="note">This is a protected intent that can only be sent
1235 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001236 */
1237 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1238 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1239 /**
1240 * Broadcast Action: This is broadcast when a user action should request a
1241 * temporary system dialog to dismiss. Some examples of temporary system
1242 * dialogs are the notification window-shade and the recent tasks dialog.
1243 */
1244 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1245 /**
1246 * Broadcast Action: Trigger the download and eventual installation
1247 * of a package.
1248 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001249 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001250 * <p class="note">This is a protected intent that can only be sent
1251 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001252 */
1253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1254 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1255 /**
1256 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001257 * device. The data contains the name of the package. Note that the
1258 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001259 * <p>My include the following extras:
1260 * <ul>
1261 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1262 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1263 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1264 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001265 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001266 * <p class="note">This is a protected intent that can only be sent
1267 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001268 */
1269 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1270 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1271 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001272 * Broadcast Action: A new version of an application package has been
1273 * installed, replacing an existing version that was previously installed.
1274 * The data contains the name of the package.
1275 * <p>My include the following extras:
1276 * <ul>
1277 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1278 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001279 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001280 * <p class="note">This is a protected intent that can only be sent
1281 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001282 */
1283 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1284 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1285 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001286 * Broadcast Action: An existing application package has been removed from
1287 * the device. The data contains the name of the package. The package
1288 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001289 * <ul>
1290 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1291 * to the package.
1292 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1293 * application -- data and code -- is being removed.
1294 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1295 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1296 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001297 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001298 * <p class="note">This is a protected intent that can only be sent
1299 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001300 */
1301 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1302 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1303 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001304 * Broadcast Action: An existing application package has been changed (e.g.
1305 * a component has been enabled or disabled). The data contains the name of
1306 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001307 * <ul>
1308 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001309 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1310 * of the changed components.
1311 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1312 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001313 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001314 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001315 * <p class="note">This is a protected intent that can only be sent
1316 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001317 */
1318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1319 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1320 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001321 * @hide
1322 * Broadcast Action: Ask system services if there is any reason to
1323 * restart the given package. The data contains the name of the
1324 * package.
1325 * <ul>
1326 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1327 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1328 * </ul>
1329 *
1330 * <p class="note">This is a protected intent that can only be sent
1331 * by the system.
1332 */
1333 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1334 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1335 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001336 * Broadcast Action: The user has restarted a package, and all of its
1337 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001338 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001339 * be removed. Note that the restarted package does <em>not</em>
1340 * receive this broadcast.
1341 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001342 * <ul>
1343 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1344 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001345 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001346 * <p class="note">This is a protected intent that can only be sent
1347 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001348 */
1349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1350 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1351 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001352 * Broadcast Action: The user has cleared the data of a package. This should
1353 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001354 * its persistent data is erased and this broadcast sent.
1355 * Note that the cleared package does <em>not</em>
1356 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001357 * <ul>
1358 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1359 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001360 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001361 * <p class="note">This is a protected intent that can only be sent
1362 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001363 */
1364 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1365 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1366 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001367 * Broadcast Action: A user ID has been removed from the system. The user
1368 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001369 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001370 * <p class="note">This is a protected intent that can only be sent
1371 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001372 */
1373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1374 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001375
1376 /**
1377 * Broadcast Action: Resources for a set of packages (which were
1378 * previously unavailable) are currently
1379 * available since the media on which they exist is available.
1380 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1381 * list of packages whose availability changed.
1382 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1383 * list of uids of packages whose availability changed.
1384 * Note that the
1385 * packages in this list do <em>not</em> receive this broadcast.
1386 * The specified set of packages are now available on the system.
1387 * <p>Includes the following extras:
1388 * <ul>
1389 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1390 * whose resources(were previously unavailable) are currently available.
1391 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1392 * packages whose resources(were previously unavailable)
1393 * are currently available.
1394 * </ul>
1395 *
1396 * <p class="note">This is a protected intent that can only be sent
1397 * by the system.
1398 * @hide
1399 */
1400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001401 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1402 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001403
1404 /**
1405 * Broadcast Action: Resources for a set of packages are currently
1406 * unavailable since the media on which they exist is unavailable.
1407 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1408 * list of packages whose availability changed.
1409 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1410 * list of uids of packages whose availability changed.
1411 * The specified set of packages can no longer be
1412 * launched and are practically unavailable on the system.
1413 * <p>Inclues the following extras:
1414 * <ul>
1415 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1416 * whose resources are no longer available.
1417 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1418 * whose resources are no longer available.
1419 * </ul>
1420 *
1421 * <p class="note">This is a protected intent that can only be sent
1422 * by the system.
1423 * @hide
1424 */
1425 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001426 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001427 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001428
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001429 /**
1430 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001431 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001432 */
1433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1434 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1435 /**
1436 * Broadcast Action: The current device {@link android.content.res.Configuration}
1437 * (orientation, locale, etc) has changed. When such a change happens, the
1438 * UIs (view hierarchy) will need to be rebuilt based on this new
1439 * information; for the most part, applications don't need to worry about
1440 * this, because the system will take care of stopping and restarting the
1441 * application to make sure it sees the new changes. Some system code that
1442 * can not be restarted will need to watch for this action and handle it
1443 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001444 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001445 * <p class="note">
1446 * You can <em>not</em> receive this through components declared
1447 * in manifests, only by explicitly registering for it with
1448 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1449 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001450 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001451 * <p class="note">This is a protected intent that can only be sent
1452 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001453 *
1454 * @see android.content.res.Configuration
1455 */
1456 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1457 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1458 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001459 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001460 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001461 * <p class="note">This is a protected intent that can only be sent
1462 * by the system.
1463 */
1464 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1465 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1466 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001467 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1468 * charging state, level, and other information about the battery.
1469 * See {@link android.os.BatteryManager} for documentation on the
1470 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001471 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001472 * <p class="note">
1473 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001474 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001475 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001476 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1477 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1478 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1479 * broadcasts that are sent and can be received through manifest
1480 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001481 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001482 * <p class="note">This is a protected intent that can only be sent
1483 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001484 */
1485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1486 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1487 /**
1488 * Broadcast Action: Indicates low battery condition on the device.
1489 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001490 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001491 * <p class="note">This is a protected intent that can only be sent
1492 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001493 */
1494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1495 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1496 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001497 * Broadcast Action: Indicates the battery is now okay after being low.
1498 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1499 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001500 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001501 * <p class="note">This is a protected intent that can only be sent
1502 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001503 */
1504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1505 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1506 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001507 * Broadcast Action: External power has been connected to the device.
1508 * This is intended for applications that wish to register specifically to this notification.
1509 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1510 * stay active to receive this notification. This action can be used to implement actions
1511 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001512 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001513 * <p class="note">This is a protected intent that can only be sent
1514 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001515 */
1516 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001517 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001518 /**
1519 * Broadcast Action: External power has been removed from the device.
1520 * This is intended for applications that wish to register specifically to this notification.
1521 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1522 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001523 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001524 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001525 * <p class="note">This is a protected intent that can only be sent
1526 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001527 */
1528 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001529 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001530 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001531 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001532 * Broadcast Action: Device is shutting down.
1533 * This is broadcast when the device is being shut down (completely turned
1534 * off, not sleeping). Once the broadcast is complete, the final shutdown
1535 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001536 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001537 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001538 * <p class="note">This is a protected intent that can only be sent
1539 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001540 */
1541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001542 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001543 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001544 * Activity Action: Start this activity to request system shutdown.
1545 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1546 * to request confirmation from the user before shutting down.
1547 *
1548 * <p class="note">This is a protected intent that can only be sent
1549 * by the system.
1550 *
1551 * {@hide}
1552 */
1553 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1554 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001555 * Broadcast Action: A sticky broadcast that indicates low memory
1556 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001557 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001558 * <p class="note">This is a protected intent that can only be sent
1559 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001560 */
1561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1562 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1563 /**
1564 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001565 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001566 * <p class="note">This is a protected intent that can only be sent
1567 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001568 */
1569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1570 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1571 /**
1572 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1573 * and package management should be started.
1574 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1575 * notification.
1576 */
1577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1578 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1579 /**
1580 * Broadcast Action: The device has entered USB Mass Storage mode.
1581 * This is used mainly for the USB Settings panel.
1582 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1583 * when the SD card file system is mounted or unmounted
1584 */
1585 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1586 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1587
1588 /**
1589 * Broadcast Action: The device has exited USB Mass Storage mode.
1590 * This is used mainly for the USB Settings panel.
1591 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1592 * when the SD card file system is mounted or unmounted
1593 */
1594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1595 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1596
1597 /**
1598 * Broadcast Action: External media has been removed.
1599 * The path to the mount point for the removed media is contained in the Intent.mData field.
1600 */
1601 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1602 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1603
1604 /**
1605 * Broadcast Action: External media is present, but not mounted at its mount point.
1606 * The path to the mount point for the removed media is contained in the Intent.mData field.
1607 */
1608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1609 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1610
1611 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001612 * Broadcast Action: External media is present, and being disk-checked
1613 * 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 -08001614 */
1615 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1616 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1617
1618 /**
1619 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1620 * 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 -08001621 */
1622 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1623 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1624
1625 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001626 * Broadcast Action: External media is present and mounted at its mount point.
1627 * The path to the mount point for the removed media is contained in the Intent.mData field.
1628 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1629 * media was mounted read only.
1630 */
1631 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1632 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1633
1634 /**
1635 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001636 * 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 -07001637 */
1638 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1639 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1640
1641 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001642 * Broadcast Action: External media is no longer being shared via USB mass storage.
1643 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1644 *
1645 * @hide
1646 */
1647 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1648
1649 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001650 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1651 * The path to the mount point for the removed media is contained in the Intent.mData field.
1652 */
1653 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1654 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1655
1656 /**
1657 * Broadcast Action: External media is present but cannot be mounted.
1658 * The path to the mount point for the removed media is contained in the Intent.mData field.
1659 */
1660 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1661 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1662
1663 /**
1664 * Broadcast Action: User has expressed the desire to remove the external storage media.
1665 * Applications should close all files they have open within the mount point when they receive this intent.
1666 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1667 */
1668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1669 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1670
1671 /**
1672 * Broadcast Action: The media scanner has started scanning a directory.
1673 * The path to the directory being scanned is contained in the Intent.mData field.
1674 */
1675 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1676 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1677
1678 /**
1679 * Broadcast Action: The media scanner has finished scanning a directory.
1680 * The path to the scanned directory is contained in the Intent.mData field.
1681 */
1682 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1683 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1684
1685 /**
1686 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1687 * The path to the file is contained in the Intent.mData field.
1688 */
1689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1690 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1691
1692 /**
1693 * Broadcast Action: The "Media Button" was pressed. Includes a single
1694 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1695 * caused the broadcast.
1696 */
1697 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1698 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1699
1700 /**
1701 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1702 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1703 * caused the broadcast.
1704 */
1705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1706 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1707
1708 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1709 // location; they are not general-purpose actions.
1710
1711 /**
1712 * Broadcast Action: An GTalk connection has been established.
1713 */
1714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1715 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1716 "android.intent.action.GTALK_CONNECTED";
1717
1718 /**
1719 * Broadcast Action: An GTalk connection has been disconnected.
1720 */
1721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1722 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1723 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001724
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001725 /**
1726 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001727 */
1728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1729 public static final String ACTION_INPUT_METHOD_CHANGED =
1730 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001731
1732 /**
1733 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1734 * more radios have been turned off or on. The intent will have the following extra value:</p>
1735 * <ul>
1736 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1737 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1738 * turned off</li>
1739 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001740 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001741 * <p class="note">This is a protected intent that can only be sent
1742 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001743 */
1744 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1745 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1746
1747 /**
1748 * Broadcast Action: Some content providers have parts of their namespace
1749 * where they publish new events or items that the user may be especially
1750 * interested in. For these things, they may broadcast this action when the
1751 * set of interesting items change.
1752 *
1753 * For example, GmailProvider sends this notification when the set of unread
1754 * mail in the inbox changes.
1755 *
1756 * <p>The data of the intent identifies which part of which provider
1757 * changed. When queried through the content resolver, the data URI will
1758 * return the data set in question.
1759 *
1760 * <p>The intent will have the following extra values:
1761 * <ul>
1762 * <li><em>count</em> - The number of items in the data set. This is the
1763 * same as the number of items in the cursor returned by querying the
1764 * data URI. </li>
1765 * </ul>
1766 *
1767 * This intent will be sent at boot (if the count is non-zero) and when the
1768 * data set changes. It is possible for the data set to change without the
1769 * count changing (for example, if a new unread message arrives in the same
1770 * sync operation in which a message is archived). The phone should still
1771 * ring/vibrate/etc as normal in this case.
1772 */
1773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1774 public static final String ACTION_PROVIDER_CHANGED =
1775 "android.intent.action.PROVIDER_CHANGED";
1776
1777 /**
1778 * Broadcast Action: Wired Headset plugged in or unplugged.
1779 *
1780 * <p>The intent will have the following extra values:
1781 * <ul>
1782 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1783 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001784 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001785 * </ul>
1786 * </ul>
1787 */
1788 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1789 public static final String ACTION_HEADSET_PLUG =
1790 "android.intent.action.HEADSET_PLUG";
1791
1792 /**
1793 * Broadcast Action: An outgoing call is about to be placed.
1794 *
1795 * <p>The Intent will have the following extra value:
1796 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07001797 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001798 * the phone number originally intended to be dialed.</li>
1799 * </ul>
1800 * <p>Once the broadcast is finished, the resultData is used as the actual
1801 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07001802 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001803 * outgoing call in turn: for example, a parental control application
1804 * might verify that the user is authorized to place the call at that
1805 * time, then a number-rewriting application might add an area code if
1806 * one was not specified.</p>
1807 * <p>For consistency, any receiver whose purpose is to prohibit phone
1808 * calls should have a priority of 0, to ensure it will see the final
1809 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07001810 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001811 * should have a positive priority.
1812 * Negative priorities are reserved for the system for this broadcast;
1813 * using them may cause problems.</p>
1814 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
1815 * abort the broadcast.</p>
1816 * <p>Emergency calls cannot be intercepted using this mechanism, and
1817 * other calls cannot be modified to call emergency numbers using this
1818 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07001819 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001820 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
1821 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08001822 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001823 * <p class="note">This is a protected intent that can only be sent
1824 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001825 */
1826 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1827 public static final String ACTION_NEW_OUTGOING_CALL =
1828 "android.intent.action.NEW_OUTGOING_CALL";
1829
1830 /**
1831 * Broadcast Action: Have the device reboot. This is only for use by
1832 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08001833 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001834 * <p class="note">This is a protected intent that can only be sent
1835 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001836 */
1837 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1838 public static final String ACTION_REBOOT =
1839 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001840
Wei Huang97ecc9c2009-05-11 17:44:20 -07001841 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08001842 * Broadcast Action: A sticky broadcast for changes in the physical
1843 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08001844 *
1845 * <p>The intent will have the following extra values:
1846 * <ul>
1847 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08001848 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08001849 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08001850 * <p>This is intended for monitoring the current physical dock state.
1851 * See {@link android.app.UiModeManager} for the normal API dealing with
1852 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001853 */
1854 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1855 public static final String ACTION_DOCK_EVENT =
1856 "android.intent.action.DOCK_EVENT";
1857
1858 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07001859 * Broadcast Action: a remote intent is to be broadcasted.
1860 *
1861 * A remote intent is used for remote RPC between devices. The remote intent
1862 * is serialized and sent from one device to another device. The receiving
1863 * device parses the remote intent and broadcasts it. Note that anyone can
1864 * broadcast a remote intent. However, if the intent receiver of the remote intent
1865 * does not trust intent broadcasts from arbitrary intent senders, it should require
1866 * the sender to hold certain permissions so only trusted sender's broadcast will be
1867 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07001868 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07001869 */
1870 public static final String ACTION_REMOTE_INTENT =
Costin Manolache63cfebf2010-02-04 16:52:34 -08001871 "com.google.android.pushmessaging.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07001872
Dianne Hackborn9acc0302009-08-25 00:27:12 -07001873 /**
1874 * Broadcast Action: hook for permforming cleanup after a system update.
1875 *
1876 * The broadcast is sent when the system is booting, before the
1877 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
1878 * image. A receiver for this should do its work and then disable itself
1879 * so that it does not get run again at the next boot.
1880 * @hide
1881 */
1882 public static final String ACTION_PRE_BOOT_COMPLETED =
1883 "android.intent.action.PRE_BOOT_COMPLETED";
1884
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001885 // ---------------------------------------------------------------------
1886 // ---------------------------------------------------------------------
1887 // Standard intent categories (see addCategory()).
1888
1889 /**
1890 * Set if the activity should be an option for the default action
1891 * (center press) to perform on a piece of data. Setting this will
1892 * hide from the user any activities without it set when performing an
1893 * action on some data. Note that this is normal -not- set in the
1894 * Intent when initiating an action -- it is for use in intent filters
1895 * specified in packages.
1896 */
1897 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1898 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
1899 /**
1900 * Activities that can be safely invoked from a browser must support this
1901 * category. For example, if the user is viewing a web page or an e-mail
1902 * and clicks on a link in the text, the Intent generated execute that
1903 * link will require the BROWSABLE category, so that only activities
1904 * supporting this category will be considered as possible actions. By
1905 * supporting this category, you are promising that there is nothing
1906 * damaging (without user intervention) that can happen by invoking any
1907 * matching Intent.
1908 */
1909 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1910 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
1911 /**
1912 * Set if the activity should be considered as an alternative action to
1913 * the data the user is currently viewing. See also
1914 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
1915 * applies to the selection in a list of items.
1916 *
1917 * <p>Supporting this category means that you would like your activity to be
1918 * displayed in the set of alternative things the user can do, usually as
1919 * part of the current activity's options menu. You will usually want to
1920 * include a specific label in the &lt;intent-filter&gt; of this action
1921 * describing to the user what it does.
1922 *
1923 * <p>The action of IntentFilter with this category is important in that it
1924 * describes the specific action the target will perform. This generally
1925 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
1926 * a specific name such as "com.android.camera.action.CROP. Only one
1927 * alternative of any particular action will be shown to the user, so using
1928 * a specific action like this makes sure that your alternative will be
1929 * displayed while also allowing other applications to provide their own
1930 * overrides of that particular action.
1931 */
1932 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1933 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
1934 /**
1935 * Set if the activity should be considered as an alternative selection
1936 * action to the data the user has currently selected. This is like
1937 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
1938 * of items from which the user can select, giving them alternatives to the
1939 * default action that will be performed on it.
1940 */
1941 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1942 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
1943 /**
1944 * Intended to be used as a tab inside of an containing TabActivity.
1945 */
1946 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1947 public static final String CATEGORY_TAB = "android.intent.category.TAB";
1948 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001949 * Should be displayed in the top-level launcher.
1950 */
1951 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1952 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
1953 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001954 * Provides information about the package it is in; typically used if
1955 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
1956 * a front-door to the user without having to be shown in the all apps list.
1957 */
1958 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1959 public static final String CATEGORY_INFO = "android.intent.category.INFO";
1960 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001961 * This is the home activity, that is the first activity that is displayed
1962 * when the device boots.
1963 */
1964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1965 public static final String CATEGORY_HOME = "android.intent.category.HOME";
1966 /**
1967 * This activity is a preference panel.
1968 */
1969 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1970 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
1971 /**
1972 * This activity is a development preference panel.
1973 */
1974 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1975 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
1976 /**
1977 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 */
1979 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1980 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
1981 /**
1982 * This activity may be exercised by the monkey or other automated test tools.
1983 */
1984 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
1985 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
1986 /**
1987 * To be used as a test (not part of the normal user experience).
1988 */
1989 public static final String CATEGORY_TEST = "android.intent.category.TEST";
1990 /**
1991 * To be used as a unit test (run through the Test Harness).
1992 */
1993 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
1994 /**
1995 * To be used as an sample code example (not part of the normal user
1996 * experience).
1997 */
1998 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
1999 /**
2000 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2001 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2002 * when queried, though it is allowable for those columns to be blank.
2003 */
2004 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2005 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2006
2007 /**
2008 * To be used as code under test for framework instrumentation tests.
2009 */
2010 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2011 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002012 /**
2013 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002014 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2015 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002016 */
2017 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2018 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2019 /**
2020 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002021 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2022 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002023 */
2024 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2025 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002026
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002027 /**
2028 * Used to indicate that the activity can be used in a car environment.
2029 */
2030 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2031 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002033 // ---------------------------------------------------------------------
2034 // ---------------------------------------------------------------------
2035 // Standard extra data keys.
2036
2037 /**
2038 * The initial data to place in a newly created record. Use with
2039 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2040 * fields as would be given to the underlying ContentProvider.insert()
2041 * call.
2042 */
2043 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2044
2045 /**
2046 * A constant CharSequence that is associated with the Intent, used with
2047 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2048 * this may be a styled CharSequence, so you must use
2049 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2050 * retrieve it.
2051 */
2052 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2053
2054 /**
2055 * A content: URI holding a stream of data associated with the Intent,
2056 * used with {@link #ACTION_SEND} to supply the data being sent.
2057 */
2058 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2059
2060 /**
2061 * A String[] holding e-mail addresses that should be delivered to.
2062 */
2063 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2064
2065 /**
2066 * A String[] holding e-mail addresses that should be carbon copied.
2067 */
2068 public static final String EXTRA_CC = "android.intent.extra.CC";
2069
2070 /**
2071 * A String[] holding e-mail addresses that should be blind carbon copied.
2072 */
2073 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2074
2075 /**
2076 * A constant string holding the desired subject line of a message.
2077 */
2078 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2079
2080 /**
2081 * An Intent describing the choices you would like shown with
2082 * {@link #ACTION_PICK_ACTIVITY}.
2083 */
2084 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2085
2086 /**
2087 * A CharSequence dialog title to provide to the user when used with a
2088 * {@link #ACTION_CHOOSER}.
2089 */
2090 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2091
2092 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002093 * A Parcelable[] of {@link Intent} or
2094 * {@link android.content.pm.LabeledIntent} objects as set with
2095 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2096 * a the front of the list of choices, when shown to the user with a
2097 * {@link #ACTION_CHOOSER}.
2098 */
2099 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2100
2101 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002102 * A {@link android.view.KeyEvent} object containing the event that
2103 * triggered the creation of the Intent it is in.
2104 */
2105 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2106
2107 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002108 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2109 * before shutting down.
2110 *
2111 * {@hide}
2112 */
2113 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2114
2115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002116 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2117 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2118 * of restarting the application.
2119 */
2120 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2121
2122 /**
2123 * A String holding the phone number originally entered in
2124 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2125 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2126 */
2127 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002128
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002129 /**
2130 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2131 * intents to supply the uid the package had been assigned. Also an optional
2132 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2133 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2134 * purpose.
2135 */
2136 public static final String EXTRA_UID = "android.intent.extra.UID";
2137
2138 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002139 * @hide String array of package names.
2140 */
2141 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2142
2143 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002144 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2145 * intents to indicate whether this represents a full uninstall (removing
2146 * both the code and its data) or a partial uninstall (leaving its data,
2147 * implying that this is an update).
2148 */
2149 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002150
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002151 /**
2152 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2153 * intents to indicate that this is a replacement of the package, so this
2154 * broadcast will immediately be followed by an add broadcast for a
2155 * different version of the same package.
2156 */
2157 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002158
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002159 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002160 * Used as an int extra field in {@link android.app.AlarmManager} intents
2161 * to tell the application being invoked how many pending alarms are being
2162 * delievered with the intent. For one-shot alarms this will always be 1.
2163 * For recurring alarms, this might be greater than 1 if the device was
2164 * asleep or powered off at the time an earlier alarm would have been
2165 * delivered.
2166 */
2167 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002168
Jacek Surazski86b6c532009-05-13 14:38:28 +02002169 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002170 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2171 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002172 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2173 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
2174 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002175 */
2176 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2177
2178 /**
2179 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2180 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002181 */
2182 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2183
2184 /**
2185 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2186 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002187 */
2188 public static final int EXTRA_DOCK_STATE_DESK = 1;
2189
2190 /**
2191 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2192 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002193 */
2194 public static final int EXTRA_DOCK_STATE_CAR = 2;
2195
2196 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002197 * Boolean that can be supplied as meta-data with a dock activity, to
2198 * indicate that the dock should take over the home key when it is active.
2199 */
2200 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002201
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002202 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002203 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2204 * the bug report.
Romain Guy4969af72009-06-17 10:53:19 -07002205 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002206 * @hide
2207 */
2208 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2209
2210 /**
Romain Guy4969af72009-06-17 10:53:19 -07002211 * Used as a string extra field when sending an intent to PackageInstaller to install a
Jacek Surazski86b6c532009-05-13 14:38:28 +02002212 * package. Specifies the installer package name; this package will receive the
2213 * {@link #ACTION_APP_ERROR} intent.
Romain Guy4969af72009-06-17 10:53:19 -07002214 *
Jacek Surazski86b6c532009-05-13 14:38:28 +02002215 * @hide
2216 */
Romain Guy4969af72009-06-17 10:53:19 -07002217 public static final String EXTRA_INSTALLER_PACKAGE_NAME
Jacek Surazski86b6c532009-05-13 14:38:28 +02002218 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002219
Wei Huang97ecc9c2009-05-11 17:44:20 -07002220 /**
2221 * Used in the extra field in the remote intent. It's astring token passed with the
2222 * remote intent.
2223 */
2224 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2225 "android.intent.extra.remote_intent_token";
2226
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002227 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002228 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002229 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002230 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002231 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002232 "android.intent.extra.changed_component_name";
2233
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002234 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002235 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002236 * and contains a string array of all of the components that have changed.
2237 */
2238 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2239 "android.intent.extra.changed_component_name_list";
2240
2241 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002242 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002243 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2244 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002245 * and contains a string array of all of the components that have changed.
2246 * @hide
2247 */
2248 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2249 "android.intent.extra.changed_package_list";
2250
2251 /**
2252 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002253 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2254 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002255 * and contains an integer array of uids of all of the components
2256 * that have changed.
2257 * @hide
2258 */
2259 public static final String EXTRA_CHANGED_UID_LIST =
2260 "android.intent.extra.changed_uid_list";
2261
2262 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002263 * @hide
2264 * Magic extra system code can use when binding, to give a label for
2265 * who it is that has bound to a service. This is an integer giving
2266 * a framework string resource that can be displayed to the user.
2267 */
2268 public static final String EXTRA_CLIENT_LABEL =
2269 "android.intent.extra.client_label";
2270
2271 /**
2272 * @hide
2273 * Magic extra system code can use when binding, to give a PendingIntent object
2274 * that can be launched for the user to disable the system's use of this
2275 * service.
2276 */
2277 public static final String EXTRA_CLIENT_INTENT =
2278 "android.intent.extra.client_intent";
2279
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002280 // ---------------------------------------------------------------------
2281 // ---------------------------------------------------------------------
2282 // Intent flags (see mFlags variable).
2283
2284 /**
2285 * If set, the recipient of this Intent will be granted permission to
2286 * perform read operations on the Uri in the Intent's data.
2287 */
2288 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2289 /**
2290 * If set, the recipient of this Intent will be granted permission to
2291 * perform write operations on the Uri in the Intent's data.
2292 */
2293 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2294 /**
2295 * Can be set by the caller to indicate that this Intent is coming from
2296 * a background operation, not from direct user interaction.
2297 */
2298 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2299 /**
2300 * A flag you can enable for debugging: when set, log messages will be
2301 * printed during the resolution of this intent to show you what has
2302 * been found to create the final resolved list.
2303 */
2304 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
2305
2306 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002307 * If set, the new activity is not kept in the history stack. As soon as
2308 * the user navigates away from it, the activity is finished. This may also
2309 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2310 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002311 */
2312 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2313 /**
2314 * If set, the activity will not be launched if it is already running
2315 * at the top of the history stack.
2316 */
2317 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2318 /**
2319 * If set, this activity will become the start of a new task on this
2320 * history stack. A task (from the activity that started it to the
2321 * next task activity) defines an atomic group of activities that the
2322 * user can move to. Tasks can be moved to the foreground and background;
2323 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002324 * the same order. See
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002325 * <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2326 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002327 *
2328 * <p>This flag is generally used by activities that want
2329 * to present a "launcher" style behavior: they give the user a list of
2330 * separate things that can be done, which otherwise run completely
2331 * independently of the activity launching them.
2332 *
2333 * <p>When using this flag, if a task is already running for the activity
2334 * you are now starting, then a new activity will not be started; instead,
2335 * the current task will simply be brought to the front of the screen with
2336 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2337 * to disable this behavior.
2338 *
2339 * <p>This flag can not be used when the caller is requesting a result from
2340 * the activity being launched.
2341 */
2342 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2343 /**
2344 * <strong>Do not use this flag unless you are implementing your own
2345 * top-level application launcher.</strong> Used in conjunction with
2346 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2347 * behavior of bringing an existing task to the foreground. When set,
2348 * a new task is <em>always</em> started to host the Activity for the
2349 * Intent, regardless of whether there is already an existing task running
2350 * the same thing.
2351 *
2352 * <p><strong>Because the default system does not include graphical task management,
2353 * you should not use this flag unless you provide some way for a user to
2354 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002355 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002356 * <p>This flag is ignored if
2357 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2358 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002359 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2360 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002361 */
2362 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2363 /**
2364 * If set, and the activity being launched is already running in the
2365 * current task, then instead of launching a new instance of that activity,
2366 * all of the other activities on top of it will be closed and this Intent
2367 * will be delivered to the (now on top) old activity as a new Intent.
2368 *
2369 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2370 * If D calls startActivity() with an Intent that resolves to the component
2371 * of activity B, then C and D will be finished and B receive the given
2372 * Intent, resulting in the stack now being: A, B.
2373 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002374 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002375 * either receive the new intent you are starting here in its
2376 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002377 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002378 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2379 * the same intent, then it will be finished and re-created; for all other
2380 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2381 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002382 *
2383 * <p>This launch mode can also be used to good effect in conjunction with
2384 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2385 * of a task, it will bring any currently running instance of that task
2386 * to the foreground, and then clear it to its root state. This is
2387 * especially useful, for example, when launching an activity from the
2388 * notification manager.
2389 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002390 * <p>See <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
2391 * Activities and Tasks</a> for more details on tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002392 */
2393 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2394 /**
2395 * If set and this intent is being used to launch a new activity from an
2396 * existing one, then the reply target of the existing activity will be
2397 * transfered to the new activity. This way the new activity can call
2398 * {@link android.app.Activity#setResult} and have that result sent back to
2399 * the reply target of the original activity.
2400 */
2401 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2402 /**
2403 * If set and this intent is being used to launch a new activity from an
2404 * existing one, the current activity will not be counted as the top
2405 * activity for deciding whether the new intent should be delivered to
2406 * the top instead of starting a new one. The previous activity will
2407 * be used as the top, with the assumption being that the current activity
2408 * will finish itself immediately.
2409 */
2410 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2411 /**
2412 * If set, the new activity is not kept in the list of recently launched
2413 * activities.
2414 */
2415 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2416 /**
2417 * This flag is not normally set by application code, but set for you by
2418 * the system as described in the
2419 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2420 * launchMode} documentation for the singleTask mode.
2421 */
2422 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2423 /**
2424 * If set, and this activity is either being started in a new task or
2425 * bringing to the top an existing task, then it will be launched as
2426 * the front door of the task. This will result in the application of
2427 * any affinities needed to have that task in the proper state (either
2428 * moving activities to or from it), or simply resetting that task to
2429 * its initial state if needed.
2430 */
2431 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2432 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002433 * This flag is not normally set by application code, but set for you by
2434 * the system if this activity is being launched from history
2435 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 */
2437 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002438 /**
2439 * If set, this marks a point in the task's activity stack that should
2440 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002441 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002442 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2443 * the user re-launching it from home), this activity and all on top of
2444 * it will be finished so that the user does not return to them, but
2445 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002446 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002447 * <p>This is useful for cases where you have a logical break in your
2448 * application. For example, an e-mail application may have a command
2449 * to view an attachment, which launches an image view activity to
2450 * display it. This activity should be part of the e-mail application's
2451 * task, since it is a part of the task the user is involved in. However,
2452 * if the user leaves that task, and later selects the e-mail app from
2453 * home, we may like them to return to the conversation they were
2454 * viewing, not the picture attachment, since that is confusing. By
2455 * setting this flag when launching the image viewer, that viewer and
2456 * any activities it starts will be removed the next time the user returns
2457 * to mail.
2458 */
2459 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002460 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002461 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002462 * callback from occurring on the current frontmost activity before it is
2463 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002464 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002465 * <p>Typically, an activity can rely on that callback to indicate that an
2466 * explicit user action has caused their activity to be moved out of the
2467 * foreground. The callback marks an appropriate point in the activity's
2468 * lifecycle for it to dismiss any notifications that it intends to display
2469 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002470 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002471 * <p>If an activity is ever started via any non-user-driven events such as
2472 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2473 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002474 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002475 */
2476 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002477 /**
2478 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2479 * this flag will cause the launched activity to be brought to the front of its
2480 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002481 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002482 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2483 * If D calls startActivity() with an Intent that resolves to the component
2484 * of activity B, then B will be brought to the front of the history stack,
2485 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002486 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002487 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002488 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002489 */
2490 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002491 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002492 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2493 * this flag will prevent the system from applying an activity transition
2494 * animation to go to the next activity state. This doesn't mean an
2495 * animation will never run -- if another activity change happens that doesn't
2496 * specify this flag before the activity started here is displayed, then
2497 * that transition will be used. This this flag can be put to good use
2498 * when you are going to do a series of activity operations but the
2499 * animation seen by the user shouldn't be driven by the first activity
2500 * change but rather a later one.
2501 */
2502 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2503 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002504 * If set, when sending a broadcast only registered receivers will be
2505 * called -- no BroadcastReceiver components will be launched.
2506 */
2507 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002508 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002509 * If set, when sending a broadcast the new broadcast will replace
2510 * any existing pending broadcast that matches it. Matching is defined
2511 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2512 * true for the intents of the two broadcasts. When a match is found,
2513 * the new broadcast (and receivers associated with it) will replace the
2514 * existing one in the pending broadcast list, remaining at the same
2515 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002516 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002517 * <p>This flag is most typically used with sticky broadcasts, which
2518 * only care about delivering the most recent values of the broadcast
2519 * to their receivers.
2520 */
2521 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2522 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002523 * If set, when sending a broadcast <i>before boot has completed</i> only
2524 * registered receivers will be called -- no BroadcastReceiver components
2525 * will be launched. Sticky intent state will be recorded properly even
2526 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2527 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002528 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002529 * <p>This flag is only for use by system sevices as a convenience to
2530 * avoid having to implement a more complex mechanism around detection
2531 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002532 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002533 * @hide
2534 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002535 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002536 /**
2537 * Set when this broadcast is for a boot upgrade, a special mode that
2538 * allows the broadcast to be sent before the system is ready and launches
2539 * the app process with no providers running in it.
2540 * @hide
2541 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002542 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002544 /**
2545 * @hide Flags that can't be changed with PendingIntent.
2546 */
2547 public static final int IMMUTABLE_FLAGS =
2548 FLAG_GRANT_READ_URI_PERMISSION
2549 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002550
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002551 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002552 // ---------------------------------------------------------------------
2553 // toUri() and parseUri() options.
2554
2555 /**
2556 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2557 * always has the "intent:" scheme. This syntax can be used when you want
2558 * to later disambiguate between URIs that are intended to describe an
2559 * Intent vs. all others that should be treated as raw URIs. When used
2560 * with {@link #parseUri}, any other scheme will result in a generic
2561 * VIEW action for that raw URI.
2562 */
2563 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002564
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002565 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002566
2567 private String mAction;
2568 private Uri mData;
2569 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002570 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002571 private ComponentName mComponent;
2572 private int mFlags;
2573 private HashSet<String> mCategories;
2574 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002575 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002576
2577 // ---------------------------------------------------------------------
2578
2579 /**
2580 * Create an empty intent.
2581 */
2582 public Intent() {
2583 }
2584
2585 /**
2586 * Copy constructor.
2587 */
2588 public Intent(Intent o) {
2589 this.mAction = o.mAction;
2590 this.mData = o.mData;
2591 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002592 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002593 this.mComponent = o.mComponent;
2594 this.mFlags = o.mFlags;
2595 if (o.mCategories != null) {
2596 this.mCategories = new HashSet<String>(o.mCategories);
2597 }
2598 if (o.mExtras != null) {
2599 this.mExtras = new Bundle(o.mExtras);
2600 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002601 if (o.mSourceBounds != null) {
2602 this.mSourceBounds = new Rect(o.mSourceBounds);
2603 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002604 }
2605
2606 @Override
2607 public Object clone() {
2608 return new Intent(this);
2609 }
2610
2611 private Intent(Intent o, boolean all) {
2612 this.mAction = o.mAction;
2613 this.mData = o.mData;
2614 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002615 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002616 this.mComponent = o.mComponent;
2617 if (o.mCategories != null) {
2618 this.mCategories = new HashSet<String>(o.mCategories);
2619 }
2620 }
2621
2622 /**
2623 * Make a clone of only the parts of the Intent that are relevant for
2624 * filter matching: the action, data, type, component, and categories.
2625 */
2626 public Intent cloneFilter() {
2627 return new Intent(this, false);
2628 }
2629
2630 /**
2631 * Create an intent with a given action. All other fields (data, type,
2632 * class) are null. Note that the action <em>must</em> be in a
2633 * namespace because Intents are used globally in the system -- for
2634 * example the system VIEW action is android.intent.action.VIEW; an
2635 * application's custom action would be something like
2636 * com.google.app.myapp.CUSTOM_ACTION.
2637 *
2638 * @param action The Intent action, such as ACTION_VIEW.
2639 */
2640 public Intent(String action) {
2641 mAction = action;
2642 }
2643
2644 /**
2645 * Create an intent with a given action and for a given data url. Note
2646 * that the action <em>must</em> be in a namespace because Intents are
2647 * used globally in the system -- for example the system VIEW action is
2648 * android.intent.action.VIEW; an application's custom action would be
2649 * something like com.google.app.myapp.CUSTOM_ACTION.
2650 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002651 * <p><em>Note: scheme and host name matching in the Android framework is
2652 * case-sensitive, unlike the formal RFC. As a result,
2653 * you should always ensure that you write your Uri with these elements
2654 * using lower case letters, and normalize any Uris you receive from
2655 * outside of Android to ensure the scheme and host is lower case.</em></p>
2656 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002657 * @param action The Intent action, such as ACTION_VIEW.
2658 * @param uri The Intent data URI.
2659 */
2660 public Intent(String action, Uri uri) {
2661 mAction = action;
2662 mData = uri;
2663 }
2664
2665 /**
2666 * Create an intent for a specific component. All other fields (action, data,
2667 * type, class) are null, though they can be modified later with explicit
2668 * calls. This provides a convenient way to create an intent that is
2669 * intended to execute a hard-coded class name, rather than relying on the
2670 * system to find an appropriate class for you; see {@link #setComponent}
2671 * for more information on the repercussions of this.
2672 *
2673 * @param packageContext A Context of the application package implementing
2674 * this class.
2675 * @param cls The component class that is to be used for the intent.
2676 *
2677 * @see #setClass
2678 * @see #setComponent
2679 * @see #Intent(String, android.net.Uri , Context, Class)
2680 */
2681 public Intent(Context packageContext, Class<?> cls) {
2682 mComponent = new ComponentName(packageContext, cls);
2683 }
2684
2685 /**
2686 * Create an intent for a specific component with a specified action and data.
2687 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
2688 * construct the Intent and then calling {@link #setClass} to set its
2689 * class.
2690 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002691 * <p><em>Note: scheme and host name matching in the Android framework is
2692 * case-sensitive, unlike the formal RFC. As a result,
2693 * you should always ensure that you write your Uri with these elements
2694 * using lower case letters, and normalize any Uris you receive from
2695 * outside of Android to ensure the scheme and host is lower case.</em></p>
2696 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002697 * @param action The Intent action, such as ACTION_VIEW.
2698 * @param uri The Intent data URI.
2699 * @param packageContext A Context of the application package implementing
2700 * this class.
2701 * @param cls The component class that is to be used for the intent.
2702 *
2703 * @see #Intent(String, android.net.Uri)
2704 * @see #Intent(Context, Class)
2705 * @see #setClass
2706 * @see #setComponent
2707 */
2708 public Intent(String action, Uri uri,
2709 Context packageContext, Class<?> cls) {
2710 mAction = action;
2711 mData = uri;
2712 mComponent = new ComponentName(packageContext, cls);
2713 }
2714
2715 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002716 * Call {@link #parseUri} with 0 flags.
2717 * @deprecated Use {@link #parseUri} instead.
2718 */
2719 @Deprecated
2720 public static Intent getIntent(String uri) throws URISyntaxException {
2721 return parseUri(uri, 0);
2722 }
Tom Taylord4a47292009-12-21 13:59:18 -08002723
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002724 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002726 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07002727 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002728 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002729 *
2730 * <p>The URI given here must not be relative -- that is, it must include
2731 * the scheme and full path.
2732 *
2733 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002734 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002735 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 *
2737 * @return Intent The newly created Intent object.
2738 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002739 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
2740 * it bad (as parsed by the Uri class) or the Intent data within the
2741 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08002742 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002743 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002744 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002745 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002746 int i = 0;
2747 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002748 // Validate intent scheme for if requested.
2749 if ((flags&URI_INTENT_SCHEME) != 0) {
2750 if (!uri.startsWith("intent:")) {
2751 Intent intent = new Intent(ACTION_VIEW);
2752 try {
2753 intent.setData(Uri.parse(uri));
2754 } catch (IllegalArgumentException e) {
2755 throw new URISyntaxException(uri, e.getMessage());
2756 }
2757 return intent;
2758 }
2759 }
Tom Taylord4a47292009-12-21 13:59:18 -08002760
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002761 // simple case
2762 i = uri.lastIndexOf("#");
2763 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
2764
2765 // old format Intent URI
2766 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07002767
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002768 // new format
2769 Intent intent = new Intent(ACTION_VIEW);
2770
2771 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002772 String data = i >= 0 ? uri.substring(0, i) : null;
2773 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002774 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07002775
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002776 // loop over contents of Intent, all name=value;
2777 while (!uri.startsWith("end", i)) {
2778 int eq = uri.indexOf('=', i);
2779 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002780 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002781
2782 // action
2783 if (uri.startsWith("action=", i)) {
2784 intent.mAction = value;
2785 }
2786
2787 // categories
2788 else if (uri.startsWith("category=", i)) {
2789 intent.addCategory(value);
2790 }
2791
2792 // type
2793 else if (uri.startsWith("type=", i)) {
2794 intent.mType = value;
2795 }
2796
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002797 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002798 else if (uri.startsWith("launchFlags=", i)) {
2799 intent.mFlags = Integer.decode(value).intValue();
2800 }
2801
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002802 // package
2803 else if (uri.startsWith("package=", i)) {
2804 intent.mPackage = value;
2805 }
2806
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002807 // component
2808 else if (uri.startsWith("component=", i)) {
2809 intent.mComponent = ComponentName.unflattenFromString(value);
2810 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002811
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002812 // scheme
2813 else if (uri.startsWith("scheme=", i)) {
2814 scheme = value;
2815 }
2816
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002817 // source bounds
2818 else if (uri.startsWith("sourceBounds=", i)) {
2819 intent.mSourceBounds = Rect.unflattenFromString(value);
2820 }
2821
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002822 // extra
2823 else {
2824 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002825 // create Bundle if it doesn't already exist
2826 if (intent.mExtras == null) intent.mExtras = new Bundle();
2827 Bundle b = intent.mExtras;
2828 // add EXTRA
2829 if (uri.startsWith("S.", i)) b.putString(key, value);
2830 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
2831 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
2832 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
2833 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
2834 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
2835 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
2836 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
2837 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
2838 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
2839 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002840
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002841 // move to the next item
2842 i = semi + 1;
2843 }
2844
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002845 if (data != null) {
2846 if (data.startsWith("intent:")) {
2847 data = data.substring(7);
2848 if (scheme != null) {
2849 data = scheme + ':' + data;
2850 }
2851 }
Tom Taylord4a47292009-12-21 13:59:18 -08002852
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002853 if (data.length() > 0) {
2854 try {
2855 intent.mData = Uri.parse(data);
2856 } catch (IllegalArgumentException e) {
2857 throw new URISyntaxException(uri, e.getMessage());
2858 }
2859 }
2860 }
Tom Taylord4a47292009-12-21 13:59:18 -08002861
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002862 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07002863
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002864 } catch (IndexOutOfBoundsException e) {
2865 throw new URISyntaxException(uri, "illegal Intent URI format", i);
2866 }
2867 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002868
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002869 public static Intent getIntentOld(String uri) throws URISyntaxException {
2870 Intent intent;
2871
2872 int i = uri.lastIndexOf('#');
2873 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002874 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002875 final int intentFragmentStart = i;
2876 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002877
2878 i++;
2879
2880 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002881 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002882 i += 7;
2883 int j = uri.indexOf(')', i);
2884 action = uri.substring(i, j);
2885 i = j + 1;
2886 }
2887
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002888 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002889
2890 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002891 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002892 i += 11;
2893 int j = uri.indexOf(')', i);
2894 while (i < j) {
2895 int sep = uri.indexOf('!', i);
2896 if (sep < 0) sep = j;
2897 if (i < sep) {
2898 intent.addCategory(uri.substring(i, sep));
2899 }
2900 i = sep + 1;
2901 }
2902 i = j + 1;
2903 }
2904
2905 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002906 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002907 i += 5;
2908 int j = uri.indexOf(')', i);
2909 intent.mType = uri.substring(i, j);
2910 i = j + 1;
2911 }
2912
2913 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002914 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002915 i += 12;
2916 int j = uri.indexOf(')', i);
2917 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
2918 i = j + 1;
2919 }
2920
2921 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002922 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002923 i += 10;
2924 int j = uri.indexOf(')', i);
2925 int sep = uri.indexOf('!', i);
2926 if (sep >= 0 && sep < j) {
2927 String pkg = uri.substring(i, sep);
2928 String cls = uri.substring(sep + 1, j);
2929 intent.mComponent = new ComponentName(pkg, cls);
2930 }
2931 i = j + 1;
2932 }
2933
2934 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07002935 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002936 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07002937
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002938 final int closeParen = uri.indexOf(')', i);
2939 if (closeParen == -1) throw new URISyntaxException(uri,
2940 "EXTRA missing trailing ')'", i);
2941
2942 while (i < closeParen) {
2943 // fetch the key value
2944 int j = uri.indexOf('=', i);
2945 if (j <= i + 1 || i >= closeParen) {
2946 throw new URISyntaxException(uri, "EXTRA missing '='", i);
2947 }
2948 char type = uri.charAt(i);
2949 i++;
2950 String key = uri.substring(i, j);
2951 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07002952
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002953 // get type-value
2954 j = uri.indexOf('!', i);
2955 if (j == -1 || j >= closeParen) j = closeParen;
2956 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
2957 String value = uri.substring(i, j);
2958 i = j;
2959
2960 // create Bundle if it doesn't already exist
2961 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07002962
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002963 // add item to bundle
2964 try {
2965 switch (type) {
2966 case 'S':
2967 intent.mExtras.putString(key, Uri.decode(value));
2968 break;
2969 case 'B':
2970 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
2971 break;
2972 case 'b':
2973 intent.mExtras.putByte(key, Byte.parseByte(value));
2974 break;
2975 case 'c':
2976 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
2977 break;
2978 case 'd':
2979 intent.mExtras.putDouble(key, Double.parseDouble(value));
2980 break;
2981 case 'f':
2982 intent.mExtras.putFloat(key, Float.parseFloat(value));
2983 break;
2984 case 'i':
2985 intent.mExtras.putInt(key, Integer.parseInt(value));
2986 break;
2987 case 'l':
2988 intent.mExtras.putLong(key, Long.parseLong(value));
2989 break;
2990 case 's':
2991 intent.mExtras.putShort(key, Short.parseShort(value));
2992 break;
2993 default:
2994 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
2995 }
2996 } catch (NumberFormatException e) {
2997 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
2998 }
The Android Open Source Project10592532009-03-18 17:39:46 -07002999
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003000 char ch = uri.charAt(i);
3001 if (ch == ')') break;
3002 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3003 i++;
3004 }
3005 }
3006
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003007 if (isIntentFragment) {
3008 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3009 } else {
3010 intent.mData = Uri.parse(uri);
3011 }
Tom Taylord4a47292009-12-21 13:59:18 -08003012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003013 if (intent.mAction == null) {
3014 // By default, if no action is specified, then use VIEW.
3015 intent.mAction = ACTION_VIEW;
3016 }
3017
3018 } else {
3019 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3020 }
3021
3022 return intent;
3023 }
3024
3025 /**
3026 * Retrieve the general action to be performed, such as
3027 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3028 * the information in the intent should be interpreted -- most importantly,
3029 * what to do with the data returned by {@link #getData}.
3030 *
3031 * @return The action of this intent or null if none is specified.
3032 *
3033 * @see #setAction
3034 */
3035 public String getAction() {
3036 return mAction;
3037 }
3038
3039 /**
3040 * Retrieve data this intent is operating on. This URI specifies the name
3041 * of the data; often it uses the content: scheme, specifying data in a
3042 * content provider. Other schemes may be handled by specific activities,
3043 * such as http: by the web browser.
3044 *
3045 * @return The URI of the data this intent is targeting or null.
3046 *
3047 * @see #getScheme
3048 * @see #setData
3049 */
3050 public Uri getData() {
3051 return mData;
3052 }
3053
3054 /**
3055 * The same as {@link #getData()}, but returns the URI as an encoded
3056 * String.
3057 */
3058 public String getDataString() {
3059 return mData != null ? mData.toString() : null;
3060 }
3061
3062 /**
3063 * Return the scheme portion of the intent's data. If the data is null or
3064 * does not include a scheme, null is returned. Otherwise, the scheme
3065 * prefix without the final ':' is returned, i.e. "http".
3066 *
3067 * <p>This is the same as calling getData().getScheme() (and checking for
3068 * null data).
3069 *
3070 * @return The scheme of this intent.
3071 *
3072 * @see #getData
3073 */
3074 public String getScheme() {
3075 return mData != null ? mData.getScheme() : null;
3076 }
3077
3078 /**
3079 * Retrieve any explicit MIME type included in the intent. This is usually
3080 * null, as the type is determined by the intent data.
3081 *
3082 * @return If a type was manually set, it is returned; else null is
3083 * returned.
3084 *
3085 * @see #resolveType(ContentResolver)
3086 * @see #setType
3087 */
3088 public String getType() {
3089 return mType;
3090 }
3091
3092 /**
3093 * Return the MIME data type of this intent. If the type field is
3094 * explicitly set, that is simply returned. Otherwise, if the data is set,
3095 * the type of that data is returned. If neither fields are set, a null is
3096 * returned.
3097 *
3098 * @return The MIME type of this intent.
3099 *
3100 * @see #getType
3101 * @see #resolveType(ContentResolver)
3102 */
3103 public String resolveType(Context context) {
3104 return resolveType(context.getContentResolver());
3105 }
3106
3107 /**
3108 * Return the MIME data type of this intent. If the type field is
3109 * explicitly set, that is simply returned. Otherwise, if the data is set,
3110 * the type of that data is returned. If neither fields are set, a null is
3111 * returned.
3112 *
3113 * @param resolver A ContentResolver that can be used to determine the MIME
3114 * type of the intent's data.
3115 *
3116 * @return The MIME type of this intent.
3117 *
3118 * @see #getType
3119 * @see #resolveType(Context)
3120 */
3121 public String resolveType(ContentResolver resolver) {
3122 if (mType != null) {
3123 return mType;
3124 }
3125 if (mData != null) {
3126 if ("content".equals(mData.getScheme())) {
3127 return resolver.getType(mData);
3128 }
3129 }
3130 return null;
3131 }
3132
3133 /**
3134 * Return the MIME data type of this intent, only if it will be needed for
3135 * intent resolution. This is not generally useful for application code;
3136 * it is used by the frameworks for communicating with back-end system
3137 * services.
3138 *
3139 * @param resolver A ContentResolver that can be used to determine the MIME
3140 * type of the intent's data.
3141 *
3142 * @return The MIME type of this intent, or null if it is unknown or not
3143 * needed.
3144 */
3145 public String resolveTypeIfNeeded(ContentResolver resolver) {
3146 if (mComponent != null) {
3147 return mType;
3148 }
3149 return resolveType(resolver);
3150 }
3151
3152 /**
3153 * Check if an category exists in the intent.
3154 *
3155 * @param category The category to check.
3156 *
3157 * @return boolean True if the intent contains the category, else false.
3158 *
3159 * @see #getCategories
3160 * @see #addCategory
3161 */
3162 public boolean hasCategory(String category) {
3163 return mCategories != null && mCategories.contains(category);
3164 }
3165
3166 /**
3167 * Return the set of all categories in the intent. If there are no categories,
3168 * returns NULL.
3169 *
3170 * @return Set The set of categories you can examine. Do not modify!
3171 *
3172 * @see #hasCategory
3173 * @see #addCategory
3174 */
3175 public Set<String> getCategories() {
3176 return mCategories;
3177 }
3178
3179 /**
3180 * Sets the ClassLoader that will be used when unmarshalling
3181 * any Parcelable values from the extras of this Intent.
3182 *
3183 * @param loader a ClassLoader, or null to use the default loader
3184 * at the time of unmarshalling.
3185 */
3186 public void setExtrasClassLoader(ClassLoader loader) {
3187 if (mExtras != null) {
3188 mExtras.setClassLoader(loader);
3189 }
3190 }
3191
3192 /**
3193 * Returns true if an extra value is associated with the given name.
3194 * @param name the extra's name
3195 * @return true if the given extra is present.
3196 */
3197 public boolean hasExtra(String name) {
3198 return mExtras != null && mExtras.containsKey(name);
3199 }
3200
3201 /**
3202 * Returns true if the Intent's extras contain a parcelled file descriptor.
3203 * @return true if the Intent contains a parcelled file descriptor.
3204 */
3205 public boolean hasFileDescriptors() {
3206 return mExtras != null && mExtras.hasFileDescriptors();
3207 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003208
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003209 /**
3210 * Retrieve extended data from the intent.
3211 *
3212 * @param name The name of the desired item.
3213 *
3214 * @return the value of an item that previously added with putExtra()
3215 * or null if none was found.
3216 *
3217 * @deprecated
3218 * @hide
3219 */
3220 @Deprecated
3221 public Object getExtra(String name) {
3222 return getExtra(name, null);
3223 }
3224
3225 /**
3226 * Retrieve extended data from the intent.
3227 *
3228 * @param name The name of the desired item.
3229 * @param defaultValue the value to be returned if no value of the desired
3230 * type is stored with the given name.
3231 *
3232 * @return the value of an item that previously added with putExtra()
3233 * or the default value if none was found.
3234 *
3235 * @see #putExtra(String, boolean)
3236 */
3237 public boolean getBooleanExtra(String name, boolean defaultValue) {
3238 return mExtras == null ? defaultValue :
3239 mExtras.getBoolean(name, defaultValue);
3240 }
3241
3242 /**
3243 * Retrieve extended data from the intent.
3244 *
3245 * @param name The name of the desired item.
3246 * @param defaultValue the value to be returned if no value of the desired
3247 * type is stored with the given name.
3248 *
3249 * @return the value of an item that previously added with putExtra()
3250 * or the default value if none was found.
3251 *
3252 * @see #putExtra(String, byte)
3253 */
3254 public byte getByteExtra(String name, byte defaultValue) {
3255 return mExtras == null ? defaultValue :
3256 mExtras.getByte(name, defaultValue);
3257 }
3258
3259 /**
3260 * Retrieve extended data from the intent.
3261 *
3262 * @param name The name of the desired item.
3263 * @param defaultValue the value to be returned if no value of the desired
3264 * type is stored with the given name.
3265 *
3266 * @return the value of an item that previously added with putExtra()
3267 * or the default value if none was found.
3268 *
3269 * @see #putExtra(String, short)
3270 */
3271 public short getShortExtra(String name, short defaultValue) {
3272 return mExtras == null ? defaultValue :
3273 mExtras.getShort(name, defaultValue);
3274 }
3275
3276 /**
3277 * Retrieve extended data from the intent.
3278 *
3279 * @param name The name of the desired item.
3280 * @param defaultValue the value to be returned if no value of the desired
3281 * type is stored with the given name.
3282 *
3283 * @return the value of an item that previously added with putExtra()
3284 * or the default value if none was found.
3285 *
3286 * @see #putExtra(String, char)
3287 */
3288 public char getCharExtra(String name, char defaultValue) {
3289 return mExtras == null ? defaultValue :
3290 mExtras.getChar(name, defaultValue);
3291 }
3292
3293 /**
3294 * Retrieve extended data from the intent.
3295 *
3296 * @param name The name of the desired item.
3297 * @param defaultValue the value to be returned if no value of the desired
3298 * type is stored with the given name.
3299 *
3300 * @return the value of an item that previously added with putExtra()
3301 * or the default value if none was found.
3302 *
3303 * @see #putExtra(String, int)
3304 */
3305 public int getIntExtra(String name, int defaultValue) {
3306 return mExtras == null ? defaultValue :
3307 mExtras.getInt(name, defaultValue);
3308 }
3309
3310 /**
3311 * Retrieve extended data from the intent.
3312 *
3313 * @param name The name of the desired item.
3314 * @param defaultValue the value to be returned if no value of the desired
3315 * type is stored with the given name.
3316 *
3317 * @return the value of an item that previously added with putExtra()
3318 * or the default value if none was found.
3319 *
3320 * @see #putExtra(String, long)
3321 */
3322 public long getLongExtra(String name, long defaultValue) {
3323 return mExtras == null ? defaultValue :
3324 mExtras.getLong(name, defaultValue);
3325 }
3326
3327 /**
3328 * Retrieve extended data from the intent.
3329 *
3330 * @param name The name of the desired item.
3331 * @param defaultValue the value to be returned if no value of the desired
3332 * type is stored with the given name.
3333 *
3334 * @return the value of an item that previously added with putExtra(),
3335 * or the default value if no such item is present
3336 *
3337 * @see #putExtra(String, float)
3338 */
3339 public float getFloatExtra(String name, float defaultValue) {
3340 return mExtras == null ? defaultValue :
3341 mExtras.getFloat(name, defaultValue);
3342 }
3343
3344 /**
3345 * Retrieve extended data from the intent.
3346 *
3347 * @param name The name of the desired item.
3348 * @param defaultValue the value to be returned if no value of the desired
3349 * type is stored with the given name.
3350 *
3351 * @return the value of an item that previously added with putExtra()
3352 * or the default value if none was found.
3353 *
3354 * @see #putExtra(String, double)
3355 */
3356 public double getDoubleExtra(String name, double defaultValue) {
3357 return mExtras == null ? defaultValue :
3358 mExtras.getDouble(name, defaultValue);
3359 }
3360
3361 /**
3362 * Retrieve extended data from the intent.
3363 *
3364 * @param name The name of the desired item.
3365 *
3366 * @return the value of an item that previously added with putExtra()
3367 * or null if no String value was found.
3368 *
3369 * @see #putExtra(String, String)
3370 */
3371 public String getStringExtra(String name) {
3372 return mExtras == null ? null : mExtras.getString(name);
3373 }
3374
3375 /**
3376 * Retrieve extended data from the intent.
3377 *
3378 * @param name The name of the desired item.
3379 *
3380 * @return the value of an item that previously added with putExtra()
3381 * or null if no CharSequence value was found.
3382 *
3383 * @see #putExtra(String, CharSequence)
3384 */
3385 public CharSequence getCharSequenceExtra(String name) {
3386 return mExtras == null ? null : mExtras.getCharSequence(name);
3387 }
3388
3389 /**
3390 * Retrieve extended data from the intent.
3391 *
3392 * @param name The name of the desired item.
3393 *
3394 * @return the value of an item that previously added with putExtra()
3395 * or null if no Parcelable value was found.
3396 *
3397 * @see #putExtra(String, Parcelable)
3398 */
3399 public <T extends Parcelable> T getParcelableExtra(String name) {
3400 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3401 }
3402
3403 /**
3404 * Retrieve extended data from the intent.
3405 *
3406 * @param name The name of the desired item.
3407 *
3408 * @return the value of an item that previously added with putExtra()
3409 * or null if no Parcelable[] value was found.
3410 *
3411 * @see #putExtra(String, Parcelable[])
3412 */
3413 public Parcelable[] getParcelableArrayExtra(String name) {
3414 return mExtras == null ? null : mExtras.getParcelableArray(name);
3415 }
3416
3417 /**
3418 * Retrieve extended data from the intent.
3419 *
3420 * @param name The name of the desired item.
3421 *
3422 * @return the value of an item that previously added with putExtra()
3423 * or null if no ArrayList<Parcelable> value was found.
3424 *
3425 * @see #putParcelableArrayListExtra(String, ArrayList)
3426 */
3427 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3428 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3429 }
3430
3431 /**
3432 * Retrieve extended data from the intent.
3433 *
3434 * @param name The name of the desired item.
3435 *
3436 * @return the value of an item that previously added with putExtra()
3437 * or null if no Serializable value was found.
3438 *
3439 * @see #putExtra(String, Serializable)
3440 */
3441 public Serializable getSerializableExtra(String name) {
3442 return mExtras == null ? null : mExtras.getSerializable(name);
3443 }
3444
3445 /**
3446 * Retrieve extended data from the intent.
3447 *
3448 * @param name The name of the desired item.
3449 *
3450 * @return the value of an item that previously added with putExtra()
3451 * or null if no ArrayList<Integer> value was found.
3452 *
3453 * @see #putIntegerArrayListExtra(String, ArrayList)
3454 */
3455 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3456 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3457 }
3458
3459 /**
3460 * Retrieve extended data from the intent.
3461 *
3462 * @param name The name of the desired item.
3463 *
3464 * @return the value of an item that previously added with putExtra()
3465 * or null if no ArrayList<String> value was found.
3466 *
3467 * @see #putStringArrayListExtra(String, ArrayList)
3468 */
3469 public ArrayList<String> getStringArrayListExtra(String name) {
3470 return mExtras == null ? null : mExtras.getStringArrayList(name);
3471 }
3472
3473 /**
3474 * Retrieve extended data from the intent.
3475 *
3476 * @param name The name of the desired item.
3477 *
3478 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003479 * or null if no ArrayList<CharSequence> value was found.
3480 *
3481 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3482 */
3483 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3484 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3485 }
3486
3487 /**
3488 * Retrieve extended data from the intent.
3489 *
3490 * @param name The name of the desired item.
3491 *
3492 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003493 * or null if no boolean array value was found.
3494 *
3495 * @see #putExtra(String, boolean[])
3496 */
3497 public boolean[] getBooleanArrayExtra(String name) {
3498 return mExtras == null ? null : mExtras.getBooleanArray(name);
3499 }
3500
3501 /**
3502 * Retrieve extended data from the intent.
3503 *
3504 * @param name The name of the desired item.
3505 *
3506 * @return the value of an item that previously added with putExtra()
3507 * or null if no byte array value was found.
3508 *
3509 * @see #putExtra(String, byte[])
3510 */
3511 public byte[] getByteArrayExtra(String name) {
3512 return mExtras == null ? null : mExtras.getByteArray(name);
3513 }
3514
3515 /**
3516 * Retrieve extended data from the intent.
3517 *
3518 * @param name The name of the desired item.
3519 *
3520 * @return the value of an item that previously added with putExtra()
3521 * or null if no short array value was found.
3522 *
3523 * @see #putExtra(String, short[])
3524 */
3525 public short[] getShortArrayExtra(String name) {
3526 return mExtras == null ? null : mExtras.getShortArray(name);
3527 }
3528
3529 /**
3530 * Retrieve extended data from the intent.
3531 *
3532 * @param name The name of the desired item.
3533 *
3534 * @return the value of an item that previously added with putExtra()
3535 * or null if no char array value was found.
3536 *
3537 * @see #putExtra(String, char[])
3538 */
3539 public char[] getCharArrayExtra(String name) {
3540 return mExtras == null ? null : mExtras.getCharArray(name);
3541 }
3542
3543 /**
3544 * Retrieve extended data from the intent.
3545 *
3546 * @param name The name of the desired item.
3547 *
3548 * @return the value of an item that previously added with putExtra()
3549 * or null if no int array value was found.
3550 *
3551 * @see #putExtra(String, int[])
3552 */
3553 public int[] getIntArrayExtra(String name) {
3554 return mExtras == null ? null : mExtras.getIntArray(name);
3555 }
3556
3557 /**
3558 * Retrieve extended data from the intent.
3559 *
3560 * @param name The name of the desired item.
3561 *
3562 * @return the value of an item that previously added with putExtra()
3563 * or null if no long array value was found.
3564 *
3565 * @see #putExtra(String, long[])
3566 */
3567 public long[] getLongArrayExtra(String name) {
3568 return mExtras == null ? null : mExtras.getLongArray(name);
3569 }
3570
3571 /**
3572 * Retrieve extended data from the intent.
3573 *
3574 * @param name The name of the desired item.
3575 *
3576 * @return the value of an item that previously added with putExtra()
3577 * or null if no float array value was found.
3578 *
3579 * @see #putExtra(String, float[])
3580 */
3581 public float[] getFloatArrayExtra(String name) {
3582 return mExtras == null ? null : mExtras.getFloatArray(name);
3583 }
3584
3585 /**
3586 * Retrieve extended data from the intent.
3587 *
3588 * @param name The name of the desired item.
3589 *
3590 * @return the value of an item that previously added with putExtra()
3591 * or null if no double array value was found.
3592 *
3593 * @see #putExtra(String, double[])
3594 */
3595 public double[] getDoubleArrayExtra(String name) {
3596 return mExtras == null ? null : mExtras.getDoubleArray(name);
3597 }
3598
3599 /**
3600 * Retrieve extended data from the intent.
3601 *
3602 * @param name The name of the desired item.
3603 *
3604 * @return the value of an item that previously added with putExtra()
3605 * or null if no String array value was found.
3606 *
3607 * @see #putExtra(String, String[])
3608 */
3609 public String[] getStringArrayExtra(String name) {
3610 return mExtras == null ? null : mExtras.getStringArray(name);
3611 }
3612
3613 /**
3614 * Retrieve extended data from the intent.
3615 *
3616 * @param name The name of the desired item.
3617 *
3618 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003619 * or null if no CharSequence array value was found.
3620 *
3621 * @see #putExtra(String, CharSequence[])
3622 */
3623 public CharSequence[] getCharSequenceArrayExtra(String name) {
3624 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3625 }
3626
3627 /**
3628 * Retrieve extended data from the intent.
3629 *
3630 * @param name The name of the desired item.
3631 *
3632 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003633 * or null if no Bundle value was found.
3634 *
3635 * @see #putExtra(String, Bundle)
3636 */
3637 public Bundle getBundleExtra(String name) {
3638 return mExtras == null ? null : mExtras.getBundle(name);
3639 }
3640
3641 /**
3642 * Retrieve extended data from the intent.
3643 *
3644 * @param name The name of the desired item.
3645 *
3646 * @return the value of an item that previously added with putExtra()
3647 * or null if no IBinder value was found.
3648 *
3649 * @see #putExtra(String, IBinder)
3650 *
3651 * @deprecated
3652 * @hide
3653 */
3654 @Deprecated
3655 public IBinder getIBinderExtra(String name) {
3656 return mExtras == null ? null : mExtras.getIBinder(name);
3657 }
3658
3659 /**
3660 * Retrieve extended data from the intent.
3661 *
3662 * @param name The name of the desired item.
3663 * @param defaultValue The default value to return in case no item is
3664 * associated with the key 'name'
3665 *
3666 * @return the value of an item that previously added with putExtra()
3667 * or defaultValue if none was found.
3668 *
3669 * @see #putExtra
3670 *
3671 * @deprecated
3672 * @hide
3673 */
3674 @Deprecated
3675 public Object getExtra(String name, Object defaultValue) {
3676 Object result = defaultValue;
3677 if (mExtras != null) {
3678 Object result2 = mExtras.get(name);
3679 if (result2 != null) {
3680 result = result2;
3681 }
3682 }
3683
3684 return result;
3685 }
3686
3687 /**
3688 * Retrieves a map of extended data from the intent.
3689 *
3690 * @return the map of all extras previously added with putExtra(),
3691 * or null if none have been added.
3692 */
3693 public Bundle getExtras() {
3694 return (mExtras != null)
3695 ? new Bundle(mExtras)
3696 : null;
3697 }
3698
3699 /**
3700 * Retrieve any special flags associated with this intent. You will
3701 * normally just set them with {@link #setFlags} and let the system
3702 * take the appropriate action with them.
3703 *
3704 * @return int The currently set flags.
3705 *
3706 * @see #setFlags
3707 */
3708 public int getFlags() {
3709 return mFlags;
3710 }
3711
3712 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003713 * Retrieve the application package name this Intent is limited to. When
3714 * resolving an Intent, if non-null this limits the resolution to only
3715 * components in the given application package.
3716 *
3717 * @return The name of the application package for the Intent.
3718 *
3719 * @see #resolveActivity
3720 * @see #setPackage
3721 */
3722 public String getPackage() {
3723 return mPackage;
3724 }
3725
3726 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003727 * Retrieve the concrete component associated with the intent. When receiving
3728 * an intent, this is the component that was found to best handle it (that is,
3729 * yourself) and will always be non-null; in all other cases it will be
3730 * null unless explicitly set.
3731 *
3732 * @return The name of the application component to handle the intent.
3733 *
3734 * @see #resolveActivity
3735 * @see #setComponent
3736 */
3737 public ComponentName getComponent() {
3738 return mComponent;
3739 }
3740
3741 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003742 * Get the bounds of the sender of this intent, in screen coordinates. This can be
3743 * used as a hint to the receiver for animations and the like. Null means that there
3744 * is no source bounds.
3745 */
3746 public Rect getSourceBounds() {
3747 return mSourceBounds;
3748 }
3749
3750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003751 * Return the Activity component that should be used to handle this intent.
3752 * The appropriate component is determined based on the information in the
3753 * intent, evaluated as follows:
3754 *
3755 * <p>If {@link #getComponent} returns an explicit class, that is returned
3756 * without any further consideration.
3757 *
3758 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
3759 * category to be considered.
3760 *
3761 * <p>If {@link #getAction} is non-NULL, the activity must handle this
3762 * action.
3763 *
3764 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
3765 * this type.
3766 *
3767 * <p>If {@link #addCategory} has added any categories, the activity must
3768 * handle ALL of the categories specified.
3769 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003770 * <p>If {@link #getPackage} is non-NULL, only activity components in
3771 * that application package will be considered.
3772 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003773 * <p>If there are no activities that satisfy all of these conditions, a
3774 * null string is returned.
3775 *
3776 * <p>If multiple activities are found to satisfy the intent, the one with
3777 * the highest priority will be used. If there are multiple activities
3778 * with the same priority, the system will either pick the best activity
3779 * based on user preference, or resolve to a system class that will allow
3780 * the user to pick an activity and forward from there.
3781 *
3782 * <p>This method is implemented simply by calling
3783 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
3784 * true.</p>
3785 * <p> This API is called for you as part of starting an activity from an
3786 * intent. You do not normally need to call it yourself.</p>
3787 *
3788 * @param pm The package manager with which to resolve the Intent.
3789 *
3790 * @return Name of the component implementing an activity that can
3791 * display the intent.
3792 *
3793 * @see #setComponent
3794 * @see #getComponent
3795 * @see #resolveActivityInfo
3796 */
3797 public ComponentName resolveActivity(PackageManager pm) {
3798 if (mComponent != null) {
3799 return mComponent;
3800 }
3801
3802 ResolveInfo info = pm.resolveActivity(
3803 this, PackageManager.MATCH_DEFAULT_ONLY);
3804 if (info != null) {
3805 return new ComponentName(
3806 info.activityInfo.applicationInfo.packageName,
3807 info.activityInfo.name);
3808 }
3809
3810 return null;
3811 }
3812
3813 /**
3814 * Resolve the Intent into an {@link ActivityInfo}
3815 * describing the activity that should execute the intent. Resolution
3816 * follows the same rules as described for {@link #resolveActivity}, but
3817 * you get back the completely information about the resolved activity
3818 * instead of just its class name.
3819 *
3820 * @param pm The package manager with which to resolve the Intent.
3821 * @param flags Addition information to retrieve as per
3822 * {@link PackageManager#getActivityInfo(ComponentName, int)
3823 * PackageManager.getActivityInfo()}.
3824 *
3825 * @return PackageManager.ActivityInfo
3826 *
3827 * @see #resolveActivity
3828 */
3829 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
3830 ActivityInfo ai = null;
3831 if (mComponent != null) {
3832 try {
3833 ai = pm.getActivityInfo(mComponent, flags);
3834 } catch (PackageManager.NameNotFoundException e) {
3835 // ignore
3836 }
3837 } else {
3838 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003839 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003840 if (info != null) {
3841 ai = info.activityInfo;
3842 }
3843 }
3844
3845 return ai;
3846 }
3847
3848 /**
3849 * Set the general action to be performed.
3850 *
3851 * @param action An action name, such as ACTION_VIEW. Application-specific
3852 * actions should be prefixed with the vendor's package name.
3853 *
3854 * @return Returns the same Intent object, for chaining multiple calls
3855 * into a single statement.
3856 *
3857 * @see #getAction
3858 */
3859 public Intent setAction(String action) {
3860 mAction = action;
3861 return this;
3862 }
3863
3864 /**
3865 * Set the data this intent is operating on. This method automatically
3866 * clears any type that was previously set by {@link #setType}.
3867 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003868 * <p><em>Note: scheme and host name matching in the Android framework is
3869 * case-sensitive, unlike the formal RFC. As a result,
3870 * you should always ensure that you write your Uri with these elements
3871 * using lower case letters, and normalize any Uris you receive from
3872 * outside of Android to ensure the scheme and host is lower case.</em></p>
3873 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003874 * @param data The URI of the data this intent is now targeting.
3875 *
3876 * @return Returns the same Intent object, for chaining multiple calls
3877 * into a single statement.
3878 *
3879 * @see #getData
3880 * @see #setType
3881 * @see #setDataAndType
3882 */
3883 public Intent setData(Uri data) {
3884 mData = data;
3885 mType = null;
3886 return this;
3887 }
3888
3889 /**
3890 * Set an explicit MIME data type. This is used to create intents that
3891 * only specify a type and not data, for example to indicate the type of
3892 * data to return. This method automatically clears any data that was
3893 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07003894 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003895 * <p><em>Note: MIME type matching in the Android framework is
3896 * case-sensitive, unlike formal RFC MIME types. As a result,
3897 * you should always write your MIME types with lower case letters,
3898 * and any MIME types you receive from outside of Android should be
3899 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003900 *
3901 * @param type The MIME type of the data being handled by this intent.
3902 *
3903 * @return Returns the same Intent object, for chaining multiple calls
3904 * into a single statement.
3905 *
3906 * @see #getType
3907 * @see #setData
3908 * @see #setDataAndType
3909 */
3910 public Intent setType(String type) {
3911 mData = null;
3912 mType = type;
3913 return this;
3914 }
3915
3916 /**
3917 * (Usually optional) Set the data for the intent along with an explicit
3918 * MIME data type. This method should very rarely be used -- it allows you
3919 * to override the MIME type that would ordinarily be inferred from the
3920 * data with your own type given here.
3921 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003922 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
3923 * Android framework is case-sensitive, unlike the formal RFC definitions.
3924 * As a result, you should always write these elements with lower case letters,
3925 * and normalize any MIME types or Uris you receive from
3926 * outside of Android to ensure these elements are lower case before
3927 * supplying them here.</em></p>
3928 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003929 * @param data The URI of the data this intent is now targeting.
3930 * @param type The MIME type of the data being handled by this intent.
3931 *
3932 * @return Returns the same Intent object, for chaining multiple calls
3933 * into a single statement.
3934 *
3935 * @see #setData
3936 * @see #setType
3937 */
3938 public Intent setDataAndType(Uri data, String type) {
3939 mData = data;
3940 mType = type;
3941 return this;
3942 }
3943
3944 /**
3945 * Add a new category to the intent. Categories provide additional detail
3946 * about the action the intent is perform. When resolving an intent, only
3947 * activities that provide <em>all</em> of the requested categories will be
3948 * used.
3949 *
3950 * @param category The desired category. This can be either one of the
3951 * predefined Intent categories, or a custom category in your own
3952 * namespace.
3953 *
3954 * @return Returns the same Intent object, for chaining multiple calls
3955 * into a single statement.
3956 *
3957 * @see #hasCategory
3958 * @see #removeCategory
3959 */
3960 public Intent addCategory(String category) {
3961 if (mCategories == null) {
3962 mCategories = new HashSet<String>();
3963 }
3964 mCategories.add(category);
3965 return this;
3966 }
3967
3968 /**
3969 * Remove an category from an intent.
3970 *
3971 * @param category The category to remove.
3972 *
3973 * @see #addCategory
3974 */
3975 public void removeCategory(String category) {
3976 if (mCategories != null) {
3977 mCategories.remove(category);
3978 if (mCategories.size() == 0) {
3979 mCategories = null;
3980 }
3981 }
3982 }
3983
3984 /**
3985 * Add extended data to the intent. The name must include a package
3986 * prefix, for example the app com.android.contacts would use names
3987 * like "com.android.contacts.ShowAll".
3988 *
3989 * @param name The name of the extra data, with package prefix.
3990 * @param value The boolean data value.
3991 *
3992 * @return Returns the same Intent object, for chaining multiple calls
3993 * into a single statement.
3994 *
3995 * @see #putExtras
3996 * @see #removeExtra
3997 * @see #getBooleanExtra(String, boolean)
3998 */
3999 public Intent putExtra(String name, boolean value) {
4000 if (mExtras == null) {
4001 mExtras = new Bundle();
4002 }
4003 mExtras.putBoolean(name, value);
4004 return this;
4005 }
4006
4007 /**
4008 * Add extended data to the intent. The name must include a package
4009 * prefix, for example the app com.android.contacts would use names
4010 * like "com.android.contacts.ShowAll".
4011 *
4012 * @param name The name of the extra data, with package prefix.
4013 * @param value The byte data value.
4014 *
4015 * @return Returns the same Intent object, for chaining multiple calls
4016 * into a single statement.
4017 *
4018 * @see #putExtras
4019 * @see #removeExtra
4020 * @see #getByteExtra(String, byte)
4021 */
4022 public Intent putExtra(String name, byte value) {
4023 if (mExtras == null) {
4024 mExtras = new Bundle();
4025 }
4026 mExtras.putByte(name, value);
4027 return this;
4028 }
4029
4030 /**
4031 * Add extended data to the intent. The name must include a package
4032 * prefix, for example the app com.android.contacts would use names
4033 * like "com.android.contacts.ShowAll".
4034 *
4035 * @param name The name of the extra data, with package prefix.
4036 * @param value The char data value.
4037 *
4038 * @return Returns the same Intent object, for chaining multiple calls
4039 * into a single statement.
4040 *
4041 * @see #putExtras
4042 * @see #removeExtra
4043 * @see #getCharExtra(String, char)
4044 */
4045 public Intent putExtra(String name, char value) {
4046 if (mExtras == null) {
4047 mExtras = new Bundle();
4048 }
4049 mExtras.putChar(name, value);
4050 return this;
4051 }
4052
4053 /**
4054 * Add extended data to the intent. The name must include a package
4055 * prefix, for example the app com.android.contacts would use names
4056 * like "com.android.contacts.ShowAll".
4057 *
4058 * @param name The name of the extra data, with package prefix.
4059 * @param value The short data value.
4060 *
4061 * @return Returns the same Intent object, for chaining multiple calls
4062 * into a single statement.
4063 *
4064 * @see #putExtras
4065 * @see #removeExtra
4066 * @see #getShortExtra(String, short)
4067 */
4068 public Intent putExtra(String name, short value) {
4069 if (mExtras == null) {
4070 mExtras = new Bundle();
4071 }
4072 mExtras.putShort(name, value);
4073 return this;
4074 }
4075
4076 /**
4077 * Add extended data to the intent. The name must include a package
4078 * prefix, for example the app com.android.contacts would use names
4079 * like "com.android.contacts.ShowAll".
4080 *
4081 * @param name The name of the extra data, with package prefix.
4082 * @param value The integer data value.
4083 *
4084 * @return Returns the same Intent object, for chaining multiple calls
4085 * into a single statement.
4086 *
4087 * @see #putExtras
4088 * @see #removeExtra
4089 * @see #getIntExtra(String, int)
4090 */
4091 public Intent putExtra(String name, int value) {
4092 if (mExtras == null) {
4093 mExtras = new Bundle();
4094 }
4095 mExtras.putInt(name, value);
4096 return this;
4097 }
4098
4099 /**
4100 * Add extended data to the intent. The name must include a package
4101 * prefix, for example the app com.android.contacts would use names
4102 * like "com.android.contacts.ShowAll".
4103 *
4104 * @param name The name of the extra data, with package prefix.
4105 * @param value The long data value.
4106 *
4107 * @return Returns the same Intent object, for chaining multiple calls
4108 * into a single statement.
4109 *
4110 * @see #putExtras
4111 * @see #removeExtra
4112 * @see #getLongExtra(String, long)
4113 */
4114 public Intent putExtra(String name, long value) {
4115 if (mExtras == null) {
4116 mExtras = new Bundle();
4117 }
4118 mExtras.putLong(name, value);
4119 return this;
4120 }
4121
4122 /**
4123 * Add extended data to the intent. The name must include a package
4124 * prefix, for example the app com.android.contacts would use names
4125 * like "com.android.contacts.ShowAll".
4126 *
4127 * @param name The name of the extra data, with package prefix.
4128 * @param value The float data value.
4129 *
4130 * @return Returns the same Intent object, for chaining multiple calls
4131 * into a single statement.
4132 *
4133 * @see #putExtras
4134 * @see #removeExtra
4135 * @see #getFloatExtra(String, float)
4136 */
4137 public Intent putExtra(String name, float value) {
4138 if (mExtras == null) {
4139 mExtras = new Bundle();
4140 }
4141 mExtras.putFloat(name, value);
4142 return this;
4143 }
4144
4145 /**
4146 * Add extended data to the intent. The name must include a package
4147 * prefix, for example the app com.android.contacts would use names
4148 * like "com.android.contacts.ShowAll".
4149 *
4150 * @param name The name of the extra data, with package prefix.
4151 * @param value The double data value.
4152 *
4153 * @return Returns the same Intent object, for chaining multiple calls
4154 * into a single statement.
4155 *
4156 * @see #putExtras
4157 * @see #removeExtra
4158 * @see #getDoubleExtra(String, double)
4159 */
4160 public Intent putExtra(String name, double value) {
4161 if (mExtras == null) {
4162 mExtras = new Bundle();
4163 }
4164 mExtras.putDouble(name, value);
4165 return this;
4166 }
4167
4168 /**
4169 * Add extended data to the intent. The name must include a package
4170 * prefix, for example the app com.android.contacts would use names
4171 * like "com.android.contacts.ShowAll".
4172 *
4173 * @param name The name of the extra data, with package prefix.
4174 * @param value The String data value.
4175 *
4176 * @return Returns the same Intent object, for chaining multiple calls
4177 * into a single statement.
4178 *
4179 * @see #putExtras
4180 * @see #removeExtra
4181 * @see #getStringExtra(String)
4182 */
4183 public Intent putExtra(String name, String value) {
4184 if (mExtras == null) {
4185 mExtras = new Bundle();
4186 }
4187 mExtras.putString(name, value);
4188 return this;
4189 }
4190
4191 /**
4192 * Add extended data to the intent. The name must include a package
4193 * prefix, for example the app com.android.contacts would use names
4194 * like "com.android.contacts.ShowAll".
4195 *
4196 * @param name The name of the extra data, with package prefix.
4197 * @param value The CharSequence data value.
4198 *
4199 * @return Returns the same Intent object, for chaining multiple calls
4200 * into a single statement.
4201 *
4202 * @see #putExtras
4203 * @see #removeExtra
4204 * @see #getCharSequenceExtra(String)
4205 */
4206 public Intent putExtra(String name, CharSequence value) {
4207 if (mExtras == null) {
4208 mExtras = new Bundle();
4209 }
4210 mExtras.putCharSequence(name, value);
4211 return this;
4212 }
4213
4214 /**
4215 * Add extended data to the intent. The name must include a package
4216 * prefix, for example the app com.android.contacts would use names
4217 * like "com.android.contacts.ShowAll".
4218 *
4219 * @param name The name of the extra data, with package prefix.
4220 * @param value The Parcelable data value.
4221 *
4222 * @return Returns the same Intent object, for chaining multiple calls
4223 * into a single statement.
4224 *
4225 * @see #putExtras
4226 * @see #removeExtra
4227 * @see #getParcelableExtra(String)
4228 */
4229 public Intent putExtra(String name, Parcelable value) {
4230 if (mExtras == null) {
4231 mExtras = new Bundle();
4232 }
4233 mExtras.putParcelable(name, value);
4234 return this;
4235 }
4236
4237 /**
4238 * Add extended data to the intent. The name must include a package
4239 * prefix, for example the app com.android.contacts would use names
4240 * like "com.android.contacts.ShowAll".
4241 *
4242 * @param name The name of the extra data, with package prefix.
4243 * @param value The Parcelable[] data value.
4244 *
4245 * @return Returns the same Intent object, for chaining multiple calls
4246 * into a single statement.
4247 *
4248 * @see #putExtras
4249 * @see #removeExtra
4250 * @see #getParcelableArrayExtra(String)
4251 */
4252 public Intent putExtra(String name, Parcelable[] value) {
4253 if (mExtras == null) {
4254 mExtras = new Bundle();
4255 }
4256 mExtras.putParcelableArray(name, value);
4257 return this;
4258 }
4259
4260 /**
4261 * Add extended data to the intent. The name must include a package
4262 * prefix, for example the app com.android.contacts would use names
4263 * like "com.android.contacts.ShowAll".
4264 *
4265 * @param name The name of the extra data, with package prefix.
4266 * @param value The ArrayList<Parcelable> data value.
4267 *
4268 * @return Returns the same Intent object, for chaining multiple calls
4269 * into a single statement.
4270 *
4271 * @see #putExtras
4272 * @see #removeExtra
4273 * @see #getParcelableArrayListExtra(String)
4274 */
4275 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4276 if (mExtras == null) {
4277 mExtras = new Bundle();
4278 }
4279 mExtras.putParcelableArrayList(name, value);
4280 return this;
4281 }
4282
4283 /**
4284 * Add extended data to the intent. The name must include a package
4285 * prefix, for example the app com.android.contacts would use names
4286 * like "com.android.contacts.ShowAll".
4287 *
4288 * @param name The name of the extra data, with package prefix.
4289 * @param value The ArrayList<Integer> data value.
4290 *
4291 * @return Returns the same Intent object, for chaining multiple calls
4292 * into a single statement.
4293 *
4294 * @see #putExtras
4295 * @see #removeExtra
4296 * @see #getIntegerArrayListExtra(String)
4297 */
4298 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4299 if (mExtras == null) {
4300 mExtras = new Bundle();
4301 }
4302 mExtras.putIntegerArrayList(name, value);
4303 return this;
4304 }
4305
4306 /**
4307 * Add extended data to the intent. The name must include a package
4308 * prefix, for example the app com.android.contacts would use names
4309 * like "com.android.contacts.ShowAll".
4310 *
4311 * @param name The name of the extra data, with package prefix.
4312 * @param value The ArrayList<String> data value.
4313 *
4314 * @return Returns the same Intent object, for chaining multiple calls
4315 * into a single statement.
4316 *
4317 * @see #putExtras
4318 * @see #removeExtra
4319 * @see #getStringArrayListExtra(String)
4320 */
4321 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4322 if (mExtras == null) {
4323 mExtras = new Bundle();
4324 }
4325 mExtras.putStringArrayList(name, value);
4326 return this;
4327 }
4328
4329 /**
4330 * Add extended data to the intent. The name must include a package
4331 * prefix, for example the app com.android.contacts would use names
4332 * like "com.android.contacts.ShowAll".
4333 *
4334 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004335 * @param value The ArrayList<CharSequence> data value.
4336 *
4337 * @return Returns the same Intent object, for chaining multiple calls
4338 * into a single statement.
4339 *
4340 * @see #putExtras
4341 * @see #removeExtra
4342 * @see #getCharSequenceArrayListExtra(String)
4343 */
4344 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4345 if (mExtras == null) {
4346 mExtras = new Bundle();
4347 }
4348 mExtras.putCharSequenceArrayList(name, value);
4349 return this;
4350 }
4351
4352 /**
4353 * Add extended data to the intent. The name must include a package
4354 * prefix, for example the app com.android.contacts would use names
4355 * like "com.android.contacts.ShowAll".
4356 *
4357 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004358 * @param value The Serializable data value.
4359 *
4360 * @return Returns the same Intent object, for chaining multiple calls
4361 * into a single statement.
4362 *
4363 * @see #putExtras
4364 * @see #removeExtra
4365 * @see #getSerializableExtra(String)
4366 */
4367 public Intent putExtra(String name, Serializable value) {
4368 if (mExtras == null) {
4369 mExtras = new Bundle();
4370 }
4371 mExtras.putSerializable(name, value);
4372 return this;
4373 }
4374
4375 /**
4376 * Add extended data to the intent. The name must include a package
4377 * prefix, for example the app com.android.contacts would use names
4378 * like "com.android.contacts.ShowAll".
4379 *
4380 * @param name The name of the extra data, with package prefix.
4381 * @param value The boolean array data value.
4382 *
4383 * @return Returns the same Intent object, for chaining multiple calls
4384 * into a single statement.
4385 *
4386 * @see #putExtras
4387 * @see #removeExtra
4388 * @see #getBooleanArrayExtra(String)
4389 */
4390 public Intent putExtra(String name, boolean[] value) {
4391 if (mExtras == null) {
4392 mExtras = new Bundle();
4393 }
4394 mExtras.putBooleanArray(name, value);
4395 return this;
4396 }
4397
4398 /**
4399 * Add extended data to the intent. The name must include a package
4400 * prefix, for example the app com.android.contacts would use names
4401 * like "com.android.contacts.ShowAll".
4402 *
4403 * @param name The name of the extra data, with package prefix.
4404 * @param value The byte array data value.
4405 *
4406 * @return Returns the same Intent object, for chaining multiple calls
4407 * into a single statement.
4408 *
4409 * @see #putExtras
4410 * @see #removeExtra
4411 * @see #getByteArrayExtra(String)
4412 */
4413 public Intent putExtra(String name, byte[] value) {
4414 if (mExtras == null) {
4415 mExtras = new Bundle();
4416 }
4417 mExtras.putByteArray(name, value);
4418 return this;
4419 }
4420
4421 /**
4422 * Add extended data to the intent. The name must include a package
4423 * prefix, for example the app com.android.contacts would use names
4424 * like "com.android.contacts.ShowAll".
4425 *
4426 * @param name The name of the extra data, with package prefix.
4427 * @param value The short array data value.
4428 *
4429 * @return Returns the same Intent object, for chaining multiple calls
4430 * into a single statement.
4431 *
4432 * @see #putExtras
4433 * @see #removeExtra
4434 * @see #getShortArrayExtra(String)
4435 */
4436 public Intent putExtra(String name, short[] value) {
4437 if (mExtras == null) {
4438 mExtras = new Bundle();
4439 }
4440 mExtras.putShortArray(name, value);
4441 return this;
4442 }
4443
4444 /**
4445 * Add extended data to the intent. The name must include a package
4446 * prefix, for example the app com.android.contacts would use names
4447 * like "com.android.contacts.ShowAll".
4448 *
4449 * @param name The name of the extra data, with package prefix.
4450 * @param value The char array data value.
4451 *
4452 * @return Returns the same Intent object, for chaining multiple calls
4453 * into a single statement.
4454 *
4455 * @see #putExtras
4456 * @see #removeExtra
4457 * @see #getCharArrayExtra(String)
4458 */
4459 public Intent putExtra(String name, char[] value) {
4460 if (mExtras == null) {
4461 mExtras = new Bundle();
4462 }
4463 mExtras.putCharArray(name, value);
4464 return this;
4465 }
4466
4467 /**
4468 * Add extended data to the intent. The name must include a package
4469 * prefix, for example the app com.android.contacts would use names
4470 * like "com.android.contacts.ShowAll".
4471 *
4472 * @param name The name of the extra data, with package prefix.
4473 * @param value The int array data value.
4474 *
4475 * @return Returns the same Intent object, for chaining multiple calls
4476 * into a single statement.
4477 *
4478 * @see #putExtras
4479 * @see #removeExtra
4480 * @see #getIntArrayExtra(String)
4481 */
4482 public Intent putExtra(String name, int[] value) {
4483 if (mExtras == null) {
4484 mExtras = new Bundle();
4485 }
4486 mExtras.putIntArray(name, value);
4487 return this;
4488 }
4489
4490 /**
4491 * Add extended data to the intent. The name must include a package
4492 * prefix, for example the app com.android.contacts would use names
4493 * like "com.android.contacts.ShowAll".
4494 *
4495 * @param name The name of the extra data, with package prefix.
4496 * @param value The byte array data value.
4497 *
4498 * @return Returns the same Intent object, for chaining multiple calls
4499 * into a single statement.
4500 *
4501 * @see #putExtras
4502 * @see #removeExtra
4503 * @see #getLongArrayExtra(String)
4504 */
4505 public Intent putExtra(String name, long[] value) {
4506 if (mExtras == null) {
4507 mExtras = new Bundle();
4508 }
4509 mExtras.putLongArray(name, value);
4510 return this;
4511 }
4512
4513 /**
4514 * Add extended data to the intent. The name must include a package
4515 * prefix, for example the app com.android.contacts would use names
4516 * like "com.android.contacts.ShowAll".
4517 *
4518 * @param name The name of the extra data, with package prefix.
4519 * @param value The float array data value.
4520 *
4521 * @return Returns the same Intent object, for chaining multiple calls
4522 * into a single statement.
4523 *
4524 * @see #putExtras
4525 * @see #removeExtra
4526 * @see #getFloatArrayExtra(String)
4527 */
4528 public Intent putExtra(String name, float[] value) {
4529 if (mExtras == null) {
4530 mExtras = new Bundle();
4531 }
4532 mExtras.putFloatArray(name, value);
4533 return this;
4534 }
4535
4536 /**
4537 * Add extended data to the intent. The name must include a package
4538 * prefix, for example the app com.android.contacts would use names
4539 * like "com.android.contacts.ShowAll".
4540 *
4541 * @param name The name of the extra data, with package prefix.
4542 * @param value The double array data value.
4543 *
4544 * @return Returns the same Intent object, for chaining multiple calls
4545 * into a single statement.
4546 *
4547 * @see #putExtras
4548 * @see #removeExtra
4549 * @see #getDoubleArrayExtra(String)
4550 */
4551 public Intent putExtra(String name, double[] value) {
4552 if (mExtras == null) {
4553 mExtras = new Bundle();
4554 }
4555 mExtras.putDoubleArray(name, value);
4556 return this;
4557 }
4558
4559 /**
4560 * Add extended data to the intent. The name must include a package
4561 * prefix, for example the app com.android.contacts would use names
4562 * like "com.android.contacts.ShowAll".
4563 *
4564 * @param name The name of the extra data, with package prefix.
4565 * @param value The String array data value.
4566 *
4567 * @return Returns the same Intent object, for chaining multiple calls
4568 * into a single statement.
4569 *
4570 * @see #putExtras
4571 * @see #removeExtra
4572 * @see #getStringArrayExtra(String)
4573 */
4574 public Intent putExtra(String name, String[] value) {
4575 if (mExtras == null) {
4576 mExtras = new Bundle();
4577 }
4578 mExtras.putStringArray(name, value);
4579 return this;
4580 }
4581
4582 /**
4583 * Add extended data to the intent. The name must include a package
4584 * prefix, for example the app com.android.contacts would use names
4585 * like "com.android.contacts.ShowAll".
4586 *
4587 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004588 * @param value The CharSequence array data value.
4589 *
4590 * @return Returns the same Intent object, for chaining multiple calls
4591 * into a single statement.
4592 *
4593 * @see #putExtras
4594 * @see #removeExtra
4595 * @see #getCharSequenceArrayExtra(String)
4596 */
4597 public Intent putExtra(String name, CharSequence[] value) {
4598 if (mExtras == null) {
4599 mExtras = new Bundle();
4600 }
4601 mExtras.putCharSequenceArray(name, value);
4602 return this;
4603 }
4604
4605 /**
4606 * Add extended data to the intent. The name must include a package
4607 * prefix, for example the app com.android.contacts would use names
4608 * like "com.android.contacts.ShowAll".
4609 *
4610 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004611 * @param value The Bundle data value.
4612 *
4613 * @return Returns the same Intent object, for chaining multiple calls
4614 * into a single statement.
4615 *
4616 * @see #putExtras
4617 * @see #removeExtra
4618 * @see #getBundleExtra(String)
4619 */
4620 public Intent putExtra(String name, Bundle value) {
4621 if (mExtras == null) {
4622 mExtras = new Bundle();
4623 }
4624 mExtras.putBundle(name, value);
4625 return this;
4626 }
4627
4628 /**
4629 * Add extended data to the intent. The name must include a package
4630 * prefix, for example the app com.android.contacts would use names
4631 * like "com.android.contacts.ShowAll".
4632 *
4633 * @param name The name of the extra data, with package prefix.
4634 * @param value The IBinder data value.
4635 *
4636 * @return Returns the same Intent object, for chaining multiple calls
4637 * into a single statement.
4638 *
4639 * @see #putExtras
4640 * @see #removeExtra
4641 * @see #getIBinderExtra(String)
4642 *
4643 * @deprecated
4644 * @hide
4645 */
4646 @Deprecated
4647 public Intent putExtra(String name, IBinder value) {
4648 if (mExtras == null) {
4649 mExtras = new Bundle();
4650 }
4651 mExtras.putIBinder(name, value);
4652 return this;
4653 }
4654
4655 /**
4656 * Copy all extras in 'src' in to this intent.
4657 *
4658 * @param src Contains the extras to copy.
4659 *
4660 * @see #putExtra
4661 */
4662 public Intent putExtras(Intent src) {
4663 if (src.mExtras != null) {
4664 if (mExtras == null) {
4665 mExtras = new Bundle(src.mExtras);
4666 } else {
4667 mExtras.putAll(src.mExtras);
4668 }
4669 }
4670 return this;
4671 }
4672
4673 /**
4674 * Add a set of extended data to the intent. The keys must include a package
4675 * prefix, for example the app com.android.contacts would use names
4676 * like "com.android.contacts.ShowAll".
4677 *
4678 * @param extras The Bundle of extras to add to this intent.
4679 *
4680 * @see #putExtra
4681 * @see #removeExtra
4682 */
4683 public Intent putExtras(Bundle extras) {
4684 if (mExtras == null) {
4685 mExtras = new Bundle();
4686 }
4687 mExtras.putAll(extras);
4688 return this;
4689 }
4690
4691 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004692 * Completely replace the extras in the Intent with the extras in the
4693 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07004694 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004695 * @param src The exact extras contained in this Intent are copied
4696 * into the target intent, replacing any that were previously there.
4697 */
4698 public Intent replaceExtras(Intent src) {
4699 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
4700 return this;
4701 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004702
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004703 /**
4704 * Completely replace the extras in the Intent with the given Bundle of
4705 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07004706 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004707 * @param extras The new set of extras in the Intent, or null to erase
4708 * all extras.
4709 */
4710 public Intent replaceExtras(Bundle extras) {
4711 mExtras = extras != null ? new Bundle(extras) : null;
4712 return this;
4713 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004714
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004715 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004716 * Remove extended data from the intent.
4717 *
4718 * @see #putExtra
4719 */
4720 public void removeExtra(String name) {
4721 if (mExtras != null) {
4722 mExtras.remove(name);
4723 if (mExtras.size() == 0) {
4724 mExtras = null;
4725 }
4726 }
4727 }
4728
4729 /**
4730 * Set special flags controlling how this intent is handled. Most values
4731 * here depend on the type of component being executed by the Intent,
4732 * specifically the FLAG_ACTIVITY_* flags are all for use with
4733 * {@link Context#startActivity Context.startActivity()} and the
4734 * FLAG_RECEIVER_* flags are all for use with
4735 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
4736 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004737 * <p>See the <a href="{@docRoot}guide/topics/fundamentals.html#acttask">Application Fundamentals:
4738 * 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 -07004739 * the behavior of your application.
4740 *
4741 * @param flags The desired flags.
4742 *
4743 * @return Returns the same Intent object, for chaining multiple calls
4744 * into a single statement.
4745 *
4746 * @see #getFlags
4747 * @see #addFlags
4748 *
4749 * @see #FLAG_GRANT_READ_URI_PERMISSION
4750 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
4751 * @see #FLAG_DEBUG_LOG_RESOLUTION
4752 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004753 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004754 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004755 * @see #FLAG_ACTIVITY_CLEAR_TOP
4756 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
4757 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004758 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004759 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4760 * @see #FLAG_ACTIVITY_NEW_TASK
4761 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004762 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004763 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
4764 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765 * @see #FLAG_ACTIVITY_SINGLE_TOP
4766 * @see #FLAG_RECEIVER_REGISTERED_ONLY
4767 */
4768 public Intent setFlags(int flags) {
4769 mFlags = flags;
4770 return this;
4771 }
4772
4773 /**
4774 * Add additional flags to the intent (or with existing flags
4775 * value).
4776 *
4777 * @param flags The new flags to set.
4778 *
4779 * @return Returns the same Intent object, for chaining multiple calls
4780 * into a single statement.
4781 *
4782 * @see #setFlags
4783 */
4784 public Intent addFlags(int flags) {
4785 mFlags |= flags;
4786 return this;
4787 }
4788
4789 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004790 * (Usually optional) Set an explicit application package name that limits
4791 * the components this Intent will resolve to. If left to the default
4792 * value of null, all components in all applications will considered.
4793 * If non-null, the Intent can only match the components in the given
4794 * application package.
4795 *
4796 * @param packageName The name of the application package to handle the
4797 * intent, or null to allow any application package.
4798 *
4799 * @return Returns the same Intent object, for chaining multiple calls
4800 * into a single statement.
4801 *
4802 * @see #getPackage
4803 * @see #resolveActivity
4804 */
4805 public Intent setPackage(String packageName) {
4806 mPackage = packageName;
4807 return this;
4808 }
4809
4810 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004811 * (Usually optional) Explicitly set the component to handle the intent.
4812 * If left with the default value of null, the system will determine the
4813 * appropriate class to use based on the other fields (action, data,
4814 * type, categories) in the Intent. If this class is defined, the
4815 * specified class will always be used regardless of the other fields. You
4816 * should only set this value when you know you absolutely want a specific
4817 * class to be used; otherwise it is better to let the system find the
4818 * appropriate class so that you will respect the installed applications
4819 * and user preferences.
4820 *
4821 * @param component The name of the application component to handle the
4822 * intent, or null to let the system find one for you.
4823 *
4824 * @return Returns the same Intent object, for chaining multiple calls
4825 * into a single statement.
4826 *
4827 * @see #setClass
4828 * @see #setClassName(Context, String)
4829 * @see #setClassName(String, String)
4830 * @see #getComponent
4831 * @see #resolveActivity
4832 */
4833 public Intent setComponent(ComponentName component) {
4834 mComponent = component;
4835 return this;
4836 }
4837
4838 /**
4839 * Convenience for calling {@link #setComponent} with an
4840 * explicit class name.
4841 *
4842 * @param packageContext A Context of the application package implementing
4843 * this class.
4844 * @param className The name of a class inside of the application package
4845 * that will be used as the component for this Intent.
4846 *
4847 * @return Returns the same Intent object, for chaining multiple calls
4848 * into a single statement.
4849 *
4850 * @see #setComponent
4851 * @see #setClass
4852 */
4853 public Intent setClassName(Context packageContext, String className) {
4854 mComponent = new ComponentName(packageContext, className);
4855 return this;
4856 }
4857
4858 /**
4859 * Convenience for calling {@link #setComponent} with an
4860 * explicit application package name and class name.
4861 *
4862 * @param packageName The name of the package implementing the desired
4863 * component.
4864 * @param className The name of a class inside of the application package
4865 * that will be used as the component for this Intent.
4866 *
4867 * @return Returns the same Intent object, for chaining multiple calls
4868 * into a single statement.
4869 *
4870 * @see #setComponent
4871 * @see #setClass
4872 */
4873 public Intent setClassName(String packageName, String className) {
4874 mComponent = new ComponentName(packageName, className);
4875 return this;
4876 }
4877
4878 /**
4879 * Convenience for calling {@link #setComponent(ComponentName)} with the
4880 * name returned by a {@link Class} object.
4881 *
4882 * @param packageContext A Context of the application package implementing
4883 * this class.
4884 * @param cls The class name to set, equivalent to
4885 * <code>setClassName(context, cls.getName())</code>.
4886 *
4887 * @return Returns the same Intent object, for chaining multiple calls
4888 * into a single statement.
4889 *
4890 * @see #setComponent
4891 */
4892 public Intent setClass(Context packageContext, Class<?> cls) {
4893 mComponent = new ComponentName(packageContext, cls);
4894 return this;
4895 }
4896
4897 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004898 * Set the bounds of the sender of this intent, in screen coordinates. This can be
4899 * used as a hint to the receiver for animations and the like. Null means that there
4900 * is no source bounds.
4901 */
4902 public void setSourceBounds(Rect r) {
4903 if (r != null) {
4904 mSourceBounds = new Rect(r);
4905 } else {
4906 r = null;
4907 }
4908 }
4909
4910 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004911 * Use with {@link #fillIn} to allow the current action value to be
4912 * overwritten, even if it is already set.
4913 */
4914 public static final int FILL_IN_ACTION = 1<<0;
4915
4916 /**
4917 * Use with {@link #fillIn} to allow the current data or type value
4918 * overwritten, even if it is already set.
4919 */
4920 public static final int FILL_IN_DATA = 1<<1;
4921
4922 /**
4923 * Use with {@link #fillIn} to allow the current categories to be
4924 * overwritten, even if they are already set.
4925 */
4926 public static final int FILL_IN_CATEGORIES = 1<<2;
4927
4928 /**
4929 * Use with {@link #fillIn} to allow the current component value to be
4930 * overwritten, even if it is already set.
4931 */
4932 public static final int FILL_IN_COMPONENT = 1<<3;
4933
4934 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004935 * Use with {@link #fillIn} to allow the current package value to be
4936 * overwritten, even if it is already set.
4937 */
4938 public static final int FILL_IN_PACKAGE = 1<<4;
4939
4940 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004941 * Use with {@link #fillIn} to allow the current package value to be
4942 * overwritten, even if it is already set.
4943 */
4944 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
4945
4946 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004947 * Copy the contents of <var>other</var> in to this object, but only
4948 * where fields are not defined by this object. For purposes of a field
4949 * being defined, the following pieces of data in the Intent are
4950 * considered to be separate fields:
4951 *
4952 * <ul>
4953 * <li> action, as set by {@link #setAction}.
4954 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
4955 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
4956 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004957 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004958 * <li> component, as set by {@link #setComponent(ComponentName)} or
4959 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004960 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004961 * <li> each top-level name in the associated extras.
4962 * </ul>
4963 *
4964 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004965 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4966 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004967 * corresponding field will not be replaced if it is already set.
4968 *
Brett Chabot3e391752009-07-21 16:07:23 -07004969 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
4970 * specified.
4971 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004972 * <p>For example, consider Intent A with {data="foo", categories="bar"}
4973 * and Intent B with {action="gotit", data-type="some/thing",
4974 * categories="one","two"}.
4975 *
4976 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
4977 * containing: {action="gotit", data-type="some/thing",
4978 * categories="bar"}.
4979 *
4980 * @param other Another Intent whose values are to be used to fill in
4981 * the current one.
4982 * @param flags Options to control which fields can be filled in.
4983 *
4984 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004985 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
4986 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004987 */
4988 public int fillIn(Intent other, int flags) {
4989 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004990 if (other.mAction != null
4991 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004992 mAction = other.mAction;
4993 changes |= FILL_IN_ACTION;
4994 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004995 if ((other.mData != null || other.mType != null)
4996 && ((mData == null && mType == null)
4997 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004998 mData = other.mData;
4999 mType = other.mType;
5000 changes |= FILL_IN_DATA;
5001 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005002 if (other.mCategories != null
5003 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005004 if (other.mCategories != null) {
5005 mCategories = new HashSet<String>(other.mCategories);
5006 }
5007 changes |= FILL_IN_CATEGORIES;
5008 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005009 if (other.mPackage != null
5010 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5011 mPackage = other.mPackage;
5012 changes |= FILL_IN_PACKAGE;
5013 }
5014 // Component is special: it can -only- be set if explicitly allowed,
5015 // since otherwise the sender could force the intent somewhere the
5016 // originator didn't intend.
5017 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005018 mComponent = other.mComponent;
5019 changes |= FILL_IN_COMPONENT;
5020 }
5021 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005022 if (other.mSourceBounds != null
5023 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5024 mSourceBounds = new Rect(other.mSourceBounds);
5025 changes |= FILL_IN_SOURCE_BOUNDS;
5026 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005027 if (mExtras == null) {
5028 if (other.mExtras != null) {
5029 mExtras = new Bundle(other.mExtras);
5030 }
5031 } else if (other.mExtras != null) {
5032 try {
5033 Bundle newb = new Bundle(other.mExtras);
5034 newb.putAll(mExtras);
5035 mExtras = newb;
5036 } catch (RuntimeException e) {
5037 // Modifying the extras can cause us to unparcel the contents
5038 // of the bundle, and if we do this in the system process that
5039 // may fail. We really should handle this (i.e., the Bundle
5040 // impl shouldn't be on top of a plain map), but for now just
5041 // ignore it and keep the original contents. :(
5042 Log.w("Intent", "Failure filling in extras", e);
5043 }
5044 }
5045 return changes;
5046 }
5047
5048 /**
5049 * Wrapper class holding an Intent and implementing comparisons on it for
5050 * the purpose of filtering. The class implements its
5051 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5052 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5053 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5054 * on the wrapped Intent.
5055 */
5056 public static final class FilterComparison {
5057 private final Intent mIntent;
5058 private final int mHashCode;
5059
5060 public FilterComparison(Intent intent) {
5061 mIntent = intent;
5062 mHashCode = intent.filterHashCode();
5063 }
5064
5065 /**
5066 * Return the Intent that this FilterComparison represents.
5067 * @return Returns the Intent held by the FilterComparison. Do
5068 * not modify!
5069 */
5070 public Intent getIntent() {
5071 return mIntent;
5072 }
5073
5074 @Override
5075 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005076 if (obj instanceof FilterComparison) {
5077 Intent other = ((FilterComparison)obj).mIntent;
5078 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005079 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005080 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005081 }
5082
5083 @Override
5084 public int hashCode() {
5085 return mHashCode;
5086 }
5087 }
5088
5089 /**
5090 * Determine if two intents are the same for the purposes of intent
5091 * resolution (filtering). That is, if their action, data, type,
5092 * class, and categories are the same. This does <em>not</em> compare
5093 * any extra data included in the intents.
5094 *
5095 * @param other The other Intent to compare against.
5096 *
5097 * @return Returns true if action, data, type, class, and categories
5098 * are the same.
5099 */
5100 public boolean filterEquals(Intent other) {
5101 if (other == null) {
5102 return false;
5103 }
5104 if (mAction != other.mAction) {
5105 if (mAction != null) {
5106 if (!mAction.equals(other.mAction)) {
5107 return false;
5108 }
5109 } else {
5110 if (!other.mAction.equals(mAction)) {
5111 return false;
5112 }
5113 }
5114 }
5115 if (mData != other.mData) {
5116 if (mData != null) {
5117 if (!mData.equals(other.mData)) {
5118 return false;
5119 }
5120 } else {
5121 if (!other.mData.equals(mData)) {
5122 return false;
5123 }
5124 }
5125 }
5126 if (mType != other.mType) {
5127 if (mType != null) {
5128 if (!mType.equals(other.mType)) {
5129 return false;
5130 }
5131 } else {
5132 if (!other.mType.equals(mType)) {
5133 return false;
5134 }
5135 }
5136 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005137 if (mPackage != other.mPackage) {
5138 if (mPackage != null) {
5139 if (!mPackage.equals(other.mPackage)) {
5140 return false;
5141 }
5142 } else {
5143 if (!other.mPackage.equals(mPackage)) {
5144 return false;
5145 }
5146 }
5147 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005148 if (mComponent != other.mComponent) {
5149 if (mComponent != null) {
5150 if (!mComponent.equals(other.mComponent)) {
5151 return false;
5152 }
5153 } else {
5154 if (!other.mComponent.equals(mComponent)) {
5155 return false;
5156 }
5157 }
5158 }
5159 if (mCategories != other.mCategories) {
5160 if (mCategories != null) {
5161 if (!mCategories.equals(other.mCategories)) {
5162 return false;
5163 }
5164 } else {
5165 if (!other.mCategories.equals(mCategories)) {
5166 return false;
5167 }
5168 }
5169 }
5170
5171 return true;
5172 }
5173
5174 /**
5175 * Generate hash code that matches semantics of filterEquals().
5176 *
5177 * @return Returns the hash value of the action, data, type, class, and
5178 * categories.
5179 *
5180 * @see #filterEquals
5181 */
5182 public int filterHashCode() {
5183 int code = 0;
5184 if (mAction != null) {
5185 code += mAction.hashCode();
5186 }
5187 if (mData != null) {
5188 code += mData.hashCode();
5189 }
5190 if (mType != null) {
5191 code += mType.hashCode();
5192 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005193 if (mPackage != null) {
5194 code += mPackage.hashCode();
5195 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005196 if (mComponent != null) {
5197 code += mComponent.hashCode();
5198 }
5199 if (mCategories != null) {
5200 code += mCategories.hashCode();
5201 }
5202 return code;
5203 }
5204
5205 @Override
5206 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005207 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005208
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005209 b.append("Intent { ");
5210 toShortString(b, true, true);
5211 b.append(" }");
5212
5213 return b.toString();
5214 }
5215
5216 /** @hide */
5217 public String toShortString(boolean comp, boolean extras) {
5218 StringBuilder b = new StringBuilder(128);
5219 toShortString(b, comp, extras);
5220 return b.toString();
5221 }
Romain Guy4969af72009-06-17 10:53:19 -07005222
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005223 /** @hide */
5224 public void toShortString(StringBuilder b, boolean comp, boolean extras) {
5225 boolean first = true;
5226 if (mAction != null) {
5227 b.append("act=").append(mAction);
5228 first = false;
5229 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005230 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005231 if (!first) {
5232 b.append(' ');
5233 }
5234 first = false;
5235 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005236 Iterator<String> i = mCategories.iterator();
5237 boolean didone = false;
5238 while (i.hasNext()) {
5239 if (didone) b.append(",");
5240 didone = true;
5241 b.append(i.next());
5242 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005243 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005244 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005245 if (mData != null) {
5246 if (!first) {
5247 b.append(' ');
5248 }
5249 first = false;
5250 b.append("dat=").append(mData);
5251 }
5252 if (mType != null) {
5253 if (!first) {
5254 b.append(' ');
5255 }
5256 first = false;
5257 b.append("typ=").append(mType);
5258 }
5259 if (mFlags != 0) {
5260 if (!first) {
5261 b.append(' ');
5262 }
5263 first = false;
5264 b.append("flg=0x").append(Integer.toHexString(mFlags));
5265 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005266 if (mPackage != null) {
5267 if (!first) {
5268 b.append(' ');
5269 }
5270 first = false;
5271 b.append("pkg=").append(mPackage);
5272 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005273 if (comp && mComponent != null) {
5274 if (!first) {
5275 b.append(' ');
5276 }
5277 first = false;
5278 b.append("cmp=").append(mComponent.flattenToShortString());
5279 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005280 if (mSourceBounds != null) {
5281 if (!first) {
5282 b.append(' ');
5283 }
5284 first = false;
5285 b.append("bnds=").append(mSourceBounds.toShortString());
5286 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005287 if (extras && mExtras != null) {
5288 if (!first) {
5289 b.append(' ');
5290 }
5291 first = false;
5292 b.append("(has extras)");
5293 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005294 }
5295
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005296 /**
5297 * Call {@link #toUri} with 0 flags.
5298 * @deprecated Use {@link #toUri} instead.
5299 */
5300 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005301 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005302 return toUri(0);
5303 }
5304
5305 /**
5306 * Convert this Intent into a String holding a URI representation of it.
5307 * The returned URI string has been properly URI encoded, so it can be
5308 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5309 * Intent's data as the base URI, with an additional fragment describing
5310 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005311 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005312 * <p>You can convert the returned string back to an Intent with
5313 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005314 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005315 * @param flags Additional operating flags. Either 0 or
5316 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005317 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005318 * @return Returns a URI encoding URI string describing the entire contents
5319 * of the Intent.
5320 */
5321 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005322 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005323 String scheme = null;
5324 if (mData != null) {
5325 String data = mData.toString();
5326 if ((flags&URI_INTENT_SCHEME) != 0) {
5327 final int N = data.length();
5328 for (int i=0; i<N; i++) {
5329 char c = data.charAt(i);
5330 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5331 || c == '.' || c == '-') {
5332 continue;
5333 }
5334 if (c == ':' && i > 0) {
5335 // Valid scheme.
5336 scheme = data.substring(0, i);
5337 uri.append("intent:");
5338 data = data.substring(i+1);
5339 break;
5340 }
Tom Taylord4a47292009-12-21 13:59:18 -08005341
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005342 // No scheme.
5343 break;
5344 }
5345 }
5346 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005347
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005348 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5349 uri.append("intent:");
5350 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005351
5352 uri.append("#Intent;");
5353
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005354 if (scheme != null) {
5355 uri.append("scheme=").append(scheme).append(';');
5356 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005357 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005358 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359 }
5360 if (mCategories != null) {
5361 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005362 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005363 }
5364 }
5365 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005366 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367 }
5368 if (mFlags != 0) {
5369 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5370 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005371 if (mPackage != null) {
5372 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5373 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005374 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005375 uri.append("component=").append(Uri.encode(
5376 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005377 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005378 if (mSourceBounds != null) {
5379 uri.append("sourceBounds=")
5380 .append(Uri.encode(mSourceBounds.flattenToString()))
5381 .append(';');
5382 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005383 if (mExtras != null) {
5384 for (String key : mExtras.keySet()) {
5385 final Object value = mExtras.get(key);
5386 char entryType =
5387 value instanceof String ? 'S' :
5388 value instanceof Boolean ? 'B' :
5389 value instanceof Byte ? 'b' :
5390 value instanceof Character ? 'c' :
5391 value instanceof Double ? 'd' :
5392 value instanceof Float ? 'f' :
5393 value instanceof Integer ? 'i' :
5394 value instanceof Long ? 'l' :
5395 value instanceof Short ? 's' :
5396 '\0';
5397
5398 if (entryType != '\0') {
5399 uri.append(entryType);
5400 uri.append('.');
5401 uri.append(Uri.encode(key));
5402 uri.append('=');
5403 uri.append(Uri.encode(value.toString()));
5404 uri.append(';');
5405 }
5406 }
5407 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005408
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005409 uri.append("end");
5410
5411 return uri.toString();
5412 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005414 public int describeContents() {
5415 return (mExtras != null) ? mExtras.describeContents() : 0;
5416 }
5417
5418 public void writeToParcel(Parcel out, int flags) {
5419 out.writeString(mAction);
5420 Uri.writeToParcel(out, mData);
5421 out.writeString(mType);
5422 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005423 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005424 ComponentName.writeToParcel(mComponent, out);
5425
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005426 if (mSourceBounds != null) {
5427 out.writeInt(1);
5428 mSourceBounds.writeToParcel(out, flags);
5429 } else {
5430 out.writeInt(0);
5431 }
5432
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005433 if (mCategories != null) {
5434 out.writeInt(mCategories.size());
5435 for (String category : mCategories) {
5436 out.writeString(category);
5437 }
5438 } else {
5439 out.writeInt(0);
5440 }
5441
5442 out.writeBundle(mExtras);
5443 }
5444
5445 public static final Parcelable.Creator<Intent> CREATOR
5446 = new Parcelable.Creator<Intent>() {
5447 public Intent createFromParcel(Parcel in) {
5448 return new Intent(in);
5449 }
5450 public Intent[] newArray(int size) {
5451 return new Intent[size];
5452 }
5453 };
5454
Dianne Hackborneb034652009-09-07 00:49:58 -07005455 /** @hide */
5456 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005457 readFromParcel(in);
5458 }
5459
5460 public void readFromParcel(Parcel in) {
5461 mAction = in.readString();
5462 mData = Uri.CREATOR.createFromParcel(in);
5463 mType = in.readString();
5464 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005465 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 mComponent = ComponentName.readFromParcel(in);
5467
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005468 if (in.readInt() != 0) {
5469 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5470 }
5471
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005472 int N = in.readInt();
5473 if (N > 0) {
5474 mCategories = new HashSet<String>();
5475 int i;
5476 for (i=0; i<N; i++) {
5477 mCategories.add(in.readString());
5478 }
5479 } else {
5480 mCategories = null;
5481 }
5482
5483 mExtras = in.readBundle();
5484 }
5485
5486 /**
5487 * Parses the "intent" element (and its children) from XML and instantiates
5488 * an Intent object. The given XML parser should be located at the tag
5489 * where parsing should start (often named "intent"), from which the
5490 * basic action, data, type, and package and class name will be
5491 * retrieved. The function will then parse in to any child elements,
5492 * looking for <category android:name="xxx"> tags to add categories and
5493 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5494 * to the intent.
5495 *
5496 * @param resources The Resources to use when inflating resources.
5497 * @param parser The XML parser pointing at an "intent" tag.
5498 * @param attrs The AttributeSet interface for retrieving extended
5499 * attribute data at the current <var>parser</var> location.
5500 * @return An Intent object matching the XML data.
5501 * @throws XmlPullParserException If there was an XML parsing error.
5502 * @throws IOException If there was an I/O error.
5503 */
5504 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5505 throws XmlPullParserException, IOException {
5506 Intent intent = new Intent();
5507
5508 TypedArray sa = resources.obtainAttributes(attrs,
5509 com.android.internal.R.styleable.Intent);
5510
5511 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5512
5513 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5514 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5515 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5516
5517 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5518 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5519 if (packageName != null && className != null) {
5520 intent.setComponent(new ComponentName(packageName, className));
5521 }
5522
5523 sa.recycle();
5524
5525 int outerDepth = parser.getDepth();
5526 int type;
5527 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5528 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5529 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5530 continue;
5531 }
5532
5533 String nodeName = parser.getName();
5534 if (nodeName.equals("category")) {
5535 sa = resources.obtainAttributes(attrs,
5536 com.android.internal.R.styleable.IntentCategory);
5537 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5538 sa.recycle();
5539
5540 if (cat != null) {
5541 intent.addCategory(cat);
5542 }
5543 XmlUtils.skipCurrentTag(parser);
5544
5545 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005546 if (intent.mExtras == null) {
5547 intent.mExtras = new Bundle();
5548 }
5549 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5550 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005551
5552 } else {
5553 XmlUtils.skipCurrentTag(parser);
5554 }
5555 }
5556
5557 return intent;
5558 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005559}