blob: 45a42e44f1cd4e680b76374a6f12d63cb5d27418 [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 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070058 * <p>An Intent provides a facility for performing late runtime binding between the code in
59 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070060 * can be thought of as the glue between activities. It is basically a passive data structure
61 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070062 *
63 * <div class="special reference">
64 * <h3>Developer Guides</h3>
65 * <p>For information about how to create and resolve intents, read the
66 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
67 * developer guide.</p>
68 * </div>
69 *
70 * <a name="IntentStructure"></a>
71 * <h3>Intent Structure</h3>
72 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070073 *
74 * <ul>
75 * <li> <p><b>action</b> -- The general action to be performed, such as
76 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
77 * etc.</p>
78 * </li>
79 * <li> <p><b>data</b> -- The data to operate on, such as a person record
80 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
81 * </li>
82 * </ul>
83 *
84 *
85 * <p>Some examples of action/data pairs are:</p>
86 *
87 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070088 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070089 * information about the person whose identifier is "1".</p>
90 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070091 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070092 * the phone dialer with the person filled in.</p>
93 * </li>
94 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
95 * the phone dialer with the given number filled in. Note how the
96 * VIEW action does what what is considered the most reasonable thing for
97 * a particular URI.</p>
98 * </li>
99 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
100 * the phone dialer with the given number filled in.</p>
101 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700102 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700103 * information about the person whose identifier is "1".</p>
104 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700105 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700106 * a list of people, which the user can browse through. This example is a
107 * typical top-level entry into the Contacts application, showing you the
108 * list of people. Selecting a particular person to view would result in a
109 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
110 * being used to start an activity to display that person.</p>
111 * </li>
112 * </ul>
113 *
114 * <p>In addition to these primary attributes, there are a number of secondary
115 * attributes that you can also include with an intent:</p>
116 *
117 * <ul>
118 * <li> <p><b>category</b> -- Gives additional information about the action
119 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
120 * appear in the Launcher as a top-level application, while
121 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
122 * of alternative actions the user can perform on a piece of data.</p>
123 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
124 * intent data. Normally the type is inferred from the data itself.
125 * By setting this attribute, you disable that evaluation and force
126 * an explicit type.</p>
127 * <li> <p><b>component</b> -- Specifies an explicit name of a component
128 * class to use for the intent. Normally this is determined by looking
129 * at the other information in the intent (the action, data/type, and
130 * categories) and matching that with a component that can handle it.
131 * If this attribute is set then none of the evaluation is performed,
132 * and this component is used exactly as is. By specifying this attribute,
133 * all of the other Intent attributes become optional.</p>
134 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
135 * This can be used to provide extended information to the component.
136 * For example, if we have a action to send an e-mail message, we could
137 * also include extra pieces of data here to supply a subject, body,
138 * etc.</p>
139 * </ul>
140 *
141 * <p>Here are some examples of other operations you can specify as intents
142 * using these additional parameters:</p>
143 *
144 * <ul>
145 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
146 * Launch the home screen.</p>
147 * </li>
148 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
149 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
150 * vnd.android.cursor.item/phone}</i></b>
151 * -- Display the list of people's phone numbers, allowing the user to
152 * browse through them and pick one and return it to the parent activity.</p>
153 * </li>
154 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
155 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
156 * -- Display all pickers for data that can be opened with
157 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
158 * allowing the user to pick one of them and then some data inside of it
159 * and returning the resulting URI to the caller. This can be used,
160 * for example, in an e-mail application to allow the user to pick some
161 * data to include as an attachment.</p>
162 * </li>
163 * </ul>
164 *
165 * <p>There are a variety of standard Intent action and category constants
166 * defined in the Intent class, but applications can also define their own.
167 * These strings use java style scoping, to ensure they are unique -- for
168 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700169 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700170 *
171 * <p>Put together, the set of actions, data types, categories, and extra data
172 * defines a language for the system allowing for the expression of phrases
173 * such as "call john smith's cell". As applications are added to the system,
174 * they can extend this language by adding new actions, types, and categories, or
175 * they can modify the behavior of existing phrases by supplying their own
176 * activities that handle them.</p>
177 *
178 * <a name="IntentResolution"></a>
179 * <h3>Intent Resolution</h3>
180 *
181 * <p>There are two primary forms of intents you will use.
182 *
183 * <ul>
184 * <li> <p><b>Explicit Intents</b> have specified a component (via
185 * {@link #setComponent} or {@link #setClass}), which provides the exact
186 * class to be run. Often these will not include any other information,
187 * simply being a way for an application to launch various internal
188 * activities it has as the user interacts with the application.
189 *
190 * <li> <p><b>Implicit Intents</b> have not specified a component;
191 * instead, they must include enough information for the system to
192 * determine which of the available components is best to run for that
193 * intent.
194 * </ul>
195 *
196 * <p>When using implicit intents, given such an arbitrary intent we need to
197 * know what to do with it. This is handled by the process of <em>Intent
198 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
199 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
200 * more activities/receivers) that can handle it.</p>
201 *
202 * <p>The intent resolution mechanism basically revolves around matching an
203 * Intent against all of the &lt;intent-filter&gt; descriptions in the
204 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
205 * objects explicitly registered with {@link Context#registerReceiver}.) More
206 * details on this can be found in the documentation on the {@link
207 * IntentFilter} class.</p>
208 *
209 * <p>There are three pieces of information in the Intent that are used for
210 * resolution: the action, type, and category. Using this information, a query
211 * is done on the {@link PackageManager} for a component that can handle the
212 * intent. The appropriate component is determined based on the intent
213 * information supplied in the <code>AndroidManifest.xml</code> file as
214 * follows:</p>
215 *
216 * <ul>
217 * <li> <p>The <b>action</b>, if given, must be listed by the component as
218 * one it handles.</p>
219 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
220 * already supplied in the Intent. Like the action, if a type is
221 * included in the intent (either explicitly or implicitly in its
222 * data), then this must be listed by the component as one it handles.</p>
223 * <li> For data that is not a <code>content:</code> URI and where no explicit
224 * type is included in the Intent, instead the <b>scheme</b> of the
225 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
226 * considered. Again like the action, if we are matching a scheme it
227 * must be listed by the component as one it can handle.
228 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
229 * by the activity as categories it handles. That is, if you include
230 * the categories {@link #CATEGORY_LAUNCHER} and
231 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
232 * with an intent that lists <em>both</em> of those categories.
233 * Activities will very often need to support the
234 * {@link #CATEGORY_DEFAULT} so that they can be found by
235 * {@link Context#startActivity Context.startActivity()}.</p>
236 * </ul>
237 *
238 * <p>For example, consider the Note Pad sample application that
239 * allows user to browse through a list of notes data and view details about
240 * individual items. Text in italics indicate places were you would replace a
241 * name with one specific to your own package.</p>
242 *
243 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
244 * package="<i>com.android.notepad</i>"&gt;
245 * &lt;application android:icon="@drawable/app_notes"
246 * android:label="@string/app_name"&gt;
247 *
248 * &lt;provider class=".NotePadProvider"
249 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
250 *
251 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
252 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700253 * &lt;action android:name="android.intent.action.MAIN" /&gt;
254 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700255 * &lt;/intent-filter&gt;
256 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700257 * &lt;action android:name="android.intent.action.VIEW" /&gt;
258 * &lt;action android:name="android.intent.action.EDIT" /&gt;
259 * &lt;action android:name="android.intent.action.PICK" /&gt;
260 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
261 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700262 * &lt;/intent-filter&gt;
263 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700264 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
265 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
266 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700267 * &lt;/intent-filter&gt;
268 * &lt;/activity&gt;
269 *
270 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
271 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700272 * &lt;action android:name="android.intent.action.VIEW" /&gt;
273 * &lt;action android:name="android.intent.action.EDIT" /&gt;
274 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
275 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700276 * &lt;/intent-filter&gt;
277 *
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.INSERT" /&gt;
280 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
281 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 * &lt;/intent-filter&gt;
283 *
284 * &lt;/activity&gt;
285 *
286 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
287 * android:theme="@android:style/Theme.Dialog"&gt;
288 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
292 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
293 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700294 * &lt;/intent-filter&gt;
295 * &lt;/activity&gt;
296 *
297 * &lt;/application&gt;
298 * &lt;/manifest&gt;</pre>
299 *
300 * <p>The first activity,
301 * <code>com.android.notepad.NotesList</code>, serves as our main
302 * entry into the app. It can do three things as described by its three intent
303 * templates:
304 * <ol>
305 * <li><pre>
306 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700307 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
308 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700309 * &lt;/intent-filter&gt;</pre>
310 * <p>This provides a top-level entry into the NotePad application: the standard
311 * MAIN action is a main entry point (not requiring any other information in
312 * the Intent), and the LAUNCHER category says that this entry point should be
313 * listed in the application launcher.</p>
314 * <li><pre>
315 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700316 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
317 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
318 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
319 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
320 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700321 * &lt;/intent-filter&gt;</pre>
322 * <p>This declares the things that the activity can do on a directory of
323 * notes. The type being supported is given with the &lt;type&gt; tag, where
324 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
325 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
326 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
327 * The activity allows the user to view or edit the directory of data (via
328 * the VIEW and EDIT actions), or to pick a particular note and return it
329 * to the caller (via the PICK action). Note also the DEFAULT category
330 * supplied here: this is <em>required</em> for the
331 * {@link Context#startActivity Context.startActivity} method to resolve your
332 * activity when its component name is not explicitly specified.</p>
333 * <li><pre>
334 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700335 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
336 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
337 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700338 * &lt;/intent-filter&gt;</pre>
339 * <p>This filter describes the ability return to the caller a note selected by
340 * the user without needing to know where it came from. The data type
341 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
342 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
343 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
344 * The GET_CONTENT action is similar to the PICK action, where the activity
345 * will return to its caller a piece of data selected by the user. Here,
346 * however, the caller specifies the type of data they desire instead of
347 * the type of data the user will be picking from.</p>
348 * </ol>
349 *
350 * <p>Given these capabilities, the following intents will resolve to the
351 * NotesList activity:</p>
352 *
353 * <ul>
354 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
355 * activities that can be used as top-level entry points into an
356 * application.</p>
357 * <li> <p><b>{ action=android.app.action.MAIN,
358 * category=android.app.category.LAUNCHER }</b> is the actual intent
359 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700360 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700361 * data=content://com.google.provider.NotePad/notes }</b>
362 * displays a list of all the notes under
363 * "content://com.google.provider.NotePad/notes", which
364 * the user can browse through and see the details on.</p>
365 * <li> <p><b>{ action=android.app.action.PICK
366 * data=content://com.google.provider.NotePad/notes }</b>
367 * provides a list of the notes under
368 * "content://com.google.provider.NotePad/notes", from which
369 * the user can pick a note whose data URL is returned back to the caller.</p>
370 * <li> <p><b>{ action=android.app.action.GET_CONTENT
371 * type=vnd.android.cursor.item/vnd.google.note }</b>
372 * is similar to the pick action, but allows the caller to specify the
373 * kind of data they want back so that the system can find the appropriate
374 * activity to pick something of that data type.</p>
375 * </ul>
376 *
377 * <p>The second activity,
378 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
379 * note entry and allows them to edit it. It can do two things as described
380 * by its two intent templates:
381 * <ol>
382 * <li><pre>
383 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700384 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
385 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
386 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
387 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700388 * &lt;/intent-filter&gt;</pre>
389 * <p>The first, primary, purpose of this activity is to let the user interact
390 * with a single note, as decribed by the MIME type
391 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
392 * either VIEW a note or allow the user to EDIT it. Again we support the
393 * DEFAULT category to allow the activity to be launched without explicitly
394 * specifying its component.</p>
395 * <li><pre>
396 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700397 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
398 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
399 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700400 * &lt;/intent-filter&gt;</pre>
401 * <p>The secondary use of this activity is to insert a new note entry into
402 * an existing directory of notes. This is used when the user creates a new
403 * note: the INSERT action is executed on the directory of notes, causing
404 * this activity to run and have the user create the new note data which
405 * it then adds to the content provider.</p>
406 * </ol>
407 *
408 * <p>Given these capabilities, the following intents will resolve to the
409 * NoteEditor activity:</p>
410 *
411 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700412 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700413 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
414 * shows the user the content of note <var>{ID}</var>.</p>
415 * <li> <p><b>{ action=android.app.action.EDIT
416 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
417 * allows the user to edit the content of note <var>{ID}</var>.</p>
418 * <li> <p><b>{ action=android.app.action.INSERT
419 * data=content://com.google.provider.NotePad/notes }</b>
420 * creates a new, empty note in the notes list at
421 * "content://com.google.provider.NotePad/notes"
422 * and allows the user to edit it. If they keep their changes, the URI
423 * of the newly created note is returned to the caller.</p>
424 * </ul>
425 *
426 * <p>The last activity,
427 * <code>com.android.notepad.TitleEditor</code>, allows the user to
428 * edit the title of a note. This could be implemented as a class that the
429 * application directly invokes (by explicitly setting its component in
430 * the Intent), but here we show a way you can publish alternative
431 * operations on existing data:</p>
432 *
433 * <pre>
434 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700435 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
436 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
437 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
438 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
439 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700440 * &lt;/intent-filter&gt;</pre>
441 *
442 * <p>In the single intent template here, we
443 * have created our own private action called
444 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
445 * edit the title of a note. It must be invoked on a specific note
446 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
447 * view and edit actions, but here displays and edits the title contained
448 * in the note data.
449 *
450 * <p>In addition to supporting the default category as usual, our title editor
451 * also supports two other standard categories: ALTERNATIVE and
452 * SELECTED_ALTERNATIVE. Implementing
453 * these categories allows others to find the special action it provides
454 * without directly knowing about it, through the
455 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
456 * more often to build dynamic menu items with
457 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
458 * template here was also supply an explicit name for the template
459 * (via <code>android:label="@string/resolve_title"</code>) to better control
460 * what the user sees when presented with this activity as an alternative
461 * action to the data they are viewing.
462 *
463 * <p>Given these capabilities, the following intent will resolve to the
464 * TitleEditor activity:</p>
465 *
466 * <ul>
467 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
468 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
469 * displays and allows the user to edit the title associated
470 * with note <var>{ID}</var>.</p>
471 * </ul>
472 *
473 * <h3>Standard Activity Actions</h3>
474 *
475 * <p>These are the current standard actions that Intent defines for launching
476 * activities (usually through {@link Context#startActivity}. The most
477 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
478 * {@link #ACTION_EDIT}.
479 *
480 * <ul>
481 * <li> {@link #ACTION_MAIN}
482 * <li> {@link #ACTION_VIEW}
483 * <li> {@link #ACTION_ATTACH_DATA}
484 * <li> {@link #ACTION_EDIT}
485 * <li> {@link #ACTION_PICK}
486 * <li> {@link #ACTION_CHOOSER}
487 * <li> {@link #ACTION_GET_CONTENT}
488 * <li> {@link #ACTION_DIAL}
489 * <li> {@link #ACTION_CALL}
490 * <li> {@link #ACTION_SEND}
491 * <li> {@link #ACTION_SENDTO}
492 * <li> {@link #ACTION_ANSWER}
493 * <li> {@link #ACTION_INSERT}
494 * <li> {@link #ACTION_DELETE}
495 * <li> {@link #ACTION_RUN}
496 * <li> {@link #ACTION_SYNC}
497 * <li> {@link #ACTION_PICK_ACTIVITY}
498 * <li> {@link #ACTION_SEARCH}
499 * <li> {@link #ACTION_WEB_SEARCH}
500 * <li> {@link #ACTION_FACTORY_TEST}
501 * </ul>
502 *
503 * <h3>Standard Broadcast Actions</h3>
504 *
505 * <p>These are the current standard actions that Intent defines for receiving
506 * broadcasts (usually through {@link Context#registerReceiver} or a
507 * &lt;receiver&gt; tag in a manifest).
508 *
509 * <ul>
510 * <li> {@link #ACTION_TIME_TICK}
511 * <li> {@link #ACTION_TIME_CHANGED}
512 * <li> {@link #ACTION_TIMEZONE_CHANGED}
513 * <li> {@link #ACTION_BOOT_COMPLETED}
514 * <li> {@link #ACTION_PACKAGE_ADDED}
515 * <li> {@link #ACTION_PACKAGE_CHANGED}
516 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800517 * <li> {@link #ACTION_PACKAGE_RESTARTED}
518 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700519 * <li> {@link #ACTION_UID_REMOVED}
520 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700521 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700522 * <li> {@link #ACTION_POWER_DISCONNECTED}
523 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700524 * </ul>
525 *
526 * <h3>Standard Categories</h3>
527 *
528 * <p>These are the current standard categories that can be used to further
529 * clarify an Intent via {@link #addCategory}.
530 *
531 * <ul>
532 * <li> {@link #CATEGORY_DEFAULT}
533 * <li> {@link #CATEGORY_BROWSABLE}
534 * <li> {@link #CATEGORY_TAB}
535 * <li> {@link #CATEGORY_ALTERNATIVE}
536 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
537 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800538 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700539 * <li> {@link #CATEGORY_HOME}
540 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400542 * <li> {@link #CATEGORY_CAR_DOCK}
543 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500544 * <li> {@link #CATEGORY_LE_DESK_DOCK}
545 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200546 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700547 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700548 * </ul>
549 *
550 * <h3>Standard Extra Data</h3>
551 *
552 * <p>These are the current standard fields that can be used as extra data via
553 * {@link #putExtra}.
554 *
555 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800556 * <li> {@link #EXTRA_ALARM_COUNT}
557 * <li> {@link #EXTRA_BCC}
558 * <li> {@link #EXTRA_CC}
559 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
560 * <li> {@link #EXTRA_DATA_REMOVED}
561 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500562 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
563 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800564 * <li> {@link #EXTRA_DOCK_STATE_CAR}
565 * <li> {@link #EXTRA_DOCK_STATE_DESK}
566 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
567 * <li> {@link #EXTRA_DONT_KILL_APP}
568 * <li> {@link #EXTRA_EMAIL}
569 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800571 * <li> {@link #EXTRA_KEY_EVENT}
572 * <li> {@link #EXTRA_PHONE_NUMBER}
573 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
574 * <li> {@link #EXTRA_REPLACING}
575 * <li> {@link #EXTRA_SHORTCUT_ICON}
576 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
577 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700578 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800579 * <li> {@link #EXTRA_SHORTCUT_NAME}
580 * <li> {@link #EXTRA_SUBJECT}
581 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700582 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_TITLE}
584 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700585 * </ul>
586 *
587 * <h3>Flags</h3>
588 *
589 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800590 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
591 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800593public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700594 // ---------------------------------------------------------------------
595 // ---------------------------------------------------------------------
596 // Standard intent activity actions (see action variable).
597
598 /**
599 * Activity Action: Start as a main entry point, does not expect to
600 * receive data.
601 * <p>Input: nothing
602 * <p>Output: nothing
603 */
604 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
605 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800606
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 /**
608 * Activity Action: Display the data to the user. This is the most common
609 * action performed on data -- it is the generic action you can use on
610 * a piece of data to get the most reasonable thing to occur. For example,
611 * when used on a contacts entry it will view the entry; when used on a
612 * mailto: URI it will bring up a compose window filled with the information
613 * supplied by the URI; when used with a tel: URI it will invoke the
614 * dialer.
615 * <p>Input: {@link #getData} is URI from which to retrieve data.
616 * <p>Output: nothing.
617 */
618 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
619 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800620
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 /**
622 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
623 * performed on a piece of data.
624 */
625 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700627 /**
628 * Used to indicate that some piece of data should be attached to some other
629 * place. For example, image data could be attached to a contact. It is up
630 * to the recipient to decide where the data should be attached; the intent
631 * does not specify the ultimate destination.
632 * <p>Input: {@link #getData} is URI of data to be attached.
633 * <p>Output: nothing.
634 */
635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
636 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
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: Provide explicit editable access to the given data.
640 * <p>Input: {@link #getData} is URI of data to be edited.
641 * <p>Output: nothing.
642 */
643 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700646 /**
647 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
648 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
649 * The extras can contain type specific data to pass through to the editing/creating
650 * activity.
651 * <p>Output: The URI of the item that was picked. This must be a content:
652 * URI so that any receiver can access it.
653 */
654 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
655 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700657 /**
658 * Activity Action: Pick an item from the data, returning what was selected.
659 * <p>Input: {@link #getData} is URI containing a directory of data
660 * (vnd.android.cursor.dir/*) from which to pick an item.
661 * <p>Output: The URI of the item that was picked.
662 */
663 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
664 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 /**
667 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800668 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700669 * <p>Output: An Intent representing the shortcut. The intent must contain three
670 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
671 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800672 * (value: ShortcutIconResource).</p>
673 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700674 * @see #EXTRA_SHORTCUT_INTENT
675 * @see #EXTRA_SHORTCUT_NAME
676 * @see #EXTRA_SHORTCUT_ICON
677 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
678 * @see android.content.Intent.ShortcutIconResource
679 */
680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
681 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
682
683 /**
684 * The name of the extra used to define the Intent of a shortcut.
685 *
686 * @see #ACTION_CREATE_SHORTCUT
687 */
688 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
689 /**
690 * The name of the extra used to define the name of a shortcut.
691 *
692 * @see #ACTION_CREATE_SHORTCUT
693 */
694 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
695 /**
696 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
697 *
698 * @see #ACTION_CREATE_SHORTCUT
699 */
700 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
701 /**
702 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
703 *
704 * @see #ACTION_CREATE_SHORTCUT
705 * @see android.content.Intent.ShortcutIconResource
706 */
707 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
708 "android.intent.extra.shortcut.ICON_RESOURCE";
709
710 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800711 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700712 *
713 * @see Intent#ACTION_CREATE_SHORTCUT
714 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
716 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700717 */
718 public static class ShortcutIconResource implements Parcelable {
719 /**
720 * The package name of the application containing the icon.
721 */
722 public String packageName;
723
724 /**
725 * The resource name of the icon, including package, name and type.
726 */
727 public String resourceName;
728
729 /**
730 * Creates a new ShortcutIconResource for the specified context and resource
731 * identifier.
732 *
733 * @param context The context of the application.
734 * @param resourceId The resource idenfitier for the icon.
735 * @return A new ShortcutIconResource with the specified's context package name
736 * and icon resource idenfitier.
737 */
738 public static ShortcutIconResource fromContext(Context context, int resourceId) {
739 ShortcutIconResource icon = new ShortcutIconResource();
740 icon.packageName = context.getPackageName();
741 icon.resourceName = context.getResources().getResourceName(resourceId);
742 return icon;
743 }
744
745 /**
746 * Used to read a ShortcutIconResource from a Parcel.
747 */
748 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
749 new Parcelable.Creator<ShortcutIconResource>() {
750
751 public ShortcutIconResource createFromParcel(Parcel source) {
752 ShortcutIconResource icon = new ShortcutIconResource();
753 icon.packageName = source.readString();
754 icon.resourceName = source.readString();
755 return icon;
756 }
757
758 public ShortcutIconResource[] newArray(int size) {
759 return new ShortcutIconResource[size];
760 }
761 };
762
763 /**
764 * No special parcel contents.
765 */
766 public int describeContents() {
767 return 0;
768 }
769
770 public void writeToParcel(Parcel dest, int flags) {
771 dest.writeString(packageName);
772 dest.writeString(resourceName);
773 }
774
775 @Override
776 public String toString() {
777 return resourceName;
778 }
779 }
780
781 /**
782 * Activity Action: Display an activity chooser, allowing the user to pick
783 * what they want to before proceeding. This can be used as an alternative
784 * to the standard activity picker that is displayed by the system when
785 * you try to start an activity with multiple possible matches, with these
786 * differences in behavior:
787 * <ul>
788 * <li>You can specify the title that will appear in the activity chooser.
789 * <li>The user does not have the option to make one of the matching
790 * activities a preferred activity, and all possible activities will
791 * always be shown even if one of them is currently marked as the
792 * preferred activity.
793 * </ul>
794 * <p>
795 * This action should be used when the user will naturally expect to
796 * select an activity in order to proceed. An example if when not to use
797 * it is when the user clicks on a "mailto:" link. They would naturally
798 * expect to go directly to their mail app, so startActivity() should be
799 * called directly: it will
800 * either launch the current preferred app, or put up a dialog allowing the
801 * user to pick an app to use and optionally marking that as preferred.
802 * <p>
803 * In contrast, if the user is selecting a menu item to send a picture
804 * they are viewing to someone else, there are many different things they
805 * may want to do at this point: send it through e-mail, upload it to a
806 * web service, etc. In this case the CHOOSER action should be used, to
807 * always present to the user a list of the things they can do, with a
808 * nice title given by the caller such as "Send this photo with:".
809 * <p>
810 * As a convenience, an Intent of this form can be created with the
811 * {@link #createChooser} function.
812 * <p>Input: No data should be specified. get*Extra must have
813 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
814 * and can optionally have a {@link #EXTRA_TITLE} field containing the
815 * title text to display in the chooser.
816 * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
817 */
818 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
819 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
820
821 /**
822 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
823 *
824 * @param target The Intent that the user will be selecting an activity
825 * to perform.
826 * @param title Optional title that will be displayed in the chooser.
827 * @return Return a new Intent object that you can hand to
828 * {@link Context#startActivity(Intent) Context.startActivity()} and
829 * related methods.
830 */
831 public static Intent createChooser(Intent target, CharSequence title) {
832 Intent intent = new Intent(ACTION_CHOOSER);
833 intent.putExtra(EXTRA_INTENT, target);
834 if (title != null) {
835 intent.putExtra(EXTRA_TITLE, title);
836 }
837 return intent;
838 }
839 /**
840 * Activity Action: Allow the user to select a particular kind of data and
841 * return it. This is different than {@link #ACTION_PICK} in that here we
842 * just say what kind of data is desired, not a URI of existing data from
843 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
844 * create the data as it runs (for example taking a picture or recording a
845 * sound), let them browser over the web and download the desired data,
846 * etc.
847 * <p>
848 * There are two main ways to use this action: if you want an specific kind
849 * of data, such as a person contact, you set the MIME type to the kind of
850 * data you want and launch it with {@link Context#startActivity(Intent)}.
851 * The system will then launch the best application to select that kind
852 * of data for you.
853 * <p>
854 * You may also be interested in any of a set of types of content the user
855 * can pick. For example, an e-mail application that wants to allow the
856 * user to add an attachment to an e-mail message can use this action to
857 * bring up a list of all of the types of content the user can attach.
858 * <p>
859 * In this case, you should wrap the GET_CONTENT intent with a chooser
860 * (through {@link #createChooser}), which will give the proper interface
861 * for the user to pick how to send your data and allow you to specify
862 * a prompt indicating what they are doing. You will usually specify a
863 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
864 * broad range of content types the user can select from.
865 * <p>
866 * When using such a broad GET_CONTENT action, it is often desireable to
867 * only pick from data that can be represented as a stream. This is
868 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
869 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800870 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
871 * the launched content chooser only return results representing data that
872 * is locally available on the device. For example, if this extra is set
873 * to true then an image picker should not show any pictures that are available
874 * from a remote server but not already on the local device (thus requiring
875 * they be downloaded when opened).
876 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700877 * Input: {@link #getType} is the desired MIME type to retrieve. Note
878 * that no URI is supplied in the intent, as there are no constraints on
879 * where the returned data originally comes from. You may also include the
880 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800881 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
882 * selection to local data.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700883 * <p>
884 * Output: The URI of the item that was picked. This must be a content:
885 * URI so that any receiver can access it.
886 */
887 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
888 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
889 /**
890 * Activity Action: Dial a number as specified by the data. This shows a
891 * UI with the number being dialed, allowing the user to explicitly
892 * initiate the call.
893 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
894 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
895 * number.
896 * <p>Output: nothing.
897 */
898 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
899 public static final String ACTION_DIAL = "android.intent.action.DIAL";
900 /**
901 * Activity Action: Perform a call to someone specified by the data.
902 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
903 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
904 * number.
905 * <p>Output: nothing.
906 *
907 * <p>Note: there will be restrictions on which applications can initiate a
908 * call; most applications should use the {@link #ACTION_DIAL}.
909 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
910 * numbers. Applications can <strong>dial</strong> emergency numbers using
911 * {@link #ACTION_DIAL}, however.
912 */
913 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
914 public static final String ACTION_CALL = "android.intent.action.CALL";
915 /**
916 * Activity Action: Perform a call to an emergency number specified by the
917 * data.
918 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
919 * tel: URI of an explicit phone number.
920 * <p>Output: nothing.
921 * @hide
922 */
923 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
924 /**
925 * Activity action: Perform a call to any number (emergency or not)
926 * specified by the data.
927 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
928 * tel: URI of an explicit phone number.
929 * <p>Output: nothing.
930 * @hide
931 */
932 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
933 /**
934 * Activity Action: Send a message to someone specified by the data.
935 * <p>Input: {@link #getData} is URI describing the target.
936 * <p>Output: nothing.
937 */
938 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
939 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
940 /**
941 * Activity Action: Deliver some data to someone else. Who the data is
942 * being delivered to is not specified; it is up to the receiver of this
943 * action to ask the user where the data should be sent.
944 * <p>
945 * When launching a SEND intent, you should usually wrap it in a chooser
946 * (through {@link #createChooser}), which will give the proper interface
947 * for the user to pick how to send your data and allow you to specify
948 * a prompt indicating what they are doing.
949 * <p>
950 * Input: {@link #getType} is the MIME type of the data being sent.
951 * get*Extra can have either a {@link #EXTRA_TEXT}
952 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
953 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
954 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
955 * if the MIME type is unknown (this will only allow senders that can
956 * handle generic data streams).
957 * <p>
958 * Optional standard extras, which may be interpreted by some recipients as
959 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
960 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
961 * <p>
962 * Output: nothing.
963 */
964 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
965 public static final String ACTION_SEND = "android.intent.action.SEND";
966 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800967 * Activity Action: Deliver multiple data to someone else.
968 * <p>
969 * Like ACTION_SEND, except the data is multiple.
970 * <p>
971 * Input: {@link #getType} is the MIME type of the data being sent.
972 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
973 * #EXTRA_STREAM} field, containing the data to be sent.
974 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +0800975 * Multiple types are supported, and receivers should handle mixed types
976 * whenever possible. The right way for the receiver to check them is to
977 * use the content resolver on each URI. The intent sender should try to
978 * put the most concrete mime type in the intent type, but it can fall
979 * back to {@literal <type>/*} or {@literal *}/* as needed.
980 * <p>
981 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
982 * be image/jpg, but if you are sending image/jpg and image/png, then the
983 * intent's type should be image/*.
984 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +0800985 * Optional standard extras, which may be interpreted by some recipients as
986 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
987 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
988 * <p>
989 * Output: nothing.
990 */
991 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
992 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
993 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700994 * Activity Action: Handle an incoming phone call.
995 * <p>Input: nothing.
996 * <p>Output: nothing.
997 */
998 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
999 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1000 /**
1001 * Activity Action: Insert an empty item into the given container.
1002 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1003 * in which to place the data.
1004 * <p>Output: URI of the new data that was created.
1005 */
1006 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1007 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1008 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001009 * Activity Action: Create a new item in the given container, initializing it
1010 * from the current contents of the clipboard.
1011 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1012 * in which to place the data.
1013 * <p>Output: URI of the new data that was created.
1014 */
1015 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1016 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1017 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 * Activity Action: Delete the given data from its container.
1019 * <p>Input: {@link #getData} is URI of data to be deleted.
1020 * <p>Output: nothing.
1021 */
1022 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1023 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1024 /**
1025 * Activity Action: Run the data, whatever that means.
1026 * <p>Input: ? (Note: this is currently specific to the test harness.)
1027 * <p>Output: nothing.
1028 */
1029 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1030 public static final String ACTION_RUN = "android.intent.action.RUN";
1031 /**
1032 * Activity Action: Perform a data synchronization.
1033 * <p>Input: ?
1034 * <p>Output: ?
1035 */
1036 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1037 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1038 /**
1039 * Activity Action: Pick an activity given an intent, returning the class
1040 * selected.
1041 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1042 * used with {@link PackageManager#queryIntentActivities} to determine the
1043 * set of activities from which to pick.
1044 * <p>Output: Class name of the activity that was selected.
1045 */
1046 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1047 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1048 /**
1049 * Activity Action: Perform a search.
1050 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1051 * is the text to search for. If empty, simply
1052 * enter your search results Activity with the search UI activated.
1053 * <p>Output: nothing.
1054 */
1055 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1056 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1057 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001058 * Activity Action: Start the platform-defined tutorial
1059 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1060 * is the text to search for. If empty, simply
1061 * enter your search results Activity with the search UI activated.
1062 * <p>Output: nothing.
1063 */
1064 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1065 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1066 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001067 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001068 * <p>
1069 * Input: {@link android.app.SearchManager#QUERY
1070 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1071 * a url starts with http or https, the site will be opened. If it is plain
1072 * text, Google search will be applied.
1073 * <p>
1074 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001075 */
1076 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1077 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1078 /**
1079 * Activity Action: List all available applications
1080 * <p>Input: Nothing.
1081 * <p>Output: nothing.
1082 */
1083 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1084 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1085 /**
1086 * Activity Action: Show settings for choosing wallpaper
1087 * <p>Input: Nothing.
1088 * <p>Output: Nothing.
1089 */
1090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1091 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1092
1093 /**
1094 * Activity Action: Show activity for reporting a bug.
1095 * <p>Input: Nothing.
1096 * <p>Output: Nothing.
1097 */
1098 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1099 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1100
1101 /**
1102 * Activity Action: Main entry point for factory tests. Only used when
1103 * the device is booting in factory test node. The implementing package
1104 * must be installed in the system image.
1105 * <p>Input: nothing
1106 * <p>Output: nothing
1107 */
1108 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1109
1110 /**
1111 * Activity Action: The user pressed the "call" button to go to the dialer
1112 * or other appropriate UI for placing a call.
1113 * <p>Input: Nothing.
1114 * <p>Output: Nothing.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1118
1119 /**
1120 * Activity Action: Start Voice Command.
1121 * <p>Input: Nothing.
1122 * <p>Output: Nothing.
1123 */
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001126
1127 /**
1128 * Activity Action: Start action associated with long pressing on the
1129 * search key.
1130 * <p>Input: Nothing.
1131 * <p>Output: Nothing.
1132 */
1133 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1134 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001135
Jacek Surazski86b6c532009-05-13 14:38:28 +02001136 /**
1137 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1138 * This intent is delivered to the package which installed the application, usually
1139 * the Market.
1140 * <p>Input: No data is specified. The bug report is passed in using
1141 * an {@link #EXTRA_BUG_REPORT} field.
1142 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001143 *
1144 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001145 */
1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1147 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001148
1149 /**
1150 * Activity Action: Show power usage information to the user.
1151 * <p>Input: Nothing.
1152 * <p>Output: Nothing.
1153 */
1154 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1155 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001156
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001157 /**
1158 * Activity Action: Setup wizard to launch after a platform update. This
1159 * activity should have a string meta-data field associated with it,
1160 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1161 * the platform for setup. The activity will be launched only if
1162 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1163 * same value.
1164 * <p>Input: Nothing.
1165 * <p>Output: Nothing.
1166 * @hide
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001170
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001171 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001172 * Activity Action: Show settings for managing network data usage of a
1173 * specific application. Applications should define an activity that offers
1174 * options to control data usage.
1175 */
1176 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1177 public static final String ACTION_MANAGE_NETWORK_USAGE =
1178 "android.intent.action.MANAGE_NETWORK_USAGE";
1179
1180 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001181 * Activity Action: Launch application installer.
1182 * <p>
1183 * Input: The data must be a content: or file: URI at which the application
1184 * can be retrieved. You can optionally supply
1185 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1186 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1187 * <p>
1188 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1189 * succeeded.
1190 *
1191 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1192 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1193 * @see #EXTRA_RETURN_RESULT
1194 */
1195 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1196 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1197
1198 /**
1199 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1200 * package. Specifies the installer package name; this package will receive the
1201 * {@link #ACTION_APP_ERROR} intent.
1202 */
1203 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1204 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1205
1206 /**
1207 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1208 * package. Specifies that the application being installed should not be
1209 * treated as coming from an unknown source, but as coming from the app
1210 * invoking the Intent. For this to work you must start the installer with
1211 * startActivityForResult().
1212 */
1213 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1214 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1215
1216 /**
1217 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1218 * package. Tells the installer UI to skip the confirmation with the user
1219 * if the .apk is replacing an existing one.
1220 */
1221 public static final String EXTRA_ALLOW_REPLACE
1222 = "android.intent.extra.ALLOW_REPLACE";
1223
1224 /**
1225 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1226 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1227 * return to the application the result code of the install/uninstall. The returned result
1228 * code will be {@link android.app.Activity#RESULT_OK} on success or
1229 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1230 */
1231 public static final String EXTRA_RETURN_RESULT
1232 = "android.intent.extra.RETURN_RESULT";
1233
1234 /**
1235 * Package manager install result code. @hide because result codes are not
1236 * yet ready to be exposed.
1237 */
1238 public static final String EXTRA_INSTALL_RESULT
1239 = "android.intent.extra.INSTALL_RESULT";
1240
1241 /**
1242 * Activity Action: Launch application uninstaller.
1243 * <p>
1244 * Input: The data must be a package: URI whose scheme specific part is
1245 * the package name of the current installed package to be uninstalled.
1246 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1247 * <p>
1248 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1249 * succeeded.
1250 */
1251 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1252 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1253
1254 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001255 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1256 * describing the last run version of the platform that was setup.
1257 * @hide
1258 */
1259 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1260
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001261 // ---------------------------------------------------------------------
1262 // ---------------------------------------------------------------------
1263 // Standard intent broadcast actions (see action variable).
1264
1265 /**
1266 * Broadcast Action: Sent after the screen turns off.
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_OFF = "android.intent.action.SCREEN_OFF";
1273 /**
1274 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001275 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001276 * <p class="note">This is a protected intent that can only be sent
1277 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001278 */
1279 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1280 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001281
1282 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001283 * 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 -07001284 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001285 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001286 * <p class="note">This is a protected intent that can only be sent
1287 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001288 */
1289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001290 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001291
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001292 /**
1293 * Broadcast Action: The current time has changed. Sent every
1294 * minute. You can <em>not</em> receive this through components declared
1295 * in manifests, only by exlicitly registering for it with
1296 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1297 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001298 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001299 * <p class="note">This is a protected intent that can only be sent
1300 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001301 */
1302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1303 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1304 /**
1305 * Broadcast Action: The time was set.
1306 */
1307 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1308 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1309 /**
1310 * Broadcast Action: The date has changed.
1311 */
1312 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1313 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1314 /**
1315 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1316 * <ul>
1317 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1318 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001319 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001320 * <p class="note">This is a protected intent that can only be sent
1321 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001322 */
1323 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1324 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1325 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001326 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1327 * DNS entries should be tossed.
1328 * @hide
1329 */
1330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1331 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1332 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001333 * Alarm Changed Action: This is broadcast when the AlarmClock
1334 * application's alarm is set or unset. It is used by the
1335 * AlarmClock application and the StatusBar service.
1336 * @hide
1337 */
1338 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1339 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1340 /**
1341 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1342 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1343 * @hide
1344 */
1345 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1346 public static final String ACTION_SYNC_STATE_CHANGED
1347 = "android.intent.action.SYNC_STATE_CHANGED";
1348 /**
1349 * Broadcast Action: This is broadcast once, after the system has finished
1350 * booting. It can be used to perform application-specific initialization,
1351 * such as installing alarms. You must hold the
1352 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1353 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001354 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001355 * <p class="note">This is a protected intent that can only be sent
1356 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001357 */
1358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1359 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1360 /**
1361 * Broadcast Action: This is broadcast when a user action should request a
1362 * temporary system dialog to dismiss. Some examples of temporary system
1363 * dialogs are the notification window-shade and the recent tasks dialog.
1364 */
1365 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1366 /**
1367 * Broadcast Action: Trigger the download and eventual installation
1368 * of a package.
1369 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001370 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001371 * <p class="note">This is a protected intent that can only be sent
1372 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001373 *
1374 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001375 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001376 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001377 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1378 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1379 /**
1380 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001381 * device. The data contains the name of the package. Note that the
1382 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001383 * <p>My include the following extras:
1384 * <ul>
1385 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1386 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1387 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1388 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001389 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001390 * <p class="note">This is a protected intent that can only be sent
1391 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001392 */
1393 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1394 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1395 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001396 * Broadcast Action: A new version of an application package has been
1397 * installed, replacing an existing version that was previously installed.
1398 * The data contains the name of the package.
1399 * <p>My include the following extras:
1400 * <ul>
1401 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1402 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001403 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001404 * <p class="note">This is a protected intent that can only be sent
1405 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001406 */
1407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1408 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1409 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001410 * Broadcast Action: A new version of your application has been installed
1411 * over an existing one. This is only sent to the application that was
1412 * replaced. It does not contain any additional data; to receive it, just
1413 * use an intent filter for this action.
1414 *
1415 * <p class="note">This is a protected intent that can only be sent
1416 * by the system.
1417 */
1418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1419 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1420 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001421 * Broadcast Action: An existing application package has been removed from
1422 * the device. The data contains the name of the package. The package
1423 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001424 * <ul>
1425 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1426 * to the package.
1427 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1428 * application -- data and code -- is being removed.
1429 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1430 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1431 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001432 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001433 * <p class="note">This is a protected intent that can only be sent
1434 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001435 */
1436 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1437 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1438 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001439 * Broadcast Action: An existing application package has been completely
1440 * removed from the device. The data contains the name of the package.
1441 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1442 * {@link #EXTRA_DATA_REMOVED} is true and
1443 * {@link #EXTRA_REPLACING} is false of that broadcast.
1444 *
1445 * <ul>
1446 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1447 * to the package.
1448 * </ul>
1449 *
1450 * <p class="note">This is a protected intent that can only be sent
1451 * by the system.
1452 */
1453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1454 public static final String ACTION_PACKAGE_FULLY_REMOVED
1455 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1456 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001457 * Broadcast Action: An existing application package has been changed (e.g.
1458 * a component has been enabled or disabled). The data contains the name of
1459 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001460 * <ul>
1461 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001462 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1463 * of the changed components.
1464 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1465 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001466 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001467 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001468 * <p class="note">This is a protected intent that can only be sent
1469 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001470 */
1471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1472 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1473 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001474 * @hide
1475 * Broadcast Action: Ask system services if there is any reason to
1476 * restart the given package. The data contains the name of the
1477 * package.
1478 * <ul>
1479 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1480 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1481 * </ul>
1482 *
1483 * <p class="note">This is a protected intent that can only be sent
1484 * by the system.
1485 */
1486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1487 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1488 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001489 * Broadcast Action: The user has restarted a package, and all of its
1490 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001491 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001492 * be removed. Note that the restarted package does <em>not</em>
1493 * receive this broadcast.
1494 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001495 * <ul>
1496 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1497 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001498 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001499 * <p class="note">This is a protected intent that can only be sent
1500 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001501 */
1502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1503 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1504 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001505 * Broadcast Action: The user has cleared the data of a package. This should
1506 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001507 * its persistent data is erased and this broadcast sent.
1508 * Note that the cleared package does <em>not</em>
1509 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001510 * <ul>
1511 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1512 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001513 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001514 * <p class="note">This is a protected intent that can only be sent
1515 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001516 */
1517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1518 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1519 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001520 * Broadcast Action: A user ID has been removed from the system. The user
1521 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001522 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001523 * <p class="note">This is a protected intent that can only be sent
1524 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001525 */
1526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1527 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001528
1529 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001530 * Broadcast Action: Sent to the installer package of an application
1531 * when that application is first launched (that is the first time it
1532 * is moved out of the stopped state). The data contains the name of the package.
1533 *
1534 * <p class="note">This is a protected intent that can only be sent
1535 * by the system.
1536 */
1537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1538 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1539
1540 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001541 * Broadcast Action: Sent to the system package verifier when a package
1542 * needs to be verified. The data contains the package URI.
1543 * <p class="note">
1544 * This is a protected intent that can only be sent by the system.
1545 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001546 */
1547 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1548 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1549
1550 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001551 * Broadcast Action: Resources for a set of packages (which were
1552 * previously unavailable) are currently
1553 * available since the media on which they exist is available.
1554 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1555 * list of packages whose availability changed.
1556 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1557 * list of uids of packages whose availability changed.
1558 * Note that the
1559 * packages in this list do <em>not</em> receive this broadcast.
1560 * The specified set of packages are now available on the system.
1561 * <p>Includes the following extras:
1562 * <ul>
1563 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1564 * whose resources(were previously unavailable) are currently available.
1565 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1566 * packages whose resources(were previously unavailable)
1567 * are currently available.
1568 * </ul>
1569 *
1570 * <p class="note">This is a protected intent that can only be sent
1571 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001572 */
1573 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001574 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1575 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001576
1577 /**
1578 * Broadcast Action: Resources for a set of packages are currently
1579 * unavailable since the media on which they exist is unavailable.
1580 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1581 * list of packages whose availability changed.
1582 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1583 * list of uids of packages whose availability changed.
1584 * The specified set of packages can no longer be
1585 * launched and are practically unavailable on the system.
1586 * <p>Inclues the following extras:
1587 * <ul>
1588 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1589 * whose resources are no longer available.
1590 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1591 * whose resources are no longer available.
1592 * </ul>
1593 *
1594 * <p class="note">This is a protected intent that can only be sent
1595 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001596 */
1597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001598 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001599 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001600
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001601 /**
1602 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001603 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001604 */
1605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1606 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1607 /**
1608 * Broadcast Action: The current device {@link android.content.res.Configuration}
1609 * (orientation, locale, etc) has changed. When such a change happens, the
1610 * UIs (view hierarchy) will need to be rebuilt based on this new
1611 * information; for the most part, applications don't need to worry about
1612 * this, because the system will take care of stopping and restarting the
1613 * application to make sure it sees the new changes. Some system code that
1614 * can not be restarted will need to watch for this action and handle it
1615 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001616 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001617 * <p class="note">
1618 * You can <em>not</em> receive this through components declared
1619 * in manifests, only by explicitly registering for it with
1620 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1621 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001622 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001623 * <p class="note">This is a protected intent that can only be sent
1624 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001625 *
1626 * @see android.content.res.Configuration
1627 */
1628 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1629 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1630 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001631 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001632 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001633 * <p class="note">This is a protected intent that can only be sent
1634 * by the system.
1635 */
1636 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1637 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1638 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001639 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1640 * charging state, level, and other information about the battery.
1641 * See {@link android.os.BatteryManager} for documentation on the
1642 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001643 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001644 * <p class="note">
1645 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001646 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001647 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001648 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1649 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1650 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1651 * broadcasts that are sent and can be received through manifest
1652 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001653 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001654 * <p class="note">This is a protected intent that can only be sent
1655 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001656 */
1657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1658 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1659 /**
1660 * Broadcast Action: Indicates low battery condition on the device.
1661 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001662 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001663 * <p class="note">This is a protected intent that can only be sent
1664 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001665 */
1666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1667 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1668 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001669 * Broadcast Action: Indicates the battery is now okay after being low.
1670 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1671 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001672 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001673 * <p class="note">This is a protected intent that can only be sent
1674 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001675 */
1676 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1677 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1678 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001679 * Broadcast Action: External power has been connected to the device.
1680 * This is intended for applications that wish to register specifically to this notification.
1681 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1682 * stay active to receive this notification. This action can be used to implement actions
1683 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001684 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001685 * <p class="note">This is a protected intent that can only be sent
1686 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001687 */
1688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001689 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001690 /**
1691 * Broadcast Action: External power has been removed from the device.
1692 * This is intended for applications that wish to register specifically to this notification.
1693 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1694 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001695 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001696 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001697 * <p class="note">This is a protected intent that can only be sent
1698 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001699 */
1700 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001701 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001702 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001703 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001704 * Broadcast Action: Device is shutting down.
1705 * This is broadcast when the device is being shut down (completely turned
1706 * off, not sleeping). Once the broadcast is complete, the final shutdown
1707 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001708 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001709 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001710 * <p class="note">This is a protected intent that can only be sent
1711 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001712 */
1713 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001714 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001715 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001716 * Activity Action: Start this activity to request system shutdown.
1717 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1718 * to request confirmation from the user before shutting down.
1719 *
1720 * <p class="note">This is a protected intent that can only be sent
1721 * by the system.
1722 *
1723 * {@hide}
1724 */
1725 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1726 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001727 * Broadcast Action: A sticky broadcast that indicates low memory
1728 * condition on the device
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_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1735 /**
1736 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001737 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001738 * <p class="note">This is a protected intent that can only be sent
1739 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001740 */
1741 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1742 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1743 /**
Jake Hambybb371632010-08-23 18:16:48 -07001744 * Broadcast Action: A sticky broadcast that indicates a memory full
1745 * condition on the device. This is intended for activities that want
1746 * to be able to fill the data partition completely, leaving only
1747 * enough free space to prevent system-wide SQLite failures.
1748 *
1749 * <p class="note">This is a protected intent that can only be sent
1750 * by the system.
1751 *
1752 * {@hide}
1753 */
1754 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1755 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1756 /**
1757 * Broadcast Action: Indicates memory full condition on the device
1758 * no longer exists.
1759 *
1760 * <p class="note">This is a protected intent that can only be sent
1761 * by the system.
1762 *
1763 * {@hide}
1764 */
1765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1766 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
1767 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001768 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1769 * and package management should be started.
1770 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1771 * notification.
1772 */
1773 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1774 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1775 /**
1776 * Broadcast Action: The device has entered USB Mass Storage mode.
1777 * This is used mainly for the USB Settings panel.
1778 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1779 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001780 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001781 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001782 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001783 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1784
1785 /**
1786 * Broadcast Action: The device has exited USB Mass Storage mode.
1787 * This is used mainly for the USB Settings panel.
1788 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1789 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001790 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001791 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001792 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001793 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1794
1795 /**
1796 * Broadcast Action: External media has been removed.
1797 * The path to the mount point for the removed media is contained in the Intent.mData field.
1798 */
1799 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1800 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1801
1802 /**
1803 * Broadcast Action: External media is present, but not mounted at its mount point.
1804 * The path to the mount point for the removed media is contained in the Intent.mData field.
1805 */
1806 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1807 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1808
1809 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001810 * Broadcast Action: External media is present, and being disk-checked
1811 * 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 -08001812 */
1813 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1814 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1815
1816 /**
1817 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1818 * 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 -08001819 */
1820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1821 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1822
1823 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001824 * Broadcast Action: External media is present and mounted at its mount point.
1825 * The path to the mount point for the removed media is contained in the Intent.mData field.
1826 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1827 * media was mounted read only.
1828 */
1829 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1830 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1831
1832 /**
1833 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001834 * 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 -07001835 */
1836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1837 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1838
1839 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001840 * Broadcast Action: External media is no longer being shared via USB mass storage.
1841 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1842 *
1843 * @hide
1844 */
1845 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1846
1847 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001848 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1849 * The path to the mount point for the removed media is contained in the Intent.mData field.
1850 */
1851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1852 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1853
1854 /**
1855 * Broadcast Action: External media is present but cannot be mounted.
1856 * The path to the mount point for the removed media is contained in the Intent.mData field.
1857 */
1858 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1859 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1860
1861 /**
1862 * Broadcast Action: User has expressed the desire to remove the external storage media.
1863 * Applications should close all files they have open within the mount point when they receive this intent.
1864 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1865 */
1866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1867 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1868
1869 /**
1870 * Broadcast Action: The media scanner has started scanning a directory.
1871 * The path to the directory being scanned is contained in the Intent.mData field.
1872 */
1873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1874 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1875
1876 /**
1877 * Broadcast Action: The media scanner has finished scanning a directory.
1878 * The path to the scanned directory is contained in the Intent.mData field.
1879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1881 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1882
1883 /**
1884 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1885 * The path to the file is contained in the Intent.mData field.
1886 */
1887 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1888 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1889
1890 /**
1891 * Broadcast Action: The "Media 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_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
1897
1898 /**
1899 * Broadcast Action: The "Camera Button" was pressed. Includes a single
1900 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1901 * caused the broadcast.
1902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
1905
1906 // *** NOTE: @todo(*) The following really should go into a more domain-specific
1907 // location; they are not general-purpose actions.
1908
1909 /**
1910 * Broadcast Action: An GTalk connection has been established.
1911 */
1912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1913 public static final String ACTION_GTALK_SERVICE_CONNECTED =
1914 "android.intent.action.GTALK_CONNECTED";
1915
1916 /**
1917 * Broadcast Action: An GTalk connection has been disconnected.
1918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
1921 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07001922
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001923 /**
1924 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001925 */
1926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1927 public static final String ACTION_INPUT_METHOD_CHANGED =
1928 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001929
1930 /**
1931 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
1932 * more radios have been turned off or on. The intent will have the following extra value:</p>
1933 * <ul>
1934 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
1935 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
1936 * turned off</li>
1937 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001938 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001939 * <p class="note">This is a protected intent that can only be sent
1940 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001941 */
1942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1943 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
1944
1945 /**
1946 * Broadcast Action: Some content providers have parts of their namespace
1947 * where they publish new events or items that the user may be especially
1948 * interested in. For these things, they may broadcast this action when the
1949 * set of interesting items change.
1950 *
1951 * For example, GmailProvider sends this notification when the set of unread
1952 * mail in the inbox changes.
1953 *
1954 * <p>The data of the intent identifies which part of which provider
1955 * changed. When queried through the content resolver, the data URI will
1956 * return the data set in question.
1957 *
1958 * <p>The intent will have the following extra values:
1959 * <ul>
1960 * <li><em>count</em> - The number of items in the data set. This is the
1961 * same as the number of items in the cursor returned by querying the
1962 * data URI. </li>
1963 * </ul>
1964 *
1965 * This intent will be sent at boot (if the count is non-zero) and when the
1966 * data set changes. It is possible for the data set to change without the
1967 * count changing (for example, if a new unread message arrives in the same
1968 * sync operation in which a message is archived). The phone should still
1969 * ring/vibrate/etc as normal in this case.
1970 */
1971 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1972 public static final String ACTION_PROVIDER_CHANGED =
1973 "android.intent.action.PROVIDER_CHANGED";
1974
1975 /**
1976 * Broadcast Action: Wired Headset plugged in or unplugged.
1977 *
1978 * <p>The intent will have the following extra values:
1979 * <ul>
1980 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1981 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08001982 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 * </ul>
1984 * </ul>
1985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1987 public static final String ACTION_HEADSET_PLUG =
1988 "android.intent.action.HEADSET_PLUG";
1989
1990 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05001991 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
1992 *
1993 * <p>The intent will have the following extra values:
1994 * <ul>
1995 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
1996 * <li><em>name</em> - Headset type, human readable string </li>
1997 * </ul>
1998 * </ul>
1999 * @hide
2000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_USB_ANLG_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08002003 "android.intent.action.USB_ANLG_HEADSET_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002004
2005 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07002006 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002007 *
2008 * <p>The intent will have the following extra values:
2009 * <ul>
2010 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2011 * <li><em>name</em> - Headset type, human readable string </li>
2012 * </ul>
2013 * </ul>
2014 * @hide
2015 */
2016 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2017 public static final String ACTION_USB_DGTL_HEADSET_PLUG =
Eric Laurent4d29b2f2010-12-16 09:18:24 -08002018 "android.intent.action.USB_DGTL_HEADSET_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07002019
2020 /**
2021 * Broadcast Action: A HMDI cable was plugged or unplugged
2022 *
2023 * <p>The intent will have the following extra values:
2024 * <ul>
2025 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2026 * <li><em>name</em> - HDMI cable, human readable string </li>
2027 * </ul>
2028 * </ul>
2029 * @hide
2030 */
2031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2032 public static final String ACTION_HDMI_AUDIO_PLUG =
2033 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002034
2035 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002036 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2037 * <ul>
2038 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2039 * </ul>
2040 *
2041 * <p class="note">This is a protected intent that can only be sent
2042 * by the system.
2043 *
2044 * @hide
2045 */
2046 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2048 = "android.intent.action.ADVANCED_SETTINGS";
2049
2050 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002051 * Broadcast Action: An outgoing call is about to be placed.
2052 *
2053 * <p>The Intent will have the following extra value:
2054 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002055 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002056 * the phone number originally intended to be dialed.</li>
2057 * </ul>
2058 * <p>Once the broadcast is finished, the resultData is used as the actual
2059 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002060 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 * outgoing call in turn: for example, a parental control application
2062 * might verify that the user is authorized to place the call at that
2063 * time, then a number-rewriting application might add an area code if
2064 * one was not specified.</p>
2065 * <p>For consistency, any receiver whose purpose is to prohibit phone
2066 * calls should have a priority of 0, to ensure it will see the final
2067 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002068 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002069 * should have a positive priority.
2070 * Negative priorities are reserved for the system for this broadcast;
2071 * using them may cause problems.</p>
2072 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2073 * abort the broadcast.</p>
2074 * <p>Emergency calls cannot be intercepted using this mechanism, and
2075 * other calls cannot be modified to call emergency numbers using this
2076 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07002077 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002078 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2079 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002080 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002081 * <p class="note">This is a protected intent that can only be sent
2082 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002083 */
2084 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2085 public static final String ACTION_NEW_OUTGOING_CALL =
2086 "android.intent.action.NEW_OUTGOING_CALL";
2087
2088 /**
2089 * Broadcast Action: Have the device reboot. This is only for use by
2090 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002091 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002092 * <p class="note">This is a protected intent that can only be sent
2093 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 */
2095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2096 public static final String ACTION_REBOOT =
2097 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098
Wei Huang97ecc9c2009-05-11 17:44:20 -07002099 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002100 * Broadcast Action: A sticky broadcast for changes in the physical
2101 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002102 *
2103 * <p>The intent will have the following extra values:
2104 * <ul>
2105 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002106 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002107 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002108 * <p>This is intended for monitoring the current physical dock state.
2109 * See {@link android.app.UiModeManager} for the normal API dealing with
2110 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002111 */
2112 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2113 public static final String ACTION_DOCK_EVENT =
2114 "android.intent.action.DOCK_EVENT";
2115
2116 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002117 * Broadcast Action: a remote intent is to be broadcasted.
2118 *
2119 * A remote intent is used for remote RPC between devices. The remote intent
2120 * is serialized and sent from one device to another device. The receiving
2121 * device parses the remote intent and broadcasts it. Note that anyone can
2122 * broadcast a remote intent. However, if the intent receiver of the remote intent
2123 * does not trust intent broadcasts from arbitrary intent senders, it should require
2124 * the sender to hold certain permissions so only trusted sender's broadcast will be
2125 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002126 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002127 */
2128 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002129 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002130
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002131 /**
2132 * Broadcast Action: hook for permforming cleanup after a system update.
2133 *
2134 * The broadcast is sent when the system is booting, before the
2135 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2136 * image. A receiver for this should do its work and then disable itself
2137 * so that it does not get run again at the next boot.
2138 * @hide
2139 */
2140 public static final String ACTION_PRE_BOOT_COMPLETED =
2141 "android.intent.action.PRE_BOOT_COMPLETED";
2142
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002143 // ---------------------------------------------------------------------
2144 // ---------------------------------------------------------------------
2145 // Standard intent categories (see addCategory()).
2146
2147 /**
2148 * Set if the activity should be an option for the default action
2149 * (center press) to perform on a piece of data. Setting this will
2150 * hide from the user any activities without it set when performing an
2151 * action on some data. Note that this is normal -not- set in the
2152 * Intent when initiating an action -- it is for use in intent filters
2153 * specified in packages.
2154 */
2155 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2156 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2157 /**
2158 * Activities that can be safely invoked from a browser must support this
2159 * category. For example, if the user is viewing a web page or an e-mail
2160 * and clicks on a link in the text, the Intent generated execute that
2161 * link will require the BROWSABLE category, so that only activities
2162 * supporting this category will be considered as possible actions. By
2163 * supporting this category, you are promising that there is nothing
2164 * damaging (without user intervention) that can happen by invoking any
2165 * matching Intent.
2166 */
2167 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2168 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2169 /**
2170 * Set if the activity should be considered as an alternative action to
2171 * the data the user is currently viewing. See also
2172 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2173 * applies to the selection in a list of items.
2174 *
2175 * <p>Supporting this category means that you would like your activity to be
2176 * displayed in the set of alternative things the user can do, usually as
2177 * part of the current activity's options menu. You will usually want to
2178 * include a specific label in the &lt;intent-filter&gt; of this action
2179 * describing to the user what it does.
2180 *
2181 * <p>The action of IntentFilter with this category is important in that it
2182 * describes the specific action the target will perform. This generally
2183 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2184 * a specific name such as "com.android.camera.action.CROP. Only one
2185 * alternative of any particular action will be shown to the user, so using
2186 * a specific action like this makes sure that your alternative will be
2187 * displayed while also allowing other applications to provide their own
2188 * overrides of that particular action.
2189 */
2190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2191 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2192 /**
2193 * Set if the activity should be considered as an alternative selection
2194 * action to the data the user has currently selected. This is like
2195 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2196 * of items from which the user can select, giving them alternatives to the
2197 * default action that will be performed on it.
2198 */
2199 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2200 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2201 /**
2202 * Intended to be used as a tab inside of an containing TabActivity.
2203 */
2204 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2205 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2206 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002207 * Should be displayed in the top-level launcher.
2208 */
2209 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2210 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2211 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002212 * Provides information about the package it is in; typically used if
2213 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2214 * a front-door to the user without having to be shown in the all apps list.
2215 */
2216 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2217 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2218 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002219 * This is the home activity, that is the first activity that is displayed
2220 * when the device boots.
2221 */
2222 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2223 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2224 /**
2225 * This activity is a preference panel.
2226 */
2227 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2228 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2229 /**
2230 * This activity is a development preference panel.
2231 */
2232 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2233 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2234 /**
2235 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002236 */
2237 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2238 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2239 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002240 * This activity allows the user to browse and download new applications.
2241 */
2242 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2243 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2244 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002245 * This activity may be exercised by the monkey or other automated test tools.
2246 */
2247 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2248 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2249 /**
2250 * To be used as a test (not part of the normal user experience).
2251 */
2252 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2253 /**
2254 * To be used as a unit test (run through the Test Harness).
2255 */
2256 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2257 /**
2258 * To be used as an sample code example (not part of the normal user
2259 * experience).
2260 */
2261 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2262 /**
2263 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2264 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2265 * when queried, though it is allowable for those columns to be blank.
2266 */
2267 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2268 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2269
2270 /**
2271 * To be used as code under test for framework instrumentation tests.
2272 */
2273 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2274 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002275 /**
2276 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002277 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2278 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002279 */
2280 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2281 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2282 /**
2283 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002284 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2285 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002286 */
2287 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2288 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002289 /**
2290 * An activity to run when device is inserted into a analog (low 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_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2296
2297 /**
2298 * An activity to run when device is inserted into a digital (high end) dock.
2299 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2300 * information, see {@link android.app.UiModeManager}.
2301 */
2302 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2303 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002304
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002305 /**
2306 * Used to indicate that the activity can be used in a car environment.
2307 */
2308 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2309 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2310
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002311 // ---------------------------------------------------------------------
2312 // ---------------------------------------------------------------------
2313 // Standard extra data keys.
2314
2315 /**
2316 * The initial data to place in a newly created record. Use with
2317 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2318 * fields as would be given to the underlying ContentProvider.insert()
2319 * call.
2320 */
2321 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2322
2323 /**
2324 * A constant CharSequence that is associated with the Intent, used with
2325 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2326 * this may be a styled CharSequence, so you must use
2327 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2328 * retrieve it.
2329 */
2330 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2331
2332 /**
2333 * A content: URI holding a stream of data associated with the Intent,
2334 * used with {@link #ACTION_SEND} to supply the data being sent.
2335 */
2336 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2337
2338 /**
2339 * A String[] holding e-mail addresses that should be delivered to.
2340 */
2341 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2342
2343 /**
2344 * A String[] holding e-mail addresses that should be carbon copied.
2345 */
2346 public static final String EXTRA_CC = "android.intent.extra.CC";
2347
2348 /**
2349 * A String[] holding e-mail addresses that should be blind carbon copied.
2350 */
2351 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2352
2353 /**
2354 * A constant string holding the desired subject line of a message.
2355 */
2356 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2357
2358 /**
2359 * An Intent describing the choices you would like shown with
2360 * {@link #ACTION_PICK_ACTIVITY}.
2361 */
2362 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2363
2364 /**
2365 * A CharSequence dialog title to provide to the user when used with a
2366 * {@link #ACTION_CHOOSER}.
2367 */
2368 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2369
2370 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002371 * A Parcelable[] of {@link Intent} or
2372 * {@link android.content.pm.LabeledIntent} objects as set with
2373 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2374 * a the front of the list of choices, when shown to the user with a
2375 * {@link #ACTION_CHOOSER}.
2376 */
2377 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2378
2379 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002380 * A {@link android.view.KeyEvent} object containing the event that
2381 * triggered the creation of the Intent it is in.
2382 */
2383 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2384
2385 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002386 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2387 * before shutting down.
2388 *
2389 * {@hide}
2390 */
2391 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2392
2393 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002394 * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2395 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2396 * of restarting the application.
2397 */
2398 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2399
2400 /**
2401 * A String holding the phone number originally entered in
2402 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2403 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2404 */
2405 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002406
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002407 /**
2408 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2409 * intents to supply the uid the package had been assigned. Also an optional
2410 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2411 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2412 * purpose.
2413 */
2414 public static final String EXTRA_UID = "android.intent.extra.UID";
2415
2416 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002417 * @hide String array of package names.
2418 */
2419 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2420
2421 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002422 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2423 * intents to indicate whether this represents a full uninstall (removing
2424 * both the code and its data) or a partial uninstall (leaving its data,
2425 * implying that this is an update).
2426 */
2427 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002428
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002429 /**
2430 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2431 * intents to indicate that this is a replacement of the package, so this
2432 * broadcast will immediately be followed by an add broadcast for a
2433 * different version of the same package.
2434 */
2435 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002436
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002437 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002438 * Used as an int extra field in {@link android.app.AlarmManager} intents
2439 * to tell the application being invoked how many pending alarms are being
2440 * delievered with the intent. For one-shot alarms this will always be 1.
2441 * For recurring alarms, this might be greater than 1 if the device was
2442 * asleep or powered off at the time an earlier alarm would have been
2443 * delivered.
2444 */
2445 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002446
Jacek Surazski86b6c532009-05-13 14:38:28 +02002447 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002448 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2449 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002450 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2451 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002452 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
2453 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
2454 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002455 */
2456 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2457
2458 /**
2459 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2460 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002461 */
2462 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2463
2464 /**
2465 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2466 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002467 */
2468 public static final int EXTRA_DOCK_STATE_DESK = 1;
2469
2470 /**
2471 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2472 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002473 */
2474 public static final int EXTRA_DOCK_STATE_CAR = 2;
2475
2476 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002477 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2478 * to represent that the phone is in a analog (low end) dock.
2479 */
2480 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
2481
2482 /**
2483 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2484 * to represent that the phone is in a digital (high end) dock.
2485 */
2486 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
2487
2488 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002489 * Boolean that can be supplied as meta-data with a dock activity, to
2490 * indicate that the dock should take over the home key when it is active.
2491 */
2492 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002493
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002494 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002495 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2496 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02002497 */
2498 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2499
2500 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002501 * Used in the extra field in the remote intent. It's astring token passed with the
2502 * remote intent.
2503 */
2504 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2505 "android.intent.extra.remote_intent_token";
2506
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002507 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002508 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002509 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002510 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002511 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002512 "android.intent.extra.changed_component_name";
2513
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002514 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002515 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002516 * and contains a string array of all of the components that have changed.
2517 */
2518 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2519 "android.intent.extra.changed_component_name_list";
2520
2521 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002522 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002523 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2524 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002525 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002526 */
2527 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2528 "android.intent.extra.changed_package_list";
2529
2530 /**
2531 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002532 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2533 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002534 * and contains an integer array of uids of all of the components
2535 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002536 */
2537 public static final String EXTRA_CHANGED_UID_LIST =
2538 "android.intent.extra.changed_uid_list";
2539
2540 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002541 * @hide
2542 * Magic extra system code can use when binding, to give a label for
2543 * who it is that has bound to a service. This is an integer giving
2544 * a framework string resource that can be displayed to the user.
2545 */
2546 public static final String EXTRA_CLIENT_LABEL =
2547 "android.intent.extra.client_label";
2548
2549 /**
2550 * @hide
2551 * Magic extra system code can use when binding, to give a PendingIntent object
2552 * that can be launched for the user to disable the system's use of this
2553 * service.
2554 */
2555 public static final String EXTRA_CLIENT_INTENT =
2556 "android.intent.extra.client_intent";
2557
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08002558 /**
2559 * Used to indicate that a {@link #ACTION_GET_CONTENT} intent should only return
2560 * data that is on the local device. This is a boolean extra; the default
2561 * is false. If true, an implementation of ACTION_GET_CONTENT should only allow
2562 * the user to select media that is already on the device, not requiring it
2563 * be downloaded from a remote service when opened. Another way to look
2564 * at it is that such content should generally have a "_data" column to the
2565 * path of the content on local external storage.
2566 */
2567 public static final String EXTRA_LOCAL_ONLY =
2568 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07002569
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002570 // ---------------------------------------------------------------------
2571 // ---------------------------------------------------------------------
2572 // Intent flags (see mFlags variable).
2573
2574 /**
2575 * If set, the recipient of this Intent will be granted permission to
2576 * perform read operations on the Uri in the Intent's data.
2577 */
2578 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2579 /**
2580 * If set, the recipient of this Intent will be granted permission to
2581 * perform write operations on the Uri in the Intent's data.
2582 */
2583 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2584 /**
2585 * Can be set by the caller to indicate that this Intent is coming from
2586 * a background operation, not from direct user interaction.
2587 */
2588 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2589 /**
2590 * A flag you can enable for debugging: when set, log messages will be
2591 * printed during the resolution of this intent to show you what has
2592 * been found to create the final resolved list.
2593 */
2594 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08002595 /**
2596 * If set, this intent will not match any components in packages that
2597 * are currently stopped. If this is not set, then the default behavior
2598 * is to include such applications in the result.
2599 */
2600 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
2601 /**
2602 * If set, this intent will always match any components in packages that
2603 * are currently stopped. This is the default behavior when
2604 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
2605 * flags are set, this one wins (it allows overriding of exclude for
2606 * places where the framework may automatically set the exclude flag).
2607 */
2608 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002609
2610 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002611 * If set, the new activity is not kept in the history stack. As soon as
2612 * the user navigates away from it, the activity is finished. This may also
2613 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2614 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 */
2616 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2617 /**
2618 * If set, the activity will not be launched if it is already running
2619 * at the top of the history stack.
2620 */
2621 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2622 /**
2623 * If set, this activity will become the start of a new task on this
2624 * history stack. A task (from the activity that started it to the
2625 * next task activity) defines an atomic group of activities that the
2626 * user can move to. Tasks can be moved to the foreground and background;
2627 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002628 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08002629 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2630 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002631 *
2632 * <p>This flag is generally used by activities that want
2633 * to present a "launcher" style behavior: they give the user a list of
2634 * separate things that can be done, which otherwise run completely
2635 * independently of the activity launching them.
2636 *
2637 * <p>When using this flag, if a task is already running for the activity
2638 * you are now starting, then a new activity will not be started; instead,
2639 * the current task will simply be brought to the front of the screen with
2640 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2641 * to disable this behavior.
2642 *
2643 * <p>This flag can not be used when the caller is requesting a result from
2644 * the activity being launched.
2645 */
2646 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2647 /**
2648 * <strong>Do not use this flag unless you are implementing your own
2649 * top-level application launcher.</strong> Used in conjunction with
2650 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2651 * behavior of bringing an existing task to the foreground. When set,
2652 * a new task is <em>always</em> started to host the Activity for the
2653 * Intent, regardless of whether there is already an existing task running
2654 * the same thing.
2655 *
2656 * <p><strong>Because the default system does not include graphical task management,
2657 * you should not use this flag unless you provide some way for a user to
2658 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002659 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002660 * <p>This flag is ignored if
2661 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2662 *
Scott Main7aee61f2011-02-08 11:25:01 -08002663 * <p>See
2664 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2665 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002666 */
2667 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2668 /**
2669 * If set, and the activity being launched is already running in the
2670 * current task, then instead of launching a new instance of that activity,
2671 * all of the other activities on top of it will be closed and this Intent
2672 * will be delivered to the (now on top) old activity as a new Intent.
2673 *
2674 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2675 * If D calls startActivity() with an Intent that resolves to the component
2676 * of activity B, then C and D will be finished and B receive the given
2677 * Intent, resulting in the stack now being: A, B.
2678 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002679 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002680 * either receive the new intent you are starting here in its
2681 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002682 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002683 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2684 * the same intent, then it will be finished and re-created; for all other
2685 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2686 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002687 *
2688 * <p>This launch mode can also be used to good effect in conjunction with
2689 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2690 * of a task, it will bring any currently running instance of that task
2691 * to the foreground, and then clear it to its root state. This is
2692 * especially useful, for example, when launching an activity from the
2693 * notification manager.
2694 *
Scott Main7aee61f2011-02-08 11:25:01 -08002695 * <p>See
2696 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2697 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002698 */
2699 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
2700 /**
2701 * If set and this intent is being used to launch a new activity from an
2702 * existing one, then the reply target of the existing activity will be
2703 * transfered to the new activity. This way the new activity can call
2704 * {@link android.app.Activity#setResult} and have that result sent back to
2705 * the reply target of the original activity.
2706 */
2707 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
2708 /**
2709 * If set and this intent is being used to launch a new activity from an
2710 * existing one, the current activity will not be counted as the top
2711 * activity for deciding whether the new intent should be delivered to
2712 * the top instead of starting a new one. The previous activity will
2713 * be used as the top, with the assumption being that the current activity
2714 * will finish itself immediately.
2715 */
2716 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
2717 /**
2718 * If set, the new activity is not kept in the list of recently launched
2719 * activities.
2720 */
2721 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
2722 /**
2723 * This flag is not normally set by application code, but set for you by
2724 * the system as described in the
2725 * {@link android.R.styleable#AndroidManifestActivity_launchMode
2726 * launchMode} documentation for the singleTask mode.
2727 */
2728 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
2729 /**
2730 * If set, and this activity is either being started in a new task or
2731 * bringing to the top an existing task, then it will be launched as
2732 * the front door of the task. This will result in the application of
2733 * any affinities needed to have that task in the proper state (either
2734 * moving activities to or from it), or simply resetting that task to
2735 * its initial state if needed.
2736 */
2737 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
2738 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002739 * This flag is not normally set by application code, but set for you by
2740 * the system if this activity is being launched from history
2741 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002742 */
2743 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002744 /**
2745 * If set, this marks a point in the task's activity stack that should
2746 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07002747 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002748 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
2749 * the user re-launching it from home), this activity and all on top of
2750 * it will be finished so that the user does not return to them, but
2751 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07002752 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002753 * <p>This is useful for cases where you have a logical break in your
2754 * application. For example, an e-mail application may have a command
2755 * to view an attachment, which launches an image view activity to
2756 * display it. This activity should be part of the e-mail application's
2757 * task, since it is a part of the task the user is involved in. However,
2758 * if the user leaves that task, and later selects the e-mail app from
2759 * home, we may like them to return to the conversation they were
2760 * viewing, not the picture attachment, since that is confusing. By
2761 * setting this flag when launching the image viewer, that viewer and
2762 * any activities it starts will be removed the next time the user returns
2763 * to mail.
2764 */
2765 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002766 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002767 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002768 * callback from occurring on the current frontmost activity before it is
2769 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07002770 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002771 * <p>Typically, an activity can rely on that callback to indicate that an
2772 * explicit user action has caused their activity to be moved out of the
2773 * foreground. The callback marks an appropriate point in the activity's
2774 * lifecycle for it to dismiss any notifications that it intends to display
2775 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07002776 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002777 * <p>If an activity is ever started via any non-user-driven events such as
2778 * phone-call receipt or an alarm handler, this flag should be passed to {@link
2779 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07002780 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002781 */
2782 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002783 /**
2784 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2785 * this flag will cause the launched activity to be brought to the front of its
2786 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07002787 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002788 * <p>For example, consider a task consisting of four activities: A, B, C, D.
2789 * If D calls startActivity() with an Intent that resolves to the component
2790 * of activity B, then B will be brought to the front of the history stack,
2791 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07002792 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002793 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07002794 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002795 */
2796 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002797 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002798 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2799 * this flag will prevent the system from applying an activity transition
2800 * animation to go to the next activity state. This doesn't mean an
2801 * animation will never run -- if another activity change happens that doesn't
2802 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002803 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07002804 * when you are going to do a series of activity operations but the
2805 * animation seen by the user shouldn't be driven by the first activity
2806 * change but rather a later one.
2807 */
2808 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
2809 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08002810 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2811 * this flag will cause any existing task that would be associated with the
2812 * activity to be cleared before the activity is started. That is, the activity
2813 * becomes the new root of an otherwise empty task, and any old activities
2814 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2815 */
2816 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
2817 /**
2818 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
2819 * this flag will cause a newly launching task to be placed on top of the current
2820 * home activity task (if there is one). That is, pressing back from the task
2821 * will always return the user to home even if that was not the last activity they
2822 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
2823 */
2824 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
2825 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002826 * If set, when sending a broadcast only registered receivers will be
2827 * called -- no BroadcastReceiver components will be launched.
2828 */
2829 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002830 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002831 * If set, when sending a broadcast the new broadcast will replace
2832 * any existing pending broadcast that matches it. Matching is defined
2833 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
2834 * true for the intents of the two broadcasts. When a match is found,
2835 * the new broadcast (and receivers associated with it) will replace the
2836 * existing one in the pending broadcast list, remaining at the same
2837 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08002838 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002839 * <p>This flag is most typically used with sticky broadcasts, which
2840 * only care about delivering the most recent values of the broadcast
2841 * to their receivers.
2842 */
2843 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
2844 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002845 * If set, when sending a broadcast <i>before boot has completed</i> only
2846 * registered receivers will be called -- no BroadcastReceiver components
2847 * will be launched. Sticky intent state will be recorded properly even
2848 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
2849 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07002850 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002851 * <p>This flag is only for use by system sevices as a convenience to
2852 * avoid having to implement a more complex mechanism around detection
2853 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07002854 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002855 * @hide
2856 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002857 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002858 /**
2859 * Set when this broadcast is for a boot upgrade, a special mode that
2860 * allows the broadcast to be sent before the system is ready and launches
2861 * the app process with no providers running in it.
2862 * @hide
2863 */
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002864 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002865
Dianne Hackbornfa82f222009-09-17 15:14:12 -07002866 /**
2867 * @hide Flags that can't be changed with PendingIntent.
2868 */
2869 public static final int IMMUTABLE_FLAGS =
2870 FLAG_GRANT_READ_URI_PERMISSION
2871 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08002872
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002874 // ---------------------------------------------------------------------
2875 // toUri() and parseUri() options.
2876
2877 /**
2878 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
2879 * always has the "intent:" scheme. This syntax can be used when you want
2880 * to later disambiguate between URIs that are intended to describe an
2881 * Intent vs. all others that should be treated as raw URIs. When used
2882 * with {@link #parseUri}, any other scheme will result in a generic
2883 * VIEW action for that raw URI.
2884 */
2885 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08002886
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002887 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002888
2889 private String mAction;
2890 private Uri mData;
2891 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002892 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002893 private ComponentName mComponent;
2894 private int mFlags;
2895 private HashSet<String> mCategories;
2896 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002897 private Rect mSourceBounds;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002898
2899 // ---------------------------------------------------------------------
2900
2901 /**
2902 * Create an empty intent.
2903 */
2904 public Intent() {
2905 }
2906
2907 /**
2908 * Copy constructor.
2909 */
2910 public Intent(Intent o) {
2911 this.mAction = o.mAction;
2912 this.mData = o.mData;
2913 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002914 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002915 this.mComponent = o.mComponent;
2916 this.mFlags = o.mFlags;
2917 if (o.mCategories != null) {
2918 this.mCategories = new HashSet<String>(o.mCategories);
2919 }
2920 if (o.mExtras != null) {
2921 this.mExtras = new Bundle(o.mExtras);
2922 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08002923 if (o.mSourceBounds != null) {
2924 this.mSourceBounds = new Rect(o.mSourceBounds);
2925 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002926 }
2927
2928 @Override
2929 public Object clone() {
2930 return new Intent(this);
2931 }
2932
2933 private Intent(Intent o, boolean all) {
2934 this.mAction = o.mAction;
2935 this.mData = o.mData;
2936 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07002937 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002938 this.mComponent = o.mComponent;
2939 if (o.mCategories != null) {
2940 this.mCategories = new HashSet<String>(o.mCategories);
2941 }
2942 }
2943
2944 /**
2945 * Make a clone of only the parts of the Intent that are relevant for
2946 * filter matching: the action, data, type, component, and categories.
2947 */
2948 public Intent cloneFilter() {
2949 return new Intent(this, false);
2950 }
2951
2952 /**
2953 * Create an intent with a given action. All other fields (data, type,
2954 * class) are null. Note that the action <em>must</em> be in a
2955 * namespace because Intents are used globally in the system -- for
2956 * example the system VIEW action is android.intent.action.VIEW; an
2957 * application's custom action would be something like
2958 * com.google.app.myapp.CUSTOM_ACTION.
2959 *
2960 * @param action The Intent action, such as ACTION_VIEW.
2961 */
2962 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002963 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002964 }
2965
2966 /**
2967 * Create an intent with a given action and for a given data url. Note
2968 * that the action <em>must</em> be in a namespace because Intents are
2969 * used globally in the system -- for example the system VIEW action is
2970 * android.intent.action.VIEW; an application's custom action would be
2971 * something like com.google.app.myapp.CUSTOM_ACTION.
2972 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07002973 * <p><em>Note: scheme and host name matching in the Android framework is
2974 * case-sensitive, unlike the formal RFC. As a result,
2975 * you should always ensure that you write your Uri with these elements
2976 * using lower case letters, and normalize any Uris you receive from
2977 * outside of Android to ensure the scheme and host is lower case.</em></p>
2978 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002979 * @param action The Intent action, such as ACTION_VIEW.
2980 * @param uri The Intent data URI.
2981 */
2982 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08002983 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002984 mData = uri;
2985 }
2986
2987 /**
2988 * Create an intent for a specific component. All other fields (action, data,
2989 * type, class) are null, though they can be modified later with explicit
2990 * calls. This provides a convenient way to create an intent that is
2991 * intended to execute a hard-coded class name, rather than relying on the
2992 * system to find an appropriate class for you; see {@link #setComponent}
2993 * for more information on the repercussions of this.
2994 *
2995 * @param packageContext A Context of the application package implementing
2996 * this class.
2997 * @param cls The component class that is to be used for the intent.
2998 *
2999 * @see #setClass
3000 * @see #setComponent
3001 * @see #Intent(String, android.net.Uri , Context, Class)
3002 */
3003 public Intent(Context packageContext, Class<?> cls) {
3004 mComponent = new ComponentName(packageContext, cls);
3005 }
3006
3007 /**
3008 * Create an intent for a specific component with a specified action and data.
3009 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
3010 * construct the Intent and then calling {@link #setClass} to set its
3011 * class.
3012 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003013 * <p><em>Note: scheme and host name matching in the Android framework is
3014 * case-sensitive, unlike the formal RFC. As a result,
3015 * you should always ensure that you write your Uri with these elements
3016 * using lower case letters, and normalize any Uris you receive from
3017 * outside of Android to ensure the scheme and host is lower case.</em></p>
3018 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003019 * @param action The Intent action, such as ACTION_VIEW.
3020 * @param uri The Intent data URI.
3021 * @param packageContext A Context of the application package implementing
3022 * this class.
3023 * @param cls The component class that is to be used for the intent.
3024 *
3025 * @see #Intent(String, android.net.Uri)
3026 * @see #Intent(Context, Class)
3027 * @see #setClass
3028 * @see #setComponent
3029 */
3030 public Intent(String action, Uri uri,
3031 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003032 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003033 mData = uri;
3034 mComponent = new ComponentName(packageContext, cls);
3035 }
3036
3037 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003038 * Create an intent to launch the main (root) activity of a task. This
3039 * is the Intent that is started when the application's is launched from
3040 * Home. For anything else that wants to launch an application in the
3041 * same way, it is important that they use an Intent structured the same
3042 * way, and can use this function to ensure this is the case.
3043 *
3044 * <p>The returned Intent has the given Activity component as its explicit
3045 * component, {@link #ACTION_MAIN} as its action, and includes the
3046 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3047 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3048 * to do that through {@link #addFlags(int)} on the returned Intent.
3049 *
3050 * @param mainActivity The main activity component that this Intent will
3051 * launch.
3052 * @return Returns a newly created Intent that can be used to launch the
3053 * activity as a main application entry.
3054 *
3055 * @see #setClass
3056 * @see #setComponent
3057 */
3058 public static Intent makeMainActivity(ComponentName mainActivity) {
3059 Intent intent = new Intent(ACTION_MAIN);
3060 intent.setComponent(mainActivity);
3061 intent.addCategory(CATEGORY_LAUNCHER);
3062 return intent;
3063 }
3064
3065 /**
3066 * Make an Intent that can be used to re-launch an application's task
3067 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
3068 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
3069 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
3070 *
3071 * @param mainActivity The activity component that is the root of the
3072 * task; this is the activity that has been published in the application's
3073 * manifest as the main launcher icon.
3074 *
3075 * @return Returns a newly created Intent that can be used to relaunch the
3076 * activity's task in its root state.
3077 */
3078 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
3079 Intent intent = makeMainActivity(mainActivity);
3080 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
3081 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
3082 return intent;
3083 }
3084
3085 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003086 * Call {@link #parseUri} with 0 flags.
3087 * @deprecated Use {@link #parseUri} instead.
3088 */
3089 @Deprecated
3090 public static Intent getIntent(String uri) throws URISyntaxException {
3091 return parseUri(uri, 0);
3092 }
Tom Taylord4a47292009-12-21 13:59:18 -08003093
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003094 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003095 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003096 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07003097 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003098 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003099 *
3100 * <p>The URI given here must not be relative -- that is, it must include
3101 * the scheme and full path.
3102 *
3103 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003104 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003105 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003106 *
3107 * @return Intent The newly created Intent object.
3108 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003109 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
3110 * it bad (as parsed by the Uri class) or the Intent data within the
3111 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08003112 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003113 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003114 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003115 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003116 int i = 0;
3117 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003118 // Validate intent scheme for if requested.
3119 if ((flags&URI_INTENT_SCHEME) != 0) {
3120 if (!uri.startsWith("intent:")) {
3121 Intent intent = new Intent(ACTION_VIEW);
3122 try {
3123 intent.setData(Uri.parse(uri));
3124 } catch (IllegalArgumentException e) {
3125 throw new URISyntaxException(uri, e.getMessage());
3126 }
3127 return intent;
3128 }
3129 }
Tom Taylord4a47292009-12-21 13:59:18 -08003130
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003131 // simple case
3132 i = uri.lastIndexOf("#");
3133 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
3134
3135 // old format Intent URI
3136 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07003137
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003138 // new format
3139 Intent intent = new Intent(ACTION_VIEW);
3140
3141 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003142 String data = i >= 0 ? uri.substring(0, i) : null;
3143 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003144 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07003145
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003146 // loop over contents of Intent, all name=value;
3147 while (!uri.startsWith("end", i)) {
3148 int eq = uri.indexOf('=', i);
3149 int semi = uri.indexOf(';', eq);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003150 String value = Uri.decode(uri.substring(eq + 1, semi));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003151
3152 // action
3153 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003154 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003155 }
3156
3157 // categories
3158 else if (uri.startsWith("category=", i)) {
3159 intent.addCategory(value);
3160 }
3161
3162 // type
3163 else if (uri.startsWith("type=", i)) {
3164 intent.mType = value;
3165 }
3166
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003167 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003168 else if (uri.startsWith("launchFlags=", i)) {
3169 intent.mFlags = Integer.decode(value).intValue();
3170 }
3171
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003172 // package
3173 else if (uri.startsWith("package=", i)) {
3174 intent.mPackage = value;
3175 }
3176
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003177 // component
3178 else if (uri.startsWith("component=", i)) {
3179 intent.mComponent = ComponentName.unflattenFromString(value);
3180 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003181
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003182 // scheme
3183 else if (uri.startsWith("scheme=", i)) {
3184 scheme = value;
3185 }
3186
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003187 // source bounds
3188 else if (uri.startsWith("sourceBounds=", i)) {
3189 intent.mSourceBounds = Rect.unflattenFromString(value);
3190 }
3191
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003192 // extra
3193 else {
3194 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003195 // create Bundle if it doesn't already exist
3196 if (intent.mExtras == null) intent.mExtras = new Bundle();
3197 Bundle b = intent.mExtras;
3198 // add EXTRA
3199 if (uri.startsWith("S.", i)) b.putString(key, value);
3200 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
3201 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
3202 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
3203 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
3204 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
3205 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
3206 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
3207 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
3208 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
3209 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003210
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003211 // move to the next item
3212 i = semi + 1;
3213 }
3214
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003215 if (data != null) {
3216 if (data.startsWith("intent:")) {
3217 data = data.substring(7);
3218 if (scheme != null) {
3219 data = scheme + ':' + data;
3220 }
3221 }
Tom Taylord4a47292009-12-21 13:59:18 -08003222
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003223 if (data.length() > 0) {
3224 try {
3225 intent.mData = Uri.parse(data);
3226 } catch (IllegalArgumentException e) {
3227 throw new URISyntaxException(uri, e.getMessage());
3228 }
3229 }
3230 }
Tom Taylord4a47292009-12-21 13:59:18 -08003231
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003232 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07003233
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003234 } catch (IndexOutOfBoundsException e) {
3235 throw new URISyntaxException(uri, "illegal Intent URI format", i);
3236 }
3237 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003238
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003239 public static Intent getIntentOld(String uri) throws URISyntaxException {
3240 Intent intent;
3241
3242 int i = uri.lastIndexOf('#');
3243 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003244 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003245 final int intentFragmentStart = i;
3246 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003247
3248 i++;
3249
3250 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003251 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003252 i += 7;
3253 int j = uri.indexOf(')', i);
3254 action = uri.substring(i, j);
3255 i = j + 1;
3256 }
3257
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003258 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003259
3260 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003261 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003262 i += 11;
3263 int j = uri.indexOf(')', i);
3264 while (i < j) {
3265 int sep = uri.indexOf('!', i);
3266 if (sep < 0) sep = j;
3267 if (i < sep) {
3268 intent.addCategory(uri.substring(i, sep));
3269 }
3270 i = sep + 1;
3271 }
3272 i = j + 1;
3273 }
3274
3275 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003276 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003277 i += 5;
3278 int j = uri.indexOf(')', i);
3279 intent.mType = uri.substring(i, j);
3280 i = j + 1;
3281 }
3282
3283 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003284 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003285 i += 12;
3286 int j = uri.indexOf(')', i);
3287 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
3288 i = j + 1;
3289 }
3290
3291 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003292 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003293 i += 10;
3294 int j = uri.indexOf(')', i);
3295 int sep = uri.indexOf('!', i);
3296 if (sep >= 0 && sep < j) {
3297 String pkg = uri.substring(i, sep);
3298 String cls = uri.substring(sep + 1, j);
3299 intent.mComponent = new ComponentName(pkg, cls);
3300 }
3301 i = j + 1;
3302 }
3303
3304 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003305 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003306 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07003307
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003308 final int closeParen = uri.indexOf(')', i);
3309 if (closeParen == -1) throw new URISyntaxException(uri,
3310 "EXTRA missing trailing ')'", i);
3311
3312 while (i < closeParen) {
3313 // fetch the key value
3314 int j = uri.indexOf('=', i);
3315 if (j <= i + 1 || i >= closeParen) {
3316 throw new URISyntaxException(uri, "EXTRA missing '='", i);
3317 }
3318 char type = uri.charAt(i);
3319 i++;
3320 String key = uri.substring(i, j);
3321 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07003322
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003323 // get type-value
3324 j = uri.indexOf('!', i);
3325 if (j == -1 || j >= closeParen) j = closeParen;
3326 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3327 String value = uri.substring(i, j);
3328 i = j;
3329
3330 // create Bundle if it doesn't already exist
3331 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07003332
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003333 // add item to bundle
3334 try {
3335 switch (type) {
3336 case 'S':
3337 intent.mExtras.putString(key, Uri.decode(value));
3338 break;
3339 case 'B':
3340 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
3341 break;
3342 case 'b':
3343 intent.mExtras.putByte(key, Byte.parseByte(value));
3344 break;
3345 case 'c':
3346 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
3347 break;
3348 case 'd':
3349 intent.mExtras.putDouble(key, Double.parseDouble(value));
3350 break;
3351 case 'f':
3352 intent.mExtras.putFloat(key, Float.parseFloat(value));
3353 break;
3354 case 'i':
3355 intent.mExtras.putInt(key, Integer.parseInt(value));
3356 break;
3357 case 'l':
3358 intent.mExtras.putLong(key, Long.parseLong(value));
3359 break;
3360 case 's':
3361 intent.mExtras.putShort(key, Short.parseShort(value));
3362 break;
3363 default:
3364 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3365 }
3366 } catch (NumberFormatException e) {
3367 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3368 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003369
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003370 char ch = uri.charAt(i);
3371 if (ch == ')') break;
3372 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3373 i++;
3374 }
3375 }
3376
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003377 if (isIntentFragment) {
3378 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3379 } else {
3380 intent.mData = Uri.parse(uri);
3381 }
Tom Taylord4a47292009-12-21 13:59:18 -08003382
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003383 if (intent.mAction == null) {
3384 // By default, if no action is specified, then use VIEW.
3385 intent.mAction = ACTION_VIEW;
3386 }
3387
3388 } else {
3389 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3390 }
3391
3392 return intent;
3393 }
3394
3395 /**
3396 * Retrieve the general action to be performed, such as
3397 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3398 * the information in the intent should be interpreted -- most importantly,
3399 * what to do with the data returned by {@link #getData}.
3400 *
3401 * @return The action of this intent or null if none is specified.
3402 *
3403 * @see #setAction
3404 */
3405 public String getAction() {
3406 return mAction;
3407 }
3408
3409 /**
3410 * Retrieve data this intent is operating on. This URI specifies the name
3411 * of the data; often it uses the content: scheme, specifying data in a
3412 * content provider. Other schemes may be handled by specific activities,
3413 * such as http: by the web browser.
3414 *
3415 * @return The URI of the data this intent is targeting or null.
3416 *
3417 * @see #getScheme
3418 * @see #setData
3419 */
3420 public Uri getData() {
3421 return mData;
3422 }
3423
3424 /**
3425 * The same as {@link #getData()}, but returns the URI as an encoded
3426 * String.
3427 */
3428 public String getDataString() {
3429 return mData != null ? mData.toString() : null;
3430 }
3431
3432 /**
3433 * Return the scheme portion of the intent's data. If the data is null or
3434 * does not include a scheme, null is returned. Otherwise, the scheme
3435 * prefix without the final ':' is returned, i.e. "http".
3436 *
3437 * <p>This is the same as calling getData().getScheme() (and checking for
3438 * null data).
3439 *
3440 * @return The scheme of this intent.
3441 *
3442 * @see #getData
3443 */
3444 public String getScheme() {
3445 return mData != null ? mData.getScheme() : null;
3446 }
3447
3448 /**
3449 * Retrieve any explicit MIME type included in the intent. This is usually
3450 * null, as the type is determined by the intent data.
3451 *
3452 * @return If a type was manually set, it is returned; else null is
3453 * returned.
3454 *
3455 * @see #resolveType(ContentResolver)
3456 * @see #setType
3457 */
3458 public String getType() {
3459 return mType;
3460 }
3461
3462 /**
3463 * Return the MIME data type of this intent. If the type field is
3464 * explicitly set, that is simply returned. Otherwise, if the data is set,
3465 * the type of that data is returned. If neither fields are set, a null is
3466 * returned.
3467 *
3468 * @return The MIME type of this intent.
3469 *
3470 * @see #getType
3471 * @see #resolveType(ContentResolver)
3472 */
3473 public String resolveType(Context context) {
3474 return resolveType(context.getContentResolver());
3475 }
3476
3477 /**
3478 * Return the MIME data type of this intent. If the type field is
3479 * explicitly set, that is simply returned. Otherwise, if the data is set,
3480 * the type of that data is returned. If neither fields are set, a null is
3481 * returned.
3482 *
3483 * @param resolver A ContentResolver that can be used to determine the MIME
3484 * type of the intent's data.
3485 *
3486 * @return The MIME type of this intent.
3487 *
3488 * @see #getType
3489 * @see #resolveType(Context)
3490 */
3491 public String resolveType(ContentResolver resolver) {
3492 if (mType != null) {
3493 return mType;
3494 }
3495 if (mData != null) {
3496 if ("content".equals(mData.getScheme())) {
3497 return resolver.getType(mData);
3498 }
3499 }
3500 return null;
3501 }
3502
3503 /**
3504 * Return the MIME data type of this intent, only if it will be needed for
3505 * intent resolution. This is not generally useful for application code;
3506 * it is used by the frameworks for communicating with back-end system
3507 * services.
3508 *
3509 * @param resolver A ContentResolver that can be used to determine the MIME
3510 * type of the intent's data.
3511 *
3512 * @return The MIME type of this intent, or null if it is unknown or not
3513 * needed.
3514 */
3515 public String resolveTypeIfNeeded(ContentResolver resolver) {
3516 if (mComponent != null) {
3517 return mType;
3518 }
3519 return resolveType(resolver);
3520 }
3521
3522 /**
3523 * Check if an category exists in the intent.
3524 *
3525 * @param category The category to check.
3526 *
3527 * @return boolean True if the intent contains the category, else false.
3528 *
3529 * @see #getCategories
3530 * @see #addCategory
3531 */
3532 public boolean hasCategory(String category) {
3533 return mCategories != null && mCategories.contains(category);
3534 }
3535
3536 /**
3537 * Return the set of all categories in the intent. If there are no categories,
3538 * returns NULL.
3539 *
3540 * @return Set The set of categories you can examine. Do not modify!
3541 *
3542 * @see #hasCategory
3543 * @see #addCategory
3544 */
3545 public Set<String> getCategories() {
3546 return mCategories;
3547 }
3548
3549 /**
3550 * Sets the ClassLoader that will be used when unmarshalling
3551 * any Parcelable values from the extras of this Intent.
3552 *
3553 * @param loader a ClassLoader, or null to use the default loader
3554 * at the time of unmarshalling.
3555 */
3556 public void setExtrasClassLoader(ClassLoader loader) {
3557 if (mExtras != null) {
3558 mExtras.setClassLoader(loader);
3559 }
3560 }
3561
3562 /**
3563 * Returns true if an extra value is associated with the given name.
3564 * @param name the extra's name
3565 * @return true if the given extra is present.
3566 */
3567 public boolean hasExtra(String name) {
3568 return mExtras != null && mExtras.containsKey(name);
3569 }
3570
3571 /**
3572 * Returns true if the Intent's extras contain a parcelled file descriptor.
3573 * @return true if the Intent contains a parcelled file descriptor.
3574 */
3575 public boolean hasFileDescriptors() {
3576 return mExtras != null && mExtras.hasFileDescriptors();
3577 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003578
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04003579 /** @hide */
3580 public void setAllowFds(boolean allowFds) {
3581 if (mExtras != null) {
3582 mExtras.setAllowFds(allowFds);
3583 }
3584 }
3585
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003586 /**
3587 * Retrieve extended data from the intent.
3588 *
3589 * @param name The name of the desired item.
3590 *
3591 * @return the value of an item that previously added with putExtra()
3592 * or null if none was found.
3593 *
3594 * @deprecated
3595 * @hide
3596 */
3597 @Deprecated
3598 public Object getExtra(String name) {
3599 return getExtra(name, null);
3600 }
3601
3602 /**
3603 * Retrieve extended data from the intent.
3604 *
3605 * @param name The name of the desired item.
3606 * @param defaultValue the value to be returned if no value of the desired
3607 * type is stored with the given name.
3608 *
3609 * @return the value of an item that previously added with putExtra()
3610 * or the default value if none was found.
3611 *
3612 * @see #putExtra(String, boolean)
3613 */
3614 public boolean getBooleanExtra(String name, boolean defaultValue) {
3615 return mExtras == null ? defaultValue :
3616 mExtras.getBoolean(name, defaultValue);
3617 }
3618
3619 /**
3620 * Retrieve extended data from the intent.
3621 *
3622 * @param name The name of the desired item.
3623 * @param defaultValue the value to be returned if no value of the desired
3624 * type is stored with the given name.
3625 *
3626 * @return the value of an item that previously added with putExtra()
3627 * or the default value if none was found.
3628 *
3629 * @see #putExtra(String, byte)
3630 */
3631 public byte getByteExtra(String name, byte defaultValue) {
3632 return mExtras == null ? defaultValue :
3633 mExtras.getByte(name, defaultValue);
3634 }
3635
3636 /**
3637 * Retrieve extended data from the intent.
3638 *
3639 * @param name The name of the desired item.
3640 * @param defaultValue the value to be returned if no value of the desired
3641 * type is stored with the given name.
3642 *
3643 * @return the value of an item that previously added with putExtra()
3644 * or the default value if none was found.
3645 *
3646 * @see #putExtra(String, short)
3647 */
3648 public short getShortExtra(String name, short defaultValue) {
3649 return mExtras == null ? defaultValue :
3650 mExtras.getShort(name, defaultValue);
3651 }
3652
3653 /**
3654 * Retrieve extended data from the intent.
3655 *
3656 * @param name The name of the desired item.
3657 * @param defaultValue the value to be returned if no value of the desired
3658 * type is stored with the given name.
3659 *
3660 * @return the value of an item that previously added with putExtra()
3661 * or the default value if none was found.
3662 *
3663 * @see #putExtra(String, char)
3664 */
3665 public char getCharExtra(String name, char defaultValue) {
3666 return mExtras == null ? defaultValue :
3667 mExtras.getChar(name, defaultValue);
3668 }
3669
3670 /**
3671 * Retrieve extended data from the intent.
3672 *
3673 * @param name The name of the desired item.
3674 * @param defaultValue the value to be returned if no value of the desired
3675 * type is stored with the given name.
3676 *
3677 * @return the value of an item that previously added with putExtra()
3678 * or the default value if none was found.
3679 *
3680 * @see #putExtra(String, int)
3681 */
3682 public int getIntExtra(String name, int defaultValue) {
3683 return mExtras == null ? defaultValue :
3684 mExtras.getInt(name, defaultValue);
3685 }
3686
3687 /**
3688 * Retrieve extended data from the intent.
3689 *
3690 * @param name The name of the desired item.
3691 * @param defaultValue the value to be returned if no value of the desired
3692 * type is stored with the given name.
3693 *
3694 * @return the value of an item that previously added with putExtra()
3695 * or the default value if none was found.
3696 *
3697 * @see #putExtra(String, long)
3698 */
3699 public long getLongExtra(String name, long defaultValue) {
3700 return mExtras == null ? defaultValue :
3701 mExtras.getLong(name, defaultValue);
3702 }
3703
3704 /**
3705 * Retrieve extended data from the intent.
3706 *
3707 * @param name The name of the desired item.
3708 * @param defaultValue the value to be returned if no value of the desired
3709 * type is stored with the given name.
3710 *
3711 * @return the value of an item that previously added with putExtra(),
3712 * or the default value if no such item is present
3713 *
3714 * @see #putExtra(String, float)
3715 */
3716 public float getFloatExtra(String name, float defaultValue) {
3717 return mExtras == null ? defaultValue :
3718 mExtras.getFloat(name, defaultValue);
3719 }
3720
3721 /**
3722 * Retrieve extended data from the intent.
3723 *
3724 * @param name The name of the desired item.
3725 * @param defaultValue the value to be returned if no value of the desired
3726 * type is stored with the given name.
3727 *
3728 * @return the value of an item that previously added with putExtra()
3729 * or the default value if none was found.
3730 *
3731 * @see #putExtra(String, double)
3732 */
3733 public double getDoubleExtra(String name, double defaultValue) {
3734 return mExtras == null ? defaultValue :
3735 mExtras.getDouble(name, defaultValue);
3736 }
3737
3738 /**
3739 * Retrieve extended data from the intent.
3740 *
3741 * @param name The name of the desired item.
3742 *
3743 * @return the value of an item that previously added with putExtra()
3744 * or null if no String value was found.
3745 *
3746 * @see #putExtra(String, String)
3747 */
3748 public String getStringExtra(String name) {
3749 return mExtras == null ? null : mExtras.getString(name);
3750 }
3751
3752 /**
3753 * Retrieve extended data from the intent.
3754 *
3755 * @param name The name of the desired item.
3756 *
3757 * @return the value of an item that previously added with putExtra()
3758 * or null if no CharSequence value was found.
3759 *
3760 * @see #putExtra(String, CharSequence)
3761 */
3762 public CharSequence getCharSequenceExtra(String name) {
3763 return mExtras == null ? null : mExtras.getCharSequence(name);
3764 }
3765
3766 /**
3767 * Retrieve extended data from the intent.
3768 *
3769 * @param name The name of the desired item.
3770 *
3771 * @return the value of an item that previously added with putExtra()
3772 * or null if no Parcelable value was found.
3773 *
3774 * @see #putExtra(String, Parcelable)
3775 */
3776 public <T extends Parcelable> T getParcelableExtra(String name) {
3777 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3778 }
3779
3780 /**
3781 * Retrieve extended data from the intent.
3782 *
3783 * @param name The name of the desired item.
3784 *
3785 * @return the value of an item that previously added with putExtra()
3786 * or null if no Parcelable[] value was found.
3787 *
3788 * @see #putExtra(String, Parcelable[])
3789 */
3790 public Parcelable[] getParcelableArrayExtra(String name) {
3791 return mExtras == null ? null : mExtras.getParcelableArray(name);
3792 }
3793
3794 /**
3795 * Retrieve extended data from the intent.
3796 *
3797 * @param name The name of the desired item.
3798 *
3799 * @return the value of an item that previously added with putExtra()
3800 * or null if no ArrayList<Parcelable> value was found.
3801 *
3802 * @see #putParcelableArrayListExtra(String, ArrayList)
3803 */
3804 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3805 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3806 }
3807
3808 /**
3809 * Retrieve extended data from the intent.
3810 *
3811 * @param name The name of the desired item.
3812 *
3813 * @return the value of an item that previously added with putExtra()
3814 * or null if no Serializable value was found.
3815 *
3816 * @see #putExtra(String, Serializable)
3817 */
3818 public Serializable getSerializableExtra(String name) {
3819 return mExtras == null ? null : mExtras.getSerializable(name);
3820 }
3821
3822 /**
3823 * Retrieve extended data from the intent.
3824 *
3825 * @param name The name of the desired item.
3826 *
3827 * @return the value of an item that previously added with putExtra()
3828 * or null if no ArrayList<Integer> value was found.
3829 *
3830 * @see #putIntegerArrayListExtra(String, ArrayList)
3831 */
3832 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3833 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3834 }
3835
3836 /**
3837 * Retrieve extended data from the intent.
3838 *
3839 * @param name The name of the desired item.
3840 *
3841 * @return the value of an item that previously added with putExtra()
3842 * or null if no ArrayList<String> value was found.
3843 *
3844 * @see #putStringArrayListExtra(String, ArrayList)
3845 */
3846 public ArrayList<String> getStringArrayListExtra(String name) {
3847 return mExtras == null ? null : mExtras.getStringArrayList(name);
3848 }
3849
3850 /**
3851 * Retrieve extended data from the intent.
3852 *
3853 * @param name The name of the desired item.
3854 *
3855 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003856 * or null if no ArrayList<CharSequence> value was found.
3857 *
3858 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3859 */
3860 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3861 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3862 }
3863
3864 /**
3865 * Retrieve extended data from the intent.
3866 *
3867 * @param name The name of the desired item.
3868 *
3869 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003870 * or null if no boolean array value was found.
3871 *
3872 * @see #putExtra(String, boolean[])
3873 */
3874 public boolean[] getBooleanArrayExtra(String name) {
3875 return mExtras == null ? null : mExtras.getBooleanArray(name);
3876 }
3877
3878 /**
3879 * Retrieve extended data from the intent.
3880 *
3881 * @param name The name of the desired item.
3882 *
3883 * @return the value of an item that previously added with putExtra()
3884 * or null if no byte array value was found.
3885 *
3886 * @see #putExtra(String, byte[])
3887 */
3888 public byte[] getByteArrayExtra(String name) {
3889 return mExtras == null ? null : mExtras.getByteArray(name);
3890 }
3891
3892 /**
3893 * Retrieve extended data from the intent.
3894 *
3895 * @param name The name of the desired item.
3896 *
3897 * @return the value of an item that previously added with putExtra()
3898 * or null if no short array value was found.
3899 *
3900 * @see #putExtra(String, short[])
3901 */
3902 public short[] getShortArrayExtra(String name) {
3903 return mExtras == null ? null : mExtras.getShortArray(name);
3904 }
3905
3906 /**
3907 * Retrieve extended data from the intent.
3908 *
3909 * @param name The name of the desired item.
3910 *
3911 * @return the value of an item that previously added with putExtra()
3912 * or null if no char array value was found.
3913 *
3914 * @see #putExtra(String, char[])
3915 */
3916 public char[] getCharArrayExtra(String name) {
3917 return mExtras == null ? null : mExtras.getCharArray(name);
3918 }
3919
3920 /**
3921 * Retrieve extended data from the intent.
3922 *
3923 * @param name The name of the desired item.
3924 *
3925 * @return the value of an item that previously added with putExtra()
3926 * or null if no int array value was found.
3927 *
3928 * @see #putExtra(String, int[])
3929 */
3930 public int[] getIntArrayExtra(String name) {
3931 return mExtras == null ? null : mExtras.getIntArray(name);
3932 }
3933
3934 /**
3935 * Retrieve extended data from the intent.
3936 *
3937 * @param name The name of the desired item.
3938 *
3939 * @return the value of an item that previously added with putExtra()
3940 * or null if no long array value was found.
3941 *
3942 * @see #putExtra(String, long[])
3943 */
3944 public long[] getLongArrayExtra(String name) {
3945 return mExtras == null ? null : mExtras.getLongArray(name);
3946 }
3947
3948 /**
3949 * Retrieve extended data from the intent.
3950 *
3951 * @param name The name of the desired item.
3952 *
3953 * @return the value of an item that previously added with putExtra()
3954 * or null if no float array value was found.
3955 *
3956 * @see #putExtra(String, float[])
3957 */
3958 public float[] getFloatArrayExtra(String name) {
3959 return mExtras == null ? null : mExtras.getFloatArray(name);
3960 }
3961
3962 /**
3963 * Retrieve extended data from the intent.
3964 *
3965 * @param name The name of the desired item.
3966 *
3967 * @return the value of an item that previously added with putExtra()
3968 * or null if no double array value was found.
3969 *
3970 * @see #putExtra(String, double[])
3971 */
3972 public double[] getDoubleArrayExtra(String name) {
3973 return mExtras == null ? null : mExtras.getDoubleArray(name);
3974 }
3975
3976 /**
3977 * Retrieve extended data from the intent.
3978 *
3979 * @param name The name of the desired item.
3980 *
3981 * @return the value of an item that previously added with putExtra()
3982 * or null if no String array value was found.
3983 *
3984 * @see #putExtra(String, String[])
3985 */
3986 public String[] getStringArrayExtra(String name) {
3987 return mExtras == null ? null : mExtras.getStringArray(name);
3988 }
3989
3990 /**
3991 * Retrieve extended data from the intent.
3992 *
3993 * @param name The name of the desired item.
3994 *
3995 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003996 * or null if no CharSequence array value was found.
3997 *
3998 * @see #putExtra(String, CharSequence[])
3999 */
4000 public CharSequence[] getCharSequenceArrayExtra(String name) {
4001 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
4002 }
4003
4004 /**
4005 * Retrieve extended data from the intent.
4006 *
4007 * @param name The name of the desired item.
4008 *
4009 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004010 * or null if no Bundle value was found.
4011 *
4012 * @see #putExtra(String, Bundle)
4013 */
4014 public Bundle getBundleExtra(String name) {
4015 return mExtras == null ? null : mExtras.getBundle(name);
4016 }
4017
4018 /**
4019 * Retrieve extended data from the intent.
4020 *
4021 * @param name The name of the desired item.
4022 *
4023 * @return the value of an item that previously added with putExtra()
4024 * or null if no IBinder value was found.
4025 *
4026 * @see #putExtra(String, IBinder)
4027 *
4028 * @deprecated
4029 * @hide
4030 */
4031 @Deprecated
4032 public IBinder getIBinderExtra(String name) {
4033 return mExtras == null ? null : mExtras.getIBinder(name);
4034 }
4035
4036 /**
4037 * Retrieve extended data from the intent.
4038 *
4039 * @param name The name of the desired item.
4040 * @param defaultValue The default value to return in case no item is
4041 * associated with the key 'name'
4042 *
4043 * @return the value of an item that previously added with putExtra()
4044 * or defaultValue if none was found.
4045 *
4046 * @see #putExtra
4047 *
4048 * @deprecated
4049 * @hide
4050 */
4051 @Deprecated
4052 public Object getExtra(String name, Object defaultValue) {
4053 Object result = defaultValue;
4054 if (mExtras != null) {
4055 Object result2 = mExtras.get(name);
4056 if (result2 != null) {
4057 result = result2;
4058 }
4059 }
4060
4061 return result;
4062 }
4063
4064 /**
4065 * Retrieves a map of extended data from the intent.
4066 *
4067 * @return the map of all extras previously added with putExtra(),
4068 * or null if none have been added.
4069 */
4070 public Bundle getExtras() {
4071 return (mExtras != null)
4072 ? new Bundle(mExtras)
4073 : null;
4074 }
4075
4076 /**
4077 * Retrieve any special flags associated with this intent. You will
4078 * normally just set them with {@link #setFlags} and let the system
4079 * take the appropriate action with them.
4080 *
4081 * @return int The currently set flags.
4082 *
4083 * @see #setFlags
4084 */
4085 public int getFlags() {
4086 return mFlags;
4087 }
4088
Dianne Hackborne7f97212011-02-24 14:40:20 -08004089 /** @hide */
4090 public boolean isExcludingStopped() {
4091 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4092 == FLAG_EXCLUDE_STOPPED_PACKAGES;
4093 }
4094
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004095 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004096 * Retrieve the application package name this Intent is limited to. When
4097 * resolving an Intent, if non-null this limits the resolution to only
4098 * components in the given application package.
4099 *
4100 * @return The name of the application package for the Intent.
4101 *
4102 * @see #resolveActivity
4103 * @see #setPackage
4104 */
4105 public String getPackage() {
4106 return mPackage;
4107 }
4108
4109 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004110 * Retrieve the concrete component associated with the intent. When receiving
4111 * an intent, this is the component that was found to best handle it (that is,
4112 * yourself) and will always be non-null; in all other cases it will be
4113 * null unless explicitly set.
4114 *
4115 * @return The name of the application component to handle the intent.
4116 *
4117 * @see #resolveActivity
4118 * @see #setComponent
4119 */
4120 public ComponentName getComponent() {
4121 return mComponent;
4122 }
4123
4124 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004125 * Get the bounds of the sender of this intent, in screen coordinates. This can be
4126 * used as a hint to the receiver for animations and the like. Null means that there
4127 * is no source bounds.
4128 */
4129 public Rect getSourceBounds() {
4130 return mSourceBounds;
4131 }
4132
4133 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004134 * Return the Activity component that should be used to handle this intent.
4135 * The appropriate component is determined based on the information in the
4136 * intent, evaluated as follows:
4137 *
4138 * <p>If {@link #getComponent} returns an explicit class, that is returned
4139 * without any further consideration.
4140 *
4141 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
4142 * category to be considered.
4143 *
4144 * <p>If {@link #getAction} is non-NULL, the activity must handle this
4145 * action.
4146 *
4147 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
4148 * this type.
4149 *
4150 * <p>If {@link #addCategory} has added any categories, the activity must
4151 * handle ALL of the categories specified.
4152 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004153 * <p>If {@link #getPackage} is non-NULL, only activity components in
4154 * that application package will be considered.
4155 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004156 * <p>If there are no activities that satisfy all of these conditions, a
4157 * null string is returned.
4158 *
4159 * <p>If multiple activities are found to satisfy the intent, the one with
4160 * the highest priority will be used. If there are multiple activities
4161 * with the same priority, the system will either pick the best activity
4162 * based on user preference, or resolve to a system class that will allow
4163 * the user to pick an activity and forward from there.
4164 *
4165 * <p>This method is implemented simply by calling
4166 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
4167 * true.</p>
4168 * <p> This API is called for you as part of starting an activity from an
4169 * intent. You do not normally need to call it yourself.</p>
4170 *
4171 * @param pm The package manager with which to resolve the Intent.
4172 *
4173 * @return Name of the component implementing an activity that can
4174 * display the intent.
4175 *
4176 * @see #setComponent
4177 * @see #getComponent
4178 * @see #resolveActivityInfo
4179 */
4180 public ComponentName resolveActivity(PackageManager pm) {
4181 if (mComponent != null) {
4182 return mComponent;
4183 }
4184
4185 ResolveInfo info = pm.resolveActivity(
4186 this, PackageManager.MATCH_DEFAULT_ONLY);
4187 if (info != null) {
4188 return new ComponentName(
4189 info.activityInfo.applicationInfo.packageName,
4190 info.activityInfo.name);
4191 }
4192
4193 return null;
4194 }
4195
4196 /**
4197 * Resolve the Intent into an {@link ActivityInfo}
4198 * describing the activity that should execute the intent. Resolution
4199 * follows the same rules as described for {@link #resolveActivity}, but
4200 * you get back the completely information about the resolved activity
4201 * instead of just its class name.
4202 *
4203 * @param pm The package manager with which to resolve the Intent.
4204 * @param flags Addition information to retrieve as per
4205 * {@link PackageManager#getActivityInfo(ComponentName, int)
4206 * PackageManager.getActivityInfo()}.
4207 *
4208 * @return PackageManager.ActivityInfo
4209 *
4210 * @see #resolveActivity
4211 */
4212 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
4213 ActivityInfo ai = null;
4214 if (mComponent != null) {
4215 try {
4216 ai = pm.getActivityInfo(mComponent, flags);
4217 } catch (PackageManager.NameNotFoundException e) {
4218 // ignore
4219 }
4220 } else {
4221 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004222 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004223 if (info != null) {
4224 ai = info.activityInfo;
4225 }
4226 }
4227
4228 return ai;
4229 }
4230
4231 /**
4232 * Set the general action to be performed.
4233 *
4234 * @param action An action name, such as ACTION_VIEW. Application-specific
4235 * actions should be prefixed with the vendor's package name.
4236 *
4237 * @return Returns the same Intent object, for chaining multiple calls
4238 * into a single statement.
4239 *
4240 * @see #getAction
4241 */
4242 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004243 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004244 return this;
4245 }
4246
4247 /**
4248 * Set the data this intent is operating on. This method automatically
4249 * clears any type that was previously set by {@link #setType}.
4250 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004251 * <p><em>Note: scheme and host name matching in the Android framework is
4252 * case-sensitive, unlike the formal RFC. As a result,
4253 * you should always ensure that you write your Uri with these elements
4254 * using lower case letters, and normalize any Uris you receive from
4255 * outside of Android to ensure the scheme and host is lower case.</em></p>
4256 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004257 * @param data The URI of the data this intent is now targeting.
4258 *
4259 * @return Returns the same Intent object, for chaining multiple calls
4260 * into a single statement.
4261 *
4262 * @see #getData
4263 * @see #setType
4264 * @see #setDataAndType
4265 */
4266 public Intent setData(Uri data) {
4267 mData = data;
4268 mType = null;
4269 return this;
4270 }
4271
4272 /**
4273 * Set an explicit MIME data type. This is used to create intents that
4274 * only specify a type and not data, for example to indicate the type of
4275 * data to return. This method automatically clears any data that was
4276 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07004277 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004278 * <p><em>Note: MIME type matching in the Android framework is
4279 * case-sensitive, unlike formal RFC MIME types. As a result,
4280 * you should always write your MIME types with lower case letters,
4281 * and any MIME types you receive from outside of Android should be
4282 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004283 *
4284 * @param type The MIME type of the data being handled by this intent.
4285 *
4286 * @return Returns the same Intent object, for chaining multiple calls
4287 * into a single statement.
4288 *
4289 * @see #getType
4290 * @see #setData
4291 * @see #setDataAndType
4292 */
4293 public Intent setType(String type) {
4294 mData = null;
4295 mType = type;
4296 return this;
4297 }
4298
4299 /**
4300 * (Usually optional) Set the data for the intent along with an explicit
4301 * MIME data type. This method should very rarely be used -- it allows you
4302 * to override the MIME type that would ordinarily be inferred from the
4303 * data with your own type given here.
4304 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004305 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
4306 * Android framework is case-sensitive, unlike the formal RFC definitions.
4307 * As a result, you should always write these elements with lower case letters,
4308 * and normalize any MIME types or Uris you receive from
4309 * outside of Android to ensure these elements are lower case before
4310 * supplying them here.</em></p>
4311 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004312 * @param data The URI of the data this intent is now targeting.
4313 * @param type The MIME type of the data being handled by this intent.
4314 *
4315 * @return Returns the same Intent object, for chaining multiple calls
4316 * into a single statement.
4317 *
4318 * @see #setData
4319 * @see #setType
4320 */
4321 public Intent setDataAndType(Uri data, String type) {
4322 mData = data;
4323 mType = type;
4324 return this;
4325 }
4326
4327 /**
4328 * Add a new category to the intent. Categories provide additional detail
4329 * about the action the intent is perform. When resolving an intent, only
4330 * activities that provide <em>all</em> of the requested categories will be
4331 * used.
4332 *
4333 * @param category The desired category. This can be either one of the
4334 * predefined Intent categories, or a custom category in your own
4335 * namespace.
4336 *
4337 * @return Returns the same Intent object, for chaining multiple calls
4338 * into a single statement.
4339 *
4340 * @see #hasCategory
4341 * @see #removeCategory
4342 */
4343 public Intent addCategory(String category) {
4344 if (mCategories == null) {
4345 mCategories = new HashSet<String>();
4346 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08004347 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004348 return this;
4349 }
4350
4351 /**
4352 * Remove an category from an intent.
4353 *
4354 * @param category The category to remove.
4355 *
4356 * @see #addCategory
4357 */
4358 public void removeCategory(String category) {
4359 if (mCategories != null) {
4360 mCategories.remove(category);
4361 if (mCategories.size() == 0) {
4362 mCategories = null;
4363 }
4364 }
4365 }
4366
4367 /**
4368 * Add extended data to the intent. The name must include a package
4369 * prefix, for example the app com.android.contacts would use names
4370 * like "com.android.contacts.ShowAll".
4371 *
4372 * @param name The name of the extra data, with package prefix.
4373 * @param value The boolean data value.
4374 *
4375 * @return Returns the same Intent object, for chaining multiple calls
4376 * into a single statement.
4377 *
4378 * @see #putExtras
4379 * @see #removeExtra
4380 * @see #getBooleanExtra(String, boolean)
4381 */
4382 public Intent putExtra(String name, boolean value) {
4383 if (mExtras == null) {
4384 mExtras = new Bundle();
4385 }
4386 mExtras.putBoolean(name, value);
4387 return this;
4388 }
4389
4390 /**
4391 * Add extended data to the intent. The name must include a package
4392 * prefix, for example the app com.android.contacts would use names
4393 * like "com.android.contacts.ShowAll".
4394 *
4395 * @param name The name of the extra data, with package prefix.
4396 * @param value The byte data value.
4397 *
4398 * @return Returns the same Intent object, for chaining multiple calls
4399 * into a single statement.
4400 *
4401 * @see #putExtras
4402 * @see #removeExtra
4403 * @see #getByteExtra(String, byte)
4404 */
4405 public Intent putExtra(String name, byte value) {
4406 if (mExtras == null) {
4407 mExtras = new Bundle();
4408 }
4409 mExtras.putByte(name, value);
4410 return this;
4411 }
4412
4413 /**
4414 * Add extended data to the intent. The name must include a package
4415 * prefix, for example the app com.android.contacts would use names
4416 * like "com.android.contacts.ShowAll".
4417 *
4418 * @param name The name of the extra data, with package prefix.
4419 * @param value The char data value.
4420 *
4421 * @return Returns the same Intent object, for chaining multiple calls
4422 * into a single statement.
4423 *
4424 * @see #putExtras
4425 * @see #removeExtra
4426 * @see #getCharExtra(String, char)
4427 */
4428 public Intent putExtra(String name, char value) {
4429 if (mExtras == null) {
4430 mExtras = new Bundle();
4431 }
4432 mExtras.putChar(name, value);
4433 return this;
4434 }
4435
4436 /**
4437 * Add extended data to the intent. The name must include a package
4438 * prefix, for example the app com.android.contacts would use names
4439 * like "com.android.contacts.ShowAll".
4440 *
4441 * @param name The name of the extra data, with package prefix.
4442 * @param value The short data value.
4443 *
4444 * @return Returns the same Intent object, for chaining multiple calls
4445 * into a single statement.
4446 *
4447 * @see #putExtras
4448 * @see #removeExtra
4449 * @see #getShortExtra(String, short)
4450 */
4451 public Intent putExtra(String name, short value) {
4452 if (mExtras == null) {
4453 mExtras = new Bundle();
4454 }
4455 mExtras.putShort(name, value);
4456 return this;
4457 }
4458
4459 /**
4460 * Add extended data to the intent. The name must include a package
4461 * prefix, for example the app com.android.contacts would use names
4462 * like "com.android.contacts.ShowAll".
4463 *
4464 * @param name The name of the extra data, with package prefix.
4465 * @param value The integer data value.
4466 *
4467 * @return Returns the same Intent object, for chaining multiple calls
4468 * into a single statement.
4469 *
4470 * @see #putExtras
4471 * @see #removeExtra
4472 * @see #getIntExtra(String, int)
4473 */
4474 public Intent putExtra(String name, int value) {
4475 if (mExtras == null) {
4476 mExtras = new Bundle();
4477 }
4478 mExtras.putInt(name, value);
4479 return this;
4480 }
4481
4482 /**
4483 * Add extended data to the intent. The name must include a package
4484 * prefix, for example the app com.android.contacts would use names
4485 * like "com.android.contacts.ShowAll".
4486 *
4487 * @param name The name of the extra data, with package prefix.
4488 * @param value The long data value.
4489 *
4490 * @return Returns the same Intent object, for chaining multiple calls
4491 * into a single statement.
4492 *
4493 * @see #putExtras
4494 * @see #removeExtra
4495 * @see #getLongExtra(String, long)
4496 */
4497 public Intent putExtra(String name, long value) {
4498 if (mExtras == null) {
4499 mExtras = new Bundle();
4500 }
4501 mExtras.putLong(name, value);
4502 return this;
4503 }
4504
4505 /**
4506 * Add extended data to the intent. The name must include a package
4507 * prefix, for example the app com.android.contacts would use names
4508 * like "com.android.contacts.ShowAll".
4509 *
4510 * @param name The name of the extra data, with package prefix.
4511 * @param value The float data value.
4512 *
4513 * @return Returns the same Intent object, for chaining multiple calls
4514 * into a single statement.
4515 *
4516 * @see #putExtras
4517 * @see #removeExtra
4518 * @see #getFloatExtra(String, float)
4519 */
4520 public Intent putExtra(String name, float value) {
4521 if (mExtras == null) {
4522 mExtras = new Bundle();
4523 }
4524 mExtras.putFloat(name, value);
4525 return this;
4526 }
4527
4528 /**
4529 * Add extended data to the intent. The name must include a package
4530 * prefix, for example the app com.android.contacts would use names
4531 * like "com.android.contacts.ShowAll".
4532 *
4533 * @param name The name of the extra data, with package prefix.
4534 * @param value The double data value.
4535 *
4536 * @return Returns the same Intent object, for chaining multiple calls
4537 * into a single statement.
4538 *
4539 * @see #putExtras
4540 * @see #removeExtra
4541 * @see #getDoubleExtra(String, double)
4542 */
4543 public Intent putExtra(String name, double value) {
4544 if (mExtras == null) {
4545 mExtras = new Bundle();
4546 }
4547 mExtras.putDouble(name, value);
4548 return this;
4549 }
4550
4551 /**
4552 * Add extended data to the intent. The name must include a package
4553 * prefix, for example the app com.android.contacts would use names
4554 * like "com.android.contacts.ShowAll".
4555 *
4556 * @param name The name of the extra data, with package prefix.
4557 * @param value The String data value.
4558 *
4559 * @return Returns the same Intent object, for chaining multiple calls
4560 * into a single statement.
4561 *
4562 * @see #putExtras
4563 * @see #removeExtra
4564 * @see #getStringExtra(String)
4565 */
4566 public Intent putExtra(String name, String value) {
4567 if (mExtras == null) {
4568 mExtras = new Bundle();
4569 }
4570 mExtras.putString(name, value);
4571 return this;
4572 }
4573
4574 /**
4575 * Add extended data to the intent. The name must include a package
4576 * prefix, for example the app com.android.contacts would use names
4577 * like "com.android.contacts.ShowAll".
4578 *
4579 * @param name The name of the extra data, with package prefix.
4580 * @param value The CharSequence data value.
4581 *
4582 * @return Returns the same Intent object, for chaining multiple calls
4583 * into a single statement.
4584 *
4585 * @see #putExtras
4586 * @see #removeExtra
4587 * @see #getCharSequenceExtra(String)
4588 */
4589 public Intent putExtra(String name, CharSequence value) {
4590 if (mExtras == null) {
4591 mExtras = new Bundle();
4592 }
4593 mExtras.putCharSequence(name, value);
4594 return this;
4595 }
4596
4597 /**
4598 * Add extended data to the intent. The name must include a package
4599 * prefix, for example the app com.android.contacts would use names
4600 * like "com.android.contacts.ShowAll".
4601 *
4602 * @param name The name of the extra data, with package prefix.
4603 * @param value The Parcelable data value.
4604 *
4605 * @return Returns the same Intent object, for chaining multiple calls
4606 * into a single statement.
4607 *
4608 * @see #putExtras
4609 * @see #removeExtra
4610 * @see #getParcelableExtra(String)
4611 */
4612 public Intent putExtra(String name, Parcelable value) {
4613 if (mExtras == null) {
4614 mExtras = new Bundle();
4615 }
4616 mExtras.putParcelable(name, value);
4617 return this;
4618 }
4619
4620 /**
4621 * Add extended data to the intent. The name must include a package
4622 * prefix, for example the app com.android.contacts would use names
4623 * like "com.android.contacts.ShowAll".
4624 *
4625 * @param name The name of the extra data, with package prefix.
4626 * @param value The Parcelable[] data value.
4627 *
4628 * @return Returns the same Intent object, for chaining multiple calls
4629 * into a single statement.
4630 *
4631 * @see #putExtras
4632 * @see #removeExtra
4633 * @see #getParcelableArrayExtra(String)
4634 */
4635 public Intent putExtra(String name, Parcelable[] value) {
4636 if (mExtras == null) {
4637 mExtras = new Bundle();
4638 }
4639 mExtras.putParcelableArray(name, value);
4640 return this;
4641 }
4642
4643 /**
4644 * Add extended data to the intent. The name must include a package
4645 * prefix, for example the app com.android.contacts would use names
4646 * like "com.android.contacts.ShowAll".
4647 *
4648 * @param name The name of the extra data, with package prefix.
4649 * @param value The ArrayList<Parcelable> data value.
4650 *
4651 * @return Returns the same Intent object, for chaining multiple calls
4652 * into a single statement.
4653 *
4654 * @see #putExtras
4655 * @see #removeExtra
4656 * @see #getParcelableArrayListExtra(String)
4657 */
4658 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4659 if (mExtras == null) {
4660 mExtras = new Bundle();
4661 }
4662 mExtras.putParcelableArrayList(name, value);
4663 return this;
4664 }
4665
4666 /**
4667 * Add extended data to the intent. The name must include a package
4668 * prefix, for example the app com.android.contacts would use names
4669 * like "com.android.contacts.ShowAll".
4670 *
4671 * @param name The name of the extra data, with package prefix.
4672 * @param value The ArrayList<Integer> data value.
4673 *
4674 * @return Returns the same Intent object, for chaining multiple calls
4675 * into a single statement.
4676 *
4677 * @see #putExtras
4678 * @see #removeExtra
4679 * @see #getIntegerArrayListExtra(String)
4680 */
4681 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4682 if (mExtras == null) {
4683 mExtras = new Bundle();
4684 }
4685 mExtras.putIntegerArrayList(name, value);
4686 return this;
4687 }
4688
4689 /**
4690 * Add extended data to the intent. The name must include a package
4691 * prefix, for example the app com.android.contacts would use names
4692 * like "com.android.contacts.ShowAll".
4693 *
4694 * @param name The name of the extra data, with package prefix.
4695 * @param value The ArrayList<String> data value.
4696 *
4697 * @return Returns the same Intent object, for chaining multiple calls
4698 * into a single statement.
4699 *
4700 * @see #putExtras
4701 * @see #removeExtra
4702 * @see #getStringArrayListExtra(String)
4703 */
4704 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4705 if (mExtras == null) {
4706 mExtras = new Bundle();
4707 }
4708 mExtras.putStringArrayList(name, value);
4709 return this;
4710 }
4711
4712 /**
4713 * Add extended data to the intent. The name must include a package
4714 * prefix, for example the app com.android.contacts would use names
4715 * like "com.android.contacts.ShowAll".
4716 *
4717 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004718 * @param value The ArrayList<CharSequence> data value.
4719 *
4720 * @return Returns the same Intent object, for chaining multiple calls
4721 * into a single statement.
4722 *
4723 * @see #putExtras
4724 * @see #removeExtra
4725 * @see #getCharSequenceArrayListExtra(String)
4726 */
4727 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4728 if (mExtras == null) {
4729 mExtras = new Bundle();
4730 }
4731 mExtras.putCharSequenceArrayList(name, value);
4732 return this;
4733 }
4734
4735 /**
4736 * Add extended data to the intent. The name must include a package
4737 * prefix, for example the app com.android.contacts would use names
4738 * like "com.android.contacts.ShowAll".
4739 *
4740 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 * @param value The Serializable data value.
4742 *
4743 * @return Returns the same Intent object, for chaining multiple calls
4744 * into a single statement.
4745 *
4746 * @see #putExtras
4747 * @see #removeExtra
4748 * @see #getSerializableExtra(String)
4749 */
4750 public Intent putExtra(String name, Serializable value) {
4751 if (mExtras == null) {
4752 mExtras = new Bundle();
4753 }
4754 mExtras.putSerializable(name, value);
4755 return this;
4756 }
4757
4758 /**
4759 * Add extended data to the intent. The name must include a package
4760 * prefix, for example the app com.android.contacts would use names
4761 * like "com.android.contacts.ShowAll".
4762 *
4763 * @param name The name of the extra data, with package prefix.
4764 * @param value The boolean array data value.
4765 *
4766 * @return Returns the same Intent object, for chaining multiple calls
4767 * into a single statement.
4768 *
4769 * @see #putExtras
4770 * @see #removeExtra
4771 * @see #getBooleanArrayExtra(String)
4772 */
4773 public Intent putExtra(String name, boolean[] value) {
4774 if (mExtras == null) {
4775 mExtras = new Bundle();
4776 }
4777 mExtras.putBooleanArray(name, value);
4778 return this;
4779 }
4780
4781 /**
4782 * Add extended data to the intent. The name must include a package
4783 * prefix, for example the app com.android.contacts would use names
4784 * like "com.android.contacts.ShowAll".
4785 *
4786 * @param name The name of the extra data, with package prefix.
4787 * @param value The byte array data value.
4788 *
4789 * @return Returns the same Intent object, for chaining multiple calls
4790 * into a single statement.
4791 *
4792 * @see #putExtras
4793 * @see #removeExtra
4794 * @see #getByteArrayExtra(String)
4795 */
4796 public Intent putExtra(String name, byte[] value) {
4797 if (mExtras == null) {
4798 mExtras = new Bundle();
4799 }
4800 mExtras.putByteArray(name, value);
4801 return this;
4802 }
4803
4804 /**
4805 * Add extended data to the intent. The name must include a package
4806 * prefix, for example the app com.android.contacts would use names
4807 * like "com.android.contacts.ShowAll".
4808 *
4809 * @param name The name of the extra data, with package prefix.
4810 * @param value The short array data value.
4811 *
4812 * @return Returns the same Intent object, for chaining multiple calls
4813 * into a single statement.
4814 *
4815 * @see #putExtras
4816 * @see #removeExtra
4817 * @see #getShortArrayExtra(String)
4818 */
4819 public Intent putExtra(String name, short[] value) {
4820 if (mExtras == null) {
4821 mExtras = new Bundle();
4822 }
4823 mExtras.putShortArray(name, value);
4824 return this;
4825 }
4826
4827 /**
4828 * Add extended data to the intent. The name must include a package
4829 * prefix, for example the app com.android.contacts would use names
4830 * like "com.android.contacts.ShowAll".
4831 *
4832 * @param name The name of the extra data, with package prefix.
4833 * @param value The char array data value.
4834 *
4835 * @return Returns the same Intent object, for chaining multiple calls
4836 * into a single statement.
4837 *
4838 * @see #putExtras
4839 * @see #removeExtra
4840 * @see #getCharArrayExtra(String)
4841 */
4842 public Intent putExtra(String name, char[] value) {
4843 if (mExtras == null) {
4844 mExtras = new Bundle();
4845 }
4846 mExtras.putCharArray(name, value);
4847 return this;
4848 }
4849
4850 /**
4851 * Add extended data to the intent. The name must include a package
4852 * prefix, for example the app com.android.contacts would use names
4853 * like "com.android.contacts.ShowAll".
4854 *
4855 * @param name The name of the extra data, with package prefix.
4856 * @param value The int array data value.
4857 *
4858 * @return Returns the same Intent object, for chaining multiple calls
4859 * into a single statement.
4860 *
4861 * @see #putExtras
4862 * @see #removeExtra
4863 * @see #getIntArrayExtra(String)
4864 */
4865 public Intent putExtra(String name, int[] value) {
4866 if (mExtras == null) {
4867 mExtras = new Bundle();
4868 }
4869 mExtras.putIntArray(name, value);
4870 return this;
4871 }
4872
4873 /**
4874 * Add extended data to the intent. The name must include a package
4875 * prefix, for example the app com.android.contacts would use names
4876 * like "com.android.contacts.ShowAll".
4877 *
4878 * @param name The name of the extra data, with package prefix.
4879 * @param value The byte array data value.
4880 *
4881 * @return Returns the same Intent object, for chaining multiple calls
4882 * into a single statement.
4883 *
4884 * @see #putExtras
4885 * @see #removeExtra
4886 * @see #getLongArrayExtra(String)
4887 */
4888 public Intent putExtra(String name, long[] value) {
4889 if (mExtras == null) {
4890 mExtras = new Bundle();
4891 }
4892 mExtras.putLongArray(name, value);
4893 return this;
4894 }
4895
4896 /**
4897 * Add extended data to the intent. The name must include a package
4898 * prefix, for example the app com.android.contacts would use names
4899 * like "com.android.contacts.ShowAll".
4900 *
4901 * @param name The name of the extra data, with package prefix.
4902 * @param value The float array data value.
4903 *
4904 * @return Returns the same Intent object, for chaining multiple calls
4905 * into a single statement.
4906 *
4907 * @see #putExtras
4908 * @see #removeExtra
4909 * @see #getFloatArrayExtra(String)
4910 */
4911 public Intent putExtra(String name, float[] value) {
4912 if (mExtras == null) {
4913 mExtras = new Bundle();
4914 }
4915 mExtras.putFloatArray(name, value);
4916 return this;
4917 }
4918
4919 /**
4920 * Add extended data to the intent. The name must include a package
4921 * prefix, for example the app com.android.contacts would use names
4922 * like "com.android.contacts.ShowAll".
4923 *
4924 * @param name The name of the extra data, with package prefix.
4925 * @param value The double array data value.
4926 *
4927 * @return Returns the same Intent object, for chaining multiple calls
4928 * into a single statement.
4929 *
4930 * @see #putExtras
4931 * @see #removeExtra
4932 * @see #getDoubleArrayExtra(String)
4933 */
4934 public Intent putExtra(String name, double[] value) {
4935 if (mExtras == null) {
4936 mExtras = new Bundle();
4937 }
4938 mExtras.putDoubleArray(name, value);
4939 return this;
4940 }
4941
4942 /**
4943 * Add extended data to the intent. The name must include a package
4944 * prefix, for example the app com.android.contacts would use names
4945 * like "com.android.contacts.ShowAll".
4946 *
4947 * @param name The name of the extra data, with package prefix.
4948 * @param value The String array data value.
4949 *
4950 * @return Returns the same Intent object, for chaining multiple calls
4951 * into a single statement.
4952 *
4953 * @see #putExtras
4954 * @see #removeExtra
4955 * @see #getStringArrayExtra(String)
4956 */
4957 public Intent putExtra(String name, String[] value) {
4958 if (mExtras == null) {
4959 mExtras = new Bundle();
4960 }
4961 mExtras.putStringArray(name, value);
4962 return this;
4963 }
4964
4965 /**
4966 * Add extended data to the intent. The name must include a package
4967 * prefix, for example the app com.android.contacts would use names
4968 * like "com.android.contacts.ShowAll".
4969 *
4970 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004971 * @param value The CharSequence array data value.
4972 *
4973 * @return Returns the same Intent object, for chaining multiple calls
4974 * into a single statement.
4975 *
4976 * @see #putExtras
4977 * @see #removeExtra
4978 * @see #getCharSequenceArrayExtra(String)
4979 */
4980 public Intent putExtra(String name, CharSequence[] value) {
4981 if (mExtras == null) {
4982 mExtras = new Bundle();
4983 }
4984 mExtras.putCharSequenceArray(name, value);
4985 return this;
4986 }
4987
4988 /**
4989 * Add extended data to the intent. The name must include a package
4990 * prefix, for example the app com.android.contacts would use names
4991 * like "com.android.contacts.ShowAll".
4992 *
4993 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004994 * @param value The Bundle data value.
4995 *
4996 * @return Returns the same Intent object, for chaining multiple calls
4997 * into a single statement.
4998 *
4999 * @see #putExtras
5000 * @see #removeExtra
5001 * @see #getBundleExtra(String)
5002 */
5003 public Intent putExtra(String name, Bundle value) {
5004 if (mExtras == null) {
5005 mExtras = new Bundle();
5006 }
5007 mExtras.putBundle(name, value);
5008 return this;
5009 }
5010
5011 /**
5012 * Add extended data to the intent. The name must include a package
5013 * prefix, for example the app com.android.contacts would use names
5014 * like "com.android.contacts.ShowAll".
5015 *
5016 * @param name The name of the extra data, with package prefix.
5017 * @param value The IBinder data value.
5018 *
5019 * @return Returns the same Intent object, for chaining multiple calls
5020 * into a single statement.
5021 *
5022 * @see #putExtras
5023 * @see #removeExtra
5024 * @see #getIBinderExtra(String)
5025 *
5026 * @deprecated
5027 * @hide
5028 */
5029 @Deprecated
5030 public Intent putExtra(String name, IBinder value) {
5031 if (mExtras == null) {
5032 mExtras = new Bundle();
5033 }
5034 mExtras.putIBinder(name, value);
5035 return this;
5036 }
5037
5038 /**
5039 * Copy all extras in 'src' in to this intent.
5040 *
5041 * @param src Contains the extras to copy.
5042 *
5043 * @see #putExtra
5044 */
5045 public Intent putExtras(Intent src) {
5046 if (src.mExtras != null) {
5047 if (mExtras == null) {
5048 mExtras = new Bundle(src.mExtras);
5049 } else {
5050 mExtras.putAll(src.mExtras);
5051 }
5052 }
5053 return this;
5054 }
5055
5056 /**
5057 * Add a set of extended data to the intent. The keys must include a package
5058 * prefix, for example the app com.android.contacts would use names
5059 * like "com.android.contacts.ShowAll".
5060 *
5061 * @param extras The Bundle of extras to add to this intent.
5062 *
5063 * @see #putExtra
5064 * @see #removeExtra
5065 */
5066 public Intent putExtras(Bundle extras) {
5067 if (mExtras == null) {
5068 mExtras = new Bundle();
5069 }
5070 mExtras.putAll(extras);
5071 return this;
5072 }
5073
5074 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005075 * Completely replace the extras in the Intent with the extras in the
5076 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07005077 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005078 * @param src The exact extras contained in this Intent are copied
5079 * into the target intent, replacing any that were previously there.
5080 */
5081 public Intent replaceExtras(Intent src) {
5082 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
5083 return this;
5084 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005085
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005086 /**
5087 * Completely replace the extras in the Intent with the given Bundle of
5088 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07005089 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005090 * @param extras The new set of extras in the Intent, or null to erase
5091 * all extras.
5092 */
5093 public Intent replaceExtras(Bundle extras) {
5094 mExtras = extras != null ? new Bundle(extras) : null;
5095 return this;
5096 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005097
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005098 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005099 * Remove extended data from the intent.
5100 *
5101 * @see #putExtra
5102 */
5103 public void removeExtra(String name) {
5104 if (mExtras != null) {
5105 mExtras.remove(name);
5106 if (mExtras.size() == 0) {
5107 mExtras = null;
5108 }
5109 }
5110 }
5111
5112 /**
5113 * Set special flags controlling how this intent is handled. Most values
5114 * here depend on the type of component being executed by the Intent,
5115 * specifically the FLAG_ACTIVITY_* flags are all for use with
5116 * {@link Context#startActivity Context.startActivity()} and the
5117 * FLAG_RECEIVER_* flags are all for use with
5118 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
5119 *
Scott Main7aee61f2011-02-08 11:25:01 -08005120 * <p>See the
5121 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5122 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005123 * the behavior of your application.
5124 *
5125 * @param flags The desired flags.
5126 *
5127 * @return Returns the same Intent object, for chaining multiple calls
5128 * into a single statement.
5129 *
5130 * @see #getFlags
5131 * @see #addFlags
5132 *
5133 * @see #FLAG_GRANT_READ_URI_PERMISSION
5134 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
5135 * @see #FLAG_DEBUG_LOG_RESOLUTION
5136 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005137 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005138 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005139 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005140 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005141 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
5142 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005143 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005144 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5145 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005146 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005147 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005148 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005149 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
5150 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005151 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005152 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005153 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005154 * @see #FLAG_RECEIVER_REGISTERED_ONLY
5155 */
5156 public Intent setFlags(int flags) {
5157 mFlags = flags;
5158 return this;
5159 }
5160
5161 /**
5162 * Add additional flags to the intent (or with existing flags
5163 * value).
5164 *
5165 * @param flags The new flags to set.
5166 *
5167 * @return Returns the same Intent object, for chaining multiple calls
5168 * into a single statement.
5169 *
5170 * @see #setFlags
5171 */
5172 public Intent addFlags(int flags) {
5173 mFlags |= flags;
5174 return this;
5175 }
5176
5177 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005178 * (Usually optional) Set an explicit application package name that limits
5179 * the components this Intent will resolve to. If left to the default
5180 * value of null, all components in all applications will considered.
5181 * If non-null, the Intent can only match the components in the given
5182 * application package.
5183 *
5184 * @param packageName The name of the application package to handle the
5185 * intent, or null to allow any application package.
5186 *
5187 * @return Returns the same Intent object, for chaining multiple calls
5188 * into a single statement.
5189 *
5190 * @see #getPackage
5191 * @see #resolveActivity
5192 */
5193 public Intent setPackage(String packageName) {
5194 mPackage = packageName;
5195 return this;
5196 }
5197
5198 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005199 * (Usually optional) Explicitly set the component to handle the intent.
5200 * If left with the default value of null, the system will determine the
5201 * appropriate class to use based on the other fields (action, data,
5202 * type, categories) in the Intent. If this class is defined, the
5203 * specified class will always be used regardless of the other fields. You
5204 * should only set this value when you know you absolutely want a specific
5205 * class to be used; otherwise it is better to let the system find the
5206 * appropriate class so that you will respect the installed applications
5207 * and user preferences.
5208 *
5209 * @param component The name of the application component to handle the
5210 * intent, or null to let the system find one for you.
5211 *
5212 * @return Returns the same Intent object, for chaining multiple calls
5213 * into a single statement.
5214 *
5215 * @see #setClass
5216 * @see #setClassName(Context, String)
5217 * @see #setClassName(String, String)
5218 * @see #getComponent
5219 * @see #resolveActivity
5220 */
5221 public Intent setComponent(ComponentName component) {
5222 mComponent = component;
5223 return this;
5224 }
5225
5226 /**
5227 * Convenience for calling {@link #setComponent} with an
5228 * explicit class name.
5229 *
5230 * @param packageContext A Context of the application package implementing
5231 * this class.
5232 * @param className The name of a class inside of the application package
5233 * that will be used as the component for this Intent.
5234 *
5235 * @return Returns the same Intent object, for chaining multiple calls
5236 * into a single statement.
5237 *
5238 * @see #setComponent
5239 * @see #setClass
5240 */
5241 public Intent setClassName(Context packageContext, String className) {
5242 mComponent = new ComponentName(packageContext, className);
5243 return this;
5244 }
5245
5246 /**
5247 * Convenience for calling {@link #setComponent} with an
5248 * explicit application package name and class name.
5249 *
5250 * @param packageName The name of the package implementing the desired
5251 * component.
5252 * @param className The name of a class inside of the application package
5253 * that will be used as the component for this Intent.
5254 *
5255 * @return Returns the same Intent object, for chaining multiple calls
5256 * into a single statement.
5257 *
5258 * @see #setComponent
5259 * @see #setClass
5260 */
5261 public Intent setClassName(String packageName, String className) {
5262 mComponent = new ComponentName(packageName, className);
5263 return this;
5264 }
5265
5266 /**
5267 * Convenience for calling {@link #setComponent(ComponentName)} with the
5268 * name returned by a {@link Class} object.
5269 *
5270 * @param packageContext A Context of the application package implementing
5271 * this class.
5272 * @param cls The class name to set, equivalent to
5273 * <code>setClassName(context, cls.getName())</code>.
5274 *
5275 * @return Returns the same Intent object, for chaining multiple calls
5276 * into a single statement.
5277 *
5278 * @see #setComponent
5279 */
5280 public Intent setClass(Context packageContext, Class<?> cls) {
5281 mComponent = new ComponentName(packageContext, cls);
5282 return this;
5283 }
5284
5285 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005286 * Set the bounds of the sender of this intent, in screen coordinates. This can be
5287 * used as a hint to the receiver for animations and the like. Null means that there
5288 * is no source bounds.
5289 */
5290 public void setSourceBounds(Rect r) {
5291 if (r != null) {
5292 mSourceBounds = new Rect(r);
5293 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005294 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005295 }
5296 }
5297
5298 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005299 * Use with {@link #fillIn} to allow the current action value to be
5300 * overwritten, even if it is already set.
5301 */
5302 public static final int FILL_IN_ACTION = 1<<0;
5303
5304 /**
5305 * Use with {@link #fillIn} to allow the current data or type value
5306 * overwritten, even if it is already set.
5307 */
5308 public static final int FILL_IN_DATA = 1<<1;
5309
5310 /**
5311 * Use with {@link #fillIn} to allow the current categories to be
5312 * overwritten, even if they are already set.
5313 */
5314 public static final int FILL_IN_CATEGORIES = 1<<2;
5315
5316 /**
5317 * Use with {@link #fillIn} to allow the current component value to be
5318 * overwritten, even if it is already set.
5319 */
5320 public static final int FILL_IN_COMPONENT = 1<<3;
5321
5322 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005323 * Use with {@link #fillIn} to allow the current package value to be
5324 * overwritten, even if it is already set.
5325 */
5326 public static final int FILL_IN_PACKAGE = 1<<4;
5327
5328 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005329 * Use with {@link #fillIn} to allow the current package value to be
5330 * overwritten, even if it is already set.
5331 */
5332 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
5333
5334 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005335 * Copy the contents of <var>other</var> in to this object, but only
5336 * where fields are not defined by this object. For purposes of a field
5337 * being defined, the following pieces of data in the Intent are
5338 * considered to be separate fields:
5339 *
5340 * <ul>
5341 * <li> action, as set by {@link #setAction}.
5342 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
5343 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
5344 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005345 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005346 * <li> component, as set by {@link #setComponent(ComponentName)} or
5347 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005348 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005349 * <li> each top-level name in the associated extras.
5350 * </ul>
5351 *
5352 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005353 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5354 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005355 * corresponding field will not be replaced if it is already set.
5356 *
Brett Chabot3e391752009-07-21 16:07:23 -07005357 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
5358 * specified.
5359 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005360 * <p>For example, consider Intent A with {data="foo", categories="bar"}
5361 * and Intent B with {action="gotit", data-type="some/thing",
5362 * categories="one","two"}.
5363 *
5364 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
5365 * containing: {action="gotit", data-type="some/thing",
5366 * categories="bar"}.
5367 *
5368 * @param other Another Intent whose values are to be used to fill in
5369 * the current one.
5370 * @param flags Options to control which fields can be filled in.
5371 *
5372 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005373 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5374 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005375 */
5376 public int fillIn(Intent other, int flags) {
5377 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005378 if (other.mAction != null
5379 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380 mAction = other.mAction;
5381 changes |= FILL_IN_ACTION;
5382 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005383 if ((other.mData != null || other.mType != null)
5384 && ((mData == null && mType == null)
5385 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005386 mData = other.mData;
5387 mType = other.mType;
5388 changes |= FILL_IN_DATA;
5389 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005390 if (other.mCategories != null
5391 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005392 if (other.mCategories != null) {
5393 mCategories = new HashSet<String>(other.mCategories);
5394 }
5395 changes |= FILL_IN_CATEGORIES;
5396 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005397 if (other.mPackage != null
5398 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5399 mPackage = other.mPackage;
5400 changes |= FILL_IN_PACKAGE;
5401 }
5402 // Component is special: it can -only- be set if explicitly allowed,
5403 // since otherwise the sender could force the intent somewhere the
5404 // originator didn't intend.
5405 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005406 mComponent = other.mComponent;
5407 changes |= FILL_IN_COMPONENT;
5408 }
5409 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005410 if (other.mSourceBounds != null
5411 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5412 mSourceBounds = new Rect(other.mSourceBounds);
5413 changes |= FILL_IN_SOURCE_BOUNDS;
5414 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005415 if (mExtras == null) {
5416 if (other.mExtras != null) {
5417 mExtras = new Bundle(other.mExtras);
5418 }
5419 } else if (other.mExtras != null) {
5420 try {
5421 Bundle newb = new Bundle(other.mExtras);
5422 newb.putAll(mExtras);
5423 mExtras = newb;
5424 } catch (RuntimeException e) {
5425 // Modifying the extras can cause us to unparcel the contents
5426 // of the bundle, and if we do this in the system process that
5427 // may fail. We really should handle this (i.e., the Bundle
5428 // impl shouldn't be on top of a plain map), but for now just
5429 // ignore it and keep the original contents. :(
5430 Log.w("Intent", "Failure filling in extras", e);
5431 }
5432 }
5433 return changes;
5434 }
5435
5436 /**
5437 * Wrapper class holding an Intent and implementing comparisons on it for
5438 * the purpose of filtering. The class implements its
5439 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5440 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5441 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5442 * on the wrapped Intent.
5443 */
5444 public static final class FilterComparison {
5445 private final Intent mIntent;
5446 private final int mHashCode;
5447
5448 public FilterComparison(Intent intent) {
5449 mIntent = intent;
5450 mHashCode = intent.filterHashCode();
5451 }
5452
5453 /**
5454 * Return the Intent that this FilterComparison represents.
5455 * @return Returns the Intent held by the FilterComparison. Do
5456 * not modify!
5457 */
5458 public Intent getIntent() {
5459 return mIntent;
5460 }
5461
5462 @Override
5463 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005464 if (obj instanceof FilterComparison) {
5465 Intent other = ((FilterComparison)obj).mIntent;
5466 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005467 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005468 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005469 }
5470
5471 @Override
5472 public int hashCode() {
5473 return mHashCode;
5474 }
5475 }
5476
5477 /**
5478 * Determine if two intents are the same for the purposes of intent
5479 * resolution (filtering). That is, if their action, data, type,
5480 * class, and categories are the same. This does <em>not</em> compare
5481 * any extra data included in the intents.
5482 *
5483 * @param other The other Intent to compare against.
5484 *
5485 * @return Returns true if action, data, type, class, and categories
5486 * are the same.
5487 */
5488 public boolean filterEquals(Intent other) {
5489 if (other == null) {
5490 return false;
5491 }
5492 if (mAction != other.mAction) {
5493 if (mAction != null) {
5494 if (!mAction.equals(other.mAction)) {
5495 return false;
5496 }
5497 } else {
5498 if (!other.mAction.equals(mAction)) {
5499 return false;
5500 }
5501 }
5502 }
5503 if (mData != other.mData) {
5504 if (mData != null) {
5505 if (!mData.equals(other.mData)) {
5506 return false;
5507 }
5508 } else {
5509 if (!other.mData.equals(mData)) {
5510 return false;
5511 }
5512 }
5513 }
5514 if (mType != other.mType) {
5515 if (mType != null) {
5516 if (!mType.equals(other.mType)) {
5517 return false;
5518 }
5519 } else {
5520 if (!other.mType.equals(mType)) {
5521 return false;
5522 }
5523 }
5524 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005525 if (mPackage != other.mPackage) {
5526 if (mPackage != null) {
5527 if (!mPackage.equals(other.mPackage)) {
5528 return false;
5529 }
5530 } else {
5531 if (!other.mPackage.equals(mPackage)) {
5532 return false;
5533 }
5534 }
5535 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005536 if (mComponent != other.mComponent) {
5537 if (mComponent != null) {
5538 if (!mComponent.equals(other.mComponent)) {
5539 return false;
5540 }
5541 } else {
5542 if (!other.mComponent.equals(mComponent)) {
5543 return false;
5544 }
5545 }
5546 }
5547 if (mCategories != other.mCategories) {
5548 if (mCategories != null) {
5549 if (!mCategories.equals(other.mCategories)) {
5550 return false;
5551 }
5552 } else {
5553 if (!other.mCategories.equals(mCategories)) {
5554 return false;
5555 }
5556 }
5557 }
5558
5559 return true;
5560 }
5561
5562 /**
5563 * Generate hash code that matches semantics of filterEquals().
5564 *
5565 * @return Returns the hash value of the action, data, type, class, and
5566 * categories.
5567 *
5568 * @see #filterEquals
5569 */
5570 public int filterHashCode() {
5571 int code = 0;
5572 if (mAction != null) {
5573 code += mAction.hashCode();
5574 }
5575 if (mData != null) {
5576 code += mData.hashCode();
5577 }
5578 if (mType != null) {
5579 code += mType.hashCode();
5580 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005581 if (mPackage != null) {
5582 code += mPackage.hashCode();
5583 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005584 if (mComponent != null) {
5585 code += mComponent.hashCode();
5586 }
5587 if (mCategories != null) {
5588 code += mCategories.hashCode();
5589 }
5590 return code;
5591 }
5592
5593 @Override
5594 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005595 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005596
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005597 b.append("Intent { ");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005598 toShortString(b, true, true, true);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005599 b.append(" }");
5600
5601 return b.toString();
5602 }
5603
5604 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005605 public String toInsecureString() {
5606 StringBuilder b = new StringBuilder(128);
5607
5608 b.append("Intent { ");
5609 toShortString(b, false, true, true);
5610 b.append(" }");
5611
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005612 return b.toString();
5613 }
Romain Guy4969af72009-06-17 10:53:19 -07005614
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005615 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005616 public String toShortString(boolean secure, boolean comp, boolean extras) {
5617 StringBuilder b = new StringBuilder(128);
5618 toShortString(b, secure, comp, extras);
5619 return b.toString();
5620 }
5621
5622 /** @hide */
5623 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005624 boolean first = true;
5625 if (mAction != null) {
5626 b.append("act=").append(mAction);
5627 first = false;
5628 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005629 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005630 if (!first) {
5631 b.append(' ');
5632 }
5633 first = false;
5634 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005635 Iterator<String> i = mCategories.iterator();
5636 boolean didone = false;
5637 while (i.hasNext()) {
5638 if (didone) b.append(",");
5639 didone = true;
5640 b.append(i.next());
5641 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005642 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005643 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005644 if (mData != null) {
5645 if (!first) {
5646 b.append(' ');
5647 }
5648 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07005649 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005650 if (secure) {
5651 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07005652 } else {
5653 b.append(mData);
5654 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005655 }
5656 if (mType != null) {
5657 if (!first) {
5658 b.append(' ');
5659 }
5660 first = false;
5661 b.append("typ=").append(mType);
5662 }
5663 if (mFlags != 0) {
5664 if (!first) {
5665 b.append(' ');
5666 }
5667 first = false;
5668 b.append("flg=0x").append(Integer.toHexString(mFlags));
5669 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005670 if (mPackage != null) {
5671 if (!first) {
5672 b.append(' ');
5673 }
5674 first = false;
5675 b.append("pkg=").append(mPackage);
5676 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005677 if (comp && mComponent != null) {
5678 if (!first) {
5679 b.append(' ');
5680 }
5681 first = false;
5682 b.append("cmp=").append(mComponent.flattenToShortString());
5683 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005684 if (mSourceBounds != null) {
5685 if (!first) {
5686 b.append(' ');
5687 }
5688 first = false;
5689 b.append("bnds=").append(mSourceBounds.toShortString());
5690 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005691 if (extras && mExtras != null) {
5692 if (!first) {
5693 b.append(' ');
5694 }
5695 first = false;
5696 b.append("(has extras)");
5697 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005698 }
5699
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005700 /**
5701 * Call {@link #toUri} with 0 flags.
5702 * @deprecated Use {@link #toUri} instead.
5703 */
5704 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005705 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005706 return toUri(0);
5707 }
5708
5709 /**
5710 * Convert this Intent into a String holding a URI representation of it.
5711 * The returned URI string has been properly URI encoded, so it can be
5712 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5713 * Intent's data as the base URI, with an additional fragment describing
5714 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005715 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005716 * <p>You can convert the returned string back to an Intent with
5717 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005718 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005719 * @param flags Additional operating flags. Either 0 or
5720 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005721 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005722 * @return Returns a URI encoding URI string describing the entire contents
5723 * of the Intent.
5724 */
5725 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005726 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005727 String scheme = null;
5728 if (mData != null) {
5729 String data = mData.toString();
5730 if ((flags&URI_INTENT_SCHEME) != 0) {
5731 final int N = data.length();
5732 for (int i=0; i<N; i++) {
5733 char c = data.charAt(i);
5734 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5735 || c == '.' || c == '-') {
5736 continue;
5737 }
5738 if (c == ':' && i > 0) {
5739 // Valid scheme.
5740 scheme = data.substring(0, i);
5741 uri.append("intent:");
5742 data = data.substring(i+1);
5743 break;
5744 }
Tom Taylord4a47292009-12-21 13:59:18 -08005745
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005746 // No scheme.
5747 break;
5748 }
5749 }
5750 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005751
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005752 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5753 uri.append("intent:");
5754 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005755
5756 uri.append("#Intent;");
5757
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005758 if (scheme != null) {
5759 uri.append("scheme=").append(scheme).append(';');
5760 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005761 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005762 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 }
5764 if (mCategories != null) {
5765 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005766 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005767 }
5768 }
5769 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005770 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005771 }
5772 if (mFlags != 0) {
5773 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5774 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005775 if (mPackage != null) {
5776 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5777 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005778 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005779 uri.append("component=").append(Uri.encode(
5780 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005781 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005782 if (mSourceBounds != null) {
5783 uri.append("sourceBounds=")
5784 .append(Uri.encode(mSourceBounds.flattenToString()))
5785 .append(';');
5786 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005787 if (mExtras != null) {
5788 for (String key : mExtras.keySet()) {
5789 final Object value = mExtras.get(key);
5790 char entryType =
5791 value instanceof String ? 'S' :
5792 value instanceof Boolean ? 'B' :
5793 value instanceof Byte ? 'b' :
5794 value instanceof Character ? 'c' :
5795 value instanceof Double ? 'd' :
5796 value instanceof Float ? 'f' :
5797 value instanceof Integer ? 'i' :
5798 value instanceof Long ? 'l' :
5799 value instanceof Short ? 's' :
5800 '\0';
5801
5802 if (entryType != '\0') {
5803 uri.append(entryType);
5804 uri.append('.');
5805 uri.append(Uri.encode(key));
5806 uri.append('=');
5807 uri.append(Uri.encode(value.toString()));
5808 uri.append(';');
5809 }
5810 }
5811 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005812
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005813 uri.append("end");
5814
5815 return uri.toString();
5816 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005817
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005818 public int describeContents() {
5819 return (mExtras != null) ? mExtras.describeContents() : 0;
5820 }
5821
5822 public void writeToParcel(Parcel out, int flags) {
5823 out.writeString(mAction);
5824 Uri.writeToParcel(out, mData);
5825 out.writeString(mType);
5826 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005827 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005828 ComponentName.writeToParcel(mComponent, out);
5829
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005830 if (mSourceBounds != null) {
5831 out.writeInt(1);
5832 mSourceBounds.writeToParcel(out, flags);
5833 } else {
5834 out.writeInt(0);
5835 }
5836
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005837 if (mCategories != null) {
5838 out.writeInt(mCategories.size());
5839 for (String category : mCategories) {
5840 out.writeString(category);
5841 }
5842 } else {
5843 out.writeInt(0);
5844 }
5845
5846 out.writeBundle(mExtras);
5847 }
5848
5849 public static final Parcelable.Creator<Intent> CREATOR
5850 = new Parcelable.Creator<Intent>() {
5851 public Intent createFromParcel(Parcel in) {
5852 return new Intent(in);
5853 }
5854 public Intent[] newArray(int size) {
5855 return new Intent[size];
5856 }
5857 };
5858
Dianne Hackborneb034652009-09-07 00:49:58 -07005859 /** @hide */
5860 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005861 readFromParcel(in);
5862 }
5863
5864 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005865 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005866 mData = Uri.CREATOR.createFromParcel(in);
5867 mType = in.readString();
5868 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005869 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005870 mComponent = ComponentName.readFromParcel(in);
5871
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005872 if (in.readInt() != 0) {
5873 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5874 }
5875
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005876 int N = in.readInt();
5877 if (N > 0) {
5878 mCategories = new HashSet<String>();
5879 int i;
5880 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005881 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005882 }
5883 } else {
5884 mCategories = null;
5885 }
5886
5887 mExtras = in.readBundle();
5888 }
5889
5890 /**
5891 * Parses the "intent" element (and its children) from XML and instantiates
5892 * an Intent object. The given XML parser should be located at the tag
5893 * where parsing should start (often named "intent"), from which the
5894 * basic action, data, type, and package and class name will be
5895 * retrieved. The function will then parse in to any child elements,
5896 * looking for <category android:name="xxx"> tags to add categories and
5897 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5898 * to the intent.
5899 *
5900 * @param resources The Resources to use when inflating resources.
5901 * @param parser The XML parser pointing at an "intent" tag.
5902 * @param attrs The AttributeSet interface for retrieving extended
5903 * attribute data at the current <var>parser</var> location.
5904 * @return An Intent object matching the XML data.
5905 * @throws XmlPullParserException If there was an XML parsing error.
5906 * @throws IOException If there was an I/O error.
5907 */
5908 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5909 throws XmlPullParserException, IOException {
5910 Intent intent = new Intent();
5911
5912 TypedArray sa = resources.obtainAttributes(attrs,
5913 com.android.internal.R.styleable.Intent);
5914
5915 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5916
5917 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5918 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5919 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5920
5921 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5922 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5923 if (packageName != null && className != null) {
5924 intent.setComponent(new ComponentName(packageName, className));
5925 }
5926
5927 sa.recycle();
5928
5929 int outerDepth = parser.getDepth();
5930 int type;
5931 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5932 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5933 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5934 continue;
5935 }
5936
5937 String nodeName = parser.getName();
5938 if (nodeName.equals("category")) {
5939 sa = resources.obtainAttributes(attrs,
5940 com.android.internal.R.styleable.IntentCategory);
5941 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5942 sa.recycle();
5943
5944 if (cat != null) {
5945 intent.addCategory(cat);
5946 }
5947 XmlUtils.skipCurrentTag(parser);
5948
5949 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005950 if (intent.mExtras == null) {
5951 intent.mExtras = new Bundle();
5952 }
5953 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5954 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005955
5956 } else {
5957 XmlUtils.skipCurrentTag(parser);
5958 }
5959 }
5960
5961 return intent;
5962 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005963}