blob: f44d038a5fee14de1c295ac4eff402a481c52537 [file] [log] [blame]
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import org.xmlpull.v1.XmlPullParser;
20import org.xmlpull.v1.XmlPullParserException;
21
22import android.annotation.SdkConstant;
23import android.annotation.SdkConstant.SdkConstantType;
24import android.content.pm.ActivityInfo;
25import android.content.pm.PackageManager;
26import android.content.pm.ResolveInfo;
27import android.content.res.Resources;
28import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080029import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.net.Uri;
31import android.os.Bundle;
32import android.os.IBinder;
33import android.os.Parcel;
34import android.os.Parcelable;
35import android.util.AttributeSet;
36import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080037
38import com.android.internal.util.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039
40import java.io.IOException;
41import java.io.Serializable;
42import java.net.URISyntaxException;
43import java.util.ArrayList;
44import java.util.HashSet;
45import java.util.Iterator;
46import java.util.Set;
47
48/**
49 * An intent is an abstract description of an operation to be performed. It
50 * can be used with {@link Context#startActivity(Intent) startActivity} to
51 * launch an {@link android.app.Activity},
52 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
53 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
54 * and {@link android.content.Context#startService} or
55 * {@link android.content.Context#bindService} to communicate with a
56 * background {@link android.app.Service}.
57 *
58 * <p>An Intent provides a facility for performing late runtime binding between
59 * the code in different applications. Its most significant use is in the
60 * launching of activities, where it can be thought of as the glue between
61 * activities. It is
62 * basically a passive data structure holding an abstract description of an
63 * action to be performed. The primary pieces of information in an intent
64 * are:</p>
65 *
66 * <ul>
67 * <li> <p><b>action</b> -- The general action to be performed, such as
68 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
69 * etc.</p>
70 * </li>
71 * <li> <p><b>data</b> -- The data to operate on, such as a person record
72 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
73 * </li>
74 * </ul>
75 *
76 *
77 * <p>Some examples of action/data pairs are:</p>
78 *
79 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070080 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070081 * information about the person whose identifier is "1".</p>
82 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070083 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070084 * the phone dialer with the person filled in.</p>
85 * </li>
86 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
87 * the phone dialer with the given number filled in. Note how the
88 * VIEW action does what what is considered the most reasonable thing for
89 * a particular URI.</p>
90 * </li>
91 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
92 * the phone dialer with the given number filled in.</p>
93 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070094 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 * information about the person whose identifier is "1".</p>
96 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070097 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 * a list of people, which the user can browse through. This example is a
99 * typical top-level entry into the Contacts application, showing you the
100 * list of people. Selecting a particular person to view would result in a
101 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
102 * being used to start an activity to display that person.</p>
103 * </li>
104 * </ul>
105 *
106 * <p>In addition to these primary attributes, there are a number of secondary
107 * attributes that you can also include with an intent:</p>
108 *
109 * <ul>
110 * <li> <p><b>category</b> -- Gives additional information about the action
111 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
112 * appear in the Launcher as a top-level application, while
113 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
114 * of alternative actions the user can perform on a piece of data.</p>
115 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
116 * intent data. Normally the type is inferred from the data itself.
117 * By setting this attribute, you disable that evaluation and force
118 * an explicit type.</p>
119 * <li> <p><b>component</b> -- Specifies an explicit name of a component
120 * class to use for the intent. Normally this is determined by looking
121 * at the other information in the intent (the action, data/type, and
122 * categories) and matching that with a component that can handle it.
123 * If this attribute is set then none of the evaluation is performed,
124 * and this component is used exactly as is. By specifying this attribute,
125 * all of the other Intent attributes become optional.</p>
126 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
127 * This can be used to provide extended information to the component.
128 * For example, if we have a action to send an e-mail message, we could
129 * also include extra pieces of data here to supply a subject, body,
130 * etc.</p>
131 * </ul>
132 *
133 * <p>Here are some examples of other operations you can specify as intents
134 * using these additional parameters:</p>
135 *
136 * <ul>
137 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
138 * Launch the home screen.</p>
139 * </li>
140 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
141 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
142 * vnd.android.cursor.item/phone}</i></b>
143 * -- Display the list of people's phone numbers, allowing the user to
144 * browse through them and pick one and return it to the parent activity.</p>
145 * </li>
146 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
147 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
148 * -- Display all pickers for data that can be opened with
149 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
150 * allowing the user to pick one of them and then some data inside of it
151 * and returning the resulting URI to the caller. This can be used,
152 * for example, in an e-mail application to allow the user to pick some
153 * data to include as an attachment.</p>
154 * </li>
155 * </ul>
156 *
157 * <p>There are a variety of standard Intent action and category constants
158 * defined in the Intent class, but applications can also define their own.
159 * These strings use java style scoping, to ensure they are unique -- for
160 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700161 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700162 *
163 * <p>Put together, the set of actions, data types, categories, and extra data
164 * defines a language for the system allowing for the expression of phrases
165 * such as "call john smith's cell". As applications are added to the system,
166 * they can extend this language by adding new actions, types, and categories, or
167 * they can modify the behavior of existing phrases by supplying their own
168 * activities that handle them.</p>
169 *
170 * <a name="IntentResolution"></a>
171 * <h3>Intent Resolution</h3>
172 *
173 * <p>There are two primary forms of intents you will use.
174 *
175 * <ul>
176 * <li> <p><b>Explicit Intents</b> have specified a component (via
177 * {@link #setComponent} or {@link #setClass}), which provides the exact
178 * class to be run. Often these will not include any other information,
179 * simply being a way for an application to launch various internal
180 * activities it has as the user interacts with the application.
181 *
182 * <li> <p><b>Implicit Intents</b> have not specified a component;
183 * instead, they must include enough information for the system to
184 * determine which of the available components is best to run for that
185 * intent.
186 * </ul>
187 *
188 * <p>When using implicit intents, given such an arbitrary intent we need to
189 * know what to do with it. This is handled by the process of <em>Intent
190 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
191 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
192 * more activities/receivers) that can handle it.</p>
193 *
194 * <p>The intent resolution mechanism basically revolves around matching an
195 * Intent against all of the &lt;intent-filter&gt; descriptions in the
196 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
197 * objects explicitly registered with {@link Context#registerReceiver}.) More
198 * details on this can be found in the documentation on the {@link
199 * IntentFilter} class.</p>
200 *
201 * <p>There are three pieces of information in the Intent that are used for
202 * resolution: the action, type, and category. Using this information, a query
203 * is done on the {@link PackageManager} for a component that can handle the
204 * intent. The appropriate component is determined based on the intent
205 * information supplied in the <code>AndroidManifest.xml</code> file as
206 * follows:</p>
207 *
208 * <ul>
209 * <li> <p>The <b>action</b>, if given, must be listed by the component as
210 * one it handles.</p>
211 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
212 * already supplied in the Intent. Like the action, if a type is
213 * included in the intent (either explicitly or implicitly in its
214 * data), then this must be listed by the component as one it handles.</p>
215 * <li> For data that is not a <code>content:</code> URI and where no explicit
216 * type is included in the Intent, instead the <b>scheme</b> of the
217 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
218 * considered. Again like the action, if we are matching a scheme it
219 * must be listed by the component as one it can handle.
220 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
221 * by the activity as categories it handles. That is, if you include
222 * the categories {@link #CATEGORY_LAUNCHER} and
223 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
224 * with an intent that lists <em>both</em> of those categories.
225 * Activities will very often need to support the
226 * {@link #CATEGORY_DEFAULT} so that they can be found by
227 * {@link Context#startActivity Context.startActivity()}.</p>
228 * </ul>
229 *
230 * <p>For example, consider the Note Pad sample application that
231 * allows user to browse through a list of notes data and view details about
232 * individual items. Text in italics indicate places were you would replace a
233 * name with one specific to your own package.</p>
234 *
235 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
236 * package="<i>com.android.notepad</i>"&gt;
237 * &lt;application android:icon="@drawable/app_notes"
238 * android:label="@string/app_name"&gt;
239 *
240 * &lt;provider class=".NotePadProvider"
241 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
242 *
243 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
244 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700245 * &lt;action android:name="android.intent.action.MAIN" /&gt;
246 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700247 * &lt;/intent-filter&gt;
248 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700249 * &lt;action android:name="android.intent.action.VIEW" /&gt;
250 * &lt;action android:name="android.intent.action.EDIT" /&gt;
251 * &lt;action android:name="android.intent.action.PICK" /&gt;
252 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
253 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700254 * &lt;/intent-filter&gt;
255 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700256 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
257 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
258 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700259 * &lt;/intent-filter&gt;
260 * &lt;/activity&gt;
261 *
262 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
263 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700264 * &lt;action android:name="android.intent.action.VIEW" /&gt;
265 * &lt;action android:name="android.intent.action.EDIT" /&gt;
266 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
267 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700268 * &lt;/intent-filter&gt;
269 *
270 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700271 * &lt;action android:name="android.intent.action.INSERT" /&gt;
272 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
273 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274 * &lt;/intent-filter&gt;
275 *
276 * &lt;/activity&gt;
277 *
278 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
279 * android:theme="@android:style/Theme.Dialog"&gt;
280 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
284 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
285 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;/activity&gt;
288 *
289 * &lt;/application&gt;
290 * &lt;/manifest&gt;</pre>
291 *
292 * <p>The first activity,
293 * <code>com.android.notepad.NotesList</code>, serves as our main
294 * entry into the app. It can do three things as described by its three intent
295 * templates:
296 * <ol>
297 * <li><pre>
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
300 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;</pre>
302 * <p>This provides a top-level entry into the NotePad application: the standard
303 * MAIN action is a main entry point (not requiring any other information in
304 * the Intent), and the LAUNCHER category says that this entry point should be
305 * listed in the application launcher.</p>
306 * <li><pre>
307 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700308 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
309 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
310 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
311 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
312 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700313 * &lt;/intent-filter&gt;</pre>
314 * <p>This declares the things that the activity can do on a directory of
315 * notes. The type being supported is given with the &lt;type&gt; tag, where
316 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
317 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
318 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
319 * The activity allows the user to view or edit the directory of data (via
320 * the VIEW and EDIT actions), or to pick a particular note and return it
321 * to the caller (via the PICK action). Note also the DEFAULT category
322 * supplied here: this is <em>required</em> for the
323 * {@link Context#startActivity Context.startActivity} method to resolve your
324 * activity when its component name is not explicitly specified.</p>
325 * <li><pre>
326 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700327 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
328 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
329 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700330 * &lt;/intent-filter&gt;</pre>
331 * <p>This filter describes the ability return to the caller a note selected by
332 * the user without needing to know where it came from. The data type
333 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
334 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
335 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
336 * The GET_CONTENT action is similar to the PICK action, where the activity
337 * will return to its caller a piece of data selected by the user. Here,
338 * however, the caller specifies the type of data they desire instead of
339 * the type of data the user will be picking from.</p>
340 * </ol>
341 *
342 * <p>Given these capabilities, the following intents will resolve to the
343 * NotesList activity:</p>
344 *
345 * <ul>
346 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
347 * activities that can be used as top-level entry points into an
348 * application.</p>
349 * <li> <p><b>{ action=android.app.action.MAIN,
350 * category=android.app.category.LAUNCHER }</b> is the actual intent
351 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700352 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * data=content://com.google.provider.NotePad/notes }</b>
354 * displays a list of all the notes under
355 * "content://com.google.provider.NotePad/notes", which
356 * the user can browse through and see the details on.</p>
357 * <li> <p><b>{ action=android.app.action.PICK
358 * data=content://com.google.provider.NotePad/notes }</b>
359 * provides a list of the notes under
360 * "content://com.google.provider.NotePad/notes", from which
361 * the user can pick a note whose data URL is returned back to the caller.</p>
362 * <li> <p><b>{ action=android.app.action.GET_CONTENT
363 * type=vnd.android.cursor.item/vnd.google.note }</b>
364 * is similar to the pick action, but allows the caller to specify the
365 * kind of data they want back so that the system can find the appropriate
366 * activity to pick something of that data type.</p>
367 * </ul>
368 *
369 * <p>The second activity,
370 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
371 * note entry and allows them to edit it. It can do two things as described
372 * by its two intent templates:
373 * <ol>
374 * <li><pre>
375 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700376 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
377 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
378 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
379 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700380 * &lt;/intent-filter&gt;</pre>
381 * <p>The first, primary, purpose of this activity is to let the user interact
382 * with a single note, as decribed by the MIME type
383 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
384 * either VIEW a note or allow the user to EDIT it. Again we support the
385 * DEFAULT category to allow the activity to be launched without explicitly
386 * specifying its component.</p>
387 * <li><pre>
388 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700389 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
390 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
391 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700392 * &lt;/intent-filter&gt;</pre>
393 * <p>The secondary use of this activity is to insert a new note entry into
394 * an existing directory of notes. This is used when the user creates a new
395 * note: the INSERT action is executed on the directory of notes, causing
396 * this activity to run and have the user create the new note data which
397 * it then adds to the content provider.</p>
398 * </ol>
399 *
400 * <p>Given these capabilities, the following intents will resolve to the
401 * NoteEditor activity:</p>
402 *
403 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700404 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700405 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
406 * shows the user the content of note <var>{ID}</var>.</p>
407 * <li> <p><b>{ action=android.app.action.EDIT
408 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
409 * allows the user to edit the content of note <var>{ID}</var>.</p>
410 * <li> <p><b>{ action=android.app.action.INSERT
411 * data=content://com.google.provider.NotePad/notes }</b>
412 * creates a new, empty note in the notes list at
413 * "content://com.google.provider.NotePad/notes"
414 * and allows the user to edit it. If they keep their changes, the URI
415 * of the newly created note is returned to the caller.</p>
416 * </ul>
417 *
418 * <p>The last activity,
419 * <code>com.android.notepad.TitleEditor</code>, allows the user to
420 * edit the title of a note. This could be implemented as a class that the
421 * application directly invokes (by explicitly setting its component in
422 * the Intent), but here we show a way you can publish alternative
423 * operations on existing data:</p>
424 *
425 * <pre>
426 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700427 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
428 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
429 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700432 * &lt;/intent-filter&gt;</pre>
433 *
434 * <p>In the single intent template here, we
435 * have created our own private action called
436 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
437 * edit the title of a note. It must be invoked on a specific note
438 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
439 * view and edit actions, but here displays and edits the title contained
440 * in the note data.
441 *
442 * <p>In addition to supporting the default category as usual, our title editor
443 * also supports two other standard categories: ALTERNATIVE and
444 * SELECTED_ALTERNATIVE. Implementing
445 * these categories allows others to find the special action it provides
446 * without directly knowing about it, through the
447 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
448 * more often to build dynamic menu items with
449 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
450 * template here was also supply an explicit name for the template
451 * (via <code>android:label="@string/resolve_title"</code>) to better control
452 * what the user sees when presented with this activity as an alternative
453 * action to the data they are viewing.
454 *
455 * <p>Given these capabilities, the following intent will resolve to the
456 * TitleEditor activity:</p>
457 *
458 * <ul>
459 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
460 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461 * displays and allows the user to edit the title associated
462 * with note <var>{ID}</var>.</p>
463 * </ul>
464 *
465 * <h3>Standard Activity Actions</h3>
466 *
467 * <p>These are the current standard actions that Intent defines for launching
468 * activities (usually through {@link Context#startActivity}. The most
469 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
470 * {@link #ACTION_EDIT}.
471 *
472 * <ul>
473 * <li> {@link #ACTION_MAIN}
474 * <li> {@link #ACTION_VIEW}
475 * <li> {@link #ACTION_ATTACH_DATA}
476 * <li> {@link #ACTION_EDIT}
477 * <li> {@link #ACTION_PICK}
478 * <li> {@link #ACTION_CHOOSER}
479 * <li> {@link #ACTION_GET_CONTENT}
480 * <li> {@link #ACTION_DIAL}
481 * <li> {@link #ACTION_CALL}
482 * <li> {@link #ACTION_SEND}
483 * <li> {@link #ACTION_SENDTO}
484 * <li> {@link #ACTION_ANSWER}
485 * <li> {@link #ACTION_INSERT}
486 * <li> {@link #ACTION_DELETE}
487 * <li> {@link #ACTION_RUN}
488 * <li> {@link #ACTION_SYNC}
489 * <li> {@link #ACTION_PICK_ACTIVITY}
490 * <li> {@link #ACTION_SEARCH}
491 * <li> {@link #ACTION_WEB_SEARCH}
492 * <li> {@link #ACTION_FACTORY_TEST}
493 * </ul>
494 *
495 * <h3>Standard Broadcast Actions</h3>
496 *
497 * <p>These are the current standard actions that Intent defines for receiving
498 * broadcasts (usually through {@link Context#registerReceiver} or a
499 * &lt;receiver&gt; tag in a manifest).
500 *
501 * <ul>
502 * <li> {@link #ACTION_TIME_TICK}
503 * <li> {@link #ACTION_TIME_CHANGED}
504 * <li> {@link #ACTION_TIMEZONE_CHANGED}
505 * <li> {@link #ACTION_BOOT_COMPLETED}
506 * <li> {@link #ACTION_PACKAGE_ADDED}
507 * <li> {@link #ACTION_PACKAGE_CHANGED}
508 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 * <li> {@link #ACTION_PACKAGE_RESTARTED}
510 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700511 * <li> {@link #ACTION_UID_REMOVED}
512 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700513 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700514 * <li> {@link #ACTION_POWER_DISCONNECTED}
515 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700516 * </ul>
517 *
518 * <h3>Standard Categories</h3>
519 *
520 * <p>These are the current standard categories that can be used to further
521 * clarify an Intent via {@link #addCategory}.
522 *
523 * <ul>
524 * <li> {@link #CATEGORY_DEFAULT}
525 * <li> {@link #CATEGORY_BROWSABLE}
526 * <li> {@link #CATEGORY_TAB}
527 * <li> {@link #CATEGORY_ALTERNATIVE}
528 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
529 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700531 * <li> {@link #CATEGORY_HOME}
532 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700533 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400534 * <li> {@link #CATEGORY_CAR_DOCK}
535 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500536 * <li> {@link #CATEGORY_LE_DESK_DOCK}
537 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200538 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700539 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700540 * </ul>
541 *
542 * <h3>Standard Extra Data</h3>
543 *
544 * <p>These are the current standard fields that can be used as extra data via
545 * {@link #putExtra}.
546 *
547 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800548 * <li> {@link #EXTRA_ALARM_COUNT}
549 * <li> {@link #EXTRA_BCC}
550 * <li> {@link #EXTRA_CC}
551 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
552 * <li> {@link #EXTRA_DATA_REMOVED}
553 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500554 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
555 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800556 * <li> {@link #EXTRA_DOCK_STATE_CAR}
557 * <li> {@link #EXTRA_DOCK_STATE_DESK}
558 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
559 * <li> {@link #EXTRA_DONT_KILL_APP}
560 * <li> {@link #EXTRA_EMAIL}
561 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700562 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800563 * <li> {@link #EXTRA_KEY_EVENT}
564 * <li> {@link #EXTRA_PHONE_NUMBER}
565 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
566 * <li> {@link #EXTRA_REPLACING}
567 * <li> {@link #EXTRA_SHORTCUT_ICON}
568 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
569 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800571 * <li> {@link #EXTRA_SHORTCUT_NAME}
572 * <li> {@link #EXTRA_SUBJECT}
573 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800575 * <li> {@link #EXTRA_TITLE}
576 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700577 * </ul>
578 *
579 * <h3>Flags</h3>
580 *
581 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800582 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
583 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700584 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800585public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700586 // ---------------------------------------------------------------------
587 // ---------------------------------------------------------------------
588 // Standard intent activity actions (see action variable).
589
590 /**
591 * Activity Action: Start as a main entry point, does not expect to
592 * receive data.
593 * <p>Input: nothing
594 * <p>Output: nothing
595 */
596 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
597 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800598
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700599 /**
600 * Activity Action: Display the data to the user. This is the most common
601 * action performed on data -- it is the generic action you can use on
602 * a piece of data to get the most reasonable thing to occur. For example,
603 * when used on a contacts entry it will view the entry; when used on a
604 * mailto: URI it will bring up a compose window filled with the information
605 * supplied by the URI; when used with a tel: URI it will invoke the
606 * dialer.
607 * <p>Input: {@link #getData} is URI from which to retrieve data.
608 * <p>Output: nothing.
609 */
610 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
611 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800612
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700613 /**
614 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
615 * performed on a piece of data.
616 */
617 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800618
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 /**
620 * Used to indicate that some piece of data should be attached to some other
621 * place. For example, image data could be attached to a contact. It is up
622 * to the recipient to decide where the data should be attached; the intent
623 * does not specify the ultimate destination.
624 * <p>Input: {@link #getData} is URI of data to be attached.
625 * <p>Output: nothing.
626 */
627 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
628 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 /**
631 * Activity Action: Provide explicit editable access to the given data.
632 * <p>Input: {@link #getData} is URI of data to be edited.
633 * <p>Output: nothing.
634 */
635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
636 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800637
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700638 /**
639 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
640 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
641 * The extras can contain type specific data to pass through to the editing/creating
642 * activity.
643 * <p>Output: The URI of the item that was picked. This must be a content:
644 * URI so that any receiver can access it.
645 */
646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
647 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800648
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700649 /**
650 * Activity Action: Pick an item from the data, returning what was selected.
651 * <p>Input: {@link #getData} is URI containing a directory of data
652 * (vnd.android.cursor.dir/*) from which to pick an item.
653 * <p>Output: The URI of the item that was picked.
654 */
655 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
656 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700658 /**
659 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800660 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700661 * <p>Output: An Intent representing the shortcut. The intent must contain three
662 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
663 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664 * (value: ShortcutIconResource).</p>
665 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 * @see #EXTRA_SHORTCUT_INTENT
667 * @see #EXTRA_SHORTCUT_NAME
668 * @see #EXTRA_SHORTCUT_ICON
669 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
670 * @see android.content.Intent.ShortcutIconResource
671 */
672 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
673 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
674
675 /**
676 * The name of the extra used to define the Intent of a shortcut.
677 *
678 * @see #ACTION_CREATE_SHORTCUT
679 */
680 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
681 /**
682 * The name of the extra used to define the name of a shortcut.
683 *
684 * @see #ACTION_CREATE_SHORTCUT
685 */
686 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
687 /**
688 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
689 *
690 * @see #ACTION_CREATE_SHORTCUT
691 */
692 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
693 /**
694 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
695 *
696 * @see #ACTION_CREATE_SHORTCUT
697 * @see android.content.Intent.ShortcutIconResource
698 */
699 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
700 "android.intent.extra.shortcut.ICON_RESOURCE";
701
702 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 *
705 * @see Intent#ACTION_CREATE_SHORTCUT
706 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800707 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
708 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700709 */
710 public static class ShortcutIconResource implements Parcelable {
711 /**
712 * The package name of the application containing the icon.
713 */
714 public String packageName;
715
716 /**
717 * The resource name of the icon, including package, name and type.
718 */
719 public String resourceName;
720
721 /**
722 * Creates a new ShortcutIconResource for the specified context and resource
723 * identifier.
724 *
725 * @param context The context of the application.
726 * @param resourceId The resource idenfitier for the icon.
727 * @return A new ShortcutIconResource with the specified's context package name
728 * and icon resource idenfitier.
729 */
730 public static ShortcutIconResource fromContext(Context context, int resourceId) {
731 ShortcutIconResource icon = new ShortcutIconResource();
732 icon.packageName = context.getPackageName();
733 icon.resourceName = context.getResources().getResourceName(resourceId);
734 return icon;
735 }
736
737 /**
738 * Used to read a ShortcutIconResource from a Parcel.
739 */
740 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
741 new Parcelable.Creator<ShortcutIconResource>() {
742
743 public ShortcutIconResource createFromParcel(Parcel source) {
744 ShortcutIconResource icon = new ShortcutIconResource();
745 icon.packageName = source.readString();
746 icon.resourceName = source.readString();
747 return icon;
748 }
749
750 public ShortcutIconResource[] newArray(int size) {
751 return new ShortcutIconResource[size];
752 }
753 };
754
755 /**
756 * No special parcel contents.
757 */
758 public int describeContents() {
759 return 0;
760 }
761
762 public void writeToParcel(Parcel dest, int flags) {
763 dest.writeString(packageName);
764 dest.writeString(resourceName);
765 }
766
767 @Override
768 public String toString() {
769 return resourceName;
770 }
771 }
772
773 /**
774 * Activity Action: Display an activity chooser, allowing the user to pick
775 * what they want to before proceeding. This can be used as an alternative
776 * to the standard activity picker that is displayed by the system when
777 * you try to start an activity with multiple possible matches, with these
778 * differences in behavior:
779 * <ul>
780 * <li>You can specify the title that will appear in the activity chooser.
781 * <li>The user does not have the option to make one of the matching
782 * activities a preferred activity, and all possible activities will
783 * always be shown even if one of them is currently marked as the
784 * preferred activity.
785 * </ul>
786 * <p>
787 * This action should be used when the user will naturally expect to
788 * select an activity in order to proceed. An example if when not to use
789 * it is when the user clicks on a "mailto:" link. They would naturally
790 * expect to go directly to their mail app, so startActivity() should be
791 * called directly: it will
792 * either launch the current preferred app, or put up a dialog allowing the
793 * user to pick an app to use and optionally marking that as preferred.
794 * <p>
795 * In contrast, if the user is selecting a menu item to send a picture
796 * they are viewing to someone else, there are many different things they
797 * may want to do at this point: send it through e-mail, upload it to a
798 * web service, etc. In this case the CHOOSER action should be used, to
799 * always present to the user a list of the things they can do, with a
800 * nice title given by the caller such as "Send this photo with:".
801 * <p>
802 * As a convenience, an Intent of this form can be created with the
803 * {@link #createChooser} function.
804 * <p>Input: No data should be specified. get*Extra must have
805 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
806 * and can optionally have a {@link #EXTRA_TITLE} field containing the
807 * title text to display in the chooser.
808 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
809 */
810 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
811 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
812
813 /**
814 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
815 *
816 * @param target The Intent that the user will be selecting an activity
817 * to perform.
818 * @param title Optional title that will be displayed in the chooser.
819 * @return Return a new Intent object that you can hand to
820 * {@link Context#startActivity(Intent) Context.startActivity()} and
821 * related methods.
822 */
823 public static Intent createChooser(Intent target, CharSequence title) {
824 Intent intent = new Intent(ACTION_CHOOSER);
825 intent.putExtra(EXTRA_INTENT, target);
826 if (title != null) {
827 intent.putExtra(EXTRA_TITLE, title);
828 }
829 return intent;
830 }
831 /**
832 * Activity Action: Allow the user to select a particular kind of data and
833 * return it. This is different than {@link #ACTION_PICK} in that here we
834 * just say what kind of data is desired, not a URI of existing data from
835 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
836 * create the data as it runs (for example taking a picture or recording a
837 * sound), let them browser over the web and download the desired data,
838 * etc.
839 * <p>
840 * There are two main ways to use this action: if you want an specific kind
841 * of data, such as a person contact, you set the MIME type to the kind of
842 * data you want and launch it with {@link Context#startActivity(Intent)}.
843 * The system will then launch the best application to select that kind
844 * of data for you.
845 * <p>
846 * You may also be interested in any of a set of types of content the user
847 * can pick. For example, an e-mail application that wants to allow the
848 * user to add an attachment to an e-mail message can use this action to
849 * bring up a list of all of the types of content the user can attach.
850 * <p>
851 * In this case, you should wrap the GET_CONTENT intent with a chooser
852 * (through {@link #createChooser}), which will give the proper interface
853 * for the user to pick how to send your data and allow you to specify
854 * a prompt indicating what they are doing. You will usually specify a
855 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
856 * broad range of content types the user can select from.
857 * <p>
858 * When using such a broad GET_CONTENT action, it is often desireable to
859 * only pick from data that can be represented as a stream. This is
860 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
861 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800862 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
863 * the launched content chooser only return results representing data that
864 * is locally available on the device. For example, if this extra is set
865 * to true then an image picker should not show any pictures that are available
866 * from a remote server but not already on the local device (thus requiring
867 * they be downloaded when opened).
868 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700869 * Input: {@link #getType} is the desired MIME type to retrieve. Note
870 * that no URI is supplied in the intent, as there are no constraints on
871 * where the returned data originally comes from. You may also include the
872 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800873 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
874 * selection to local data.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700875 * <p>
876 * Output: The URI of the item that was picked. This must be a content:
877 * URI so that any receiver can access it.
878 */
879 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
880 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
881 /**
882 * Activity Action: Dial a number as specified by the data. This shows a
883 * UI with the number being dialed, allowing the user to explicitly
884 * initiate the call.
885 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
886 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
887 * number.
888 * <p>Output: nothing.
889 */
890 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
891 public static final String ACTION_DIAL = "android.intent.action.DIAL";
892 /**
893 * Activity Action: Perform a call to someone specified by the data.
894 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
895 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
896 * number.
897 * <p>Output: nothing.
898 *
899 * <p>Note: there will be restrictions on which applications can initiate a
900 * call; most applications should use the {@link #ACTION_DIAL}.
901 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
902 * numbers. Applications can <strong>dial</strong> emergency numbers using
903 * {@link #ACTION_DIAL}, however.
904 */
905 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
906 public static final String ACTION_CALL = "android.intent.action.CALL";
907 /**
908 * Activity Action: Perform a call to an emergency number specified by the
909 * data.
910 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
911 * tel: URI of an explicit phone number.
912 * <p>Output: nothing.
913 * @hide
914 */
915 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
916 /**
917 * Activity action: Perform a call to any number (emergency or not)
918 * specified by the data.
919 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
920 * tel: URI of an explicit phone number.
921 * <p>Output: nothing.
922 * @hide
923 */
924 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
925 /**
926 * Activity Action: Send a message to someone specified by the data.
927 * <p>Input: {@link #getData} is URI describing the target.
928 * <p>Output: nothing.
929 */
930 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
931 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
932 /**
933 * Activity Action: Deliver some data to someone else. Who the data is
934 * being delivered to is not specified; it is up to the receiver of this
935 * action to ask the user where the data should be sent.
936 * <p>
937 * When launching a SEND intent, you should usually wrap it in a chooser
938 * (through {@link #createChooser}), which will give the proper interface
939 * for the user to pick how to send your data and allow you to specify
940 * a prompt indicating what they are doing.
941 * <p>
942 * Input: {@link #getType} is the MIME type of the data being sent.
943 * get*Extra can have either a {@link #EXTRA_TEXT}
944 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
945 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
946 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
947 * if the MIME type is unknown (this will only allow senders that can
948 * handle generic data streams).
949 * <p>
950 * Optional standard extras, which may be interpreted by some recipients as
951 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
952 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
953 * <p>
954 * Output: nothing.
955 */
956 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
957 public static final String ACTION_SEND = "android.intent.action.SEND";
958 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800959 * Activity Action: Deliver multiple data to someone else.
960 * <p>
961 * Like ACTION_SEND, except the data is multiple.
962 * <p>
963 * Input: {@link #getType} is the MIME type of the data being sent.
964 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
965 * #EXTRA_STREAM} field, containing the data to be sent.
966 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800967 * Multiple types are supported, and receivers should handle mixed types
968 * whenever possible. The right way for the receiver to check them is to
969 * use the content resolver on each URI. The intent sender should try to
970 * put the most concrete mime type in the intent type, but it can fall
971 * back to {@literal <type>/*} or {@literal *}/* as needed.
972 * <p>
973 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
974 * be image/jpg, but if you are sending image/jpg and image/png, then the
975 * intent's type should be image/*.
976 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800977 * Optional standard extras, which may be interpreted by some recipients as
978 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
979 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
980 * <p>
981 * Output: nothing.
982 */
983 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
984 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
985 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700986 * Activity Action: Handle an incoming phone call.
987 * <p>Input: nothing.
988 * <p>Output: nothing.
989 */
990 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
991 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
992 /**
993 * Activity Action: Insert an empty item into the given container.
994 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
995 * in which to place the data.
996 * <p>Output: URI of the new data that was created.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1000 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001001 * Activity Action: Create a new item in the given container, initializing it
1002 * from the current contents of the clipboard.
1003 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1004 * in which to place the data.
1005 * <p>Output: URI of the new data that was created.
1006 */
1007 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1008 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1009 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001010 * Activity Action: Delete the given data from its container.
1011 * <p>Input: {@link #getData} is URI of data to be deleted.
1012 * <p>Output: nothing.
1013 */
1014 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1015 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1016 /**
1017 * Activity Action: Run the data, whatever that means.
1018 * <p>Input: ? (Note: this is currently specific to the test harness.)
1019 * <p>Output: nothing.
1020 */
1021 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1022 public static final String ACTION_RUN = "android.intent.action.RUN";
1023 /**
1024 * Activity Action: Perform a data synchronization.
1025 * <p>Input: ?
1026 * <p>Output: ?
1027 */
1028 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1029 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1030 /**
1031 * Activity Action: Pick an activity given an intent, returning the class
1032 * selected.
1033 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1034 * used with {@link PackageManager#queryIntentActivities} to determine the
1035 * set of activities from which to pick.
1036 * <p>Output: Class name of the activity that was selected.
1037 */
1038 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1039 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1040 /**
1041 * Activity Action: Perform a search.
1042 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1043 * is the text to search for. If empty, simply
1044 * enter your search results Activity with the search UI activated.
1045 * <p>Output: nothing.
1046 */
1047 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1048 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1049 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001050 * Activity Action: Start the platform-defined tutorial
1051 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1052 * is the text to search for. If empty, simply
1053 * enter your search results Activity with the search UI activated.
1054 * <p>Output: nothing.
1055 */
1056 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1057 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1058 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001059 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001060 * <p>
1061 * Input: {@link android.app.SearchManager#QUERY
1062 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1063 * a url starts with http or https, the site will be opened. If it is plain
1064 * text, Google search will be applied.
1065 * <p>
1066 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001067 */
1068 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1069 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1070 /**
1071 * Activity Action: List all available applications
1072 * <p>Input: Nothing.
1073 * <p>Output: nothing.
1074 */
1075 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1076 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1077 /**
1078 * Activity Action: Show settings for choosing wallpaper
1079 * <p>Input: Nothing.
1080 * <p>Output: Nothing.
1081 */
1082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1083 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1084
1085 /**
1086 * Activity Action: Show activity for reporting a bug.
1087 * <p>Input: Nothing.
1088 * <p>Output: Nothing.
1089 */
1090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1091 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1092
1093 /**
1094 * Activity Action: Main entry point for factory tests. Only used when
1095 * the device is booting in factory test node. The implementing package
1096 * must be installed in the system image.
1097 * <p>Input: nothing
1098 * <p>Output: nothing
1099 */
1100 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1101
1102 /**
1103 * Activity Action: The user pressed the "call" button to go to the dialer
1104 * or other appropriate UI for placing a call.
1105 * <p>Input: Nothing.
1106 * <p>Output: Nothing.
1107 */
1108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1109 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1110
1111 /**
1112 * Activity Action: Start Voice Command.
1113 * <p>Input: Nothing.
1114 * <p>Output: Nothing.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001118
1119 /**
1120 * Activity Action: Start action associated with long pressing on the
1121 * search key.
1122 * <p>Input: Nothing.
1123 * <p>Output: Nothing.
1124 */
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1126 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001127
Jacek Surazski86b6c532009-05-13 14:38:28 +02001128 /**
1129 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1130 * This intent is delivered to the package which installed the application, usually
1131 * the Market.
1132 * <p>Input: No data is specified. The bug report is passed in using
1133 * an {@link #EXTRA_BUG_REPORT} field.
1134 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001135 *
1136 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001137 */
1138 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1139 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001140
1141 /**
1142 * Activity Action: Show power usage information to the user.
1143 * <p>Input: Nothing.
1144 * <p>Output: Nothing.
1145 */
1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1147 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001148
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001149 /**
1150 * Activity Action: Setup wizard to launch after a platform update. This
1151 * activity should have a string meta-data field associated with it,
1152 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1153 * the platform for setup. The activity will be launched only if
1154 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1155 * same value.
1156 * <p>Input: Nothing.
1157 * <p>Output: Nothing.
1158 * @hide
1159 */
1160 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1161 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001162
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001163 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001164 * Activity Action: Show settings for managing network data usage of a
1165 * specific application. Applications should define an activity that offers
1166 * options to control data usage.
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_MANAGE_NETWORK_USAGE =
1170 "android.intent.action.MANAGE_NETWORK_USAGE";
1171
1172 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001173 * Activity Action: Launch application installer.
1174 * <p>
1175 * Input: The data must be a content: or file: URI at which the application
1176 * can be retrieved. You can optionally supply
1177 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1178 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1179 * <p>
1180 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1181 * succeeded.
1182 *
1183 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1184 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1185 * @see #EXTRA_RETURN_RESULT
1186 */
1187 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1188 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1189
1190 /**
1191 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1192 * package. Specifies the installer package name; this package will receive the
1193 * {@link #ACTION_APP_ERROR} intent.
1194 */
1195 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1196 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1197
1198 /**
1199 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1200 * package. Specifies that the application being installed should not be
1201 * treated as coming from an unknown source, but as coming from the app
1202 * invoking the Intent. For this to work you must start the installer with
1203 * startActivityForResult().
1204 */
1205 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1206 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1207
1208 /**
1209 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1210 * package. Tells the installer UI to skip the confirmation with the user
1211 * if the .apk is replacing an existing one.
1212 */
1213 public static final String EXTRA_ALLOW_REPLACE
1214 = "android.intent.extra.ALLOW_REPLACE";
1215
1216 /**
1217 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1218 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1219 * return to the application the result code of the install/uninstall. The returned result
1220 * code will be {@link android.app.Activity#RESULT_OK} on success or
1221 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1222 */
1223 public static final String EXTRA_RETURN_RESULT
1224 = "android.intent.extra.RETURN_RESULT";
1225
1226 /**
1227 * Package manager install result code. @hide because result codes are not
1228 * yet ready to be exposed.
1229 */
1230 public static final String EXTRA_INSTALL_RESULT
1231 = "android.intent.extra.INSTALL_RESULT";
1232
1233 /**
1234 * Activity Action: Launch application uninstaller.
1235 * <p>
1236 * Input: The data must be a package: URI whose scheme specific part is
1237 * the package name of the current installed package to be uninstalled.
1238 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1239 * <p>
1240 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1241 * succeeded.
1242 */
1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1245
1246 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001247 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1248 * describing the last run version of the platform that was setup.
1249 * @hide
1250 */
1251 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1252
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001253 // ---------------------------------------------------------------------
1254 // ---------------------------------------------------------------------
1255 // Standard intent broadcast actions (see action variable).
1256
1257 /**
1258 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001259 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001260 * <p class="note">This is a protected intent that can only be sent
1261 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001262 */
1263 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1264 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1265 /**
1266 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001267 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001268 * <p class="note">This is a protected intent that can only be sent
1269 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001270 */
1271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1272 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001273
1274 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001275 * 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 -07001276 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001277 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001278 * <p class="note">This is a protected intent that can only be sent
1279 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001280 */
1281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001282 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001284 /**
1285 * Broadcast Action: The current time has changed. Sent every
1286 * minute. You can <em>not</em> receive this through components declared
1287 * in manifests, only by exlicitly registering for it with
1288 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1289 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001290 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001291 * <p class="note">This is a protected intent that can only be sent
1292 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001293 */
1294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1295 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1296 /**
1297 * Broadcast Action: The time was set.
1298 */
1299 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1300 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1301 /**
1302 * Broadcast Action: The date has changed.
1303 */
1304 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1305 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1306 /**
1307 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1308 * <ul>
1309 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1310 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001311 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001312 * <p class="note">This is a protected intent that can only be sent
1313 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 */
1315 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1316 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1317 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001318 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1319 * DNS entries should be tossed.
1320 * @hide
1321 */
1322 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1323 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1324 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001325 * Alarm Changed Action: This is broadcast when the AlarmClock
1326 * application's alarm is set or unset. It is used by the
1327 * AlarmClock application and the StatusBar service.
1328 * @hide
1329 */
1330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1331 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1332 /**
1333 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1334 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1335 * @hide
1336 */
1337 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1338 public static final String ACTION_SYNC_STATE_CHANGED
1339 = "android.intent.action.SYNC_STATE_CHANGED";
1340 /**
1341 * Broadcast Action: This is broadcast once, after the system has finished
1342 * booting. It can be used to perform application-specific initialization,
1343 * such as installing alarms. You must hold the
1344 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1345 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001346 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001347 * <p class="note">This is a protected intent that can only be sent
1348 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001349 */
1350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1351 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1352 /**
1353 * Broadcast Action: This is broadcast when a user action should request a
1354 * temporary system dialog to dismiss. Some examples of temporary system
1355 * dialogs are the notification window-shade and the recent tasks dialog.
1356 */
1357 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1358 /**
1359 * Broadcast Action: Trigger the download and eventual installation
1360 * of a package.
1361 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001362 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001363 * <p class="note">This is a protected intent that can only be sent
1364 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001365 *
1366 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001367 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001368 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001369 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1370 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1371 /**
1372 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001373 * device. The data contains the name of the package. Note that the
1374 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001375 * <p>My include the following extras:
1376 * <ul>
1377 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1378 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1379 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1380 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001381 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001382 * <p class="note">This is a protected intent that can only be sent
1383 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001384 */
1385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1386 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1387 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001388 * Broadcast Action: A new version of an application package has been
1389 * installed, replacing an existing version that was previously installed.
1390 * The data contains the name of the package.
1391 * <p>My include the following extras:
1392 * <ul>
1393 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1394 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001395 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001396 * <p class="note">This is a protected intent that can only be sent
1397 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001398 */
1399 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1400 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1401 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001402 * Broadcast Action: A new version of your application has been installed
1403 * over an existing one. This is only sent to the application that was
1404 * replaced. It does not contain any additional data; to receive it, just
1405 * use an intent filter for this action.
1406 *
1407 * <p class="note">This is a protected intent that can only be sent
1408 * by the system.
1409 */
1410 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1411 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1412 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001413 * Broadcast Action: An existing application package has been removed from
1414 * the device. The data contains the name of the package. The package
1415 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001416 * <ul>
1417 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1418 * to the package.
1419 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1420 * application -- data and code -- is being removed.
1421 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1422 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1423 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001424 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001425 * <p class="note">This is a protected intent that can only be sent
1426 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001427 */
1428 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1429 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1430 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001431 * Broadcast Action: An existing application package has been completely
1432 * removed from the device. The data contains the name of the package.
1433 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1434 * {@link #EXTRA_DATA_REMOVED} is true and
1435 * {@link #EXTRA_REPLACING} is false of that broadcast.
1436 *
1437 * <ul>
1438 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1439 * to the package.
1440 * </ul>
1441 *
1442 * <p class="note">This is a protected intent that can only be sent
1443 * by the system.
1444 */
1445 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1446 public static final String ACTION_PACKAGE_FULLY_REMOVED
1447 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1448 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001449 * Broadcast Action: An existing application package has been changed (e.g.
1450 * a component has been enabled or disabled). The data contains the name of
1451 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001452 * <ul>
1453 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001454 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1455 * of the changed components.
1456 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1457 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001458 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001459 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001460 * <p class="note">This is a protected intent that can only be sent
1461 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001462 */
1463 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1464 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1465 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001466 * @hide
1467 * Broadcast Action: Ask system services if there is any reason to
1468 * restart the given package. The data contains the name of the
1469 * package.
1470 * <ul>
1471 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1472 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1473 * </ul>
1474 *
1475 * <p class="note">This is a protected intent that can only be sent
1476 * by the system.
1477 */
1478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1479 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1480 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001481 * Broadcast Action: The user has restarted a package, and all of its
1482 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001483 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001484 * be removed. Note that the restarted package does <em>not</em>
1485 * receive this broadcast.
1486 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001487 * <ul>
1488 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1489 * </ul>
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_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1496 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001497 * Broadcast Action: The user has cleared the data of a package. This should
1498 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001499 * its persistent data is erased and this broadcast sent.
1500 * Note that the cleared package does <em>not</em>
1501 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001502 * <ul>
1503 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1504 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001505 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001506 * <p class="note">This is a protected intent that can only be sent
1507 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001508 */
1509 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1510 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1511 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001512 * Broadcast Action: A user ID has been removed from the system. The user
1513 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001514 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001515 * <p class="note">This is a protected intent that can only be sent
1516 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001517 */
1518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1519 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001520
1521 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001522 * Broadcast Action: Sent to the installer package of an application
1523 * when that application is first launched (that is the first time it
1524 * is moved out of the stopped state). The data contains the name of the package.
1525 *
1526 * <p class="note">This is a protected intent that can only be sent
1527 * by the system.
1528 */
1529 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1530 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1531
1532 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001533 * Broadcast Action: Sent to the system package verifier when a package
1534 * needs to be verified. The data contains the package URI.
1535 * <p class="note">
1536 * This is a protected intent that can only be sent by the system.
1537 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001538 */
1539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1540 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1541
1542 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001543 * Broadcast Action: Resources for a set of packages (which were
1544 * previously unavailable) are currently
1545 * available since the media on which they exist is available.
1546 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1547 * list of packages whose availability changed.
1548 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1549 * list of uids of packages whose availability changed.
1550 * Note that the
1551 * packages in this list do <em>not</em> receive this broadcast.
1552 * The specified set of packages are now available on the system.
1553 * <p>Includes the following extras:
1554 * <ul>
1555 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1556 * whose resources(were previously unavailable) are currently available.
1557 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1558 * packages whose resources(were previously unavailable)
1559 * are currently available.
1560 * </ul>
1561 *
1562 * <p class="note">This is a protected intent that can only be sent
1563 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001564 */
1565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001566 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1567 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001568
1569 /**
1570 * Broadcast Action: Resources for a set of packages are currently
1571 * unavailable since the media on which they exist is unavailable.
1572 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1573 * list of packages whose availability changed.
1574 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1575 * list of uids of packages whose availability changed.
1576 * The specified set of packages can no longer be
1577 * launched and are practically unavailable on the system.
1578 * <p>Inclues the following extras:
1579 * <ul>
1580 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1581 * whose resources are no longer available.
1582 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1583 * whose resources are no longer available.
1584 * </ul>
1585 *
1586 * <p class="note">This is a protected intent that can only be sent
1587 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001588 */
1589 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001590 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001591 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001593 /**
1594 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001595 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001596 */
1597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1598 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1599 /**
1600 * Broadcast Action: The current device {@link android.content.res.Configuration}
1601 * (orientation, locale, etc) has changed. When such a change happens, the
1602 * UIs (view hierarchy) will need to be rebuilt based on this new
1603 * information; for the most part, applications don't need to worry about
1604 * this, because the system will take care of stopping and restarting the
1605 * application to make sure it sees the new changes. Some system code that
1606 * can not be restarted will need to watch for this action and handle it
1607 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001608 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001609 * <p class="note">
1610 * You can <em>not</em> receive this through components declared
1611 * in manifests, only by explicitly registering for it with
1612 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1613 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001614 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001615 * <p class="note">This is a protected intent that can only be sent
1616 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001617 *
1618 * @see android.content.res.Configuration
1619 */
1620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1621 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1622 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001623 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001624 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001625 * <p class="note">This is a protected intent that can only be sent
1626 * by the system.
1627 */
1628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1629 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1630 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001631 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1632 * charging state, level, and other information about the battery.
1633 * See {@link android.os.BatteryManager} for documentation on the
1634 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001635 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001636 * <p class="note">
1637 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001638 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001639 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001640 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1641 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1642 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1643 * broadcasts that are sent and can be received through manifest
1644 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001645 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001646 * <p class="note">This is a protected intent that can only be sent
1647 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001648 */
1649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1650 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1651 /**
1652 * Broadcast Action: Indicates low battery condition on the device.
1653 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001654 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001655 * <p class="note">This is a protected intent that can only be sent
1656 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001657 */
1658 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1659 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1660 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001661 * Broadcast Action: Indicates the battery is now okay after being low.
1662 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1663 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001664 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001665 * <p class="note">This is a protected intent that can only be sent
1666 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001667 */
1668 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1669 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1670 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001671 * Broadcast Action: External power has been connected to the device.
1672 * This is intended for applications that wish to register specifically to this notification.
1673 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1674 * stay active to receive this notification. This action can be used to implement actions
1675 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001676 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001677 * <p class="note">This is a protected intent that can only be sent
1678 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001679 */
1680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001681 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001682 /**
1683 * Broadcast Action: External power has been removed from the device.
1684 * This is intended for applications that wish to register specifically to this notification.
1685 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1686 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001687 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001688 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001689 * <p class="note">This is a protected intent that can only be sent
1690 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001691 */
1692 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001693 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001694 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001695 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001696 * Broadcast Action: Device is shutting down.
1697 * This is broadcast when the device is being shut down (completely turned
1698 * off, not sleeping). Once the broadcast is complete, the final shutdown
1699 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001700 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001701 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001702 * <p class="note">This is a protected intent that can only be sent
1703 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001704 */
1705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001706 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001707 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001708 * Activity Action: Start this activity to request system shutdown.
1709 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1710 * to request confirmation from the user before shutting down.
1711 *
1712 * <p class="note">This is a protected intent that can only be sent
1713 * by the system.
1714 *
1715 * {@hide}
1716 */
1717 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1718 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001719 * Broadcast Action: A sticky broadcast that indicates low memory
1720 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001721 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001722 * <p class="note">This is a protected intent that can only be sent
1723 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001724 */
1725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1726 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1727 /**
1728 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001729 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001730 * <p class="note">This is a protected intent that can only be sent
1731 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001732 */
1733 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1734 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1735 /**
Jake Hambybb371632010-08-23 18:16:48 -07001736 * Broadcast Action: A sticky broadcast that indicates a memory full
1737 * condition on the device. This is intended for activities that want
1738 * to be able to fill the data partition completely, leaving only
1739 * enough free space to prevent system-wide SQLite failures.
1740 *
1741 * <p class="note">This is a protected intent that can only be sent
1742 * by the system.
1743 *
1744 * {@hide}
1745 */
1746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1747 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1748 /**
1749 * Broadcast Action: Indicates memory full condition on the device
1750 * no longer exists.
1751 *
1752 * <p class="note">This is a protected intent that can only be sent
1753 * by the system.
1754 *
1755 * {@hide}
1756 */
1757 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1758 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
1759 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001760 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1761 * and package management should be started.
1762 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1763 * notification.
1764 */
1765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1766 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1767 /**
1768 * Broadcast Action: The device has entered USB Mass Storage mode.
1769 * This is used mainly for the USB Settings panel.
1770 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1771 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001772 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001773 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001775 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1776
1777 /**
1778 * Broadcast Action: The device has exited USB Mass Storage mode.
1779 * This is used mainly for the USB Settings panel.
1780 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1781 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001782 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001783 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001784 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001785 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1786
1787 /**
1788 * Broadcast Action: External media has been removed.
1789 * The path to the mount point for the removed media is contained in the Intent.mData field.
1790 */
1791 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1792 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1793
1794 /**
1795 * Broadcast Action: External media is present, but not mounted at its mount point.
1796 * The path to the mount point for the removed media is contained in the Intent.mData field.
1797 */
1798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1799 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1800
1801 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001802 * Broadcast Action: External media is present, and being disk-checked
1803 * 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 -08001804 */
1805 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1806 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1807
1808 /**
1809 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1810 * 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 -08001811 */
1812 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1813 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1814
1815 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001816 * Broadcast Action: External media is present and mounted at its mount point.
1817 * The path to the mount point for the removed media is contained in the Intent.mData field.
1818 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1819 * media was mounted read only.
1820 */
1821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1822 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1823
1824 /**
1825 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001826 * 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 -07001827 */
1828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1829 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1830
1831 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001832 * Broadcast Action: External media is no longer being shared via USB mass storage.
1833 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1834 *
1835 * @hide
1836 */
1837 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1838
1839 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001840 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1841 * The path to the mount point for the removed media is contained in the Intent.mData field.
1842 */
1843 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1844 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1845
1846 /**
1847 * Broadcast Action: External media is present but cannot be mounted.
1848 * The path to the mount point for the removed media is contained in the Intent.mData field.
1849 */
1850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1851 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1852
1853 /**
1854 * Broadcast Action: User has expressed the desire to remove the external storage media.
1855 * Applications should close all files they have open within the mount point when they receive this intent.
1856 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1857 */
1858 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1859 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1860
1861 /**
1862 * Broadcast Action: The media scanner has started scanning a directory.
1863 * The path to the directory being scanned is contained in the Intent.mData field.
1864 */
1865 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1866 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1867
1868 /**
1869 * Broadcast Action: The media scanner has finished scanning a directory.
1870 * The path to the scanned directory is contained in the Intent.mData field.
1871 */
1872 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1873 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1874
1875 /**
1876 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1877 * The path to the file is contained in the Intent.mData field.
1878 */
1879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1880 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1881
1882 /**
1883 * Broadcast Action: The "Media Button" was pressed. Includes a single
1884 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1885 * caused the broadcast.
1886 */
1887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1888 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1889
1890 /**
1891 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1892 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1893 * caused the broadcast.
1894 */
1895 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1896 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1897
1898 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1899 // location; they are not general-purpose actions.
1900
1901 /**
1902 * Broadcast Action: An GTalk connection has been established.
1903 */
1904 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1905 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1906 "android.intent.action.GTALK_CONNECTED";
1907
1908 /**
1909 * Broadcast Action: An GTalk connection has been disconnected.
1910 */
1911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1912 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1913 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001914
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001915 /**
1916 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001917 */
1918 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1919 public static final String ACTION_INPUT_METHOD_CHANGED =
1920 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001921
1922 /**
1923 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1924 * more radios have been turned off or on. The intent will have the following extra value:</p>
1925 * <ul>
1926 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1927 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1928 * turned off</li>
1929 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001930 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001931 * <p class="note">This is a protected intent that can only be sent
1932 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001933 */
1934 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1935 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1936
1937 /**
1938 * Broadcast Action: Some content providers have parts of their namespace
1939 * where they publish new events or items that the user may be especially
1940 * interested in. For these things, they may broadcast this action when the
1941 * set of interesting items change.
1942 *
1943 * For example, GmailProvider sends this notification when the set of unread
1944 * mail in the inbox changes.
1945 *
1946 * <p>The data of the intent identifies which part of which provider
1947 * changed. When queried through the content resolver, the data URI will
1948 * return the data set in question.
1949 *
1950 * <p>The intent will have the following extra values:
1951 * <ul>
1952 * <li><em>count</em> - The number of items in the data set. This is the
1953 * same as the number of items in the cursor returned by querying the
1954 * data URI. </li>
1955 * </ul>
1956 *
1957 * This intent will be sent at boot (if the count is non-zero) and when the
1958 * data set changes. It is possible for the data set to change without the
1959 * count changing (for example, if a new unread message arrives in the same
1960 * sync operation in which a message is archived). The phone should still
1961 * ring/vibrate/etc as normal in this case.
1962 */
1963 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1964 public static final String ACTION_PROVIDER_CHANGED =
1965 "android.intent.action.PROVIDER_CHANGED";
1966
1967 /**
1968 * Broadcast Action: Wired Headset plugged in or unplugged.
1969 *
1970 * <p>The intent will have the following extra values:
1971 * <ul>
1972 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1973 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001974 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 * </ul>
1976 * </ul>
1977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1979 public static final String ACTION_HEADSET_PLUG =
1980 "android.intent.action.HEADSET_PLUG";
1981
1982 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001983 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
1984 *
1985 * <p>The intent will have the following extra values:
1986 * <ul>
1987 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1988 * <li><em>name</em> - Headset type, human readable string </li>
1989 * </ul>
1990 * </ul>
1991 * @hide
1992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_USB_ANLG_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08001995 "android.intent.action.USB_ANLG_HEADSET_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001996
1997 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07001998 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001999 *
2000 * <p>The intent will have the following extra values:
2001 * <ul>
2002 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2003 * <li><em>name</em> - Headset type, human readable string </li>
2004 * </ul>
2005 * </ul>
2006 * @hide
2007 */
2008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2009 public static final String ACTION_USB_DGTL_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08002010 "android.intent.action.USB_DGTL_HEADSET_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07002011
2012 /**
2013 * Broadcast Action: A HMDI cable was plugged or unplugged
2014 *
2015 * <p>The intent will have the following extra values:
2016 * <ul>
2017 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2018 * <li><em>name</em> - HDMI cable, human readable string </li>
2019 * </ul>
2020 * </ul>
2021 * @hide
2022 */
2023 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2024 public static final String ACTION_HDMI_AUDIO_PLUG =
2025 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002026
2027 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002028 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2029 * <ul>
2030 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2031 * </ul>
2032 *
2033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
2035 *
2036 * @hide
2037 */
2038 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2039 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2040 = "android.intent.action.ADVANCED_SETTINGS";
2041
2042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002043 * Broadcast Action: An outgoing call is about to be placed.
2044 *
2045 * <p>The Intent will have the following extra value:
2046 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002047 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002048 * the phone number originally intended to be dialed.</li>
2049 * </ul>
2050 * <p>Once the broadcast is finished, the resultData is used as the actual
2051 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002052 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002053 * outgoing call in turn: for example, a parental control application
2054 * might verify that the user is authorized to place the call at that
2055 * time, then a number-rewriting application might add an area code if
2056 * one was not specified.</p>
2057 * <p>For consistency, any receiver whose purpose is to prohibit phone
2058 * calls should have a priority of 0, to ensure it will see the final
2059 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002060 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 * should have a positive priority.
2062 * Negative priorities are reserved for the system for this broadcast;
2063 * using them may cause problems.</p>
2064 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2065 * abort the broadcast.</p>
2066 * <p>Emergency calls cannot be intercepted using this mechanism, and
2067 * other calls cannot be modified to call emergency numbers using this
2068 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07002069 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002070 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2071 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002072 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002073 * <p class="note">This is a protected intent that can only be sent
2074 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002075 */
2076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2077 public static final String ACTION_NEW_OUTGOING_CALL =
2078 "android.intent.action.NEW_OUTGOING_CALL";
2079
2080 /**
2081 * Broadcast Action: Have the device reboot. This is only for use by
2082 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002083 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002084 * <p class="note">This is a protected intent that can only be sent
2085 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002086 */
2087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2088 public static final String ACTION_REBOOT =
2089 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002090
Wei Huang97ecc9c2009-05-11 17:44:20 -07002091 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002092 * Broadcast Action: A sticky broadcast for changes in the physical
2093 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002094 *
2095 * <p>The intent will have the following extra values:
2096 * <ul>
2097 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002098 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002099 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002100 * <p>This is intended for monitoring the current physical dock state.
2101 * See {@link android.app.UiModeManager} for the normal API dealing with
2102 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002103 */
2104 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2105 public static final String ACTION_DOCK_EVENT =
2106 "android.intent.action.DOCK_EVENT";
2107
2108 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002109 * Broadcast Action: a remote intent is to be broadcasted.
2110 *
2111 * A remote intent is used for remote RPC between devices. The remote intent
2112 * is serialized and sent from one device to another device. The receiving
2113 * device parses the remote intent and broadcasts it. Note that anyone can
2114 * broadcast a remote intent. However, if the intent receiver of the remote intent
2115 * does not trust intent broadcasts from arbitrary intent senders, it should require
2116 * the sender to hold certain permissions so only trusted sender's broadcast will be
2117 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002118 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002119 */
2120 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002121 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002122
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002123 /**
2124 * Broadcast Action: hook for permforming cleanup after a system update.
2125 *
2126 * The broadcast is sent when the system is booting, before the
2127 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2128 * image. A receiver for this should do its work and then disable itself
2129 * so that it does not get run again at the next boot.
2130 * @hide
2131 */
2132 public static final String ACTION_PRE_BOOT_COMPLETED =
2133 "android.intent.action.PRE_BOOT_COMPLETED";
2134
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002135 // ---------------------------------------------------------------------
2136 // ---------------------------------------------------------------------
2137 // Standard intent categories (see addCategory()).
2138
2139 /**
2140 * Set if the activity should be an option for the default action
2141 * (center press) to perform on a piece of data. Setting this will
2142 * hide from the user any activities without it set when performing an
2143 * action on some data. Note that this is normal -not- set in the
2144 * Intent when initiating an action -- it is for use in intent filters
2145 * specified in packages.
2146 */
2147 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2148 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2149 /**
2150 * Activities that can be safely invoked from a browser must support this
2151 * category. For example, if the user is viewing a web page or an e-mail
2152 * and clicks on a link in the text, the Intent generated execute that
2153 * link will require the BROWSABLE category, so that only activities
2154 * supporting this category will be considered as possible actions. By
2155 * supporting this category, you are promising that there is nothing
2156 * damaging (without user intervention) that can happen by invoking any
2157 * matching Intent.
2158 */
2159 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2160 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2161 /**
2162 * Set if the activity should be considered as an alternative action to
2163 * the data the user is currently viewing. See also
2164 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2165 * applies to the selection in a list of items.
2166 *
2167 * <p>Supporting this category means that you would like your activity to be
2168 * displayed in the set of alternative things the user can do, usually as
2169 * part of the current activity's options menu. You will usually want to
2170 * include a specific label in the &lt;intent-filter&gt; of this action
2171 * describing to the user what it does.
2172 *
2173 * <p>The action of IntentFilter with this category is important in that it
2174 * describes the specific action the target will perform. This generally
2175 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2176 * a specific name such as "com.android.camera.action.CROP. Only one
2177 * alternative of any particular action will be shown to the user, so using
2178 * a specific action like this makes sure that your alternative will be
2179 * displayed while also allowing other applications to provide their own
2180 * overrides of that particular action.
2181 */
2182 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2183 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2184 /**
2185 * Set if the activity should be considered as an alternative selection
2186 * action to the data the user has currently selected. This is like
2187 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2188 * of items from which the user can select, giving them alternatives to the
2189 * default action that will be performed on it.
2190 */
2191 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2192 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2193 /**
2194 * Intended to be used as a tab inside of an containing TabActivity.
2195 */
2196 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2197 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2198 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002199 * Should be displayed in the top-level launcher.
2200 */
2201 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2202 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2203 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002204 * Provides information about the package it is in; typically used if
2205 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2206 * a front-door to the user without having to be shown in the all apps list.
2207 */
2208 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2209 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2210 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002211 * This is the home activity, that is the first activity that is displayed
2212 * when the device boots.
2213 */
2214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2215 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2216 /**
2217 * This activity is a preference panel.
2218 */
2219 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2220 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2221 /**
2222 * This activity is a development preference panel.
2223 */
2224 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2225 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2226 /**
2227 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002228 */
2229 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2230 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2231 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002232 * This activity allows the user to browse and download new applications.
2233 */
2234 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2235 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2236 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002237 * This activity may be exercised by the monkey or other automated test tools.
2238 */
2239 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2240 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2241 /**
2242 * To be used as a test (not part of the normal user experience).
2243 */
2244 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2245 /**
2246 * To be used as a unit test (run through the Test Harness).
2247 */
2248 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2249 /**
2250 * To be used as an sample code example (not part of the normal user
2251 * experience).
2252 */
2253 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2254 /**
2255 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2256 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2257 * when queried, though it is allowable for those columns to be blank.
2258 */
2259 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2260 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2261
2262 /**
2263 * To be used as code under test for framework instrumentation tests.
2264 */
2265 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2266 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002267 /**
2268 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002269 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2270 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002271 */
2272 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2273 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2274 /**
2275 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002276 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2277 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002278 */
2279 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2280 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002281 /**
2282 * An activity to run when device is inserted into a analog (low end) dock.
2283 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2284 * information, see {@link android.app.UiModeManager}.
2285 */
2286 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2287 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2288
2289 /**
2290 * An activity to run when device is inserted into a digital (high end) dock.
2291 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2292 * information, see {@link android.app.UiModeManager}.
2293 */
2294 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2295 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002296
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002297 /**
2298 * Used to indicate that the activity can be used in a car environment.
2299 */
2300 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2301 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2302
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002303 // ---------------------------------------------------------------------
2304 // ---------------------------------------------------------------------
2305 // Standard extra data keys.
2306
2307 /**
2308 * The initial data to place in a newly created record. Use with
2309 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2310 * fields as would be given to the underlying ContentProvider.insert()
2311 * call.
2312 */
2313 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2314
2315 /**
2316 * A constant CharSequence that is associated with the Intent, used with
2317 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2318 * this may be a styled CharSequence, so you must use
2319 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2320 * retrieve it.
2321 */
2322 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2323
2324 /**
2325 * A content: URI holding a stream of data associated with the Intent,
2326 * used with {@link #ACTION_SEND} to supply the data being sent.
2327 */
2328 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2329
2330 /**
2331 * A String[] holding e-mail addresses that should be delivered to.
2332 */
2333 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2334
2335 /**
2336 * A String[] holding e-mail addresses that should be carbon copied.
2337 */
2338 public static final String EXTRA_CC = "android.intent.extra.CC";
2339
2340 /**
2341 * A String[] holding e-mail addresses that should be blind carbon copied.
2342 */
2343 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2344
2345 /**
2346 * A constant string holding the desired subject line of a message.
2347 */
2348 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2349
2350 /**
2351 * An Intent describing the choices you would like shown with
2352 * {@link #ACTION_PICK_ACTIVITY}.
2353 */
2354 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2355
2356 /**
2357 * A CharSequence dialog title to provide to the user when used with a
2358 * {@link #ACTION_CHOOSER}.
2359 */
2360 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2361
2362 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002363 * A Parcelable[] of {@link Intent} or
2364 * {@link android.content.pm.LabeledIntent} objects as set with
2365 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2366 * a the front of the list of choices, when shown to the user with a
2367 * {@link #ACTION_CHOOSER}.
2368 */
2369 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2370
2371 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002372 * A {@link android.view.KeyEvent} object containing the event that
2373 * triggered the creation of the Intent it is in.
2374 */
2375 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2376
2377 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002378 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2379 * before shutting down.
2380 *
2381 * {@hide}
2382 */
2383 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2384
2385 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002386 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2387 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2388 * of restarting the application.
2389 */
2390 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2391
2392 /**
2393 * A String holding the phone number originally entered in
2394 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2395 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2396 */
2397 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002398
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002399 /**
2400 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2401 * intents to supply the uid the package had been assigned. Also an optional
2402 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2403 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2404 * purpose.
2405 */
2406 public static final String EXTRA_UID = "android.intent.extra.UID";
2407
2408 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002409 * @hide String array of package names.
2410 */
2411 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2412
2413 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002414 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2415 * intents to indicate whether this represents a full uninstall (removing
2416 * both the code and its data) or a partial uninstall (leaving its data,
2417 * implying that this is an update).
2418 */
2419 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002420
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002421 /**
2422 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2423 * intents to indicate that this is a replacement of the package, so this
2424 * broadcast will immediately be followed by an add broadcast for a
2425 * different version of the same package.
2426 */
2427 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002428
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002429 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002430 * Used as an int extra field in {@link android.app.AlarmManager} intents
2431 * to tell the application being invoked how many pending alarms are being
2432 * delievered with the intent. For one-shot alarms this will always be 1.
2433 * For recurring alarms, this might be greater than 1 if the device was
2434 * asleep or powered off at the time an earlier alarm would have been
2435 * delivered.
2436 */
2437 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002438
Jacek Surazski86b6c532009-05-13 14:38:28 +02002439 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002440 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2441 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002442 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2443 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002444 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
2445 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
2446 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002447 */
2448 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2449
2450 /**
2451 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2452 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002453 */
2454 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2455
2456 /**
2457 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2458 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002459 */
2460 public static final int EXTRA_DOCK_STATE_DESK = 1;
2461
2462 /**
2463 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2464 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002465 */
2466 public static final int EXTRA_DOCK_STATE_CAR = 2;
2467
2468 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002469 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2470 * to represent that the phone is in a analog (low end) dock.
2471 */
2472 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
2473
2474 /**
2475 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2476 * to represent that the phone is in a digital (high end) dock.
2477 */
2478 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
2479
2480 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002481 * Boolean that can be supplied as meta-data with a dock activity, to
2482 * indicate that the dock should take over the home key when it is active.
2483 */
2484 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002485
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002486 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002487 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2488 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02002489 */
2490 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2491
2492 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002493 * Used in the extra field in the remote intent. It's astring token passed with the
2494 * remote intent.
2495 */
2496 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2497 "android.intent.extra.remote_intent_token";
2498
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002499 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002500 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002501 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002502 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002503 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002504 "android.intent.extra.changed_component_name";
2505
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002506 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002507 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002508 * and contains a string array of all of the components that have changed.
2509 */
2510 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2511 "android.intent.extra.changed_component_name_list";
2512
2513 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002514 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002515 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2516 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002517 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002518 */
2519 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2520 "android.intent.extra.changed_package_list";
2521
2522 /**
2523 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002524 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2525 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002526 * and contains an integer array of uids of all of the components
2527 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002528 */
2529 public static final String EXTRA_CHANGED_UID_LIST =
2530 "android.intent.extra.changed_uid_list";
2531
2532 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002533 * @hide
2534 * Magic extra system code can use when binding, to give a label for
2535 * who it is that has bound to a service. This is an integer giving
2536 * a framework string resource that can be displayed to the user.
2537 */
2538 public static final String EXTRA_CLIENT_LABEL =
2539 "android.intent.extra.client_label";
2540
2541 /**
2542 * @hide
2543 * Magic extra system code can use when binding, to give a PendingIntent object
2544 * that can be launched for the user to disable the system's use of this
2545 * service.
2546 */
2547 public static final String EXTRA_CLIENT_INTENT =
2548 "android.intent.extra.client_intent";
2549
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08002550 /**
2551 * Used to indicate that a {@link #ACTION_GET_CONTENT} intent should only return
2552 * data that is on the local device. This is a boolean extra; the default
2553 * is false. If true, an implementation of ACTION_GET_CONTENT should only allow
2554 * the user to select media that is already on the device, not requiring it
2555 * be downloaded from a remote service when opened. Another way to look
2556 * at it is that such content should generally have a "_data" column to the
2557 * path of the content on local external storage.
2558 */
2559 public static final String EXTRA_LOCAL_ONLY =
2560 "android.intent.extra.LOCAL_ONLY";
2561
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002562 // ---------------------------------------------------------------------
2563 // ---------------------------------------------------------------------
2564 // Intent flags (see mFlags variable).
2565
2566 /**
2567 * If set, the recipient of this Intent will be granted permission to
2568 * perform read operations on the Uri in the Intent's data.
2569 */
2570 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2571 /**
2572 * If set, the recipient of this Intent will be granted permission to
2573 * perform write operations on the Uri in the Intent's data.
2574 */
2575 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2576 /**
2577 * Can be set by the caller to indicate that this Intent is coming from
2578 * a background operation, not from direct user interaction.
2579 */
2580 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2581 /**
2582 * A flag you can enable for debugging: when set, log messages will be
2583 * printed during the resolution of this intent to show you what has
2584 * been found to create the final resolved list.
2585 */
2586 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08002587 /**
2588 * If set, this intent will not match any components in packages that
2589 * are currently stopped. If this is not set, then the default behavior
2590 * is to include such applications in the result.
2591 */
2592 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
2593 /**
2594 * If set, this intent will always match any components in packages that
2595 * are currently stopped. This is the default behavior when
2596 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
2597 * flags are set, this one wins (it allows overriding of exclude for
2598 * places where the framework may automatically set the exclude flag).
2599 */
2600 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002601
2602 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002603 * If set, the new activity is not kept in the history stack. As soon as
2604 * the user navigates away from it, the activity is finished. This may also
2605 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2606 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002607 */
2608 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2609 /**
2610 * If set, the activity will not be launched if it is already running
2611 * at the top of the history stack.
2612 */
2613 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2614 /**
2615 * If set, this activity will become the start of a new task on this
2616 * history stack. A task (from the activity that started it to the
2617 * next task activity) defines an atomic group of activities that the
2618 * user can move to. Tasks can be moved to the foreground and background;
2619 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002620 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08002621 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2622 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002623 *
2624 * <p>This flag is generally used by activities that want
2625 * to present a "launcher" style behavior: they give the user a list of
2626 * separate things that can be done, which otherwise run completely
2627 * independently of the activity launching them.
2628 *
2629 * <p>When using this flag, if a task is already running for the activity
2630 * you are now starting, then a new activity will not be started; instead,
2631 * the current task will simply be brought to the front of the screen with
2632 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2633 * to disable this behavior.
2634 *
2635 * <p>This flag can not be used when the caller is requesting a result from
2636 * the activity being launched.
2637 */
2638 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2639 /**
2640 * <strong>Do not use this flag unless you are implementing your own
2641 * top-level application launcher.</strong> Used in conjunction with
2642 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2643 * behavior of bringing an existing task to the foreground. When set,
2644 * a new task is <em>always</em> started to host the Activity for the
2645 * Intent, regardless of whether there is already an existing task running
2646 * the same thing.
2647 *
2648 * <p><strong>Because the default system does not include graphical task management,
2649 * you should not use this flag unless you provide some way for a user to
2650 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002651 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002652 * <p>This flag is ignored if
2653 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2654 *
Scott Main7aee61f2011-02-08 11:25:01 -08002655 * <p>See
2656 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2657 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 */
2659 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2660 /**
2661 * If set, and the activity being launched is already running in the
2662 * current task, then instead of launching a new instance of that activity,
2663 * all of the other activities on top of it will be closed and this Intent
2664 * will be delivered to the (now on top) old activity as a new Intent.
2665 *
2666 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2667 * If D calls startActivity() with an Intent that resolves to the component
2668 * of activity B, then C and D will be finished and B receive the given
2669 * Intent, resulting in the stack now being: A, B.
2670 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002671 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002672 * either receive the new intent you are starting here in its
2673 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002674 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002675 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2676 * the same intent, then it will be finished and re-created; for all other
2677 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2678 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679 *
2680 * <p>This launch mode can also be used to good effect in conjunction with
2681 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2682 * of a task, it will bring any currently running instance of that task
2683 * to the foreground, and then clear it to its root state. This is
2684 * especially useful, for example, when launching an activity from the
2685 * notification manager.
2686 *
Scott Main7aee61f2011-02-08 11:25:01 -08002687 * <p>See
2688 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2689 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002690 */
2691 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2692 /**
2693 * If set and this intent is being used to launch a new activity from an
2694 * existing one, then the reply target of the existing activity will be
2695 * transfered to the new activity. This way the new activity can call
2696 * {@link android.app.Activity#setResult} and have that result sent back to
2697 * the reply target of the original activity.
2698 */
2699 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2700 /**
2701 * If set and this intent is being used to launch a new activity from an
2702 * existing one, the current activity will not be counted as the top
2703 * activity for deciding whether the new intent should be delivered to
2704 * the top instead of starting a new one. The previous activity will
2705 * be used as the top, with the assumption being that the current activity
2706 * will finish itself immediately.
2707 */
2708 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2709 /**
2710 * If set, the new activity is not kept in the list of recently launched
2711 * activities.
2712 */
2713 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2714 /**
2715 * This flag is not normally set by application code, but set for you by
2716 * the system as described in the
2717 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2718 * launchMode} documentation for the singleTask mode.
2719 */
2720 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2721 /**
2722 * If set, and this activity is either being started in a new task or
2723 * bringing to the top an existing task, then it will be launched as
2724 * the front door of the task. This will result in the application of
2725 * any affinities needed to have that task in the proper state (either
2726 * moving activities to or from it), or simply resetting that task to
2727 * its initial state if needed.
2728 */
2729 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2730 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002731 * This flag is not normally set by application code, but set for you by
2732 * the system if this activity is being launched from history
2733 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002734 */
2735 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002736 /**
2737 * If set, this marks a point in the task's activity stack that should
2738 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002739 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002740 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2741 * the user re-launching it from home), this activity and all on top of
2742 * it will be finished so that the user does not return to them, but
2743 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002744 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002745 * <p>This is useful for cases where you have a logical break in your
2746 * application. For example, an e-mail application may have a command
2747 * to view an attachment, which launches an image view activity to
2748 * display it. This activity should be part of the e-mail application's
2749 * task, since it is a part of the task the user is involved in. However,
2750 * if the user leaves that task, and later selects the e-mail app from
2751 * home, we may like them to return to the conversation they were
2752 * viewing, not the picture attachment, since that is confusing. By
2753 * setting this flag when launching the image viewer, that viewer and
2754 * any activities it starts will be removed the next time the user returns
2755 * to mail.
2756 */
2757 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002758 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002759 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002760 * callback from occurring on the current frontmost activity before it is
2761 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002762 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002763 * <p>Typically, an activity can rely on that callback to indicate that an
2764 * explicit user action has caused their activity to be moved out of the
2765 * foreground. The callback marks an appropriate point in the activity's
2766 * lifecycle for it to dismiss any notifications that it intends to display
2767 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002768 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002769 * <p>If an activity is ever started via any non-user-driven events such as
2770 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2771 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002772 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002773 */
2774 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002775 /**
2776 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2777 * this flag will cause the launched activity to be brought to the front of its
2778 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002779 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002780 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2781 * If D calls startActivity() with an Intent that resolves to the component
2782 * of activity B, then B will be brought to the front of the history stack,
2783 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002784 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002785 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002786 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002787 */
2788 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002789 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002790 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2791 * this flag will prevent the system from applying an activity transition
2792 * animation to go to the next activity state. This doesn't mean an
2793 * animation will never run -- if another activity change happens that doesn't
2794 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002795 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002796 * when you are going to do a series of activity operations but the
2797 * animation seen by the user shouldn't be driven by the first activity
2798 * change but rather a later one.
2799 */
2800 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2801 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002802 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2803 * this flag will cause any existing task that would be associated with the
2804 * activity to be cleared before the activity is started. That is, the activity
2805 * becomes the new root of an otherwise empty task, and any old activities
2806 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2807 */
2808 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
2809 /**
2810 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2811 * this flag will cause a newly launching task to be placed on top of the current
2812 * home activity task (if there is one). That is, pressing back from the task
2813 * will always return the user to home even if that was not the last activity they
2814 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2815 */
2816 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
2817 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 * If set, when sending a broadcast only registered receivers will be
2819 * called -- no BroadcastReceiver components will be launched.
2820 */
2821 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002822 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002823 * If set, when sending a broadcast the new broadcast will replace
2824 * any existing pending broadcast that matches it. Matching is defined
2825 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2826 * true for the intents of the two broadcasts. When a match is found,
2827 * the new broadcast (and receivers associated with it) will replace the
2828 * existing one in the pending broadcast list, remaining at the same
2829 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002830 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002831 * <p>This flag is most typically used with sticky broadcasts, which
2832 * only care about delivering the most recent values of the broadcast
2833 * to their receivers.
2834 */
2835 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2836 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002837 * If set, when sending a broadcast <i>before boot has completed</i> only
2838 * registered receivers will be called -- no BroadcastReceiver components
2839 * will be launched. Sticky intent state will be recorded properly even
2840 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2841 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002842 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002843 * <p>This flag is only for use by system sevices as a convenience to
2844 * avoid having to implement a more complex mechanism around detection
2845 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002846 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002847 * @hide
2848 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002849 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002850 /**
2851 * Set when this broadcast is for a boot upgrade, a special mode that
2852 * allows the broadcast to be sent before the system is ready and launches
2853 * the app process with no providers running in it.
2854 * @hide
2855 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002856 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002857
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002858 /**
2859 * @hide Flags that can't be changed with PendingIntent.
2860 */
2861 public static final int IMMUTABLE_FLAGS =
2862 FLAG_GRANT_READ_URI_PERMISSION
2863 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002864
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002866 // ---------------------------------------------------------------------
2867 // toUri() and parseUri() options.
2868
2869 /**
2870 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2871 * always has the "intent:" scheme. This syntax can be used when you want
2872 * to later disambiguate between URIs that are intended to describe an
2873 * Intent vs. all others that should be treated as raw URIs. When used
2874 * with {@link #parseUri}, any other scheme will result in a generic
2875 * VIEW action for that raw URI.
2876 */
2877 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002878
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002879 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002880
2881 private String mAction;
2882 private Uri mData;
2883 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002884 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002885 private ComponentName mComponent;
2886 private int mFlags;
2887 private HashSet<String> mCategories;
2888 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002889 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002890
2891 // ---------------------------------------------------------------------
2892
2893 /**
2894 * Create an empty intent.
2895 */
2896 public Intent() {
2897 }
2898
2899 /**
2900 * Copy constructor.
2901 */
2902 public Intent(Intent o) {
2903 this.mAction = o.mAction;
2904 this.mData = o.mData;
2905 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002906 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002907 this.mComponent = o.mComponent;
2908 this.mFlags = o.mFlags;
2909 if (o.mCategories != null) {
2910 this.mCategories = new HashSet<String>(o.mCategories);
2911 }
2912 if (o.mExtras != null) {
2913 this.mExtras = new Bundle(o.mExtras);
2914 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002915 if (o.mSourceBounds != null) {
2916 this.mSourceBounds = new Rect(o.mSourceBounds);
2917 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002918 }
2919
2920 @Override
2921 public Object clone() {
2922 return new Intent(this);
2923 }
2924
2925 private Intent(Intent o, boolean all) {
2926 this.mAction = o.mAction;
2927 this.mData = o.mData;
2928 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002929 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002930 this.mComponent = o.mComponent;
2931 if (o.mCategories != null) {
2932 this.mCategories = new HashSet<String>(o.mCategories);
2933 }
2934 }
2935
2936 /**
2937 * Make a clone of only the parts of the Intent that are relevant for
2938 * filter matching: the action, data, type, component, and categories.
2939 */
2940 public Intent cloneFilter() {
2941 return new Intent(this, false);
2942 }
2943
2944 /**
2945 * Create an intent with a given action. All other fields (data, type,
2946 * class) are null. Note that the action <em>must</em> be in a
2947 * namespace because Intents are used globally in the system -- for
2948 * example the system VIEW action is android.intent.action.VIEW; an
2949 * application's custom action would be something like
2950 * com.google.app.myapp.CUSTOM_ACTION.
2951 *
2952 * @param action The Intent action, such as ACTION_VIEW.
2953 */
2954 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002955 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002956 }
2957
2958 /**
2959 * Create an intent with a given action and for a given data url. Note
2960 * that the action <em>must</em> be in a namespace because Intents are
2961 * used globally in the system -- for example the system VIEW action is
2962 * android.intent.action.VIEW; an application's custom action would be
2963 * something like com.google.app.myapp.CUSTOM_ACTION.
2964 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002965 * <p><em>Note: scheme and host name matching in the Android framework is
2966 * case-sensitive, unlike the formal RFC. As a result,
2967 * you should always ensure that you write your Uri with these elements
2968 * using lower case letters, and normalize any Uris you receive from
2969 * outside of Android to ensure the scheme and host is lower case.</em></p>
2970 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002971 * @param action The Intent action, such as ACTION_VIEW.
2972 * @param uri The Intent data URI.
2973 */
2974 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002975 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002976 mData = uri;
2977 }
2978
2979 /**
2980 * Create an intent for a specific component. All other fields (action, data,
2981 * type, class) are null, though they can be modified later with explicit
2982 * calls. This provides a convenient way to create an intent that is
2983 * intended to execute a hard-coded class name, rather than relying on the
2984 * system to find an appropriate class for you; see {@link #setComponent}
2985 * for more information on the repercussions of this.
2986 *
2987 * @param packageContext A Context of the application package implementing
2988 * this class.
2989 * @param cls The component class that is to be used for the intent.
2990 *
2991 * @see #setClass
2992 * @see #setComponent
2993 * @see #Intent(String, android.net.Uri , Context, Class)
2994 */
2995 public Intent(Context packageContext, Class<?> cls) {
2996 mComponent = new ComponentName(packageContext, cls);
2997 }
2998
2999 /**
3000 * Create an intent for a specific component with a specified action and data.
3001 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
3002 * construct the Intent and then calling {@link #setClass} to set its
3003 * class.
3004 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003005 * <p><em>Note: scheme and host name matching in the Android framework is
3006 * case-sensitive, unlike the formal RFC. As a result,
3007 * you should always ensure that you write your Uri with these elements
3008 * using lower case letters, and normalize any Uris you receive from
3009 * outside of Android to ensure the scheme and host is lower case.</em></p>
3010 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003011 * @param action The Intent action, such as ACTION_VIEW.
3012 * @param uri The Intent data URI.
3013 * @param packageContext A Context of the application package implementing
3014 * this class.
3015 * @param cls The component class that is to be used for the intent.
3016 *
3017 * @see #Intent(String, android.net.Uri)
3018 * @see #Intent(Context, Class)
3019 * @see #setClass
3020 * @see #setComponent
3021 */
3022 public Intent(String action, Uri uri,
3023 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003024 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003025 mData = uri;
3026 mComponent = new ComponentName(packageContext, cls);
3027 }
3028
3029 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003030 * Create an intent to launch the main (root) activity of a task. This
3031 * is the Intent that is started when the application's is launched from
3032 * Home. For anything else that wants to launch an application in the
3033 * same way, it is important that they use an Intent structured the same
3034 * way, and can use this function to ensure this is the case.
3035 *
3036 * <p>The returned Intent has the given Activity component as its explicit
3037 * component, {@link #ACTION_MAIN} as its action, and includes the
3038 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3039 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3040 * to do that through {@link #addFlags(int)} on the returned Intent.
3041 *
3042 * @param mainActivity The main activity component that this Intent will
3043 * launch.
3044 * @return Returns a newly created Intent that can be used to launch the
3045 * activity as a main application entry.
3046 *
3047 * @see #setClass
3048 * @see #setComponent
3049 */
3050 public static Intent makeMainActivity(ComponentName mainActivity) {
3051 Intent intent = new Intent(ACTION_MAIN);
3052 intent.setComponent(mainActivity);
3053 intent.addCategory(CATEGORY_LAUNCHER);
3054 return intent;
3055 }
3056
3057 /**
3058 * Make an Intent that can be used to re-launch an application's task
3059 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
3060 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
3061 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
3062 *
3063 * @param mainActivity The activity component that is the root of the
3064 * task; this is the activity that has been published in the application's
3065 * manifest as the main launcher icon.
3066 *
3067 * @return Returns a newly created Intent that can be used to relaunch the
3068 * activity's task in its root state.
3069 */
3070 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
3071 Intent intent = makeMainActivity(mainActivity);
3072 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
3073 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
3074 return intent;
3075 }
3076
3077 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003078 * Call {@link #parseUri} with 0 flags.
3079 * @deprecated Use {@link #parseUri} instead.
3080 */
3081 @Deprecated
3082 public static Intent getIntent(String uri) throws URISyntaxException {
3083 return parseUri(uri, 0);
3084 }
Tom Taylord4a47292009-12-21 13:59:18 -08003085
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003086 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003087 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003088 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07003089 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003090 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003091 *
3092 * <p>The URI given here must not be relative -- that is, it must include
3093 * the scheme and full path.
3094 *
3095 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003096 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003097 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003098 *
3099 * @return Intent The newly created Intent object.
3100 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003101 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
3102 * it bad (as parsed by the Uri class) or the Intent data within the
3103 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08003104 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003105 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003106 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003107 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003108 int i = 0;
3109 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003110 // Validate intent scheme for if requested.
3111 if ((flags&URI_INTENT_SCHEME) != 0) {
3112 if (!uri.startsWith("intent:")) {
3113 Intent intent = new Intent(ACTION_VIEW);
3114 try {
3115 intent.setData(Uri.parse(uri));
3116 } catch (IllegalArgumentException e) {
3117 throw new URISyntaxException(uri, e.getMessage());
3118 }
3119 return intent;
3120 }
3121 }
Tom Taylord4a47292009-12-21 13:59:18 -08003122
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003123 // simple case
3124 i = uri.lastIndexOf("#");
3125 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
3126
3127 // old format Intent URI
3128 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07003129
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003130 // new format
3131 Intent intent = new Intent(ACTION_VIEW);
3132
3133 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003134 String data = i >= 0 ? uri.substring(0, i) : null;
3135 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003136 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07003137
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003138 // loop over contents of Intent, all name=value;
3139 while (!uri.startsWith("end", i)) {
3140 int eq = uri.indexOf('=', i);
3141 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003142 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003143
3144 // action
3145 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003146 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003147 }
3148
3149 // categories
3150 else if (uri.startsWith("category=", i)) {
3151 intent.addCategory(value);
3152 }
3153
3154 // type
3155 else if (uri.startsWith("type=", i)) {
3156 intent.mType = value;
3157 }
3158
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003159 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003160 else if (uri.startsWith("launchFlags=", i)) {
3161 intent.mFlags = Integer.decode(value).intValue();
3162 }
3163
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003164 // package
3165 else if (uri.startsWith("package=", i)) {
3166 intent.mPackage = value;
3167 }
3168
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003169 // component
3170 else if (uri.startsWith("component=", i)) {
3171 intent.mComponent = ComponentName.unflattenFromString(value);
3172 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003173
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003174 // scheme
3175 else if (uri.startsWith("scheme=", i)) {
3176 scheme = value;
3177 }
3178
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003179 // source bounds
3180 else if (uri.startsWith("sourceBounds=", i)) {
3181 intent.mSourceBounds = Rect.unflattenFromString(value);
3182 }
3183
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003184 // extra
3185 else {
3186 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003187 // create Bundle if it doesn't already exist
3188 if (intent.mExtras == null) intent.mExtras = new Bundle();
3189 Bundle b = intent.mExtras;
3190 // add EXTRA
3191 if (uri.startsWith("S.", i)) b.putString(key, value);
3192 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
3193 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
3194 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
3195 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
3196 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
3197 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
3198 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
3199 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
3200 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
3201 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003202
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003203 // move to the next item
3204 i = semi + 1;
3205 }
3206
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003207 if (data != null) {
3208 if (data.startsWith("intent:")) {
3209 data = data.substring(7);
3210 if (scheme != null) {
3211 data = scheme + ':' + data;
3212 }
3213 }
Tom Taylord4a47292009-12-21 13:59:18 -08003214
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003215 if (data.length() > 0) {
3216 try {
3217 intent.mData = Uri.parse(data);
3218 } catch (IllegalArgumentException e) {
3219 throw new URISyntaxException(uri, e.getMessage());
3220 }
3221 }
3222 }
Tom Taylord4a47292009-12-21 13:59:18 -08003223
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003224 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07003225
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003226 } catch (IndexOutOfBoundsException e) {
3227 throw new URISyntaxException(uri, "illegal Intent URI format", i);
3228 }
3229 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003230
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003231 public static Intent getIntentOld(String uri) throws URISyntaxException {
3232 Intent intent;
3233
3234 int i = uri.lastIndexOf('#');
3235 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003236 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003237 final int intentFragmentStart = i;
3238 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003239
3240 i++;
3241
3242 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003243 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003244 i += 7;
3245 int j = uri.indexOf(')', i);
3246 action = uri.substring(i, j);
3247 i = j + 1;
3248 }
3249
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003250 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003251
3252 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003253 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003254 i += 11;
3255 int j = uri.indexOf(')', i);
3256 while (i < j) {
3257 int sep = uri.indexOf('!', i);
3258 if (sep < 0) sep = j;
3259 if (i < sep) {
3260 intent.addCategory(uri.substring(i, sep));
3261 }
3262 i = sep + 1;
3263 }
3264 i = j + 1;
3265 }
3266
3267 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003268 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003269 i += 5;
3270 int j = uri.indexOf(')', i);
3271 intent.mType = uri.substring(i, j);
3272 i = j + 1;
3273 }
3274
3275 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003276 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003277 i += 12;
3278 int j = uri.indexOf(')', i);
3279 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
3280 i = j + 1;
3281 }
3282
3283 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003284 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003285 i += 10;
3286 int j = uri.indexOf(')', i);
3287 int sep = uri.indexOf('!', i);
3288 if (sep >= 0 && sep < j) {
3289 String pkg = uri.substring(i, sep);
3290 String cls = uri.substring(sep + 1, j);
3291 intent.mComponent = new ComponentName(pkg, cls);
3292 }
3293 i = j + 1;
3294 }
3295
3296 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003297 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003298 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07003299
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003300 final int closeParen = uri.indexOf(')', i);
3301 if (closeParen == -1) throw new URISyntaxException(uri,
3302 "EXTRA missing trailing ')'", i);
3303
3304 while (i < closeParen) {
3305 // fetch the key value
3306 int j = uri.indexOf('=', i);
3307 if (j <= i + 1 || i >= closeParen) {
3308 throw new URISyntaxException(uri, "EXTRA missing '='", i);
3309 }
3310 char type = uri.charAt(i);
3311 i++;
3312 String key = uri.substring(i, j);
3313 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07003314
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003315 // get type-value
3316 j = uri.indexOf('!', i);
3317 if (j == -1 || j >= closeParen) j = closeParen;
3318 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3319 String value = uri.substring(i, j);
3320 i = j;
3321
3322 // create Bundle if it doesn't already exist
3323 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07003324
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003325 // add item to bundle
3326 try {
3327 switch (type) {
3328 case 'S':
3329 intent.mExtras.putString(key, Uri.decode(value));
3330 break;
3331 case 'B':
3332 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
3333 break;
3334 case 'b':
3335 intent.mExtras.putByte(key, Byte.parseByte(value));
3336 break;
3337 case 'c':
3338 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
3339 break;
3340 case 'd':
3341 intent.mExtras.putDouble(key, Double.parseDouble(value));
3342 break;
3343 case 'f':
3344 intent.mExtras.putFloat(key, Float.parseFloat(value));
3345 break;
3346 case 'i':
3347 intent.mExtras.putInt(key, Integer.parseInt(value));
3348 break;
3349 case 'l':
3350 intent.mExtras.putLong(key, Long.parseLong(value));
3351 break;
3352 case 's':
3353 intent.mExtras.putShort(key, Short.parseShort(value));
3354 break;
3355 default:
3356 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3357 }
3358 } catch (NumberFormatException e) {
3359 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3360 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003361
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003362 char ch = uri.charAt(i);
3363 if (ch == ')') break;
3364 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3365 i++;
3366 }
3367 }
3368
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003369 if (isIntentFragment) {
3370 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3371 } else {
3372 intent.mData = Uri.parse(uri);
3373 }
Tom Taylord4a47292009-12-21 13:59:18 -08003374
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003375 if (intent.mAction == null) {
3376 // By default, if no action is specified, then use VIEW.
3377 intent.mAction = ACTION_VIEW;
3378 }
3379
3380 } else {
3381 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3382 }
3383
3384 return intent;
3385 }
3386
3387 /**
3388 * Retrieve the general action to be performed, such as
3389 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3390 * the information in the intent should be interpreted -- most importantly,
3391 * what to do with the data returned by {@link #getData}.
3392 *
3393 * @return The action of this intent or null if none is specified.
3394 *
3395 * @see #setAction
3396 */
3397 public String getAction() {
3398 return mAction;
3399 }
3400
3401 /**
3402 * Retrieve data this intent is operating on. This URI specifies the name
3403 * of the data; often it uses the content: scheme, specifying data in a
3404 * content provider. Other schemes may be handled by specific activities,
3405 * such as http: by the web browser.
3406 *
3407 * @return The URI of the data this intent is targeting or null.
3408 *
3409 * @see #getScheme
3410 * @see #setData
3411 */
3412 public Uri getData() {
3413 return mData;
3414 }
3415
3416 /**
3417 * The same as {@link #getData()}, but returns the URI as an encoded
3418 * String.
3419 */
3420 public String getDataString() {
3421 return mData != null ? mData.toString() : null;
3422 }
3423
3424 /**
3425 * Return the scheme portion of the intent's data. If the data is null or
3426 * does not include a scheme, null is returned. Otherwise, the scheme
3427 * prefix without the final ':' is returned, i.e. "http".
3428 *
3429 * <p>This is the same as calling getData().getScheme() (and checking for
3430 * null data).
3431 *
3432 * @return The scheme of this intent.
3433 *
3434 * @see #getData
3435 */
3436 public String getScheme() {
3437 return mData != null ? mData.getScheme() : null;
3438 }
3439
3440 /**
3441 * Retrieve any explicit MIME type included in the intent. This is usually
3442 * null, as the type is determined by the intent data.
3443 *
3444 * @return If a type was manually set, it is returned; else null is
3445 * returned.
3446 *
3447 * @see #resolveType(ContentResolver)
3448 * @see #setType
3449 */
3450 public String getType() {
3451 return mType;
3452 }
3453
3454 /**
3455 * Return the MIME data type of this intent. If the type field is
3456 * explicitly set, that is simply returned. Otherwise, if the data is set,
3457 * the type of that data is returned. If neither fields are set, a null is
3458 * returned.
3459 *
3460 * @return The MIME type of this intent.
3461 *
3462 * @see #getType
3463 * @see #resolveType(ContentResolver)
3464 */
3465 public String resolveType(Context context) {
3466 return resolveType(context.getContentResolver());
3467 }
3468
3469 /**
3470 * Return the MIME data type of this intent. If the type field is
3471 * explicitly set, that is simply returned. Otherwise, if the data is set,
3472 * the type of that data is returned. If neither fields are set, a null is
3473 * returned.
3474 *
3475 * @param resolver A ContentResolver that can be used to determine the MIME
3476 * type of the intent's data.
3477 *
3478 * @return The MIME type of this intent.
3479 *
3480 * @see #getType
3481 * @see #resolveType(Context)
3482 */
3483 public String resolveType(ContentResolver resolver) {
3484 if (mType != null) {
3485 return mType;
3486 }
3487 if (mData != null) {
3488 if ("content".equals(mData.getScheme())) {
3489 return resolver.getType(mData);
3490 }
3491 }
3492 return null;
3493 }
3494
3495 /**
3496 * Return the MIME data type of this intent, only if it will be needed for
3497 * intent resolution. This is not generally useful for application code;
3498 * it is used by the frameworks for communicating with back-end system
3499 * services.
3500 *
3501 * @param resolver A ContentResolver that can be used to determine the MIME
3502 * type of the intent's data.
3503 *
3504 * @return The MIME type of this intent, or null if it is unknown or not
3505 * needed.
3506 */
3507 public String resolveTypeIfNeeded(ContentResolver resolver) {
3508 if (mComponent != null) {
3509 return mType;
3510 }
3511 return resolveType(resolver);
3512 }
3513
3514 /**
3515 * Check if an category exists in the intent.
3516 *
3517 * @param category The category to check.
3518 *
3519 * @return boolean True if the intent contains the category, else false.
3520 *
3521 * @see #getCategories
3522 * @see #addCategory
3523 */
3524 public boolean hasCategory(String category) {
3525 return mCategories != null && mCategories.contains(category);
3526 }
3527
3528 /**
3529 * Return the set of all categories in the intent. If there are no categories,
3530 * returns NULL.
3531 *
3532 * @return Set The set of categories you can examine. Do not modify!
3533 *
3534 * @see #hasCategory
3535 * @see #addCategory
3536 */
3537 public Set<String> getCategories() {
3538 return mCategories;
3539 }
3540
3541 /**
3542 * Sets the ClassLoader that will be used when unmarshalling
3543 * any Parcelable values from the extras of this Intent.
3544 *
3545 * @param loader a ClassLoader, or null to use the default loader
3546 * at the time of unmarshalling.
3547 */
3548 public void setExtrasClassLoader(ClassLoader loader) {
3549 if (mExtras != null) {
3550 mExtras.setClassLoader(loader);
3551 }
3552 }
3553
3554 /**
3555 * Returns true if an extra value is associated with the given name.
3556 * @param name the extra's name
3557 * @return true if the given extra is present.
3558 */
3559 public boolean hasExtra(String name) {
3560 return mExtras != null && mExtras.containsKey(name);
3561 }
3562
3563 /**
3564 * Returns true if the Intent's extras contain a parcelled file descriptor.
3565 * @return true if the Intent contains a parcelled file descriptor.
3566 */
3567 public boolean hasFileDescriptors() {
3568 return mExtras != null && mExtras.hasFileDescriptors();
3569 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003570
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003571 /**
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 none was found.
3578 *
3579 * @deprecated
3580 * @hide
3581 */
3582 @Deprecated
3583 public Object getExtra(String name) {
3584 return getExtra(name, null);
3585 }
3586
3587 /**
3588 * Retrieve extended data from the intent.
3589 *
3590 * @param name The name of the desired item.
3591 * @param defaultValue the value to be returned if no value of the desired
3592 * type is stored with the given name.
3593 *
3594 * @return the value of an item that previously added with putExtra()
3595 * or the default value if none was found.
3596 *
3597 * @see #putExtra(String, boolean)
3598 */
3599 public boolean getBooleanExtra(String name, boolean defaultValue) {
3600 return mExtras == null ? defaultValue :
3601 mExtras.getBoolean(name, defaultValue);
3602 }
3603
3604 /**
3605 * Retrieve extended data from the intent.
3606 *
3607 * @param name The name of the desired item.
3608 * @param defaultValue the value to be returned if no value of the desired
3609 * type is stored with the given name.
3610 *
3611 * @return the value of an item that previously added with putExtra()
3612 * or the default value if none was found.
3613 *
3614 * @see #putExtra(String, byte)
3615 */
3616 public byte getByteExtra(String name, byte defaultValue) {
3617 return mExtras == null ? defaultValue :
3618 mExtras.getByte(name, defaultValue);
3619 }
3620
3621 /**
3622 * Retrieve extended data from the intent.
3623 *
3624 * @param name The name of the desired item.
3625 * @param defaultValue the value to be returned if no value of the desired
3626 * type is stored with the given name.
3627 *
3628 * @return the value of an item that previously added with putExtra()
3629 * or the default value if none was found.
3630 *
3631 * @see #putExtra(String, short)
3632 */
3633 public short getShortExtra(String name, short defaultValue) {
3634 return mExtras == null ? defaultValue :
3635 mExtras.getShort(name, defaultValue);
3636 }
3637
3638 /**
3639 * Retrieve extended data from the intent.
3640 *
3641 * @param name The name of the desired item.
3642 * @param defaultValue the value to be returned if no value of the desired
3643 * type is stored with the given name.
3644 *
3645 * @return the value of an item that previously added with putExtra()
3646 * or the default value if none was found.
3647 *
3648 * @see #putExtra(String, char)
3649 */
3650 public char getCharExtra(String name, char defaultValue) {
3651 return mExtras == null ? defaultValue :
3652 mExtras.getChar(name, defaultValue);
3653 }
3654
3655 /**
3656 * Retrieve extended data from the intent.
3657 *
3658 * @param name The name of the desired item.
3659 * @param defaultValue the value to be returned if no value of the desired
3660 * type is stored with the given name.
3661 *
3662 * @return the value of an item that previously added with putExtra()
3663 * or the default value if none was found.
3664 *
3665 * @see #putExtra(String, int)
3666 */
3667 public int getIntExtra(String name, int defaultValue) {
3668 return mExtras == null ? defaultValue :
3669 mExtras.getInt(name, defaultValue);
3670 }
3671
3672 /**
3673 * Retrieve extended data from the intent.
3674 *
3675 * @param name The name of the desired item.
3676 * @param defaultValue the value to be returned if no value of the desired
3677 * type is stored with the given name.
3678 *
3679 * @return the value of an item that previously added with putExtra()
3680 * or the default value if none was found.
3681 *
3682 * @see #putExtra(String, long)
3683 */
3684 public long getLongExtra(String name, long defaultValue) {
3685 return mExtras == null ? defaultValue :
3686 mExtras.getLong(name, defaultValue);
3687 }
3688
3689 /**
3690 * Retrieve extended data from the intent.
3691 *
3692 * @param name The name of the desired item.
3693 * @param defaultValue the value to be returned if no value of the desired
3694 * type is stored with the given name.
3695 *
3696 * @return the value of an item that previously added with putExtra(),
3697 * or the default value if no such item is present
3698 *
3699 * @see #putExtra(String, float)
3700 */
3701 public float getFloatExtra(String name, float defaultValue) {
3702 return mExtras == null ? defaultValue :
3703 mExtras.getFloat(name, defaultValue);
3704 }
3705
3706 /**
3707 * Retrieve extended data from the intent.
3708 *
3709 * @param name The name of the desired item.
3710 * @param defaultValue the value to be returned if no value of the desired
3711 * type is stored with the given name.
3712 *
3713 * @return the value of an item that previously added with putExtra()
3714 * or the default value if none was found.
3715 *
3716 * @see #putExtra(String, double)
3717 */
3718 public double getDoubleExtra(String name, double defaultValue) {
3719 return mExtras == null ? defaultValue :
3720 mExtras.getDouble(name, defaultValue);
3721 }
3722
3723 /**
3724 * Retrieve extended data from the intent.
3725 *
3726 * @param name The name of the desired item.
3727 *
3728 * @return the value of an item that previously added with putExtra()
3729 * or null if no String value was found.
3730 *
3731 * @see #putExtra(String, String)
3732 */
3733 public String getStringExtra(String name) {
3734 return mExtras == null ? null : mExtras.getString(name);
3735 }
3736
3737 /**
3738 * Retrieve extended data from the intent.
3739 *
3740 * @param name The name of the desired item.
3741 *
3742 * @return the value of an item that previously added with putExtra()
3743 * or null if no CharSequence value was found.
3744 *
3745 * @see #putExtra(String, CharSequence)
3746 */
3747 public CharSequence getCharSequenceExtra(String name) {
3748 return mExtras == null ? null : mExtras.getCharSequence(name);
3749 }
3750
3751 /**
3752 * Retrieve extended data from the intent.
3753 *
3754 * @param name The name of the desired item.
3755 *
3756 * @return the value of an item that previously added with putExtra()
3757 * or null if no Parcelable value was found.
3758 *
3759 * @see #putExtra(String, Parcelable)
3760 */
3761 public <T extends Parcelable> T getParcelableExtra(String name) {
3762 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3763 }
3764
3765 /**
3766 * Retrieve extended data from the intent.
3767 *
3768 * @param name The name of the desired item.
3769 *
3770 * @return the value of an item that previously added with putExtra()
3771 * or null if no Parcelable[] value was found.
3772 *
3773 * @see #putExtra(String, Parcelable[])
3774 */
3775 public Parcelable[] getParcelableArrayExtra(String name) {
3776 return mExtras == null ? null : mExtras.getParcelableArray(name);
3777 }
3778
3779 /**
3780 * Retrieve extended data from the intent.
3781 *
3782 * @param name The name of the desired item.
3783 *
3784 * @return the value of an item that previously added with putExtra()
3785 * or null if no ArrayList<Parcelable> value was found.
3786 *
3787 * @see #putParcelableArrayListExtra(String, ArrayList)
3788 */
3789 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3790 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3791 }
3792
3793 /**
3794 * Retrieve extended data from the intent.
3795 *
3796 * @param name The name of the desired item.
3797 *
3798 * @return the value of an item that previously added with putExtra()
3799 * or null if no Serializable value was found.
3800 *
3801 * @see #putExtra(String, Serializable)
3802 */
3803 public Serializable getSerializableExtra(String name) {
3804 return mExtras == null ? null : mExtras.getSerializable(name);
3805 }
3806
3807 /**
3808 * Retrieve extended data from the intent.
3809 *
3810 * @param name The name of the desired item.
3811 *
3812 * @return the value of an item that previously added with putExtra()
3813 * or null if no ArrayList<Integer> value was found.
3814 *
3815 * @see #putIntegerArrayListExtra(String, ArrayList)
3816 */
3817 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3818 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3819 }
3820
3821 /**
3822 * Retrieve extended data from the intent.
3823 *
3824 * @param name The name of the desired item.
3825 *
3826 * @return the value of an item that previously added with putExtra()
3827 * or null if no ArrayList<String> value was found.
3828 *
3829 * @see #putStringArrayListExtra(String, ArrayList)
3830 */
3831 public ArrayList<String> getStringArrayListExtra(String name) {
3832 return mExtras == null ? null : mExtras.getStringArrayList(name);
3833 }
3834
3835 /**
3836 * Retrieve extended data from the intent.
3837 *
3838 * @param name The name of the desired item.
3839 *
3840 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003841 * or null if no ArrayList<CharSequence> value was found.
3842 *
3843 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3844 */
3845 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3846 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3847 }
3848
3849 /**
3850 * Retrieve extended data from the intent.
3851 *
3852 * @param name The name of the desired item.
3853 *
3854 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003855 * or null if no boolean array value was found.
3856 *
3857 * @see #putExtra(String, boolean[])
3858 */
3859 public boolean[] getBooleanArrayExtra(String name) {
3860 return mExtras == null ? null : mExtras.getBooleanArray(name);
3861 }
3862
3863 /**
3864 * Retrieve extended data from the intent.
3865 *
3866 * @param name The name of the desired item.
3867 *
3868 * @return the value of an item that previously added with putExtra()
3869 * or null if no byte array value was found.
3870 *
3871 * @see #putExtra(String, byte[])
3872 */
3873 public byte[] getByteArrayExtra(String name) {
3874 return mExtras == null ? null : mExtras.getByteArray(name);
3875 }
3876
3877 /**
3878 * Retrieve extended data from the intent.
3879 *
3880 * @param name The name of the desired item.
3881 *
3882 * @return the value of an item that previously added with putExtra()
3883 * or null if no short array value was found.
3884 *
3885 * @see #putExtra(String, short[])
3886 */
3887 public short[] getShortArrayExtra(String name) {
3888 return mExtras == null ? null : mExtras.getShortArray(name);
3889 }
3890
3891 /**
3892 * Retrieve extended data from the intent.
3893 *
3894 * @param name The name of the desired item.
3895 *
3896 * @return the value of an item that previously added with putExtra()
3897 * or null if no char array value was found.
3898 *
3899 * @see #putExtra(String, char[])
3900 */
3901 public char[] getCharArrayExtra(String name) {
3902 return mExtras == null ? null : mExtras.getCharArray(name);
3903 }
3904
3905 /**
3906 * Retrieve extended data from the intent.
3907 *
3908 * @param name The name of the desired item.
3909 *
3910 * @return the value of an item that previously added with putExtra()
3911 * or null if no int array value was found.
3912 *
3913 * @see #putExtra(String, int[])
3914 */
3915 public int[] getIntArrayExtra(String name) {
3916 return mExtras == null ? null : mExtras.getIntArray(name);
3917 }
3918
3919 /**
3920 * Retrieve extended data from the intent.
3921 *
3922 * @param name The name of the desired item.
3923 *
3924 * @return the value of an item that previously added with putExtra()
3925 * or null if no long array value was found.
3926 *
3927 * @see #putExtra(String, long[])
3928 */
3929 public long[] getLongArrayExtra(String name) {
3930 return mExtras == null ? null : mExtras.getLongArray(name);
3931 }
3932
3933 /**
3934 * Retrieve extended data from the intent.
3935 *
3936 * @param name The name of the desired item.
3937 *
3938 * @return the value of an item that previously added with putExtra()
3939 * or null if no float array value was found.
3940 *
3941 * @see #putExtra(String, float[])
3942 */
3943 public float[] getFloatArrayExtra(String name) {
3944 return mExtras == null ? null : mExtras.getFloatArray(name);
3945 }
3946
3947 /**
3948 * Retrieve extended data from the intent.
3949 *
3950 * @param name The name of the desired item.
3951 *
3952 * @return the value of an item that previously added with putExtra()
3953 * or null if no double array value was found.
3954 *
3955 * @see #putExtra(String, double[])
3956 */
3957 public double[] getDoubleArrayExtra(String name) {
3958 return mExtras == null ? null : mExtras.getDoubleArray(name);
3959 }
3960
3961 /**
3962 * Retrieve extended data from the intent.
3963 *
3964 * @param name The name of the desired item.
3965 *
3966 * @return the value of an item that previously added with putExtra()
3967 * or null if no String array value was found.
3968 *
3969 * @see #putExtra(String, String[])
3970 */
3971 public String[] getStringArrayExtra(String name) {
3972 return mExtras == null ? null : mExtras.getStringArray(name);
3973 }
3974
3975 /**
3976 * Retrieve extended data from the intent.
3977 *
3978 * @param name The name of the desired item.
3979 *
3980 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003981 * or null if no CharSequence array value was found.
3982 *
3983 * @see #putExtra(String, CharSequence[])
3984 */
3985 public CharSequence[] getCharSequenceArrayExtra(String name) {
3986 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3987 }
3988
3989 /**
3990 * Retrieve extended data from the intent.
3991 *
3992 * @param name The name of the desired item.
3993 *
3994 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003995 * or null if no Bundle value was found.
3996 *
3997 * @see #putExtra(String, Bundle)
3998 */
3999 public Bundle getBundleExtra(String name) {
4000 return mExtras == null ? null : mExtras.getBundle(name);
4001 }
4002
4003 /**
4004 * Retrieve extended data from the intent.
4005 *
4006 * @param name The name of the desired item.
4007 *
4008 * @return the value of an item that previously added with putExtra()
4009 * or null if no IBinder value was found.
4010 *
4011 * @see #putExtra(String, IBinder)
4012 *
4013 * @deprecated
4014 * @hide
4015 */
4016 @Deprecated
4017 public IBinder getIBinderExtra(String name) {
4018 return mExtras == null ? null : mExtras.getIBinder(name);
4019 }
4020
4021 /**
4022 * Retrieve extended data from the intent.
4023 *
4024 * @param name The name of the desired item.
4025 * @param defaultValue The default value to return in case no item is
4026 * associated with the key 'name'
4027 *
4028 * @return the value of an item that previously added with putExtra()
4029 * or defaultValue if none was found.
4030 *
4031 * @see #putExtra
4032 *
4033 * @deprecated
4034 * @hide
4035 */
4036 @Deprecated
4037 public Object getExtra(String name, Object defaultValue) {
4038 Object result = defaultValue;
4039 if (mExtras != null) {
4040 Object result2 = mExtras.get(name);
4041 if (result2 != null) {
4042 result = result2;
4043 }
4044 }
4045
4046 return result;
4047 }
4048
4049 /**
4050 * Retrieves a map of extended data from the intent.
4051 *
4052 * @return the map of all extras previously added with putExtra(),
4053 * or null if none have been added.
4054 */
4055 public Bundle getExtras() {
4056 return (mExtras != null)
4057 ? new Bundle(mExtras)
4058 : null;
4059 }
4060
4061 /**
4062 * Retrieve any special flags associated with this intent. You will
4063 * normally just set them with {@link #setFlags} and let the system
4064 * take the appropriate action with them.
4065 *
4066 * @return int The currently set flags.
4067 *
4068 * @see #setFlags
4069 */
4070 public int getFlags() {
4071 return mFlags;
4072 }
4073
Dianne Hackborne7f97212011-02-24 14:40:20 -08004074 /** @hide */
4075 public boolean isExcludingStopped() {
4076 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4077 == FLAG_EXCLUDE_STOPPED_PACKAGES;
4078 }
4079
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004080 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004081 * Retrieve the application package name this Intent is limited to. When
4082 * resolving an Intent, if non-null this limits the resolution to only
4083 * components in the given application package.
4084 *
4085 * @return The name of the application package for the Intent.
4086 *
4087 * @see #resolveActivity
4088 * @see #setPackage
4089 */
4090 public String getPackage() {
4091 return mPackage;
4092 }
4093
4094 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004095 * Retrieve the concrete component associated with the intent. When receiving
4096 * an intent, this is the component that was found to best handle it (that is,
4097 * yourself) and will always be non-null; in all other cases it will be
4098 * null unless explicitly set.
4099 *
4100 * @return The name of the application component to handle the intent.
4101 *
4102 * @see #resolveActivity
4103 * @see #setComponent
4104 */
4105 public ComponentName getComponent() {
4106 return mComponent;
4107 }
4108
4109 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004110 * Get the bounds of the sender of this intent, in screen coordinates. This can be
4111 * used as a hint to the receiver for animations and the like. Null means that there
4112 * is no source bounds.
4113 */
4114 public Rect getSourceBounds() {
4115 return mSourceBounds;
4116 }
4117
4118 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004119 * Return the Activity component that should be used to handle this intent.
4120 * The appropriate component is determined based on the information in the
4121 * intent, evaluated as follows:
4122 *
4123 * <p>If {@link #getComponent} returns an explicit class, that is returned
4124 * without any further consideration.
4125 *
4126 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
4127 * category to be considered.
4128 *
4129 * <p>If {@link #getAction} is non-NULL, the activity must handle this
4130 * action.
4131 *
4132 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
4133 * this type.
4134 *
4135 * <p>If {@link #addCategory} has added any categories, the activity must
4136 * handle ALL of the categories specified.
4137 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004138 * <p>If {@link #getPackage} is non-NULL, only activity components in
4139 * that application package will be considered.
4140 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004141 * <p>If there are no activities that satisfy all of these conditions, a
4142 * null string is returned.
4143 *
4144 * <p>If multiple activities are found to satisfy the intent, the one with
4145 * the highest priority will be used. If there are multiple activities
4146 * with the same priority, the system will either pick the best activity
4147 * based on user preference, or resolve to a system class that will allow
4148 * the user to pick an activity and forward from there.
4149 *
4150 * <p>This method is implemented simply by calling
4151 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
4152 * true.</p>
4153 * <p> This API is called for you as part of starting an activity from an
4154 * intent. You do not normally need to call it yourself.</p>
4155 *
4156 * @param pm The package manager with which to resolve the Intent.
4157 *
4158 * @return Name of the component implementing an activity that can
4159 * display the intent.
4160 *
4161 * @see #setComponent
4162 * @see #getComponent
4163 * @see #resolveActivityInfo
4164 */
4165 public ComponentName resolveActivity(PackageManager pm) {
4166 if (mComponent != null) {
4167 return mComponent;
4168 }
4169
4170 ResolveInfo info = pm.resolveActivity(
4171 this, PackageManager.MATCH_DEFAULT_ONLY);
4172 if (info != null) {
4173 return new ComponentName(
4174 info.activityInfo.applicationInfo.packageName,
4175 info.activityInfo.name);
4176 }
4177
4178 return null;
4179 }
4180
4181 /**
4182 * Resolve the Intent into an {@link ActivityInfo}
4183 * describing the activity that should execute the intent. Resolution
4184 * follows the same rules as described for {@link #resolveActivity}, but
4185 * you get back the completely information about the resolved activity
4186 * instead of just its class name.
4187 *
4188 * @param pm The package manager with which to resolve the Intent.
4189 * @param flags Addition information to retrieve as per
4190 * {@link PackageManager#getActivityInfo(ComponentName, int)
4191 * PackageManager.getActivityInfo()}.
4192 *
4193 * @return PackageManager.ActivityInfo
4194 *
4195 * @see #resolveActivity
4196 */
4197 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
4198 ActivityInfo ai = null;
4199 if (mComponent != null) {
4200 try {
4201 ai = pm.getActivityInfo(mComponent, flags);
4202 } catch (PackageManager.NameNotFoundException e) {
4203 // ignore
4204 }
4205 } else {
4206 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004207 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004208 if (info != null) {
4209 ai = info.activityInfo;
4210 }
4211 }
4212
4213 return ai;
4214 }
4215
4216 /**
4217 * Set the general action to be performed.
4218 *
4219 * @param action An action name, such as ACTION_VIEW. Application-specific
4220 * actions should be prefixed with the vendor's package name.
4221 *
4222 * @return Returns the same Intent object, for chaining multiple calls
4223 * into a single statement.
4224 *
4225 * @see #getAction
4226 */
4227 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004228 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004229 return this;
4230 }
4231
4232 /**
4233 * Set the data this intent is operating on. This method automatically
4234 * clears any type that was previously set by {@link #setType}.
4235 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004236 * <p><em>Note: scheme and host name matching in the Android framework is
4237 * case-sensitive, unlike the formal RFC. As a result,
4238 * you should always ensure that you write your Uri with these elements
4239 * using lower case letters, and normalize any Uris you receive from
4240 * outside of Android to ensure the scheme and host is lower case.</em></p>
4241 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004242 * @param data The URI of the data this intent is now targeting.
4243 *
4244 * @return Returns the same Intent object, for chaining multiple calls
4245 * into a single statement.
4246 *
4247 * @see #getData
4248 * @see #setType
4249 * @see #setDataAndType
4250 */
4251 public Intent setData(Uri data) {
4252 mData = data;
4253 mType = null;
4254 return this;
4255 }
4256
4257 /**
4258 * Set an explicit MIME data type. This is used to create intents that
4259 * only specify a type and not data, for example to indicate the type of
4260 * data to return. This method automatically clears any data that was
4261 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07004262 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004263 * <p><em>Note: MIME type matching in the Android framework is
4264 * case-sensitive, unlike formal RFC MIME types. As a result,
4265 * you should always write your MIME types with lower case letters,
4266 * and any MIME types you receive from outside of Android should be
4267 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004268 *
4269 * @param type The MIME type of the data being handled by this intent.
4270 *
4271 * @return Returns the same Intent object, for chaining multiple calls
4272 * into a single statement.
4273 *
4274 * @see #getType
4275 * @see #setData
4276 * @see #setDataAndType
4277 */
4278 public Intent setType(String type) {
4279 mData = null;
4280 mType = type;
4281 return this;
4282 }
4283
4284 /**
4285 * (Usually optional) Set the data for the intent along with an explicit
4286 * MIME data type. This method should very rarely be used -- it allows you
4287 * to override the MIME type that would ordinarily be inferred from the
4288 * data with your own type given here.
4289 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004290 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
4291 * Android framework is case-sensitive, unlike the formal RFC definitions.
4292 * As a result, you should always write these elements with lower case letters,
4293 * and normalize any MIME types or Uris you receive from
4294 * outside of Android to ensure these elements are lower case before
4295 * supplying them here.</em></p>
4296 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004297 * @param data The URI of the data this intent is now targeting.
4298 * @param type The MIME type of the data being handled by this intent.
4299 *
4300 * @return Returns the same Intent object, for chaining multiple calls
4301 * into a single statement.
4302 *
4303 * @see #setData
4304 * @see #setType
4305 */
4306 public Intent setDataAndType(Uri data, String type) {
4307 mData = data;
4308 mType = type;
4309 return this;
4310 }
4311
4312 /**
4313 * Add a new category to the intent. Categories provide additional detail
4314 * about the action the intent is perform. When resolving an intent, only
4315 * activities that provide <em>all</em> of the requested categories will be
4316 * used.
4317 *
4318 * @param category The desired category. This can be either one of the
4319 * predefined Intent categories, or a custom category in your own
4320 * namespace.
4321 *
4322 * @return Returns the same Intent object, for chaining multiple calls
4323 * into a single statement.
4324 *
4325 * @see #hasCategory
4326 * @see #removeCategory
4327 */
4328 public Intent addCategory(String category) {
4329 if (mCategories == null) {
4330 mCategories = new HashSet<String>();
4331 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08004332 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004333 return this;
4334 }
4335
4336 /**
4337 * Remove an category from an intent.
4338 *
4339 * @param category The category to remove.
4340 *
4341 * @see #addCategory
4342 */
4343 public void removeCategory(String category) {
4344 if (mCategories != null) {
4345 mCategories.remove(category);
4346 if (mCategories.size() == 0) {
4347 mCategories = null;
4348 }
4349 }
4350 }
4351
4352 /**
4353 * Add extended data to the intent. The name must include a package
4354 * prefix, for example the app com.android.contacts would use names
4355 * like "com.android.contacts.ShowAll".
4356 *
4357 * @param name The name of the extra data, with package prefix.
4358 * @param value The boolean 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 #getBooleanExtra(String, boolean)
4366 */
4367 public Intent putExtra(String name, boolean value) {
4368 if (mExtras == null) {
4369 mExtras = new Bundle();
4370 }
4371 mExtras.putBoolean(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 byte 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 #getByteExtra(String, byte)
4389 */
4390 public Intent putExtra(String name, byte value) {
4391 if (mExtras == null) {
4392 mExtras = new Bundle();
4393 }
4394 mExtras.putByte(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 char 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 #getCharExtra(String, char)
4412 */
4413 public Intent putExtra(String name, char value) {
4414 if (mExtras == null) {
4415 mExtras = new Bundle();
4416 }
4417 mExtras.putChar(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 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 #getShortExtra(String, short)
4435 */
4436 public Intent putExtra(String name, short value) {
4437 if (mExtras == null) {
4438 mExtras = new Bundle();
4439 }
4440 mExtras.putShort(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 integer 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 #getIntExtra(String, int)
4458 */
4459 public Intent putExtra(String name, int value) {
4460 if (mExtras == null) {
4461 mExtras = new Bundle();
4462 }
4463 mExtras.putInt(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 long 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 #getLongExtra(String, long)
4481 */
4482 public Intent putExtra(String name, long value) {
4483 if (mExtras == null) {
4484 mExtras = new Bundle();
4485 }
4486 mExtras.putLong(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 float 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 #getFloatExtra(String, float)
4504 */
4505 public Intent putExtra(String name, float value) {
4506 if (mExtras == null) {
4507 mExtras = new Bundle();
4508 }
4509 mExtras.putFloat(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 double 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 #getDoubleExtra(String, double)
4527 */
4528 public Intent putExtra(String name, double value) {
4529 if (mExtras == null) {
4530 mExtras = new Bundle();
4531 }
4532 mExtras.putDouble(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 String 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 #getStringExtra(String)
4550 */
4551 public Intent putExtra(String name, String value) {
4552 if (mExtras == null) {
4553 mExtras = new Bundle();
4554 }
4555 mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
4573 */
4574 public Intent putExtra(String name, CharSequence value) {
4575 if (mExtras == null) {
4576 mExtras = new Bundle();
4577 }
4578 mExtras.putCharSequence(name, value);
4579 return this;
4580 }
4581
4582 /**
4583 * Add extended data to the intent. The name must include a package
4584 * prefix, for example the app com.android.contacts would use names
4585 * like "com.android.contacts.ShowAll".
4586 *
4587 * @param name The name of the extra data, with package prefix.
4588 * @param value The Parcelable 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 #getParcelableExtra(String)
4596 */
4597 public Intent putExtra(String name, Parcelable value) {
4598 if (mExtras == null) {
4599 mExtras = new Bundle();
4600 }
4601 mExtras.putParcelable(name, value);
4602 return this;
4603 }
4604
4605 /**
4606 * Add extended data to the intent. The name must include a package
4607 * prefix, for example the app com.android.contacts would use names
4608 * like "com.android.contacts.ShowAll".
4609 *
4610 * @param name The name of the extra data, with package prefix.
4611 * @param value The Parcelable[] 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 #getParcelableArrayExtra(String)
4619 */
4620 public Intent putExtra(String name, Parcelable[] value) {
4621 if (mExtras == null) {
4622 mExtras = new Bundle();
4623 }
4624 mExtras.putParcelableArray(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 ArrayList<Parcelable> 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 #getParcelableArrayListExtra(String)
4642 */
4643 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4644 if (mExtras == null) {
4645 mExtras = new Bundle();
4646 }
4647 mExtras.putParcelableArrayList(name, value);
4648 return this;
4649 }
4650
4651 /**
4652 * Add extended data to the intent. The name must include a package
4653 * prefix, for example the app com.android.contacts would use names
4654 * like "com.android.contacts.ShowAll".
4655 *
4656 * @param name The name of the extra data, with package prefix.
4657 * @param value The ArrayList<Integer> data value.
4658 *
4659 * @return Returns the same Intent object, for chaining multiple calls
4660 * into a single statement.
4661 *
4662 * @see #putExtras
4663 * @see #removeExtra
4664 * @see #getIntegerArrayListExtra(String)
4665 */
4666 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4667 if (mExtras == null) {
4668 mExtras = new Bundle();
4669 }
4670 mExtras.putIntegerArrayList(name, value);
4671 return this;
4672 }
4673
4674 /**
4675 * Add extended data to the intent. The name must include a package
4676 * prefix, for example the app com.android.contacts would use names
4677 * like "com.android.contacts.ShowAll".
4678 *
4679 * @param name The name of the extra data, with package prefix.
4680 * @param value The ArrayList<String> data value.
4681 *
4682 * @return Returns the same Intent object, for chaining multiple calls
4683 * into a single statement.
4684 *
4685 * @see #putExtras
4686 * @see #removeExtra
4687 * @see #getStringArrayListExtra(String)
4688 */
4689 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4690 if (mExtras == null) {
4691 mExtras = new Bundle();
4692 }
4693 mExtras.putStringArrayList(name, value);
4694 return this;
4695 }
4696
4697 /**
4698 * Add extended data to the intent. The name must include a package
4699 * prefix, for example the app com.android.contacts would use names
4700 * like "com.android.contacts.ShowAll".
4701 *
4702 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004703 * @param value The ArrayList<CharSequence> data value.
4704 *
4705 * @return Returns the same Intent object, for chaining multiple calls
4706 * into a single statement.
4707 *
4708 * @see #putExtras
4709 * @see #removeExtra
4710 * @see #getCharSequenceArrayListExtra(String)
4711 */
4712 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4713 if (mExtras == null) {
4714 mExtras = new Bundle();
4715 }
4716 mExtras.putCharSequenceArrayList(name, value);
4717 return this;
4718 }
4719
4720 /**
4721 * Add extended data to the intent. The name must include a package
4722 * prefix, for example the app com.android.contacts would use names
4723 * like "com.android.contacts.ShowAll".
4724 *
4725 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004726 * @param value The Serializable data value.
4727 *
4728 * @return Returns the same Intent object, for chaining multiple calls
4729 * into a single statement.
4730 *
4731 * @see #putExtras
4732 * @see #removeExtra
4733 * @see #getSerializableExtra(String)
4734 */
4735 public Intent putExtra(String name, Serializable value) {
4736 if (mExtras == null) {
4737 mExtras = new Bundle();
4738 }
4739 mExtras.putSerializable(name, value);
4740 return this;
4741 }
4742
4743 /**
4744 * Add extended data to the intent. The name must include a package
4745 * prefix, for example the app com.android.contacts would use names
4746 * like "com.android.contacts.ShowAll".
4747 *
4748 * @param name The name of the extra data, with package prefix.
4749 * @param value The boolean array data value.
4750 *
4751 * @return Returns the same Intent object, for chaining multiple calls
4752 * into a single statement.
4753 *
4754 * @see #putExtras
4755 * @see #removeExtra
4756 * @see #getBooleanArrayExtra(String)
4757 */
4758 public Intent putExtra(String name, boolean[] value) {
4759 if (mExtras == null) {
4760 mExtras = new Bundle();
4761 }
4762 mExtras.putBooleanArray(name, value);
4763 return this;
4764 }
4765
4766 /**
4767 * Add extended data to the intent. The name must include a package
4768 * prefix, for example the app com.android.contacts would use names
4769 * like "com.android.contacts.ShowAll".
4770 *
4771 * @param name The name of the extra data, with package prefix.
4772 * @param value The byte array data value.
4773 *
4774 * @return Returns the same Intent object, for chaining multiple calls
4775 * into a single statement.
4776 *
4777 * @see #putExtras
4778 * @see #removeExtra
4779 * @see #getByteArrayExtra(String)
4780 */
4781 public Intent putExtra(String name, byte[] value) {
4782 if (mExtras == null) {
4783 mExtras = new Bundle();
4784 }
4785 mExtras.putByteArray(name, value);
4786 return this;
4787 }
4788
4789 /**
4790 * Add extended data to the intent. The name must include a package
4791 * prefix, for example the app com.android.contacts would use names
4792 * like "com.android.contacts.ShowAll".
4793 *
4794 * @param name The name of the extra data, with package prefix.
4795 * @param value The short array data value.
4796 *
4797 * @return Returns the same Intent object, for chaining multiple calls
4798 * into a single statement.
4799 *
4800 * @see #putExtras
4801 * @see #removeExtra
4802 * @see #getShortArrayExtra(String)
4803 */
4804 public Intent putExtra(String name, short[] value) {
4805 if (mExtras == null) {
4806 mExtras = new Bundle();
4807 }
4808 mExtras.putShortArray(name, value);
4809 return this;
4810 }
4811
4812 /**
4813 * Add extended data to the intent. The name must include a package
4814 * prefix, for example the app com.android.contacts would use names
4815 * like "com.android.contacts.ShowAll".
4816 *
4817 * @param name The name of the extra data, with package prefix.
4818 * @param value The char array data value.
4819 *
4820 * @return Returns the same Intent object, for chaining multiple calls
4821 * into a single statement.
4822 *
4823 * @see #putExtras
4824 * @see #removeExtra
4825 * @see #getCharArrayExtra(String)
4826 */
4827 public Intent putExtra(String name, char[] value) {
4828 if (mExtras == null) {
4829 mExtras = new Bundle();
4830 }
4831 mExtras.putCharArray(name, value);
4832 return this;
4833 }
4834
4835 /**
4836 * Add extended data to the intent. The name must include a package
4837 * prefix, for example the app com.android.contacts would use names
4838 * like "com.android.contacts.ShowAll".
4839 *
4840 * @param name The name of the extra data, with package prefix.
4841 * @param value The int array data value.
4842 *
4843 * @return Returns the same Intent object, for chaining multiple calls
4844 * into a single statement.
4845 *
4846 * @see #putExtras
4847 * @see #removeExtra
4848 * @see #getIntArrayExtra(String)
4849 */
4850 public Intent putExtra(String name, int[] value) {
4851 if (mExtras == null) {
4852 mExtras = new Bundle();
4853 }
4854 mExtras.putIntArray(name, value);
4855 return this;
4856 }
4857
4858 /**
4859 * Add extended data to the intent. The name must include a package
4860 * prefix, for example the app com.android.contacts would use names
4861 * like "com.android.contacts.ShowAll".
4862 *
4863 * @param name The name of the extra data, with package prefix.
4864 * @param value The byte array data value.
4865 *
4866 * @return Returns the same Intent object, for chaining multiple calls
4867 * into a single statement.
4868 *
4869 * @see #putExtras
4870 * @see #removeExtra
4871 * @see #getLongArrayExtra(String)
4872 */
4873 public Intent putExtra(String name, long[] value) {
4874 if (mExtras == null) {
4875 mExtras = new Bundle();
4876 }
4877 mExtras.putLongArray(name, value);
4878 return this;
4879 }
4880
4881 /**
4882 * Add extended data to the intent. The name must include a package
4883 * prefix, for example the app com.android.contacts would use names
4884 * like "com.android.contacts.ShowAll".
4885 *
4886 * @param name The name of the extra data, with package prefix.
4887 * @param value The float array data value.
4888 *
4889 * @return Returns the same Intent object, for chaining multiple calls
4890 * into a single statement.
4891 *
4892 * @see #putExtras
4893 * @see #removeExtra
4894 * @see #getFloatArrayExtra(String)
4895 */
4896 public Intent putExtra(String name, float[] value) {
4897 if (mExtras == null) {
4898 mExtras = new Bundle();
4899 }
4900 mExtras.putFloatArray(name, value);
4901 return this;
4902 }
4903
4904 /**
4905 * Add extended data to the intent. The name must include a package
4906 * prefix, for example the app com.android.contacts would use names
4907 * like "com.android.contacts.ShowAll".
4908 *
4909 * @param name The name of the extra data, with package prefix.
4910 * @param value The double array data value.
4911 *
4912 * @return Returns the same Intent object, for chaining multiple calls
4913 * into a single statement.
4914 *
4915 * @see #putExtras
4916 * @see #removeExtra
4917 * @see #getDoubleArrayExtra(String)
4918 */
4919 public Intent putExtra(String name, double[] value) {
4920 if (mExtras == null) {
4921 mExtras = new Bundle();
4922 }
4923 mExtras.putDoubleArray(name, value);
4924 return this;
4925 }
4926
4927 /**
4928 * Add extended data to the intent. The name must include a package
4929 * prefix, for example the app com.android.contacts would use names
4930 * like "com.android.contacts.ShowAll".
4931 *
4932 * @param name The name of the extra data, with package prefix.
4933 * @param value The String array data value.
4934 *
4935 * @return Returns the same Intent object, for chaining multiple calls
4936 * into a single statement.
4937 *
4938 * @see #putExtras
4939 * @see #removeExtra
4940 * @see #getStringArrayExtra(String)
4941 */
4942 public Intent putExtra(String name, String[] value) {
4943 if (mExtras == null) {
4944 mExtras = new Bundle();
4945 }
4946 mExtras.putStringArray(name, value);
4947 return this;
4948 }
4949
4950 /**
4951 * Add extended data to the intent. The name must include a package
4952 * prefix, for example the app com.android.contacts would use names
4953 * like "com.android.contacts.ShowAll".
4954 *
4955 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004956 * @param value The CharSequence array data value.
4957 *
4958 * @return Returns the same Intent object, for chaining multiple calls
4959 * into a single statement.
4960 *
4961 * @see #putExtras
4962 * @see #removeExtra
4963 * @see #getCharSequenceArrayExtra(String)
4964 */
4965 public Intent putExtra(String name, CharSequence[] value) {
4966 if (mExtras == null) {
4967 mExtras = new Bundle();
4968 }
4969 mExtras.putCharSequenceArray(name, value);
4970 return this;
4971 }
4972
4973 /**
4974 * Add extended data to the intent. The name must include a package
4975 * prefix, for example the app com.android.contacts would use names
4976 * like "com.android.contacts.ShowAll".
4977 *
4978 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004979 * @param value The Bundle data value.
4980 *
4981 * @return Returns the same Intent object, for chaining multiple calls
4982 * into a single statement.
4983 *
4984 * @see #putExtras
4985 * @see #removeExtra
4986 * @see #getBundleExtra(String)
4987 */
4988 public Intent putExtra(String name, Bundle value) {
4989 if (mExtras == null) {
4990 mExtras = new Bundle();
4991 }
4992 mExtras.putBundle(name, value);
4993 return this;
4994 }
4995
4996 /**
4997 * Add extended data to the intent. The name must include a package
4998 * prefix, for example the app com.android.contacts would use names
4999 * like "com.android.contacts.ShowAll".
5000 *
5001 * @param name The name of the extra data, with package prefix.
5002 * @param value The IBinder data value.
5003 *
5004 * @return Returns the same Intent object, for chaining multiple calls
5005 * into a single statement.
5006 *
5007 * @see #putExtras
5008 * @see #removeExtra
5009 * @see #getIBinderExtra(String)
5010 *
5011 * @deprecated
5012 * @hide
5013 */
5014 @Deprecated
5015 public Intent putExtra(String name, IBinder value) {
5016 if (mExtras == null) {
5017 mExtras = new Bundle();
5018 }
5019 mExtras.putIBinder(name, value);
5020 return this;
5021 }
5022
5023 /**
5024 * Copy all extras in 'src' in to this intent.
5025 *
5026 * @param src Contains the extras to copy.
5027 *
5028 * @see #putExtra
5029 */
5030 public Intent putExtras(Intent src) {
5031 if (src.mExtras != null) {
5032 if (mExtras == null) {
5033 mExtras = new Bundle(src.mExtras);
5034 } else {
5035 mExtras.putAll(src.mExtras);
5036 }
5037 }
5038 return this;
5039 }
5040
5041 /**
5042 * Add a set of extended data to the intent. The keys must include a package
5043 * prefix, for example the app com.android.contacts would use names
5044 * like "com.android.contacts.ShowAll".
5045 *
5046 * @param extras The Bundle of extras to add to this intent.
5047 *
5048 * @see #putExtra
5049 * @see #removeExtra
5050 */
5051 public Intent putExtras(Bundle extras) {
5052 if (mExtras == null) {
5053 mExtras = new Bundle();
5054 }
5055 mExtras.putAll(extras);
5056 return this;
5057 }
5058
5059 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005060 * Completely replace the extras in the Intent with the extras in the
5061 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07005062 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005063 * @param src The exact extras contained in this Intent are copied
5064 * into the target intent, replacing any that were previously there.
5065 */
5066 public Intent replaceExtras(Intent src) {
5067 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
5068 return this;
5069 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005070
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005071 /**
5072 * Completely replace the extras in the Intent with the given Bundle of
5073 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07005074 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005075 * @param extras The new set of extras in the Intent, or null to erase
5076 * all extras.
5077 */
5078 public Intent replaceExtras(Bundle extras) {
5079 mExtras = extras != null ? new Bundle(extras) : null;
5080 return this;
5081 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005082
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005083 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005084 * Remove extended data from the intent.
5085 *
5086 * @see #putExtra
5087 */
5088 public void removeExtra(String name) {
5089 if (mExtras != null) {
5090 mExtras.remove(name);
5091 if (mExtras.size() == 0) {
5092 mExtras = null;
5093 }
5094 }
5095 }
5096
5097 /**
5098 * Set special flags controlling how this intent is handled. Most values
5099 * here depend on the type of component being executed by the Intent,
5100 * specifically the FLAG_ACTIVITY_* flags are all for use with
5101 * {@link Context#startActivity Context.startActivity()} and the
5102 * FLAG_RECEIVER_* flags are all for use with
5103 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
5104 *
Scott Main7aee61f2011-02-08 11:25:01 -08005105 * <p>See the
5106 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5107 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005108 * the behavior of your application.
5109 *
5110 * @param flags The desired flags.
5111 *
5112 * @return Returns the same Intent object, for chaining multiple calls
5113 * into a single statement.
5114 *
5115 * @see #getFlags
5116 * @see #addFlags
5117 *
5118 * @see #FLAG_GRANT_READ_URI_PERMISSION
5119 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
5120 * @see #FLAG_DEBUG_LOG_RESOLUTION
5121 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005122 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005123 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005124 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005125 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005126 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
5127 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005128 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005129 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5130 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005131 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005132 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005133 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005134 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
5135 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005136 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005137 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005138 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005139 * @see #FLAG_RECEIVER_REGISTERED_ONLY
5140 */
5141 public Intent setFlags(int flags) {
5142 mFlags = flags;
5143 return this;
5144 }
5145
5146 /**
5147 * Add additional flags to the intent (or with existing flags
5148 * value).
5149 *
5150 * @param flags The new flags to set.
5151 *
5152 * @return Returns the same Intent object, for chaining multiple calls
5153 * into a single statement.
5154 *
5155 * @see #setFlags
5156 */
5157 public Intent addFlags(int flags) {
5158 mFlags |= flags;
5159 return this;
5160 }
5161
5162 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005163 * (Usually optional) Set an explicit application package name that limits
5164 * the components this Intent will resolve to. If left to the default
5165 * value of null, all components in all applications will considered.
5166 * If non-null, the Intent can only match the components in the given
5167 * application package.
5168 *
5169 * @param packageName The name of the application package to handle the
5170 * intent, or null to allow any application package.
5171 *
5172 * @return Returns the same Intent object, for chaining multiple calls
5173 * into a single statement.
5174 *
5175 * @see #getPackage
5176 * @see #resolveActivity
5177 */
5178 public Intent setPackage(String packageName) {
5179 mPackage = packageName;
5180 return this;
5181 }
5182
5183 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005184 * (Usually optional) Explicitly set the component to handle the intent.
5185 * If left with the default value of null, the system will determine the
5186 * appropriate class to use based on the other fields (action, data,
5187 * type, categories) in the Intent. If this class is defined, the
5188 * specified class will always be used regardless of the other fields. You
5189 * should only set this value when you know you absolutely want a specific
5190 * class to be used; otherwise it is better to let the system find the
5191 * appropriate class so that you will respect the installed applications
5192 * and user preferences.
5193 *
5194 * @param component The name of the application component to handle the
5195 * intent, or null to let the system find one for you.
5196 *
5197 * @return Returns the same Intent object, for chaining multiple calls
5198 * into a single statement.
5199 *
5200 * @see #setClass
5201 * @see #setClassName(Context, String)
5202 * @see #setClassName(String, String)
5203 * @see #getComponent
5204 * @see #resolveActivity
5205 */
5206 public Intent setComponent(ComponentName component) {
5207 mComponent = component;
5208 return this;
5209 }
5210
5211 /**
5212 * Convenience for calling {@link #setComponent} with an
5213 * explicit class name.
5214 *
5215 * @param packageContext A Context of the application package implementing
5216 * this class.
5217 * @param className The name of a class inside of the application package
5218 * that will be used as the component for this Intent.
5219 *
5220 * @return Returns the same Intent object, for chaining multiple calls
5221 * into a single statement.
5222 *
5223 * @see #setComponent
5224 * @see #setClass
5225 */
5226 public Intent setClassName(Context packageContext, String className) {
5227 mComponent = new ComponentName(packageContext, className);
5228 return this;
5229 }
5230
5231 /**
5232 * Convenience for calling {@link #setComponent} with an
5233 * explicit application package name and class name.
5234 *
5235 * @param packageName The name of the package implementing the desired
5236 * component.
5237 * @param className The name of a class inside of the application package
5238 * that will be used as the component for this Intent.
5239 *
5240 * @return Returns the same Intent object, for chaining multiple calls
5241 * into a single statement.
5242 *
5243 * @see #setComponent
5244 * @see #setClass
5245 */
5246 public Intent setClassName(String packageName, String className) {
5247 mComponent = new ComponentName(packageName, className);
5248 return this;
5249 }
5250
5251 /**
5252 * Convenience for calling {@link #setComponent(ComponentName)} with the
5253 * name returned by a {@link Class} object.
5254 *
5255 * @param packageContext A Context of the application package implementing
5256 * this class.
5257 * @param cls The class name to set, equivalent to
5258 * <code>setClassName(context, cls.getName())</code>.
5259 *
5260 * @return Returns the same Intent object, for chaining multiple calls
5261 * into a single statement.
5262 *
5263 * @see #setComponent
5264 */
5265 public Intent setClass(Context packageContext, Class<?> cls) {
5266 mComponent = new ComponentName(packageContext, cls);
5267 return this;
5268 }
5269
5270 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005271 * Set the bounds of the sender of this intent, in screen coordinates. This can be
5272 * used as a hint to the receiver for animations and the like. Null means that there
5273 * is no source bounds.
5274 */
5275 public void setSourceBounds(Rect r) {
5276 if (r != null) {
5277 mSourceBounds = new Rect(r);
5278 } else {
5279 r = null;
5280 }
5281 }
5282
5283 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005284 * Use with {@link #fillIn} to allow the current action value to be
5285 * overwritten, even if it is already set.
5286 */
5287 public static final int FILL_IN_ACTION = 1<<0;
5288
5289 /**
5290 * Use with {@link #fillIn} to allow the current data or type value
5291 * overwritten, even if it is already set.
5292 */
5293 public static final int FILL_IN_DATA = 1<<1;
5294
5295 /**
5296 * Use with {@link #fillIn} to allow the current categories to be
5297 * overwritten, even if they are already set.
5298 */
5299 public static final int FILL_IN_CATEGORIES = 1<<2;
5300
5301 /**
5302 * Use with {@link #fillIn} to allow the current component value to be
5303 * overwritten, even if it is already set.
5304 */
5305 public static final int FILL_IN_COMPONENT = 1<<3;
5306
5307 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005308 * Use with {@link #fillIn} to allow the current package value to be
5309 * overwritten, even if it is already set.
5310 */
5311 public static final int FILL_IN_PACKAGE = 1<<4;
5312
5313 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005314 * Use with {@link #fillIn} to allow the current package value to be
5315 * overwritten, even if it is already set.
5316 */
5317 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
5318
5319 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005320 * Copy the contents of <var>other</var> in to this object, but only
5321 * where fields are not defined by this object. For purposes of a field
5322 * being defined, the following pieces of data in the Intent are
5323 * considered to be separate fields:
5324 *
5325 * <ul>
5326 * <li> action, as set by {@link #setAction}.
5327 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
5328 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
5329 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005330 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005331 * <li> component, as set by {@link #setComponent(ComponentName)} or
5332 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005333 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005334 * <li> each top-level name in the associated extras.
5335 * </ul>
5336 *
5337 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005338 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5339 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005340 * corresponding field will not be replaced if it is already set.
5341 *
Brett Chabot3e391752009-07-21 16:07:23 -07005342 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
5343 * specified.
5344 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005345 * <p>For example, consider Intent A with {data="foo", categories="bar"}
5346 * and Intent B with {action="gotit", data-type="some/thing",
5347 * categories="one","two"}.
5348 *
5349 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
5350 * containing: {action="gotit", data-type="some/thing",
5351 * categories="bar"}.
5352 *
5353 * @param other Another Intent whose values are to be used to fill in
5354 * the current one.
5355 * @param flags Options to control which fields can be filled in.
5356 *
5357 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005358 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5359 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005360 */
5361 public int fillIn(Intent other, int flags) {
5362 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005363 if (other.mAction != null
5364 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005365 mAction = other.mAction;
5366 changes |= FILL_IN_ACTION;
5367 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005368 if ((other.mData != null || other.mType != null)
5369 && ((mData == null && mType == null)
5370 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005371 mData = other.mData;
5372 mType = other.mType;
5373 changes |= FILL_IN_DATA;
5374 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005375 if (other.mCategories != null
5376 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005377 if (other.mCategories != null) {
5378 mCategories = new HashSet<String>(other.mCategories);
5379 }
5380 changes |= FILL_IN_CATEGORIES;
5381 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005382 if (other.mPackage != null
5383 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5384 mPackage = other.mPackage;
5385 changes |= FILL_IN_PACKAGE;
5386 }
5387 // Component is special: it can -only- be set if explicitly allowed,
5388 // since otherwise the sender could force the intent somewhere the
5389 // originator didn't intend.
5390 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005391 mComponent = other.mComponent;
5392 changes |= FILL_IN_COMPONENT;
5393 }
5394 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005395 if (other.mSourceBounds != null
5396 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5397 mSourceBounds = new Rect(other.mSourceBounds);
5398 changes |= FILL_IN_SOURCE_BOUNDS;
5399 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005400 if (mExtras == null) {
5401 if (other.mExtras != null) {
5402 mExtras = new Bundle(other.mExtras);
5403 }
5404 } else if (other.mExtras != null) {
5405 try {
5406 Bundle newb = new Bundle(other.mExtras);
5407 newb.putAll(mExtras);
5408 mExtras = newb;
5409 } catch (RuntimeException e) {
5410 // Modifying the extras can cause us to unparcel the contents
5411 // of the bundle, and if we do this in the system process that
5412 // may fail. We really should handle this (i.e., the Bundle
5413 // impl shouldn't be on top of a plain map), but for now just
5414 // ignore it and keep the original contents. :(
5415 Log.w("Intent", "Failure filling in extras", e);
5416 }
5417 }
5418 return changes;
5419 }
5420
5421 /**
5422 * Wrapper class holding an Intent and implementing comparisons on it for
5423 * the purpose of filtering. The class implements its
5424 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5425 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5426 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5427 * on the wrapped Intent.
5428 */
5429 public static final class FilterComparison {
5430 private final Intent mIntent;
5431 private final int mHashCode;
5432
5433 public FilterComparison(Intent intent) {
5434 mIntent = intent;
5435 mHashCode = intent.filterHashCode();
5436 }
5437
5438 /**
5439 * Return the Intent that this FilterComparison represents.
5440 * @return Returns the Intent held by the FilterComparison. Do
5441 * not modify!
5442 */
5443 public Intent getIntent() {
5444 return mIntent;
5445 }
5446
5447 @Override
5448 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005449 if (obj instanceof FilterComparison) {
5450 Intent other = ((FilterComparison)obj).mIntent;
5451 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005452 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005453 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005454 }
5455
5456 @Override
5457 public int hashCode() {
5458 return mHashCode;
5459 }
5460 }
5461
5462 /**
5463 * Determine if two intents are the same for the purposes of intent
5464 * resolution (filtering). That is, if their action, data, type,
5465 * class, and categories are the same. This does <em>not</em> compare
5466 * any extra data included in the intents.
5467 *
5468 * @param other The other Intent to compare against.
5469 *
5470 * @return Returns true if action, data, type, class, and categories
5471 * are the same.
5472 */
5473 public boolean filterEquals(Intent other) {
5474 if (other == null) {
5475 return false;
5476 }
5477 if (mAction != other.mAction) {
5478 if (mAction != null) {
5479 if (!mAction.equals(other.mAction)) {
5480 return false;
5481 }
5482 } else {
5483 if (!other.mAction.equals(mAction)) {
5484 return false;
5485 }
5486 }
5487 }
5488 if (mData != other.mData) {
5489 if (mData != null) {
5490 if (!mData.equals(other.mData)) {
5491 return false;
5492 }
5493 } else {
5494 if (!other.mData.equals(mData)) {
5495 return false;
5496 }
5497 }
5498 }
5499 if (mType != other.mType) {
5500 if (mType != null) {
5501 if (!mType.equals(other.mType)) {
5502 return false;
5503 }
5504 } else {
5505 if (!other.mType.equals(mType)) {
5506 return false;
5507 }
5508 }
5509 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005510 if (mPackage != other.mPackage) {
5511 if (mPackage != null) {
5512 if (!mPackage.equals(other.mPackage)) {
5513 return false;
5514 }
5515 } else {
5516 if (!other.mPackage.equals(mPackage)) {
5517 return false;
5518 }
5519 }
5520 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005521 if (mComponent != other.mComponent) {
5522 if (mComponent != null) {
5523 if (!mComponent.equals(other.mComponent)) {
5524 return false;
5525 }
5526 } else {
5527 if (!other.mComponent.equals(mComponent)) {
5528 return false;
5529 }
5530 }
5531 }
5532 if (mCategories != other.mCategories) {
5533 if (mCategories != null) {
5534 if (!mCategories.equals(other.mCategories)) {
5535 return false;
5536 }
5537 } else {
5538 if (!other.mCategories.equals(mCategories)) {
5539 return false;
5540 }
5541 }
5542 }
5543
5544 return true;
5545 }
5546
5547 /**
5548 * Generate hash code that matches semantics of filterEquals().
5549 *
5550 * @return Returns the hash value of the action, data, type, class, and
5551 * categories.
5552 *
5553 * @see #filterEquals
5554 */
5555 public int filterHashCode() {
5556 int code = 0;
5557 if (mAction != null) {
5558 code += mAction.hashCode();
5559 }
5560 if (mData != null) {
5561 code += mData.hashCode();
5562 }
5563 if (mType != null) {
5564 code += mType.hashCode();
5565 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005566 if (mPackage != null) {
5567 code += mPackage.hashCode();
5568 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005569 if (mComponent != null) {
5570 code += mComponent.hashCode();
5571 }
5572 if (mCategories != null) {
5573 code += mCategories.hashCode();
5574 }
5575 return code;
5576 }
5577
5578 @Override
5579 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005580 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005581
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005582 b.append("Intent { ");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005583 toShortString(b, true, true, true);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005584 b.append(" }");
5585
5586 return b.toString();
5587 }
5588
5589 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005590 public String toInsecureString() {
5591 StringBuilder b = new StringBuilder(128);
5592
5593 b.append("Intent { ");
5594 toShortString(b, false, true, true);
5595 b.append(" }");
5596
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005597 return b.toString();
5598 }
Romain Guy4969af72009-06-17 10:53:19 -07005599
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005600 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005601 public String toShortString(boolean secure, boolean comp, boolean extras) {
5602 StringBuilder b = new StringBuilder(128);
5603 toShortString(b, secure, comp, extras);
5604 return b.toString();
5605 }
5606
5607 /** @hide */
5608 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005609 boolean first = true;
5610 if (mAction != null) {
5611 b.append("act=").append(mAction);
5612 first = false;
5613 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005614 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005615 if (!first) {
5616 b.append(' ');
5617 }
5618 first = false;
5619 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005620 Iterator<String> i = mCategories.iterator();
5621 boolean didone = false;
5622 while (i.hasNext()) {
5623 if (didone) b.append(",");
5624 didone = true;
5625 b.append(i.next());
5626 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005627 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005629 if (mData != null) {
5630 if (!first) {
5631 b.append(' ');
5632 }
5633 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07005634 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005635 if (secure) {
5636 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07005637 } else {
5638 b.append(mData);
5639 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005640 }
5641 if (mType != null) {
5642 if (!first) {
5643 b.append(' ');
5644 }
5645 first = false;
5646 b.append("typ=").append(mType);
5647 }
5648 if (mFlags != 0) {
5649 if (!first) {
5650 b.append(' ');
5651 }
5652 first = false;
5653 b.append("flg=0x").append(Integer.toHexString(mFlags));
5654 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005655 if (mPackage != null) {
5656 if (!first) {
5657 b.append(' ');
5658 }
5659 first = false;
5660 b.append("pkg=").append(mPackage);
5661 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005662 if (comp && mComponent != null) {
5663 if (!first) {
5664 b.append(' ');
5665 }
5666 first = false;
5667 b.append("cmp=").append(mComponent.flattenToShortString());
5668 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005669 if (mSourceBounds != null) {
5670 if (!first) {
5671 b.append(' ');
5672 }
5673 first = false;
5674 b.append("bnds=").append(mSourceBounds.toShortString());
5675 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005676 if (extras && mExtras != null) {
5677 if (!first) {
5678 b.append(' ');
5679 }
5680 first = false;
5681 b.append("(has extras)");
5682 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005683 }
5684
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005685 /**
5686 * Call {@link #toUri} with 0 flags.
5687 * @deprecated Use {@link #toUri} instead.
5688 */
5689 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005690 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005691 return toUri(0);
5692 }
5693
5694 /**
5695 * Convert this Intent into a String holding a URI representation of it.
5696 * The returned URI string has been properly URI encoded, so it can be
5697 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5698 * Intent's data as the base URI, with an additional fragment describing
5699 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005700 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005701 * <p>You can convert the returned string back to an Intent with
5702 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005703 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005704 * @param flags Additional operating flags. Either 0 or
5705 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005706 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005707 * @return Returns a URI encoding URI string describing the entire contents
5708 * of the Intent.
5709 */
5710 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005711 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005712 String scheme = null;
5713 if (mData != null) {
5714 String data = mData.toString();
5715 if ((flags&URI_INTENT_SCHEME) != 0) {
5716 final int N = data.length();
5717 for (int i=0; i<N; i++) {
5718 char c = data.charAt(i);
5719 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5720 || c == '.' || c == '-') {
5721 continue;
5722 }
5723 if (c == ':' && i > 0) {
5724 // Valid scheme.
5725 scheme = data.substring(0, i);
5726 uri.append("intent:");
5727 data = data.substring(i+1);
5728 break;
5729 }
Tom Taylord4a47292009-12-21 13:59:18 -08005730
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005731 // No scheme.
5732 break;
5733 }
5734 }
5735 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005736
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005737 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5738 uri.append("intent:");
5739 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005740
5741 uri.append("#Intent;");
5742
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005743 if (scheme != null) {
5744 uri.append("scheme=").append(scheme).append(';');
5745 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005746 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005747 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005748 }
5749 if (mCategories != null) {
5750 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005751 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005752 }
5753 }
5754 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005755 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 }
5757 if (mFlags != 0) {
5758 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5759 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005760 if (mPackage != null) {
5761 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5762 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005764 uri.append("component=").append(Uri.encode(
5765 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005766 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005767 if (mSourceBounds != null) {
5768 uri.append("sourceBounds=")
5769 .append(Uri.encode(mSourceBounds.flattenToString()))
5770 .append(';');
5771 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005772 if (mExtras != null) {
5773 for (String key : mExtras.keySet()) {
5774 final Object value = mExtras.get(key);
5775 char entryType =
5776 value instanceof String ? 'S' :
5777 value instanceof Boolean ? 'B' :
5778 value instanceof Byte ? 'b' :
5779 value instanceof Character ? 'c' :
5780 value instanceof Double ? 'd' :
5781 value instanceof Float ? 'f' :
5782 value instanceof Integer ? 'i' :
5783 value instanceof Long ? 'l' :
5784 value instanceof Short ? 's' :
5785 '\0';
5786
5787 if (entryType != '\0') {
5788 uri.append(entryType);
5789 uri.append('.');
5790 uri.append(Uri.encode(key));
5791 uri.append('=');
5792 uri.append(Uri.encode(value.toString()));
5793 uri.append(';');
5794 }
5795 }
5796 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005797
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005798 uri.append("end");
5799
5800 return uri.toString();
5801 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005803 public int describeContents() {
5804 return (mExtras != null) ? mExtras.describeContents() : 0;
5805 }
5806
5807 public void writeToParcel(Parcel out, int flags) {
5808 out.writeString(mAction);
5809 Uri.writeToParcel(out, mData);
5810 out.writeString(mType);
5811 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005812 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005813 ComponentName.writeToParcel(mComponent, out);
5814
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005815 if (mSourceBounds != null) {
5816 out.writeInt(1);
5817 mSourceBounds.writeToParcel(out, flags);
5818 } else {
5819 out.writeInt(0);
5820 }
5821
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005822 if (mCategories != null) {
5823 out.writeInt(mCategories.size());
5824 for (String category : mCategories) {
5825 out.writeString(category);
5826 }
5827 } else {
5828 out.writeInt(0);
5829 }
5830
5831 out.writeBundle(mExtras);
5832 }
5833
5834 public static final Parcelable.Creator<Intent> CREATOR
5835 = new Parcelable.Creator<Intent>() {
5836 public Intent createFromParcel(Parcel in) {
5837 return new Intent(in);
5838 }
5839 public Intent[] newArray(int size) {
5840 return new Intent[size];
5841 }
5842 };
5843
Dianne Hackborneb034652009-09-07 00:49:58 -07005844 /** @hide */
5845 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005846 readFromParcel(in);
5847 }
5848
5849 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005850 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005851 mData = Uri.CREATOR.createFromParcel(in);
5852 mType = in.readString();
5853 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005854 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005855 mComponent = ComponentName.readFromParcel(in);
5856
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005857 if (in.readInt() != 0) {
5858 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5859 }
5860
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005861 int N = in.readInt();
5862 if (N > 0) {
5863 mCategories = new HashSet<String>();
5864 int i;
5865 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005866 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005867 }
5868 } else {
5869 mCategories = null;
5870 }
5871
5872 mExtras = in.readBundle();
5873 }
5874
5875 /**
5876 * Parses the "intent" element (and its children) from XML and instantiates
5877 * an Intent object. The given XML parser should be located at the tag
5878 * where parsing should start (often named "intent"), from which the
5879 * basic action, data, type, and package and class name will be
5880 * retrieved. The function will then parse in to any child elements,
5881 * looking for <category android:name="xxx"> tags to add categories and
5882 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5883 * to the intent.
5884 *
5885 * @param resources The Resources to use when inflating resources.
5886 * @param parser The XML parser pointing at an "intent" tag.
5887 * @param attrs The AttributeSet interface for retrieving extended
5888 * attribute data at the current <var>parser</var> location.
5889 * @return An Intent object matching the XML data.
5890 * @throws XmlPullParserException If there was an XML parsing error.
5891 * @throws IOException If there was an I/O error.
5892 */
5893 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5894 throws XmlPullParserException, IOException {
5895 Intent intent = new Intent();
5896
5897 TypedArray sa = resources.obtainAttributes(attrs,
5898 com.android.internal.R.styleable.Intent);
5899
5900 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5901
5902 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5903 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5904 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5905
5906 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5907 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5908 if (packageName != null && className != null) {
5909 intent.setComponent(new ComponentName(packageName, className));
5910 }
5911
5912 sa.recycle();
5913
5914 int outerDepth = parser.getDepth();
5915 int type;
5916 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5917 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5918 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5919 continue;
5920 }
5921
5922 String nodeName = parser.getName();
5923 if (nodeName.equals("category")) {
5924 sa = resources.obtainAttributes(attrs,
5925 com.android.internal.R.styleable.IntentCategory);
5926 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5927 sa.recycle();
5928
5929 if (cat != null) {
5930 intent.addCategory(cat);
5931 }
5932 XmlUtils.skipCurrentTag(parser);
5933
5934 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005935 if (intent.mExtras == null) {
5936 intent.mExtras = new Bundle();
5937 }
5938 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5939 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005940
5941 } else {
5942 XmlUtils.skipCurrentTag(parser);
5943 }
5944 }
5945
5946 return intent;
5947 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948}