blob: 28965cbba6e1a739d6b5077d1783a2fd918ed1f1 [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
60 * 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>
62 *
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";
2569
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
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003579 /**
3580 * Retrieve extended data from the intent.
3581 *
3582 * @param name The name of the desired item.
3583 *
3584 * @return the value of an item that previously added with putExtra()
3585 * or null if none was found.
3586 *
3587 * @deprecated
3588 * @hide
3589 */
3590 @Deprecated
3591 public Object getExtra(String name) {
3592 return getExtra(name, null);
3593 }
3594
3595 /**
3596 * Retrieve extended data from the intent.
3597 *
3598 * @param name The name of the desired item.
3599 * @param defaultValue the value to be returned if no value of the desired
3600 * type is stored with the given name.
3601 *
3602 * @return the value of an item that previously added with putExtra()
3603 * or the default value if none was found.
3604 *
3605 * @see #putExtra(String, boolean)
3606 */
3607 public boolean getBooleanExtra(String name, boolean defaultValue) {
3608 return mExtras == null ? defaultValue :
3609 mExtras.getBoolean(name, defaultValue);
3610 }
3611
3612 /**
3613 * Retrieve extended data from the intent.
3614 *
3615 * @param name The name of the desired item.
3616 * @param defaultValue the value to be returned if no value of the desired
3617 * type is stored with the given name.
3618 *
3619 * @return the value of an item that previously added with putExtra()
3620 * or the default value if none was found.
3621 *
3622 * @see #putExtra(String, byte)
3623 */
3624 public byte getByteExtra(String name, byte defaultValue) {
3625 return mExtras == null ? defaultValue :
3626 mExtras.getByte(name, defaultValue);
3627 }
3628
3629 /**
3630 * Retrieve extended data from the intent.
3631 *
3632 * @param name The name of the desired item.
3633 * @param defaultValue the value to be returned if no value of the desired
3634 * type is stored with the given name.
3635 *
3636 * @return the value of an item that previously added with putExtra()
3637 * or the default value if none was found.
3638 *
3639 * @see #putExtra(String, short)
3640 */
3641 public short getShortExtra(String name, short defaultValue) {
3642 return mExtras == null ? defaultValue :
3643 mExtras.getShort(name, defaultValue);
3644 }
3645
3646 /**
3647 * Retrieve extended data from the intent.
3648 *
3649 * @param name The name of the desired item.
3650 * @param defaultValue the value to be returned if no value of the desired
3651 * type is stored with the given name.
3652 *
3653 * @return the value of an item that previously added with putExtra()
3654 * or the default value if none was found.
3655 *
3656 * @see #putExtra(String, char)
3657 */
3658 public char getCharExtra(String name, char defaultValue) {
3659 return mExtras == null ? defaultValue :
3660 mExtras.getChar(name, defaultValue);
3661 }
3662
3663 /**
3664 * Retrieve extended data from the intent.
3665 *
3666 * @param name The name of the desired item.
3667 * @param defaultValue the value to be returned if no value of the desired
3668 * type is stored with the given name.
3669 *
3670 * @return the value of an item that previously added with putExtra()
3671 * or the default value if none was found.
3672 *
3673 * @see #putExtra(String, int)
3674 */
3675 public int getIntExtra(String name, int defaultValue) {
3676 return mExtras == null ? defaultValue :
3677 mExtras.getInt(name, defaultValue);
3678 }
3679
3680 /**
3681 * Retrieve extended data from the intent.
3682 *
3683 * @param name The name of the desired item.
3684 * @param defaultValue the value to be returned if no value of the desired
3685 * type is stored with the given name.
3686 *
3687 * @return the value of an item that previously added with putExtra()
3688 * or the default value if none was found.
3689 *
3690 * @see #putExtra(String, long)
3691 */
3692 public long getLongExtra(String name, long defaultValue) {
3693 return mExtras == null ? defaultValue :
3694 mExtras.getLong(name, defaultValue);
3695 }
3696
3697 /**
3698 * Retrieve extended data from the intent.
3699 *
3700 * @param name The name of the desired item.
3701 * @param defaultValue the value to be returned if no value of the desired
3702 * type is stored with the given name.
3703 *
3704 * @return the value of an item that previously added with putExtra(),
3705 * or the default value if no such item is present
3706 *
3707 * @see #putExtra(String, float)
3708 */
3709 public float getFloatExtra(String name, float defaultValue) {
3710 return mExtras == null ? defaultValue :
3711 mExtras.getFloat(name, defaultValue);
3712 }
3713
3714 /**
3715 * Retrieve extended data from the intent.
3716 *
3717 * @param name The name of the desired item.
3718 * @param defaultValue the value to be returned if no value of the desired
3719 * type is stored with the given name.
3720 *
3721 * @return the value of an item that previously added with putExtra()
3722 * or the default value if none was found.
3723 *
3724 * @see #putExtra(String, double)
3725 */
3726 public double getDoubleExtra(String name, double defaultValue) {
3727 return mExtras == null ? defaultValue :
3728 mExtras.getDouble(name, defaultValue);
3729 }
3730
3731 /**
3732 * Retrieve extended data from the intent.
3733 *
3734 * @param name The name of the desired item.
3735 *
3736 * @return the value of an item that previously added with putExtra()
3737 * or null if no String value was found.
3738 *
3739 * @see #putExtra(String, String)
3740 */
3741 public String getStringExtra(String name) {
3742 return mExtras == null ? null : mExtras.getString(name);
3743 }
3744
3745 /**
3746 * Retrieve extended data from the intent.
3747 *
3748 * @param name The name of the desired item.
3749 *
3750 * @return the value of an item that previously added with putExtra()
3751 * or null if no CharSequence value was found.
3752 *
3753 * @see #putExtra(String, CharSequence)
3754 */
3755 public CharSequence getCharSequenceExtra(String name) {
3756 return mExtras == null ? null : mExtras.getCharSequence(name);
3757 }
3758
3759 /**
3760 * Retrieve extended data from the intent.
3761 *
3762 * @param name The name of the desired item.
3763 *
3764 * @return the value of an item that previously added with putExtra()
3765 * or null if no Parcelable value was found.
3766 *
3767 * @see #putExtra(String, Parcelable)
3768 */
3769 public <T extends Parcelable> T getParcelableExtra(String name) {
3770 return mExtras == null ? null : mExtras.<T>getParcelable(name);
3771 }
3772
3773 /**
3774 * Retrieve extended data from the intent.
3775 *
3776 * @param name The name of the desired item.
3777 *
3778 * @return the value of an item that previously added with putExtra()
3779 * or null if no Parcelable[] value was found.
3780 *
3781 * @see #putExtra(String, Parcelable[])
3782 */
3783 public Parcelable[] getParcelableArrayExtra(String name) {
3784 return mExtras == null ? null : mExtras.getParcelableArray(name);
3785 }
3786
3787 /**
3788 * Retrieve extended data from the intent.
3789 *
3790 * @param name The name of the desired item.
3791 *
3792 * @return the value of an item that previously added with putExtra()
3793 * or null if no ArrayList<Parcelable> value was found.
3794 *
3795 * @see #putParcelableArrayListExtra(String, ArrayList)
3796 */
3797 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
3798 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
3799 }
3800
3801 /**
3802 * Retrieve extended data from the intent.
3803 *
3804 * @param name The name of the desired item.
3805 *
3806 * @return the value of an item that previously added with putExtra()
3807 * or null if no Serializable value was found.
3808 *
3809 * @see #putExtra(String, Serializable)
3810 */
3811 public Serializable getSerializableExtra(String name) {
3812 return mExtras == null ? null : mExtras.getSerializable(name);
3813 }
3814
3815 /**
3816 * Retrieve extended data from the intent.
3817 *
3818 * @param name The name of the desired item.
3819 *
3820 * @return the value of an item that previously added with putExtra()
3821 * or null if no ArrayList<Integer> value was found.
3822 *
3823 * @see #putIntegerArrayListExtra(String, ArrayList)
3824 */
3825 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
3826 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
3827 }
3828
3829 /**
3830 * Retrieve extended data from the intent.
3831 *
3832 * @param name The name of the desired item.
3833 *
3834 * @return the value of an item that previously added with putExtra()
3835 * or null if no ArrayList<String> value was found.
3836 *
3837 * @see #putStringArrayListExtra(String, ArrayList)
3838 */
3839 public ArrayList<String> getStringArrayListExtra(String name) {
3840 return mExtras == null ? null : mExtras.getStringArrayList(name);
3841 }
3842
3843 /**
3844 * Retrieve extended data from the intent.
3845 *
3846 * @param name The name of the desired item.
3847 *
3848 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003849 * or null if no ArrayList<CharSequence> value was found.
3850 *
3851 * @see #putCharSequenceArrayListExtra(String, ArrayList)
3852 */
3853 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
3854 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
3855 }
3856
3857 /**
3858 * Retrieve extended data from the intent.
3859 *
3860 * @param name The name of the desired item.
3861 *
3862 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003863 * or null if no boolean array value was found.
3864 *
3865 * @see #putExtra(String, boolean[])
3866 */
3867 public boolean[] getBooleanArrayExtra(String name) {
3868 return mExtras == null ? null : mExtras.getBooleanArray(name);
3869 }
3870
3871 /**
3872 * Retrieve extended data from the intent.
3873 *
3874 * @param name The name of the desired item.
3875 *
3876 * @return the value of an item that previously added with putExtra()
3877 * or null if no byte array value was found.
3878 *
3879 * @see #putExtra(String, byte[])
3880 */
3881 public byte[] getByteArrayExtra(String name) {
3882 return mExtras == null ? null : mExtras.getByteArray(name);
3883 }
3884
3885 /**
3886 * Retrieve extended data from the intent.
3887 *
3888 * @param name The name of the desired item.
3889 *
3890 * @return the value of an item that previously added with putExtra()
3891 * or null if no short array value was found.
3892 *
3893 * @see #putExtra(String, short[])
3894 */
3895 public short[] getShortArrayExtra(String name) {
3896 return mExtras == null ? null : mExtras.getShortArray(name);
3897 }
3898
3899 /**
3900 * Retrieve extended data from the intent.
3901 *
3902 * @param name The name of the desired item.
3903 *
3904 * @return the value of an item that previously added with putExtra()
3905 * or null if no char array value was found.
3906 *
3907 * @see #putExtra(String, char[])
3908 */
3909 public char[] getCharArrayExtra(String name) {
3910 return mExtras == null ? null : mExtras.getCharArray(name);
3911 }
3912
3913 /**
3914 * Retrieve extended data from the intent.
3915 *
3916 * @param name The name of the desired item.
3917 *
3918 * @return the value of an item that previously added with putExtra()
3919 * or null if no int array value was found.
3920 *
3921 * @see #putExtra(String, int[])
3922 */
3923 public int[] getIntArrayExtra(String name) {
3924 return mExtras == null ? null : mExtras.getIntArray(name);
3925 }
3926
3927 /**
3928 * Retrieve extended data from the intent.
3929 *
3930 * @param name The name of the desired item.
3931 *
3932 * @return the value of an item that previously added with putExtra()
3933 * or null if no long array value was found.
3934 *
3935 * @see #putExtra(String, long[])
3936 */
3937 public long[] getLongArrayExtra(String name) {
3938 return mExtras == null ? null : mExtras.getLongArray(name);
3939 }
3940
3941 /**
3942 * Retrieve extended data from the intent.
3943 *
3944 * @param name The name of the desired item.
3945 *
3946 * @return the value of an item that previously added with putExtra()
3947 * or null if no float array value was found.
3948 *
3949 * @see #putExtra(String, float[])
3950 */
3951 public float[] getFloatArrayExtra(String name) {
3952 return mExtras == null ? null : mExtras.getFloatArray(name);
3953 }
3954
3955 /**
3956 * Retrieve extended data from the intent.
3957 *
3958 * @param name The name of the desired item.
3959 *
3960 * @return the value of an item that previously added with putExtra()
3961 * or null if no double array value was found.
3962 *
3963 * @see #putExtra(String, double[])
3964 */
3965 public double[] getDoubleArrayExtra(String name) {
3966 return mExtras == null ? null : mExtras.getDoubleArray(name);
3967 }
3968
3969 /**
3970 * Retrieve extended data from the intent.
3971 *
3972 * @param name The name of the desired item.
3973 *
3974 * @return the value of an item that previously added with putExtra()
3975 * or null if no String array value was found.
3976 *
3977 * @see #putExtra(String, String[])
3978 */
3979 public String[] getStringArrayExtra(String name) {
3980 return mExtras == null ? null : mExtras.getStringArray(name);
3981 }
3982
3983 /**
3984 * Retrieve extended data from the intent.
3985 *
3986 * @param name The name of the desired item.
3987 *
3988 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00003989 * or null if no CharSequence array value was found.
3990 *
3991 * @see #putExtra(String, CharSequence[])
3992 */
3993 public CharSequence[] getCharSequenceArrayExtra(String name) {
3994 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
3995 }
3996
3997 /**
3998 * Retrieve extended data from the intent.
3999 *
4000 * @param name The name of the desired item.
4001 *
4002 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004003 * or null if no Bundle value was found.
4004 *
4005 * @see #putExtra(String, Bundle)
4006 */
4007 public Bundle getBundleExtra(String name) {
4008 return mExtras == null ? null : mExtras.getBundle(name);
4009 }
4010
4011 /**
4012 * Retrieve extended data from the intent.
4013 *
4014 * @param name The name of the desired item.
4015 *
4016 * @return the value of an item that previously added with putExtra()
4017 * or null if no IBinder value was found.
4018 *
4019 * @see #putExtra(String, IBinder)
4020 *
4021 * @deprecated
4022 * @hide
4023 */
4024 @Deprecated
4025 public IBinder getIBinderExtra(String name) {
4026 return mExtras == null ? null : mExtras.getIBinder(name);
4027 }
4028
4029 /**
4030 * Retrieve extended data from the intent.
4031 *
4032 * @param name The name of the desired item.
4033 * @param defaultValue The default value to return in case no item is
4034 * associated with the key 'name'
4035 *
4036 * @return the value of an item that previously added with putExtra()
4037 * or defaultValue if none was found.
4038 *
4039 * @see #putExtra
4040 *
4041 * @deprecated
4042 * @hide
4043 */
4044 @Deprecated
4045 public Object getExtra(String name, Object defaultValue) {
4046 Object result = defaultValue;
4047 if (mExtras != null) {
4048 Object result2 = mExtras.get(name);
4049 if (result2 != null) {
4050 result = result2;
4051 }
4052 }
4053
4054 return result;
4055 }
4056
4057 /**
4058 * Retrieves a map of extended data from the intent.
4059 *
4060 * @return the map of all extras previously added with putExtra(),
4061 * or null if none have been added.
4062 */
4063 public Bundle getExtras() {
4064 return (mExtras != null)
4065 ? new Bundle(mExtras)
4066 : null;
4067 }
4068
4069 /**
4070 * Retrieve any special flags associated with this intent. You will
4071 * normally just set them with {@link #setFlags} and let the system
4072 * take the appropriate action with them.
4073 *
4074 * @return int The currently set flags.
4075 *
4076 * @see #setFlags
4077 */
4078 public int getFlags() {
4079 return mFlags;
4080 }
4081
Dianne Hackborne7f97212011-02-24 14:40:20 -08004082 /** @hide */
4083 public boolean isExcludingStopped() {
4084 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4085 == FLAG_EXCLUDE_STOPPED_PACKAGES;
4086 }
4087
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004088 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004089 * Retrieve the application package name this Intent is limited to. When
4090 * resolving an Intent, if non-null this limits the resolution to only
4091 * components in the given application package.
4092 *
4093 * @return The name of the application package for the Intent.
4094 *
4095 * @see #resolveActivity
4096 * @see #setPackage
4097 */
4098 public String getPackage() {
4099 return mPackage;
4100 }
4101
4102 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004103 * Retrieve the concrete component associated with the intent. When receiving
4104 * an intent, this is the component that was found to best handle it (that is,
4105 * yourself) and will always be non-null; in all other cases it will be
4106 * null unless explicitly set.
4107 *
4108 * @return The name of the application component to handle the intent.
4109 *
4110 * @see #resolveActivity
4111 * @see #setComponent
4112 */
4113 public ComponentName getComponent() {
4114 return mComponent;
4115 }
4116
4117 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004118 * Get the bounds of the sender of this intent, in screen coordinates. This can be
4119 * used as a hint to the receiver for animations and the like. Null means that there
4120 * is no source bounds.
4121 */
4122 public Rect getSourceBounds() {
4123 return mSourceBounds;
4124 }
4125
4126 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004127 * Return the Activity component that should be used to handle this intent.
4128 * The appropriate component is determined based on the information in the
4129 * intent, evaluated as follows:
4130 *
4131 * <p>If {@link #getComponent} returns an explicit class, that is returned
4132 * without any further consideration.
4133 *
4134 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
4135 * category to be considered.
4136 *
4137 * <p>If {@link #getAction} is non-NULL, the activity must handle this
4138 * action.
4139 *
4140 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
4141 * this type.
4142 *
4143 * <p>If {@link #addCategory} has added any categories, the activity must
4144 * handle ALL of the categories specified.
4145 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004146 * <p>If {@link #getPackage} is non-NULL, only activity components in
4147 * that application package will be considered.
4148 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004149 * <p>If there are no activities that satisfy all of these conditions, a
4150 * null string is returned.
4151 *
4152 * <p>If multiple activities are found to satisfy the intent, the one with
4153 * the highest priority will be used. If there are multiple activities
4154 * with the same priority, the system will either pick the best activity
4155 * based on user preference, or resolve to a system class that will allow
4156 * the user to pick an activity and forward from there.
4157 *
4158 * <p>This method is implemented simply by calling
4159 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
4160 * true.</p>
4161 * <p> This API is called for you as part of starting an activity from an
4162 * intent. You do not normally need to call it yourself.</p>
4163 *
4164 * @param pm The package manager with which to resolve the Intent.
4165 *
4166 * @return Name of the component implementing an activity that can
4167 * display the intent.
4168 *
4169 * @see #setComponent
4170 * @see #getComponent
4171 * @see #resolveActivityInfo
4172 */
4173 public ComponentName resolveActivity(PackageManager pm) {
4174 if (mComponent != null) {
4175 return mComponent;
4176 }
4177
4178 ResolveInfo info = pm.resolveActivity(
4179 this, PackageManager.MATCH_DEFAULT_ONLY);
4180 if (info != null) {
4181 return new ComponentName(
4182 info.activityInfo.applicationInfo.packageName,
4183 info.activityInfo.name);
4184 }
4185
4186 return null;
4187 }
4188
4189 /**
4190 * Resolve the Intent into an {@link ActivityInfo}
4191 * describing the activity that should execute the intent. Resolution
4192 * follows the same rules as described for {@link #resolveActivity}, but
4193 * you get back the completely information about the resolved activity
4194 * instead of just its class name.
4195 *
4196 * @param pm The package manager with which to resolve the Intent.
4197 * @param flags Addition information to retrieve as per
4198 * {@link PackageManager#getActivityInfo(ComponentName, int)
4199 * PackageManager.getActivityInfo()}.
4200 *
4201 * @return PackageManager.ActivityInfo
4202 *
4203 * @see #resolveActivity
4204 */
4205 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
4206 ActivityInfo ai = null;
4207 if (mComponent != null) {
4208 try {
4209 ai = pm.getActivityInfo(mComponent, flags);
4210 } catch (PackageManager.NameNotFoundException e) {
4211 // ignore
4212 }
4213 } else {
4214 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004215 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 if (info != null) {
4217 ai = info.activityInfo;
4218 }
4219 }
4220
4221 return ai;
4222 }
4223
4224 /**
4225 * Set the general action to be performed.
4226 *
4227 * @param action An action name, such as ACTION_VIEW. Application-specific
4228 * actions should be prefixed with the vendor's package name.
4229 *
4230 * @return Returns the same Intent object, for chaining multiple calls
4231 * into a single statement.
4232 *
4233 * @see #getAction
4234 */
4235 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004236 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004237 return this;
4238 }
4239
4240 /**
4241 * Set the data this intent is operating on. This method automatically
4242 * clears any type that was previously set by {@link #setType}.
4243 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004244 * <p><em>Note: scheme and host name matching in the Android framework is
4245 * case-sensitive, unlike the formal RFC. As a result,
4246 * you should always ensure that you write your Uri with these elements
4247 * using lower case letters, and normalize any Uris you receive from
4248 * outside of Android to ensure the scheme and host is lower case.</em></p>
4249 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004250 * @param data The URI of the data this intent is now targeting.
4251 *
4252 * @return Returns the same Intent object, for chaining multiple calls
4253 * into a single statement.
4254 *
4255 * @see #getData
4256 * @see #setType
4257 * @see #setDataAndType
4258 */
4259 public Intent setData(Uri data) {
4260 mData = data;
4261 mType = null;
4262 return this;
4263 }
4264
4265 /**
4266 * Set an explicit MIME data type. This is used to create intents that
4267 * only specify a type and not data, for example to indicate the type of
4268 * data to return. This method automatically clears any data that was
4269 * previously set by {@link #setData}.
Romain Guy4969af72009-06-17 10:53:19 -07004270 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004271 * <p><em>Note: MIME type matching in the Android framework is
4272 * case-sensitive, unlike formal RFC MIME types. As a result,
4273 * you should always write your MIME types with lower case letters,
4274 * and any MIME types you receive from outside of Android should be
4275 * converted to lower case before supplying them here.</em></p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004276 *
4277 * @param type The MIME type of the data being handled by this intent.
4278 *
4279 * @return Returns the same Intent object, for chaining multiple calls
4280 * into a single statement.
4281 *
4282 * @see #getType
4283 * @see #setData
4284 * @see #setDataAndType
4285 */
4286 public Intent setType(String type) {
4287 mData = null;
4288 mType = type;
4289 return this;
4290 }
4291
4292 /**
4293 * (Usually optional) Set the data for the intent along with an explicit
4294 * MIME data type. This method should very rarely be used -- it allows you
4295 * to override the MIME type that would ordinarily be inferred from the
4296 * data with your own type given here.
4297 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004298 * <p><em>Note: MIME type, Uri scheme, and host name matching in the
4299 * Android framework is case-sensitive, unlike the formal RFC definitions.
4300 * As a result, you should always write these elements with lower case letters,
4301 * and normalize any MIME types or Uris you receive from
4302 * outside of Android to ensure these elements are lower case before
4303 * supplying them here.</em></p>
4304 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004305 * @param data The URI of the data this intent is now targeting.
4306 * @param type The MIME type of the data being handled by this intent.
4307 *
4308 * @return Returns the same Intent object, for chaining multiple calls
4309 * into a single statement.
4310 *
4311 * @see #setData
4312 * @see #setType
4313 */
4314 public Intent setDataAndType(Uri data, String type) {
4315 mData = data;
4316 mType = type;
4317 return this;
4318 }
4319
4320 /**
4321 * Add a new category to the intent. Categories provide additional detail
4322 * about the action the intent is perform. When resolving an intent, only
4323 * activities that provide <em>all</em> of the requested categories will be
4324 * used.
4325 *
4326 * @param category The desired category. This can be either one of the
4327 * predefined Intent categories, or a custom category in your own
4328 * namespace.
4329 *
4330 * @return Returns the same Intent object, for chaining multiple calls
4331 * into a single statement.
4332 *
4333 * @see #hasCategory
4334 * @see #removeCategory
4335 */
4336 public Intent addCategory(String category) {
4337 if (mCategories == null) {
4338 mCategories = new HashSet<String>();
4339 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08004340 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004341 return this;
4342 }
4343
4344 /**
4345 * Remove an category from an intent.
4346 *
4347 * @param category The category to remove.
4348 *
4349 * @see #addCategory
4350 */
4351 public void removeCategory(String category) {
4352 if (mCategories != null) {
4353 mCategories.remove(category);
4354 if (mCategories.size() == 0) {
4355 mCategories = null;
4356 }
4357 }
4358 }
4359
4360 /**
4361 * Add extended data to the intent. The name must include a package
4362 * prefix, for example the app com.android.contacts would use names
4363 * like "com.android.contacts.ShowAll".
4364 *
4365 * @param name The name of the extra data, with package prefix.
4366 * @param value The boolean data value.
4367 *
4368 * @return Returns the same Intent object, for chaining multiple calls
4369 * into a single statement.
4370 *
4371 * @see #putExtras
4372 * @see #removeExtra
4373 * @see #getBooleanExtra(String, boolean)
4374 */
4375 public Intent putExtra(String name, boolean value) {
4376 if (mExtras == null) {
4377 mExtras = new Bundle();
4378 }
4379 mExtras.putBoolean(name, value);
4380 return this;
4381 }
4382
4383 /**
4384 * Add extended data to the intent. The name must include a package
4385 * prefix, for example the app com.android.contacts would use names
4386 * like "com.android.contacts.ShowAll".
4387 *
4388 * @param name The name of the extra data, with package prefix.
4389 * @param value The byte data value.
4390 *
4391 * @return Returns the same Intent object, for chaining multiple calls
4392 * into a single statement.
4393 *
4394 * @see #putExtras
4395 * @see #removeExtra
4396 * @see #getByteExtra(String, byte)
4397 */
4398 public Intent putExtra(String name, byte value) {
4399 if (mExtras == null) {
4400 mExtras = new Bundle();
4401 }
4402 mExtras.putByte(name, value);
4403 return this;
4404 }
4405
4406 /**
4407 * Add extended data to the intent. The name must include a package
4408 * prefix, for example the app com.android.contacts would use names
4409 * like "com.android.contacts.ShowAll".
4410 *
4411 * @param name The name of the extra data, with package prefix.
4412 * @param value The char data value.
4413 *
4414 * @return Returns the same Intent object, for chaining multiple calls
4415 * into a single statement.
4416 *
4417 * @see #putExtras
4418 * @see #removeExtra
4419 * @see #getCharExtra(String, char)
4420 */
4421 public Intent putExtra(String name, char value) {
4422 if (mExtras == null) {
4423 mExtras = new Bundle();
4424 }
4425 mExtras.putChar(name, value);
4426 return this;
4427 }
4428
4429 /**
4430 * Add extended data to the intent. The name must include a package
4431 * prefix, for example the app com.android.contacts would use names
4432 * like "com.android.contacts.ShowAll".
4433 *
4434 * @param name The name of the extra data, with package prefix.
4435 * @param value The short data value.
4436 *
4437 * @return Returns the same Intent object, for chaining multiple calls
4438 * into a single statement.
4439 *
4440 * @see #putExtras
4441 * @see #removeExtra
4442 * @see #getShortExtra(String, short)
4443 */
4444 public Intent putExtra(String name, short value) {
4445 if (mExtras == null) {
4446 mExtras = new Bundle();
4447 }
4448 mExtras.putShort(name, value);
4449 return this;
4450 }
4451
4452 /**
4453 * Add extended data to the intent. The name must include a package
4454 * prefix, for example the app com.android.contacts would use names
4455 * like "com.android.contacts.ShowAll".
4456 *
4457 * @param name The name of the extra data, with package prefix.
4458 * @param value The integer data value.
4459 *
4460 * @return Returns the same Intent object, for chaining multiple calls
4461 * into a single statement.
4462 *
4463 * @see #putExtras
4464 * @see #removeExtra
4465 * @see #getIntExtra(String, int)
4466 */
4467 public Intent putExtra(String name, int value) {
4468 if (mExtras == null) {
4469 mExtras = new Bundle();
4470 }
4471 mExtras.putInt(name, value);
4472 return this;
4473 }
4474
4475 /**
4476 * Add extended data to the intent. The name must include a package
4477 * prefix, for example the app com.android.contacts would use names
4478 * like "com.android.contacts.ShowAll".
4479 *
4480 * @param name The name of the extra data, with package prefix.
4481 * @param value The long data value.
4482 *
4483 * @return Returns the same Intent object, for chaining multiple calls
4484 * into a single statement.
4485 *
4486 * @see #putExtras
4487 * @see #removeExtra
4488 * @see #getLongExtra(String, long)
4489 */
4490 public Intent putExtra(String name, long value) {
4491 if (mExtras == null) {
4492 mExtras = new Bundle();
4493 }
4494 mExtras.putLong(name, value);
4495 return this;
4496 }
4497
4498 /**
4499 * Add extended data to the intent. The name must include a package
4500 * prefix, for example the app com.android.contacts would use names
4501 * like "com.android.contacts.ShowAll".
4502 *
4503 * @param name The name of the extra data, with package prefix.
4504 * @param value The float data value.
4505 *
4506 * @return Returns the same Intent object, for chaining multiple calls
4507 * into a single statement.
4508 *
4509 * @see #putExtras
4510 * @see #removeExtra
4511 * @see #getFloatExtra(String, float)
4512 */
4513 public Intent putExtra(String name, float value) {
4514 if (mExtras == null) {
4515 mExtras = new Bundle();
4516 }
4517 mExtras.putFloat(name, value);
4518 return this;
4519 }
4520
4521 /**
4522 * Add extended data to the intent. The name must include a package
4523 * prefix, for example the app com.android.contacts would use names
4524 * like "com.android.contacts.ShowAll".
4525 *
4526 * @param name The name of the extra data, with package prefix.
4527 * @param value The double data value.
4528 *
4529 * @return Returns the same Intent object, for chaining multiple calls
4530 * into a single statement.
4531 *
4532 * @see #putExtras
4533 * @see #removeExtra
4534 * @see #getDoubleExtra(String, double)
4535 */
4536 public Intent putExtra(String name, double value) {
4537 if (mExtras == null) {
4538 mExtras = new Bundle();
4539 }
4540 mExtras.putDouble(name, value);
4541 return this;
4542 }
4543
4544 /**
4545 * Add extended data to the intent. The name must include a package
4546 * prefix, for example the app com.android.contacts would use names
4547 * like "com.android.contacts.ShowAll".
4548 *
4549 * @param name The name of the extra data, with package prefix.
4550 * @param value The String data value.
4551 *
4552 * @return Returns the same Intent object, for chaining multiple calls
4553 * into a single statement.
4554 *
4555 * @see #putExtras
4556 * @see #removeExtra
4557 * @see #getStringExtra(String)
4558 */
4559 public Intent putExtra(String name, String value) {
4560 if (mExtras == null) {
4561 mExtras = new Bundle();
4562 }
4563 mExtras.putString(name, value);
4564 return this;
4565 }
4566
4567 /**
4568 * Add extended data to the intent. The name must include a package
4569 * prefix, for example the app com.android.contacts would use names
4570 * like "com.android.contacts.ShowAll".
4571 *
4572 * @param name The name of the extra data, with package prefix.
4573 * @param value The CharSequence data value.
4574 *
4575 * @return Returns the same Intent object, for chaining multiple calls
4576 * into a single statement.
4577 *
4578 * @see #putExtras
4579 * @see #removeExtra
4580 * @see #getCharSequenceExtra(String)
4581 */
4582 public Intent putExtra(String name, CharSequence value) {
4583 if (mExtras == null) {
4584 mExtras = new Bundle();
4585 }
4586 mExtras.putCharSequence(name, value);
4587 return this;
4588 }
4589
4590 /**
4591 * Add extended data to the intent. The name must include a package
4592 * prefix, for example the app com.android.contacts would use names
4593 * like "com.android.contacts.ShowAll".
4594 *
4595 * @param name The name of the extra data, with package prefix.
4596 * @param value The Parcelable data value.
4597 *
4598 * @return Returns the same Intent object, for chaining multiple calls
4599 * into a single statement.
4600 *
4601 * @see #putExtras
4602 * @see #removeExtra
4603 * @see #getParcelableExtra(String)
4604 */
4605 public Intent putExtra(String name, Parcelable value) {
4606 if (mExtras == null) {
4607 mExtras = new Bundle();
4608 }
4609 mExtras.putParcelable(name, value);
4610 return this;
4611 }
4612
4613 /**
4614 * Add extended data to the intent. The name must include a package
4615 * prefix, for example the app com.android.contacts would use names
4616 * like "com.android.contacts.ShowAll".
4617 *
4618 * @param name The name of the extra data, with package prefix.
4619 * @param value The Parcelable[] data value.
4620 *
4621 * @return Returns the same Intent object, for chaining multiple calls
4622 * into a single statement.
4623 *
4624 * @see #putExtras
4625 * @see #removeExtra
4626 * @see #getParcelableArrayExtra(String)
4627 */
4628 public Intent putExtra(String name, Parcelable[] value) {
4629 if (mExtras == null) {
4630 mExtras = new Bundle();
4631 }
4632 mExtras.putParcelableArray(name, value);
4633 return this;
4634 }
4635
4636 /**
4637 * Add extended data to the intent. The name must include a package
4638 * prefix, for example the app com.android.contacts would use names
4639 * like "com.android.contacts.ShowAll".
4640 *
4641 * @param name The name of the extra data, with package prefix.
4642 * @param value The ArrayList<Parcelable> data value.
4643 *
4644 * @return Returns the same Intent object, for chaining multiple calls
4645 * into a single statement.
4646 *
4647 * @see #putExtras
4648 * @see #removeExtra
4649 * @see #getParcelableArrayListExtra(String)
4650 */
4651 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
4652 if (mExtras == null) {
4653 mExtras = new Bundle();
4654 }
4655 mExtras.putParcelableArrayList(name, value);
4656 return this;
4657 }
4658
4659 /**
4660 * Add extended data to the intent. The name must include a package
4661 * prefix, for example the app com.android.contacts would use names
4662 * like "com.android.contacts.ShowAll".
4663 *
4664 * @param name The name of the extra data, with package prefix.
4665 * @param value The ArrayList<Integer> data value.
4666 *
4667 * @return Returns the same Intent object, for chaining multiple calls
4668 * into a single statement.
4669 *
4670 * @see #putExtras
4671 * @see #removeExtra
4672 * @see #getIntegerArrayListExtra(String)
4673 */
4674 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
4675 if (mExtras == null) {
4676 mExtras = new Bundle();
4677 }
4678 mExtras.putIntegerArrayList(name, value);
4679 return this;
4680 }
4681
4682 /**
4683 * Add extended data to the intent. The name must include a package
4684 * prefix, for example the app com.android.contacts would use names
4685 * like "com.android.contacts.ShowAll".
4686 *
4687 * @param name The name of the extra data, with package prefix.
4688 * @param value The ArrayList<String> data value.
4689 *
4690 * @return Returns the same Intent object, for chaining multiple calls
4691 * into a single statement.
4692 *
4693 * @see #putExtras
4694 * @see #removeExtra
4695 * @see #getStringArrayListExtra(String)
4696 */
4697 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
4698 if (mExtras == null) {
4699 mExtras = new Bundle();
4700 }
4701 mExtras.putStringArrayList(name, value);
4702 return this;
4703 }
4704
4705 /**
4706 * Add extended data to the intent. The name must include a package
4707 * prefix, for example the app com.android.contacts would use names
4708 * like "com.android.contacts.ShowAll".
4709 *
4710 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004711 * @param value The ArrayList<CharSequence> data value.
4712 *
4713 * @return Returns the same Intent object, for chaining multiple calls
4714 * into a single statement.
4715 *
4716 * @see #putExtras
4717 * @see #removeExtra
4718 * @see #getCharSequenceArrayListExtra(String)
4719 */
4720 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
4721 if (mExtras == null) {
4722 mExtras = new Bundle();
4723 }
4724 mExtras.putCharSequenceArrayList(name, value);
4725 return this;
4726 }
4727
4728 /**
4729 * Add extended data to the intent. The name must include a package
4730 * prefix, for example the app com.android.contacts would use names
4731 * like "com.android.contacts.ShowAll".
4732 *
4733 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004734 * @param value The Serializable data value.
4735 *
4736 * @return Returns the same Intent object, for chaining multiple calls
4737 * into a single statement.
4738 *
4739 * @see #putExtras
4740 * @see #removeExtra
4741 * @see #getSerializableExtra(String)
4742 */
4743 public Intent putExtra(String name, Serializable value) {
4744 if (mExtras == null) {
4745 mExtras = new Bundle();
4746 }
4747 mExtras.putSerializable(name, value);
4748 return this;
4749 }
4750
4751 /**
4752 * Add extended data to the intent. The name must include a package
4753 * prefix, for example the app com.android.contacts would use names
4754 * like "com.android.contacts.ShowAll".
4755 *
4756 * @param name The name of the extra data, with package prefix.
4757 * @param value The boolean array data value.
4758 *
4759 * @return Returns the same Intent object, for chaining multiple calls
4760 * into a single statement.
4761 *
4762 * @see #putExtras
4763 * @see #removeExtra
4764 * @see #getBooleanArrayExtra(String)
4765 */
4766 public Intent putExtra(String name, boolean[] value) {
4767 if (mExtras == null) {
4768 mExtras = new Bundle();
4769 }
4770 mExtras.putBooleanArray(name, value);
4771 return this;
4772 }
4773
4774 /**
4775 * Add extended data to the intent. The name must include a package
4776 * prefix, for example the app com.android.contacts would use names
4777 * like "com.android.contacts.ShowAll".
4778 *
4779 * @param name The name of the extra data, with package prefix.
4780 * @param value The byte array data value.
4781 *
4782 * @return Returns the same Intent object, for chaining multiple calls
4783 * into a single statement.
4784 *
4785 * @see #putExtras
4786 * @see #removeExtra
4787 * @see #getByteArrayExtra(String)
4788 */
4789 public Intent putExtra(String name, byte[] value) {
4790 if (mExtras == null) {
4791 mExtras = new Bundle();
4792 }
4793 mExtras.putByteArray(name, value);
4794 return this;
4795 }
4796
4797 /**
4798 * Add extended data to the intent. The name must include a package
4799 * prefix, for example the app com.android.contacts would use names
4800 * like "com.android.contacts.ShowAll".
4801 *
4802 * @param name The name of the extra data, with package prefix.
4803 * @param value The short array data value.
4804 *
4805 * @return Returns the same Intent object, for chaining multiple calls
4806 * into a single statement.
4807 *
4808 * @see #putExtras
4809 * @see #removeExtra
4810 * @see #getShortArrayExtra(String)
4811 */
4812 public Intent putExtra(String name, short[] value) {
4813 if (mExtras == null) {
4814 mExtras = new Bundle();
4815 }
4816 mExtras.putShortArray(name, value);
4817 return this;
4818 }
4819
4820 /**
4821 * Add extended data to the intent. The name must include a package
4822 * prefix, for example the app com.android.contacts would use names
4823 * like "com.android.contacts.ShowAll".
4824 *
4825 * @param name The name of the extra data, with package prefix.
4826 * @param value The char array data value.
4827 *
4828 * @return Returns the same Intent object, for chaining multiple calls
4829 * into a single statement.
4830 *
4831 * @see #putExtras
4832 * @see #removeExtra
4833 * @see #getCharArrayExtra(String)
4834 */
4835 public Intent putExtra(String name, char[] value) {
4836 if (mExtras == null) {
4837 mExtras = new Bundle();
4838 }
4839 mExtras.putCharArray(name, value);
4840 return this;
4841 }
4842
4843 /**
4844 * Add extended data to the intent. The name must include a package
4845 * prefix, for example the app com.android.contacts would use names
4846 * like "com.android.contacts.ShowAll".
4847 *
4848 * @param name The name of the extra data, with package prefix.
4849 * @param value The int array data value.
4850 *
4851 * @return Returns the same Intent object, for chaining multiple calls
4852 * into a single statement.
4853 *
4854 * @see #putExtras
4855 * @see #removeExtra
4856 * @see #getIntArrayExtra(String)
4857 */
4858 public Intent putExtra(String name, int[] value) {
4859 if (mExtras == null) {
4860 mExtras = new Bundle();
4861 }
4862 mExtras.putIntArray(name, value);
4863 return this;
4864 }
4865
4866 /**
4867 * Add extended data to the intent. The name must include a package
4868 * prefix, for example the app com.android.contacts would use names
4869 * like "com.android.contacts.ShowAll".
4870 *
4871 * @param name The name of the extra data, with package prefix.
4872 * @param value The byte array data value.
4873 *
4874 * @return Returns the same Intent object, for chaining multiple calls
4875 * into a single statement.
4876 *
4877 * @see #putExtras
4878 * @see #removeExtra
4879 * @see #getLongArrayExtra(String)
4880 */
4881 public Intent putExtra(String name, long[] value) {
4882 if (mExtras == null) {
4883 mExtras = new Bundle();
4884 }
4885 mExtras.putLongArray(name, value);
4886 return this;
4887 }
4888
4889 /**
4890 * Add extended data to the intent. The name must include a package
4891 * prefix, for example the app com.android.contacts would use names
4892 * like "com.android.contacts.ShowAll".
4893 *
4894 * @param name The name of the extra data, with package prefix.
4895 * @param value The float array data value.
4896 *
4897 * @return Returns the same Intent object, for chaining multiple calls
4898 * into a single statement.
4899 *
4900 * @see #putExtras
4901 * @see #removeExtra
4902 * @see #getFloatArrayExtra(String)
4903 */
4904 public Intent putExtra(String name, float[] value) {
4905 if (mExtras == null) {
4906 mExtras = new Bundle();
4907 }
4908 mExtras.putFloatArray(name, value);
4909 return this;
4910 }
4911
4912 /**
4913 * Add extended data to the intent. The name must include a package
4914 * prefix, for example the app com.android.contacts would use names
4915 * like "com.android.contacts.ShowAll".
4916 *
4917 * @param name The name of the extra data, with package prefix.
4918 * @param value The double array data value.
4919 *
4920 * @return Returns the same Intent object, for chaining multiple calls
4921 * into a single statement.
4922 *
4923 * @see #putExtras
4924 * @see #removeExtra
4925 * @see #getDoubleArrayExtra(String)
4926 */
4927 public Intent putExtra(String name, double[] value) {
4928 if (mExtras == null) {
4929 mExtras = new Bundle();
4930 }
4931 mExtras.putDoubleArray(name, value);
4932 return this;
4933 }
4934
4935 /**
4936 * Add extended data to the intent. The name must include a package
4937 * prefix, for example the app com.android.contacts would use names
4938 * like "com.android.contacts.ShowAll".
4939 *
4940 * @param name The name of the extra data, with package prefix.
4941 * @param value The String array data value.
4942 *
4943 * @return Returns the same Intent object, for chaining multiple calls
4944 * into a single statement.
4945 *
4946 * @see #putExtras
4947 * @see #removeExtra
4948 * @see #getStringArrayExtra(String)
4949 */
4950 public Intent putExtra(String name, String[] value) {
4951 if (mExtras == null) {
4952 mExtras = new Bundle();
4953 }
4954 mExtras.putStringArray(name, value);
4955 return this;
4956 }
4957
4958 /**
4959 * Add extended data to the intent. The name must include a package
4960 * prefix, for example the app com.android.contacts would use names
4961 * like "com.android.contacts.ShowAll".
4962 *
4963 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004964 * @param value The CharSequence array data value.
4965 *
4966 * @return Returns the same Intent object, for chaining multiple calls
4967 * into a single statement.
4968 *
4969 * @see #putExtras
4970 * @see #removeExtra
4971 * @see #getCharSequenceArrayExtra(String)
4972 */
4973 public Intent putExtra(String name, CharSequence[] value) {
4974 if (mExtras == null) {
4975 mExtras = new Bundle();
4976 }
4977 mExtras.putCharSequenceArray(name, value);
4978 return this;
4979 }
4980
4981 /**
4982 * Add extended data to the intent. The name must include a package
4983 * prefix, for example the app com.android.contacts would use names
4984 * like "com.android.contacts.ShowAll".
4985 *
4986 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004987 * @param value The Bundle data value.
4988 *
4989 * @return Returns the same Intent object, for chaining multiple calls
4990 * into a single statement.
4991 *
4992 * @see #putExtras
4993 * @see #removeExtra
4994 * @see #getBundleExtra(String)
4995 */
4996 public Intent putExtra(String name, Bundle value) {
4997 if (mExtras == null) {
4998 mExtras = new Bundle();
4999 }
5000 mExtras.putBundle(name, value);
5001 return this;
5002 }
5003
5004 /**
5005 * Add extended data to the intent. The name must include a package
5006 * prefix, for example the app com.android.contacts would use names
5007 * like "com.android.contacts.ShowAll".
5008 *
5009 * @param name The name of the extra data, with package prefix.
5010 * @param value The IBinder data value.
5011 *
5012 * @return Returns the same Intent object, for chaining multiple calls
5013 * into a single statement.
5014 *
5015 * @see #putExtras
5016 * @see #removeExtra
5017 * @see #getIBinderExtra(String)
5018 *
5019 * @deprecated
5020 * @hide
5021 */
5022 @Deprecated
5023 public Intent putExtra(String name, IBinder value) {
5024 if (mExtras == null) {
5025 mExtras = new Bundle();
5026 }
5027 mExtras.putIBinder(name, value);
5028 return this;
5029 }
5030
5031 /**
5032 * Copy all extras in 'src' in to this intent.
5033 *
5034 * @param src Contains the extras to copy.
5035 *
5036 * @see #putExtra
5037 */
5038 public Intent putExtras(Intent src) {
5039 if (src.mExtras != null) {
5040 if (mExtras == null) {
5041 mExtras = new Bundle(src.mExtras);
5042 } else {
5043 mExtras.putAll(src.mExtras);
5044 }
5045 }
5046 return this;
5047 }
5048
5049 /**
5050 * Add a set of extended data to the intent. The keys must include a package
5051 * prefix, for example the app com.android.contacts would use names
5052 * like "com.android.contacts.ShowAll".
5053 *
5054 * @param extras The Bundle of extras to add to this intent.
5055 *
5056 * @see #putExtra
5057 * @see #removeExtra
5058 */
5059 public Intent putExtras(Bundle extras) {
5060 if (mExtras == null) {
5061 mExtras = new Bundle();
5062 }
5063 mExtras.putAll(extras);
5064 return this;
5065 }
5066
5067 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005068 * Completely replace the extras in the Intent with the extras in the
5069 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07005070 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005071 * @param src The exact extras contained in this Intent are copied
5072 * into the target intent, replacing any that were previously there.
5073 */
5074 public Intent replaceExtras(Intent src) {
5075 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
5076 return this;
5077 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005078
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005079 /**
5080 * Completely replace the extras in the Intent with the given Bundle of
5081 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07005082 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005083 * @param extras The new set of extras in the Intent, or null to erase
5084 * all extras.
5085 */
5086 public Intent replaceExtras(Bundle extras) {
5087 mExtras = extras != null ? new Bundle(extras) : null;
5088 return this;
5089 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005090
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005091 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005092 * Remove extended data from the intent.
5093 *
5094 * @see #putExtra
5095 */
5096 public void removeExtra(String name) {
5097 if (mExtras != null) {
5098 mExtras.remove(name);
5099 if (mExtras.size() == 0) {
5100 mExtras = null;
5101 }
5102 }
5103 }
5104
5105 /**
5106 * Set special flags controlling how this intent is handled. Most values
5107 * here depend on the type of component being executed by the Intent,
5108 * specifically the FLAG_ACTIVITY_* flags are all for use with
5109 * {@link Context#startActivity Context.startActivity()} and the
5110 * FLAG_RECEIVER_* flags are all for use with
5111 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
5112 *
Scott Main7aee61f2011-02-08 11:25:01 -08005113 * <p>See the
5114 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5115 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005116 * the behavior of your application.
5117 *
5118 * @param flags The desired flags.
5119 *
5120 * @return Returns the same Intent object, for chaining multiple calls
5121 * into a single statement.
5122 *
5123 * @see #getFlags
5124 * @see #addFlags
5125 *
5126 * @see #FLAG_GRANT_READ_URI_PERMISSION
5127 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
5128 * @see #FLAG_DEBUG_LOG_RESOLUTION
5129 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005130 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005131 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005132 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005133 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005134 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
5135 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005136 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005137 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5138 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005139 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005140 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005141 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005142 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
5143 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005144 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005145 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005146 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005147 * @see #FLAG_RECEIVER_REGISTERED_ONLY
5148 */
5149 public Intent setFlags(int flags) {
5150 mFlags = flags;
5151 return this;
5152 }
5153
5154 /**
5155 * Add additional flags to the intent (or with existing flags
5156 * value).
5157 *
5158 * @param flags The new flags to set.
5159 *
5160 * @return Returns the same Intent object, for chaining multiple calls
5161 * into a single statement.
5162 *
5163 * @see #setFlags
5164 */
5165 public Intent addFlags(int flags) {
5166 mFlags |= flags;
5167 return this;
5168 }
5169
5170 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005171 * (Usually optional) Set an explicit application package name that limits
5172 * the components this Intent will resolve to. If left to the default
5173 * value of null, all components in all applications will considered.
5174 * If non-null, the Intent can only match the components in the given
5175 * application package.
5176 *
5177 * @param packageName The name of the application package to handle the
5178 * intent, or null to allow any application package.
5179 *
5180 * @return Returns the same Intent object, for chaining multiple calls
5181 * into a single statement.
5182 *
5183 * @see #getPackage
5184 * @see #resolveActivity
5185 */
5186 public Intent setPackage(String packageName) {
5187 mPackage = packageName;
5188 return this;
5189 }
5190
5191 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005192 * (Usually optional) Explicitly set the component to handle the intent.
5193 * If left with the default value of null, the system will determine the
5194 * appropriate class to use based on the other fields (action, data,
5195 * type, categories) in the Intent. If this class is defined, the
5196 * specified class will always be used regardless of the other fields. You
5197 * should only set this value when you know you absolutely want a specific
5198 * class to be used; otherwise it is better to let the system find the
5199 * appropriate class so that you will respect the installed applications
5200 * and user preferences.
5201 *
5202 * @param component The name of the application component to handle the
5203 * intent, or null to let the system find one for you.
5204 *
5205 * @return Returns the same Intent object, for chaining multiple calls
5206 * into a single statement.
5207 *
5208 * @see #setClass
5209 * @see #setClassName(Context, String)
5210 * @see #setClassName(String, String)
5211 * @see #getComponent
5212 * @see #resolveActivity
5213 */
5214 public Intent setComponent(ComponentName component) {
5215 mComponent = component;
5216 return this;
5217 }
5218
5219 /**
5220 * Convenience for calling {@link #setComponent} with an
5221 * explicit class name.
5222 *
5223 * @param packageContext A Context of the application package implementing
5224 * this class.
5225 * @param className The name of a class inside of the application package
5226 * that will be used as the component for this Intent.
5227 *
5228 * @return Returns the same Intent object, for chaining multiple calls
5229 * into a single statement.
5230 *
5231 * @see #setComponent
5232 * @see #setClass
5233 */
5234 public Intent setClassName(Context packageContext, String className) {
5235 mComponent = new ComponentName(packageContext, className);
5236 return this;
5237 }
5238
5239 /**
5240 * Convenience for calling {@link #setComponent} with an
5241 * explicit application package name and class name.
5242 *
5243 * @param packageName The name of the package implementing the desired
5244 * component.
5245 * @param className The name of a class inside of the application package
5246 * that will be used as the component for this Intent.
5247 *
5248 * @return Returns the same Intent object, for chaining multiple calls
5249 * into a single statement.
5250 *
5251 * @see #setComponent
5252 * @see #setClass
5253 */
5254 public Intent setClassName(String packageName, String className) {
5255 mComponent = new ComponentName(packageName, className);
5256 return this;
5257 }
5258
5259 /**
5260 * Convenience for calling {@link #setComponent(ComponentName)} with the
5261 * name returned by a {@link Class} object.
5262 *
5263 * @param packageContext A Context of the application package implementing
5264 * this class.
5265 * @param cls The class name to set, equivalent to
5266 * <code>setClassName(context, cls.getName())</code>.
5267 *
5268 * @return Returns the same Intent object, for chaining multiple calls
5269 * into a single statement.
5270 *
5271 * @see #setComponent
5272 */
5273 public Intent setClass(Context packageContext, Class<?> cls) {
5274 mComponent = new ComponentName(packageContext, cls);
5275 return this;
5276 }
5277
5278 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005279 * Set the bounds of the sender of this intent, in screen coordinates. This can be
5280 * used as a hint to the receiver for animations and the like. Null means that there
5281 * is no source bounds.
5282 */
5283 public void setSourceBounds(Rect r) {
5284 if (r != null) {
5285 mSourceBounds = new Rect(r);
5286 } else {
5287 r = null;
5288 }
5289 }
5290
5291 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005292 * Use with {@link #fillIn} to allow the current action value to be
5293 * overwritten, even if it is already set.
5294 */
5295 public static final int FILL_IN_ACTION = 1<<0;
5296
5297 /**
5298 * Use with {@link #fillIn} to allow the current data or type value
5299 * overwritten, even if it is already set.
5300 */
5301 public static final int FILL_IN_DATA = 1<<1;
5302
5303 /**
5304 * Use with {@link #fillIn} to allow the current categories to be
5305 * overwritten, even if they are already set.
5306 */
5307 public static final int FILL_IN_CATEGORIES = 1<<2;
5308
5309 /**
5310 * Use with {@link #fillIn} to allow the current component value to be
5311 * overwritten, even if it is already set.
5312 */
5313 public static final int FILL_IN_COMPONENT = 1<<3;
5314
5315 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005316 * Use with {@link #fillIn} to allow the current package value to be
5317 * overwritten, even if it is already set.
5318 */
5319 public static final int FILL_IN_PACKAGE = 1<<4;
5320
5321 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005322 * Use with {@link #fillIn} to allow the current package value to be
5323 * overwritten, even if it is already set.
5324 */
5325 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
5326
5327 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005328 * Copy the contents of <var>other</var> in to this object, but only
5329 * where fields are not defined by this object. For purposes of a field
5330 * being defined, the following pieces of data in the Intent are
5331 * considered to be separate fields:
5332 *
5333 * <ul>
5334 * <li> action, as set by {@link #setAction}.
5335 * <li> data URI and MIME type, as set by {@link #setData(Uri)},
5336 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
5337 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005338 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005339 * <li> component, as set by {@link #setComponent(ComponentName)} or
5340 * related methods.
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005341 * <li> source bounds, as set by {@link #setSourceBounds}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005342 * <li> each top-level name in the associated extras.
5343 * </ul>
5344 *
5345 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005346 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5347 * and {@link #FILL_IN_COMPONENT} to override the restriction where the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005348 * corresponding field will not be replaced if it is already set.
5349 *
Brett Chabot3e391752009-07-21 16:07:23 -07005350 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
5351 * specified.
5352 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005353 * <p>For example, consider Intent A with {data="foo", categories="bar"}
5354 * and Intent B with {action="gotit", data-type="some/thing",
5355 * categories="one","two"}.
5356 *
5357 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
5358 * containing: {action="gotit", data-type="some/thing",
5359 * categories="bar"}.
5360 *
5361 * @param other Another Intent whose values are to be used to fill in
5362 * the current one.
5363 * @param flags Options to control which fields can be filled in.
5364 *
5365 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005366 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
5367 * and {@link #FILL_IN_COMPONENT} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005368 */
5369 public int fillIn(Intent other, int flags) {
5370 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005371 if (other.mAction != null
5372 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005373 mAction = other.mAction;
5374 changes |= FILL_IN_ACTION;
5375 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005376 if ((other.mData != null || other.mType != null)
5377 && ((mData == null && mType == null)
5378 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005379 mData = other.mData;
5380 mType = other.mType;
5381 changes |= FILL_IN_DATA;
5382 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005383 if (other.mCategories != null
5384 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005385 if (other.mCategories != null) {
5386 mCategories = new HashSet<String>(other.mCategories);
5387 }
5388 changes |= FILL_IN_CATEGORIES;
5389 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005390 if (other.mPackage != null
5391 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
5392 mPackage = other.mPackage;
5393 changes |= FILL_IN_PACKAGE;
5394 }
5395 // Component is special: it can -only- be set if explicitly allowed,
5396 // since otherwise the sender could force the intent somewhere the
5397 // originator didn't intend.
5398 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005399 mComponent = other.mComponent;
5400 changes |= FILL_IN_COMPONENT;
5401 }
5402 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005403 if (other.mSourceBounds != null
5404 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5405 mSourceBounds = new Rect(other.mSourceBounds);
5406 changes |= FILL_IN_SOURCE_BOUNDS;
5407 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005408 if (mExtras == null) {
5409 if (other.mExtras != null) {
5410 mExtras = new Bundle(other.mExtras);
5411 }
5412 } else if (other.mExtras != null) {
5413 try {
5414 Bundle newb = new Bundle(other.mExtras);
5415 newb.putAll(mExtras);
5416 mExtras = newb;
5417 } catch (RuntimeException e) {
5418 // Modifying the extras can cause us to unparcel the contents
5419 // of the bundle, and if we do this in the system process that
5420 // may fail. We really should handle this (i.e., the Bundle
5421 // impl shouldn't be on top of a plain map), but for now just
5422 // ignore it and keep the original contents. :(
5423 Log.w("Intent", "Failure filling in extras", e);
5424 }
5425 }
5426 return changes;
5427 }
5428
5429 /**
5430 * Wrapper class holding an Intent and implementing comparisons on it for
5431 * the purpose of filtering. The class implements its
5432 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
5433 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
5434 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
5435 * on the wrapped Intent.
5436 */
5437 public static final class FilterComparison {
5438 private final Intent mIntent;
5439 private final int mHashCode;
5440
5441 public FilterComparison(Intent intent) {
5442 mIntent = intent;
5443 mHashCode = intent.filterHashCode();
5444 }
5445
5446 /**
5447 * Return the Intent that this FilterComparison represents.
5448 * @return Returns the Intent held by the FilterComparison. Do
5449 * not modify!
5450 */
5451 public Intent getIntent() {
5452 return mIntent;
5453 }
5454
5455 @Override
5456 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005457 if (obj instanceof FilterComparison) {
5458 Intent other = ((FilterComparison)obj).mIntent;
5459 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005460 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005461 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005462 }
5463
5464 @Override
5465 public int hashCode() {
5466 return mHashCode;
5467 }
5468 }
5469
5470 /**
5471 * Determine if two intents are the same for the purposes of intent
5472 * resolution (filtering). That is, if their action, data, type,
5473 * class, and categories are the same. This does <em>not</em> compare
5474 * any extra data included in the intents.
5475 *
5476 * @param other The other Intent to compare against.
5477 *
5478 * @return Returns true if action, data, type, class, and categories
5479 * are the same.
5480 */
5481 public boolean filterEquals(Intent other) {
5482 if (other == null) {
5483 return false;
5484 }
5485 if (mAction != other.mAction) {
5486 if (mAction != null) {
5487 if (!mAction.equals(other.mAction)) {
5488 return false;
5489 }
5490 } else {
5491 if (!other.mAction.equals(mAction)) {
5492 return false;
5493 }
5494 }
5495 }
5496 if (mData != other.mData) {
5497 if (mData != null) {
5498 if (!mData.equals(other.mData)) {
5499 return false;
5500 }
5501 } else {
5502 if (!other.mData.equals(mData)) {
5503 return false;
5504 }
5505 }
5506 }
5507 if (mType != other.mType) {
5508 if (mType != null) {
5509 if (!mType.equals(other.mType)) {
5510 return false;
5511 }
5512 } else {
5513 if (!other.mType.equals(mType)) {
5514 return false;
5515 }
5516 }
5517 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005518 if (mPackage != other.mPackage) {
5519 if (mPackage != null) {
5520 if (!mPackage.equals(other.mPackage)) {
5521 return false;
5522 }
5523 } else {
5524 if (!other.mPackage.equals(mPackage)) {
5525 return false;
5526 }
5527 }
5528 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005529 if (mComponent != other.mComponent) {
5530 if (mComponent != null) {
5531 if (!mComponent.equals(other.mComponent)) {
5532 return false;
5533 }
5534 } else {
5535 if (!other.mComponent.equals(mComponent)) {
5536 return false;
5537 }
5538 }
5539 }
5540 if (mCategories != other.mCategories) {
5541 if (mCategories != null) {
5542 if (!mCategories.equals(other.mCategories)) {
5543 return false;
5544 }
5545 } else {
5546 if (!other.mCategories.equals(mCategories)) {
5547 return false;
5548 }
5549 }
5550 }
5551
5552 return true;
5553 }
5554
5555 /**
5556 * Generate hash code that matches semantics of filterEquals().
5557 *
5558 * @return Returns the hash value of the action, data, type, class, and
5559 * categories.
5560 *
5561 * @see #filterEquals
5562 */
5563 public int filterHashCode() {
5564 int code = 0;
5565 if (mAction != null) {
5566 code += mAction.hashCode();
5567 }
5568 if (mData != null) {
5569 code += mData.hashCode();
5570 }
5571 if (mType != null) {
5572 code += mType.hashCode();
5573 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005574 if (mPackage != null) {
5575 code += mPackage.hashCode();
5576 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 if (mComponent != null) {
5578 code += mComponent.hashCode();
5579 }
5580 if (mCategories != null) {
5581 code += mCategories.hashCode();
5582 }
5583 return code;
5584 }
5585
5586 @Override
5587 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005588 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005589
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005590 b.append("Intent { ");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005591 toShortString(b, true, true, true);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005592 b.append(" }");
5593
5594 return b.toString();
5595 }
5596
5597 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005598 public String toInsecureString() {
5599 StringBuilder b = new StringBuilder(128);
5600
5601 b.append("Intent { ");
5602 toShortString(b, false, true, true);
5603 b.append(" }");
5604
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005605 return b.toString();
5606 }
Romain Guy4969af72009-06-17 10:53:19 -07005607
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005608 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005609 public String toShortString(boolean secure, boolean comp, boolean extras) {
5610 StringBuilder b = new StringBuilder(128);
5611 toShortString(b, secure, comp, extras);
5612 return b.toString();
5613 }
5614
5615 /** @hide */
5616 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005617 boolean first = true;
5618 if (mAction != null) {
5619 b.append("act=").append(mAction);
5620 first = false;
5621 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005622 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005623 if (!first) {
5624 b.append(' ');
5625 }
5626 first = false;
5627 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005628 Iterator<String> i = mCategories.iterator();
5629 boolean didone = false;
5630 while (i.hasNext()) {
5631 if (didone) b.append(",");
5632 didone = true;
5633 b.append(i.next());
5634 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005635 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005636 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005637 if (mData != null) {
5638 if (!first) {
5639 b.append(' ');
5640 }
5641 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07005642 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07005643 if (secure) {
5644 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07005645 } else {
5646 b.append(mData);
5647 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005648 }
5649 if (mType != null) {
5650 if (!first) {
5651 b.append(' ');
5652 }
5653 first = false;
5654 b.append("typ=").append(mType);
5655 }
5656 if (mFlags != 0) {
5657 if (!first) {
5658 b.append(' ');
5659 }
5660 first = false;
5661 b.append("flg=0x").append(Integer.toHexString(mFlags));
5662 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005663 if (mPackage != null) {
5664 if (!first) {
5665 b.append(' ');
5666 }
5667 first = false;
5668 b.append("pkg=").append(mPackage);
5669 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005670 if (comp && mComponent != null) {
5671 if (!first) {
5672 b.append(' ');
5673 }
5674 first = false;
5675 b.append("cmp=").append(mComponent.flattenToShortString());
5676 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005677 if (mSourceBounds != null) {
5678 if (!first) {
5679 b.append(' ');
5680 }
5681 first = false;
5682 b.append("bnds=").append(mSourceBounds.toShortString());
5683 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005684 if (extras && mExtras != null) {
5685 if (!first) {
5686 b.append(' ');
5687 }
5688 first = false;
5689 b.append("(has extras)");
5690 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005691 }
5692
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005693 /**
5694 * Call {@link #toUri} with 0 flags.
5695 * @deprecated Use {@link #toUri} instead.
5696 */
5697 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005698 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005699 return toUri(0);
5700 }
5701
5702 /**
5703 * Convert this Intent into a String holding a URI representation of it.
5704 * The returned URI string has been properly URI encoded, so it can be
5705 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
5706 * Intent's data as the base URI, with an additional fragment describing
5707 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08005708 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005709 * <p>You can convert the returned string back to an Intent with
5710 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08005711 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005712 * @param flags Additional operating flags. Either 0 or
5713 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08005714 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005715 * @return Returns a URI encoding URI string describing the entire contents
5716 * of the Intent.
5717 */
5718 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07005719 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005720 String scheme = null;
5721 if (mData != null) {
5722 String data = mData.toString();
5723 if ((flags&URI_INTENT_SCHEME) != 0) {
5724 final int N = data.length();
5725 for (int i=0; i<N; i++) {
5726 char c = data.charAt(i);
5727 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
5728 || c == '.' || c == '-') {
5729 continue;
5730 }
5731 if (c == ':' && i > 0) {
5732 // Valid scheme.
5733 scheme = data.substring(0, i);
5734 uri.append("intent:");
5735 data = data.substring(i+1);
5736 break;
5737 }
Tom Taylord4a47292009-12-21 13:59:18 -08005738
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005739 // No scheme.
5740 break;
5741 }
5742 }
5743 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08005744
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005745 } else if ((flags&URI_INTENT_SCHEME) != 0) {
5746 uri.append("intent:");
5747 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005748
5749 uri.append("#Intent;");
5750
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005751 if (scheme != null) {
5752 uri.append("scheme=").append(scheme).append(';');
5753 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005754 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005755 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 }
5757 if (mCategories != null) {
5758 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005759 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005760 }
5761 }
5762 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005763 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005764 }
5765 if (mFlags != 0) {
5766 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
5767 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005768 if (mPackage != null) {
5769 uri.append("package=").append(Uri.encode(mPackage)).append(';');
5770 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005771 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005772 uri.append("component=").append(Uri.encode(
5773 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005775 if (mSourceBounds != null) {
5776 uri.append("sourceBounds=")
5777 .append(Uri.encode(mSourceBounds.flattenToString()))
5778 .append(';');
5779 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005780 if (mExtras != null) {
5781 for (String key : mExtras.keySet()) {
5782 final Object value = mExtras.get(key);
5783 char entryType =
5784 value instanceof String ? 'S' :
5785 value instanceof Boolean ? 'B' :
5786 value instanceof Byte ? 'b' :
5787 value instanceof Character ? 'c' :
5788 value instanceof Double ? 'd' :
5789 value instanceof Float ? 'f' :
5790 value instanceof Integer ? 'i' :
5791 value instanceof Long ? 'l' :
5792 value instanceof Short ? 's' :
5793 '\0';
5794
5795 if (entryType != '\0') {
5796 uri.append(entryType);
5797 uri.append('.');
5798 uri.append(Uri.encode(key));
5799 uri.append('=');
5800 uri.append(Uri.encode(value.toString()));
5801 uri.append(';');
5802 }
5803 }
5804 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005805
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005806 uri.append("end");
5807
5808 return uri.toString();
5809 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005810
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005811 public int describeContents() {
5812 return (mExtras != null) ? mExtras.describeContents() : 0;
5813 }
5814
5815 public void writeToParcel(Parcel out, int flags) {
5816 out.writeString(mAction);
5817 Uri.writeToParcel(out, mData);
5818 out.writeString(mType);
5819 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005820 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005821 ComponentName.writeToParcel(mComponent, out);
5822
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005823 if (mSourceBounds != null) {
5824 out.writeInt(1);
5825 mSourceBounds.writeToParcel(out, flags);
5826 } else {
5827 out.writeInt(0);
5828 }
5829
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005830 if (mCategories != null) {
5831 out.writeInt(mCategories.size());
5832 for (String category : mCategories) {
5833 out.writeString(category);
5834 }
5835 } else {
5836 out.writeInt(0);
5837 }
5838
5839 out.writeBundle(mExtras);
5840 }
5841
5842 public static final Parcelable.Creator<Intent> CREATOR
5843 = new Parcelable.Creator<Intent>() {
5844 public Intent createFromParcel(Parcel in) {
5845 return new Intent(in);
5846 }
5847 public Intent[] newArray(int size) {
5848 return new Intent[size];
5849 }
5850 };
5851
Dianne Hackborneb034652009-09-07 00:49:58 -07005852 /** @hide */
5853 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005854 readFromParcel(in);
5855 }
5856
5857 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005858 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005859 mData = Uri.CREATOR.createFromParcel(in);
5860 mType = in.readString();
5861 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005862 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005863 mComponent = ComponentName.readFromParcel(in);
5864
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005865 if (in.readInt() != 0) {
5866 mSourceBounds = Rect.CREATOR.createFromParcel(in);
5867 }
5868
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005869 int N = in.readInt();
5870 if (N > 0) {
5871 mCategories = new HashSet<String>();
5872 int i;
5873 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005874 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005875 }
5876 } else {
5877 mCategories = null;
5878 }
5879
5880 mExtras = in.readBundle();
5881 }
5882
5883 /**
5884 * Parses the "intent" element (and its children) from XML and instantiates
5885 * an Intent object. The given XML parser should be located at the tag
5886 * where parsing should start (often named "intent"), from which the
5887 * basic action, data, type, and package and class name will be
5888 * retrieved. The function will then parse in to any child elements,
5889 * looking for <category android:name="xxx"> tags to add categories and
5890 * <extra android:name="xxx" android:value="yyy"> to attach extra data
5891 * to the intent.
5892 *
5893 * @param resources The Resources to use when inflating resources.
5894 * @param parser The XML parser pointing at an "intent" tag.
5895 * @param attrs The AttributeSet interface for retrieving extended
5896 * attribute data at the current <var>parser</var> location.
5897 * @return An Intent object matching the XML data.
5898 * @throws XmlPullParserException If there was an XML parsing error.
5899 * @throws IOException If there was an I/O error.
5900 */
5901 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
5902 throws XmlPullParserException, IOException {
5903 Intent intent = new Intent();
5904
5905 TypedArray sa = resources.obtainAttributes(attrs,
5906 com.android.internal.R.styleable.Intent);
5907
5908 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
5909
5910 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
5911 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
5912 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
5913
5914 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
5915 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
5916 if (packageName != null && className != null) {
5917 intent.setComponent(new ComponentName(packageName, className));
5918 }
5919
5920 sa.recycle();
5921
5922 int outerDepth = parser.getDepth();
5923 int type;
5924 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
5925 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
5926 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
5927 continue;
5928 }
5929
5930 String nodeName = parser.getName();
5931 if (nodeName.equals("category")) {
5932 sa = resources.obtainAttributes(attrs,
5933 com.android.internal.R.styleable.IntentCategory);
5934 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
5935 sa.recycle();
5936
5937 if (cat != null) {
5938 intent.addCategory(cat);
5939 }
5940 XmlUtils.skipCurrentTag(parser);
5941
5942 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005943 if (intent.mExtras == null) {
5944 intent.mExtras = new Bundle();
5945 }
5946 resources.parseBundleExtra("extra", attrs, intent.mExtras);
5947 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005948
5949 } else {
5950 XmlUtils.skipCurrentTag(parser);
5951 }
5952 }
5953
5954 return intent;
5955 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005956}