blob: 06edf32bbe24e9252a24ec09aba55a98e1806ae9 [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;
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -070030import android.media.RemoteControlClient;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.net.Uri;
32import android.os.Bundle;
33import android.os.IBinder;
34import android.os.Parcel;
35import android.os.Parcelable;
36import android.util.AttributeSet;
37import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080038
39import com.android.internal.util.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070040
41import java.io.IOException;
42import java.io.Serializable;
43import java.net.URISyntaxException;
44import java.util.ArrayList;
45import java.util.HashSet;
46import java.util.Iterator;
Nick Pellyccae4122012-01-09 14:12:58 -080047import java.util.Locale;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070048import java.util.Set;
49
50/**
51 * An intent is an abstract description of an operation to be performed. It
52 * can be used with {@link Context#startActivity(Intent) startActivity} to
53 * launch an {@link android.app.Activity},
54 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
55 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
56 * and {@link android.content.Context#startService} or
57 * {@link android.content.Context#bindService} to communicate with a
58 * background {@link android.app.Service}.
59 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070060 * <p>An Intent provides a facility for performing late runtime binding between the code in
61 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070062 * can be thought of as the glue between activities. It is basically a passive data structure
63 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070064 *
65 * <div class="special reference">
66 * <h3>Developer Guides</h3>
67 * <p>For information about how to create and resolve intents, read the
68 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
69 * developer guide.</p>
70 * </div>
71 *
72 * <a name="IntentStructure"></a>
73 * <h3>Intent Structure</h3>
74 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070075 *
76 * <ul>
77 * <li> <p><b>action</b> -- The general action to be performed, such as
78 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
79 * etc.</p>
80 * </li>
81 * <li> <p><b>data</b> -- The data to operate on, such as a person record
82 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
83 * </li>
84 * </ul>
85 *
86 *
87 * <p>Some examples of action/data pairs are:</p>
88 *
89 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070090 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070091 * information about the person whose identifier is "1".</p>
92 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070093 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070094 * the phone dialer with the person filled in.</p>
95 * </li>
96 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
97 * the phone dialer with the given number filled in. Note how the
98 * VIEW action does what what is considered the most reasonable thing for
99 * a particular URI.</p>
100 * </li>
101 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
102 * the phone dialer with the given number filled in.</p>
103 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700104 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700105 * information about the person whose identifier is "1".</p>
106 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700107 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700108 * a list of people, which the user can browse through. This example is a
109 * typical top-level entry into the Contacts application, showing you the
110 * list of people. Selecting a particular person to view would result in a
111 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
112 * being used to start an activity to display that person.</p>
113 * </li>
114 * </ul>
115 *
116 * <p>In addition to these primary attributes, there are a number of secondary
117 * attributes that you can also include with an intent:</p>
118 *
119 * <ul>
120 * <li> <p><b>category</b> -- Gives additional information about the action
121 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
122 * appear in the Launcher as a top-level application, while
123 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
124 * of alternative actions the user can perform on a piece of data.</p>
125 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
126 * intent data. Normally the type is inferred from the data itself.
127 * By setting this attribute, you disable that evaluation and force
128 * an explicit type.</p>
129 * <li> <p><b>component</b> -- Specifies an explicit name of a component
130 * class to use for the intent. Normally this is determined by looking
131 * at the other information in the intent (the action, data/type, and
132 * categories) and matching that with a component that can handle it.
133 * If this attribute is set then none of the evaluation is performed,
134 * and this component is used exactly as is. By specifying this attribute,
135 * all of the other Intent attributes become optional.</p>
136 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
137 * This can be used to provide extended information to the component.
138 * For example, if we have a action to send an e-mail message, we could
139 * also include extra pieces of data here to supply a subject, body,
140 * etc.</p>
141 * </ul>
142 *
143 * <p>Here are some examples of other operations you can specify as intents
144 * using these additional parameters:</p>
145 *
146 * <ul>
147 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
148 * Launch the home screen.</p>
149 * </li>
150 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
151 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
152 * vnd.android.cursor.item/phone}</i></b>
153 * -- Display the list of people's phone numbers, allowing the user to
154 * browse through them and pick one and return it to the parent activity.</p>
155 * </li>
156 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
157 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
158 * -- Display all pickers for data that can be opened with
159 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
160 * allowing the user to pick one of them and then some data inside of it
161 * and returning the resulting URI to the caller. This can be used,
162 * for example, in an e-mail application to allow the user to pick some
163 * data to include as an attachment.</p>
164 * </li>
165 * </ul>
166 *
167 * <p>There are a variety of standard Intent action and category constants
168 * defined in the Intent class, but applications can also define their own.
169 * These strings use java style scoping, to ensure they are unique -- for
170 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700171 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700172 *
173 * <p>Put together, the set of actions, data types, categories, and extra data
174 * defines a language for the system allowing for the expression of phrases
175 * such as "call john smith's cell". As applications are added to the system,
176 * they can extend this language by adding new actions, types, and categories, or
177 * they can modify the behavior of existing phrases by supplying their own
178 * activities that handle them.</p>
179 *
180 * <a name="IntentResolution"></a>
181 * <h3>Intent Resolution</h3>
182 *
183 * <p>There are two primary forms of intents you will use.
184 *
185 * <ul>
186 * <li> <p><b>Explicit Intents</b> have specified a component (via
187 * {@link #setComponent} or {@link #setClass}), which provides the exact
188 * class to be run. Often these will not include any other information,
189 * simply being a way for an application to launch various internal
190 * activities it has as the user interacts with the application.
191 *
192 * <li> <p><b>Implicit Intents</b> have not specified a component;
193 * instead, they must include enough information for the system to
194 * determine which of the available components is best to run for that
195 * intent.
196 * </ul>
197 *
198 * <p>When using implicit intents, given such an arbitrary intent we need to
199 * know what to do with it. This is handled by the process of <em>Intent
200 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
201 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
202 * more activities/receivers) that can handle it.</p>
203 *
204 * <p>The intent resolution mechanism basically revolves around matching an
205 * Intent against all of the &lt;intent-filter&gt; descriptions in the
206 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
207 * objects explicitly registered with {@link Context#registerReceiver}.) More
208 * details on this can be found in the documentation on the {@link
209 * IntentFilter} class.</p>
210 *
211 * <p>There are three pieces of information in the Intent that are used for
212 * resolution: the action, type, and category. Using this information, a query
213 * is done on the {@link PackageManager} for a component that can handle the
214 * intent. The appropriate component is determined based on the intent
215 * information supplied in the <code>AndroidManifest.xml</code> file as
216 * follows:</p>
217 *
218 * <ul>
219 * <li> <p>The <b>action</b>, if given, must be listed by the component as
220 * one it handles.</p>
221 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
222 * already supplied in the Intent. Like the action, if a type is
223 * included in the intent (either explicitly or implicitly in its
224 * data), then this must be listed by the component as one it handles.</p>
225 * <li> For data that is not a <code>content:</code> URI and where no explicit
226 * type is included in the Intent, instead the <b>scheme</b> of the
227 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
228 * considered. Again like the action, if we are matching a scheme it
229 * must be listed by the component as one it can handle.
230 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
231 * by the activity as categories it handles. That is, if you include
232 * the categories {@link #CATEGORY_LAUNCHER} and
233 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
234 * with an intent that lists <em>both</em> of those categories.
235 * Activities will very often need to support the
236 * {@link #CATEGORY_DEFAULT} so that they can be found by
237 * {@link Context#startActivity Context.startActivity()}.</p>
238 * </ul>
239 *
240 * <p>For example, consider the Note Pad sample application that
241 * allows user to browse through a list of notes data and view details about
242 * individual items. Text in italics indicate places were you would replace a
243 * name with one specific to your own package.</p>
244 *
245 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
246 * package="<i>com.android.notepad</i>"&gt;
247 * &lt;application android:icon="@drawable/app_notes"
248 * android:label="@string/app_name"&gt;
249 *
250 * &lt;provider class=".NotePadProvider"
251 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
252 *
253 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
254 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700255 * &lt;action android:name="android.intent.action.MAIN" /&gt;
256 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700257 * &lt;/intent-filter&gt;
258 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700259 * &lt;action android:name="android.intent.action.VIEW" /&gt;
260 * &lt;action android:name="android.intent.action.EDIT" /&gt;
261 * &lt;action android:name="android.intent.action.PICK" /&gt;
262 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
263 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700264 * &lt;/intent-filter&gt;
265 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700266 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
267 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
268 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700269 * &lt;/intent-filter&gt;
270 * &lt;/activity&gt;
271 *
272 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
273 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700274 * &lt;action android:name="android.intent.action.VIEW" /&gt;
275 * &lt;action android:name="android.intent.action.EDIT" /&gt;
276 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
277 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700278 * &lt;/intent-filter&gt;
279 *
280 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700281 * &lt;action android:name="android.intent.action.INSERT" /&gt;
282 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
283 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700284 * &lt;/intent-filter&gt;
285 *
286 * &lt;/activity&gt;
287 *
288 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
289 * android:theme="@android:style/Theme.Dialog"&gt;
290 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700291 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
292 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
293 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
294 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 * &lt;/activity&gt;
298 *
299 * &lt;/application&gt;
300 * &lt;/manifest&gt;</pre>
301 *
302 * <p>The first activity,
303 * <code>com.android.notepad.NotesList</code>, serves as our main
304 * entry into the app. It can do three things as described by its three intent
305 * templates:
306 * <ol>
307 * <li><pre>
308 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700309 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
310 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700311 * &lt;/intent-filter&gt;</pre>
312 * <p>This provides a top-level entry into the NotePad application: the standard
313 * MAIN action is a main entry point (not requiring any other information in
314 * the Intent), and the LAUNCHER category says that this entry point should be
315 * listed in the application launcher.</p>
316 * <li><pre>
317 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700318 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
319 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
320 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
321 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
322 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700323 * &lt;/intent-filter&gt;</pre>
324 * <p>This declares the things that the activity can do on a directory of
325 * notes. The type being supported is given with the &lt;type&gt; tag, where
326 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
327 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
328 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
329 * The activity allows the user to view or edit the directory of data (via
330 * the VIEW and EDIT actions), or to pick a particular note and return it
331 * to the caller (via the PICK action). Note also the DEFAULT category
332 * supplied here: this is <em>required</em> for the
333 * {@link Context#startActivity Context.startActivity} method to resolve your
334 * activity when its component name is not explicitly specified.</p>
335 * <li><pre>
336 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700337 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
338 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
339 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700340 * &lt;/intent-filter&gt;</pre>
341 * <p>This filter describes the ability return to the caller a note selected by
342 * the user without needing to know where it came from. The data type
343 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
344 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
345 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
346 * The GET_CONTENT action is similar to the PICK action, where the activity
347 * will return to its caller a piece of data selected by the user. Here,
348 * however, the caller specifies the type of data they desire instead of
349 * the type of data the user will be picking from.</p>
350 * </ol>
351 *
352 * <p>Given these capabilities, the following intents will resolve to the
353 * NotesList activity:</p>
354 *
355 * <ul>
356 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
357 * activities that can be used as top-level entry points into an
358 * application.</p>
359 * <li> <p><b>{ action=android.app.action.MAIN,
360 * category=android.app.category.LAUNCHER }</b> is the actual intent
361 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700362 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * data=content://com.google.provider.NotePad/notes }</b>
364 * displays a list of all the notes under
365 * "content://com.google.provider.NotePad/notes", which
366 * the user can browse through and see the details on.</p>
367 * <li> <p><b>{ action=android.app.action.PICK
368 * data=content://com.google.provider.NotePad/notes }</b>
369 * provides a list of the notes under
370 * "content://com.google.provider.NotePad/notes", from which
371 * the user can pick a note whose data URL is returned back to the caller.</p>
372 * <li> <p><b>{ action=android.app.action.GET_CONTENT
373 * type=vnd.android.cursor.item/vnd.google.note }</b>
374 * is similar to the pick action, but allows the caller to specify the
375 * kind of data they want back so that the system can find the appropriate
376 * activity to pick something of that data type.</p>
377 * </ul>
378 *
379 * <p>The second activity,
380 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
381 * note entry and allows them to edit it. It can do two things as described
382 * by its two intent templates:
383 * <ol>
384 * <li><pre>
385 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700386 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
387 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
388 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
389 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700390 * &lt;/intent-filter&gt;</pre>
391 * <p>The first, primary, purpose of this activity is to let the user interact
392 * with a single note, as decribed by the MIME type
393 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
394 * either VIEW a note or allow the user to EDIT it. Again we support the
395 * DEFAULT category to allow the activity to be launched without explicitly
396 * specifying its component.</p>
397 * <li><pre>
398 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700399 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
400 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
401 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700402 * &lt;/intent-filter&gt;</pre>
403 * <p>The secondary use of this activity is to insert a new note entry into
404 * an existing directory of notes. This is used when the user creates a new
405 * note: the INSERT action is executed on the directory of notes, causing
406 * this activity to run and have the user create the new note data which
407 * it then adds to the content provider.</p>
408 * </ol>
409 *
410 * <p>Given these capabilities, the following intents will resolve to the
411 * NoteEditor activity:</p>
412 *
413 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700414 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700415 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
416 * shows the user the content of note <var>{ID}</var>.</p>
417 * <li> <p><b>{ action=android.app.action.EDIT
418 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
419 * allows the user to edit the content of note <var>{ID}</var>.</p>
420 * <li> <p><b>{ action=android.app.action.INSERT
421 * data=content://com.google.provider.NotePad/notes }</b>
422 * creates a new, empty note in the notes list at
423 * "content://com.google.provider.NotePad/notes"
424 * and allows the user to edit it. If they keep their changes, the URI
425 * of the newly created note is returned to the caller.</p>
426 * </ul>
427 *
428 * <p>The last activity,
429 * <code>com.android.notepad.TitleEditor</code>, allows the user to
430 * edit the title of a note. This could be implemented as a class that the
431 * application directly invokes (by explicitly setting its component in
432 * the Intent), but here we show a way you can publish alternative
433 * operations on existing data:</p>
434 *
435 * <pre>
436 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700437 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
438 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
439 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
440 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
441 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700442 * &lt;/intent-filter&gt;</pre>
443 *
444 * <p>In the single intent template here, we
445 * have created our own private action called
446 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
447 * edit the title of a note. It must be invoked on a specific note
448 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
449 * view and edit actions, but here displays and edits the title contained
450 * in the note data.
451 *
452 * <p>In addition to supporting the default category as usual, our title editor
453 * also supports two other standard categories: ALTERNATIVE and
454 * SELECTED_ALTERNATIVE. Implementing
455 * these categories allows others to find the special action it provides
456 * without directly knowing about it, through the
457 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
458 * more often to build dynamic menu items with
459 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
460 * template here was also supply an explicit name for the template
461 * (via <code>android:label="@string/resolve_title"</code>) to better control
462 * what the user sees when presented with this activity as an alternative
463 * action to the data they are viewing.
464 *
465 * <p>Given these capabilities, the following intent will resolve to the
466 * TitleEditor activity:</p>
467 *
468 * <ul>
469 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
470 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
471 * displays and allows the user to edit the title associated
472 * with note <var>{ID}</var>.</p>
473 * </ul>
474 *
475 * <h3>Standard Activity Actions</h3>
476 *
477 * <p>These are the current standard actions that Intent defines for launching
478 * activities (usually through {@link Context#startActivity}. The most
479 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
480 * {@link #ACTION_EDIT}.
481 *
482 * <ul>
483 * <li> {@link #ACTION_MAIN}
484 * <li> {@link #ACTION_VIEW}
485 * <li> {@link #ACTION_ATTACH_DATA}
486 * <li> {@link #ACTION_EDIT}
487 * <li> {@link #ACTION_PICK}
488 * <li> {@link #ACTION_CHOOSER}
489 * <li> {@link #ACTION_GET_CONTENT}
490 * <li> {@link #ACTION_DIAL}
491 * <li> {@link #ACTION_CALL}
492 * <li> {@link #ACTION_SEND}
493 * <li> {@link #ACTION_SENDTO}
494 * <li> {@link #ACTION_ANSWER}
495 * <li> {@link #ACTION_INSERT}
496 * <li> {@link #ACTION_DELETE}
497 * <li> {@link #ACTION_RUN}
498 * <li> {@link #ACTION_SYNC}
499 * <li> {@link #ACTION_PICK_ACTIVITY}
500 * <li> {@link #ACTION_SEARCH}
501 * <li> {@link #ACTION_WEB_SEARCH}
502 * <li> {@link #ACTION_FACTORY_TEST}
503 * </ul>
504 *
505 * <h3>Standard Broadcast Actions</h3>
506 *
507 * <p>These are the current standard actions that Intent defines for receiving
508 * broadcasts (usually through {@link Context#registerReceiver} or a
509 * &lt;receiver&gt; tag in a manifest).
510 *
511 * <ul>
512 * <li> {@link #ACTION_TIME_TICK}
513 * <li> {@link #ACTION_TIME_CHANGED}
514 * <li> {@link #ACTION_TIMEZONE_CHANGED}
515 * <li> {@link #ACTION_BOOT_COMPLETED}
516 * <li> {@link #ACTION_PACKAGE_ADDED}
517 * <li> {@link #ACTION_PACKAGE_CHANGED}
518 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800519 * <li> {@link #ACTION_PACKAGE_RESTARTED}
520 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700521 * <li> {@link #ACTION_UID_REMOVED}
522 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700523 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700524 * <li> {@link #ACTION_POWER_DISCONNECTED}
525 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700526 * </ul>
527 *
528 * <h3>Standard Categories</h3>
529 *
530 * <p>These are the current standard categories that can be used to further
531 * clarify an Intent via {@link #addCategory}.
532 *
533 * <ul>
534 * <li> {@link #CATEGORY_DEFAULT}
535 * <li> {@link #CATEGORY_BROWSABLE}
536 * <li> {@link #CATEGORY_TAB}
537 * <li> {@link #CATEGORY_ALTERNATIVE}
538 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
539 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #CATEGORY_HOME}
542 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700543 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400544 * <li> {@link #CATEGORY_CAR_DOCK}
545 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500546 * <li> {@link #CATEGORY_LE_DESK_DOCK}
547 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200548 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700549 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700550 * </ul>
551 *
552 * <h3>Standard Extra Data</h3>
553 *
554 * <p>These are the current standard fields that can be used as extra data via
555 * {@link #putExtra}.
556 *
557 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800558 * <li> {@link #EXTRA_ALARM_COUNT}
559 * <li> {@link #EXTRA_BCC}
560 * <li> {@link #EXTRA_CC}
561 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
562 * <li> {@link #EXTRA_DATA_REMOVED}
563 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500564 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
565 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800566 * <li> {@link #EXTRA_DOCK_STATE_CAR}
567 * <li> {@link #EXTRA_DOCK_STATE_DESK}
568 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
569 * <li> {@link #EXTRA_DONT_KILL_APP}
570 * <li> {@link #EXTRA_EMAIL}
571 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800573 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700574 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800575 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700576 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800577 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
578 * <li> {@link #EXTRA_REPLACING}
579 * <li> {@link #EXTRA_SHORTCUT_ICON}
580 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
581 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700582 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_SHORTCUT_NAME}
584 * <li> {@link #EXTRA_SUBJECT}
585 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700586 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800587 * <li> {@link #EXTRA_TITLE}
588 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700589 * </ul>
590 *
591 * <h3>Flags</h3>
592 *
593 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800594 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
595 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700596 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800597public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700598 // ---------------------------------------------------------------------
599 // ---------------------------------------------------------------------
600 // Standard intent activity actions (see action variable).
601
602 /**
603 * Activity Action: Start as a main entry point, does not expect to
604 * receive data.
605 * <p>Input: nothing
606 * <p>Output: nothing
607 */
608 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
609 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800610
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 /**
612 * Activity Action: Display the data to the user. This is the most common
613 * action performed on data -- it is the generic action you can use on
614 * a piece of data to get the most reasonable thing to occur. For example,
615 * when used on a contacts entry it will view the entry; when used on a
616 * mailto: URI it will bring up a compose window filled with the information
617 * supplied by the URI; when used with a tel: URI it will invoke the
618 * dialer.
619 * <p>Input: {@link #getData} is URI from which to retrieve data.
620 * <p>Output: nothing.
621 */
622 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
623 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800624
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700625 /**
626 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
627 * performed on a piece of data.
628 */
629 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800630
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631 /**
632 * Used to indicate that some piece of data should be attached to some other
633 * place. For example, image data could be attached to a contact. It is up
634 * to the recipient to decide where the data should be attached; the intent
635 * does not specify the ultimate destination.
636 * <p>Input: {@link #getData} is URI of data to be attached.
637 * <p>Output: nothing.
638 */
639 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
640 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700642 /**
643 * Activity Action: Provide explicit editable access to the given data.
644 * <p>Input: {@link #getData} is URI of data to be edited.
645 * <p>Output: nothing.
646 */
647 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
648 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800649
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700650 /**
651 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
652 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
653 * The extras can contain type specific data to pass through to the editing/creating
654 * activity.
655 * <p>Output: The URI of the item that was picked. This must be a content:
656 * URI so that any receiver can access it.
657 */
658 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
659 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800660
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700661 /**
662 * Activity Action: Pick an item from the data, returning what was selected.
663 * <p>Input: {@link #getData} is URI containing a directory of data
664 * (vnd.android.cursor.dir/*) from which to pick an item.
665 * <p>Output: The URI of the item that was picked.
666 */
667 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
668 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800669
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 /**
671 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800672 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700673 * <p>Output: An Intent representing the shortcut. The intent must contain three
674 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
675 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800676 * (value: ShortcutIconResource).</p>
677 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700678 * @see #EXTRA_SHORTCUT_INTENT
679 * @see #EXTRA_SHORTCUT_NAME
680 * @see #EXTRA_SHORTCUT_ICON
681 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
682 * @see android.content.Intent.ShortcutIconResource
683 */
684 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
685 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
686
687 /**
688 * The name of the extra used to define the Intent of a shortcut.
689 *
690 * @see #ACTION_CREATE_SHORTCUT
691 */
692 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
693 /**
694 * The name of the extra used to define the name of a shortcut.
695 *
696 * @see #ACTION_CREATE_SHORTCUT
697 */
698 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
699 /**
700 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
701 *
702 * @see #ACTION_CREATE_SHORTCUT
703 */
704 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
705 /**
706 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
707 *
708 * @see #ACTION_CREATE_SHORTCUT
709 * @see android.content.Intent.ShortcutIconResource
710 */
711 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
712 "android.intent.extra.shortcut.ICON_RESOURCE";
713
714 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 *
717 * @see Intent#ACTION_CREATE_SHORTCUT
718 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
720 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700721 */
722 public static class ShortcutIconResource implements Parcelable {
723 /**
724 * The package name of the application containing the icon.
725 */
726 public String packageName;
727
728 /**
729 * The resource name of the icon, including package, name and type.
730 */
731 public String resourceName;
732
733 /**
734 * Creates a new ShortcutIconResource for the specified context and resource
735 * identifier.
736 *
737 * @param context The context of the application.
738 * @param resourceId The resource idenfitier for the icon.
739 * @return A new ShortcutIconResource with the specified's context package name
740 * and icon resource idenfitier.
741 */
742 public static ShortcutIconResource fromContext(Context context, int resourceId) {
743 ShortcutIconResource icon = new ShortcutIconResource();
744 icon.packageName = context.getPackageName();
745 icon.resourceName = context.getResources().getResourceName(resourceId);
746 return icon;
747 }
748
749 /**
750 * Used to read a ShortcutIconResource from a Parcel.
751 */
752 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
753 new Parcelable.Creator<ShortcutIconResource>() {
754
755 public ShortcutIconResource createFromParcel(Parcel source) {
756 ShortcutIconResource icon = new ShortcutIconResource();
757 icon.packageName = source.readString();
758 icon.resourceName = source.readString();
759 return icon;
760 }
761
762 public ShortcutIconResource[] newArray(int size) {
763 return new ShortcutIconResource[size];
764 }
765 };
766
767 /**
768 * No special parcel contents.
769 */
770 public int describeContents() {
771 return 0;
772 }
773
774 public void writeToParcel(Parcel dest, int flags) {
775 dest.writeString(packageName);
776 dest.writeString(resourceName);
777 }
778
779 @Override
780 public String toString() {
781 return resourceName;
782 }
783 }
784
785 /**
786 * Activity Action: Display an activity chooser, allowing the user to pick
787 * what they want to before proceeding. This can be used as an alternative
788 * to the standard activity picker that is displayed by the system when
789 * you try to start an activity with multiple possible matches, with these
790 * differences in behavior:
791 * <ul>
792 * <li>You can specify the title that will appear in the activity chooser.
793 * <li>The user does not have the option to make one of the matching
794 * activities a preferred activity, and all possible activities will
795 * always be shown even if one of them is currently marked as the
796 * preferred activity.
797 * </ul>
798 * <p>
799 * This action should be used when the user will naturally expect to
800 * select an activity in order to proceed. An example if when not to use
801 * it is when the user clicks on a "mailto:" link. They would naturally
802 * expect to go directly to their mail app, so startActivity() should be
803 * called directly: it will
804 * either launch the current preferred app, or put up a dialog allowing the
805 * user to pick an app to use and optionally marking that as preferred.
806 * <p>
807 * In contrast, if the user is selecting a menu item to send a picture
808 * they are viewing to someone else, there are many different things they
809 * may want to do at this point: send it through e-mail, upload it to a
810 * web service, etc. In this case the CHOOSER action should be used, to
811 * always present to the user a list of the things they can do, with a
812 * nice title given by the caller such as "Send this photo with:".
813 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700814 * If you need to grant URI permissions through a chooser, you must specify
815 * the permissions to be granted on the ACTION_CHOOSER Intent
816 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
817 * {@link #setClipData} to specify the URIs to be granted as well as
818 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
819 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
820 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821 * As a convenience, an Intent of this form can be created with the
822 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700823 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700824 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
826 * and can optionally have a {@link #EXTRA_TITLE} field containing the
827 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700828 * <p>
829 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700830 */
831 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
832 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
833
834 /**
835 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
836 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700837 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
838 * target intent, also optionally supplying a title. If the target
839 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
840 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
841 * set in the returned chooser intent, with its ClipData set appropriately:
842 * either a direct reflection of {@link #getClipData()} if that is non-null,
843 * or a new ClipData build from {@link #getData()}.
844 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845 * @param target The Intent that the user will be selecting an activity
846 * to perform.
847 * @param title Optional title that will be displayed in the chooser.
848 * @return Return a new Intent object that you can hand to
849 * {@link Context#startActivity(Intent) Context.startActivity()} and
850 * related methods.
851 */
852 public static Intent createChooser(Intent target, CharSequence title) {
853 Intent intent = new Intent(ACTION_CHOOSER);
854 intent.putExtra(EXTRA_INTENT, target);
855 if (title != null) {
856 intent.putExtra(EXTRA_TITLE, title);
857 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700858
859 // Migrate any clip data and flags from target.
Dianne Hackborne302a162012-05-15 14:58:32 -0700860 int permFlags = target.getFlags()
861 & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION);
862 if (permFlags != 0) {
863 ClipData targetClipData = target.getClipData();
864 if (targetClipData == null && target.getData() != null) {
865 ClipData.Item item = new ClipData.Item(target.getData());
866 String[] mimeTypes;
867 if (target.getType() != null) {
868 mimeTypes = new String[] { target.getType() };
869 } else {
870 mimeTypes = new String[] { };
871 }
872 targetClipData = new ClipData(null, mimeTypes, item);
873 }
874 if (targetClipData != null) {
875 intent.setClipData(targetClipData);
876 intent.addFlags(permFlags);
877 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700878 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700879
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700880 return intent;
881 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700882
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700883 /**
884 * Activity Action: Allow the user to select a particular kind of data and
885 * return it. This is different than {@link #ACTION_PICK} in that here we
886 * just say what kind of data is desired, not a URI of existing data from
887 * which the user can pick. A ACTION_GET_CONTENT could allow the user to
888 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900889 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700890 * etc.
891 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900892 * There are two main ways to use this action: if you want a specific kind
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700893 * of data, such as a person contact, you set the MIME type to the kind of
894 * data you want and launch it with {@link Context#startActivity(Intent)}.
895 * The system will then launch the best application to select that kind
896 * of data for you.
897 * <p>
898 * You may also be interested in any of a set of types of content the user
899 * can pick. For example, an e-mail application that wants to allow the
900 * user to add an attachment to an e-mail message can use this action to
901 * bring up a list of all of the types of content the user can attach.
902 * <p>
903 * In this case, you should wrap the GET_CONTENT intent with a chooser
904 * (through {@link #createChooser}), which will give the proper interface
905 * for the user to pick how to send your data and allow you to specify
906 * a prompt indicating what they are doing. You will usually specify a
907 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
908 * broad range of content types the user can select from.
909 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900910 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * only pick from data that can be represented as a stream. This is
912 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
913 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800914 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900915 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800916 * is locally available on the device. For example, if this extra is set
917 * to true then an image picker should not show any pictures that are available
918 * from a remote server but not already on the local device (thus requiring
919 * they be downloaded when opened).
920 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700921 * Input: {@link #getType} is the desired MIME type to retrieve. Note
922 * that no URI is supplied in the intent, as there are no constraints on
923 * where the returned data originally comes from. You may also include the
924 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800925 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
926 * selection to local data.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700927 * <p>
928 * Output: The URI of the item that was picked. This must be a content:
929 * URI so that any receiver can access it.
930 */
931 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
932 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
933 /**
934 * Activity Action: Dial a number as specified by the data. This shows a
935 * UI with the number being dialed, allowing the user to explicitly
936 * initiate the call.
937 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
938 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
939 * number.
940 * <p>Output: nothing.
941 */
942 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
943 public static final String ACTION_DIAL = "android.intent.action.DIAL";
944 /**
945 * Activity Action: Perform a call to someone specified by the data.
946 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
947 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
948 * number.
949 * <p>Output: nothing.
950 *
951 * <p>Note: there will be restrictions on which applications can initiate a
952 * call; most applications should use the {@link #ACTION_DIAL}.
953 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
954 * numbers. Applications can <strong>dial</strong> emergency numbers using
955 * {@link #ACTION_DIAL}, however.
956 */
957 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
958 public static final String ACTION_CALL = "android.intent.action.CALL";
959 /**
960 * Activity Action: Perform a call to an emergency number specified by the
961 * data.
962 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
963 * tel: URI of an explicit phone number.
964 * <p>Output: nothing.
965 * @hide
966 */
967 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
968 /**
969 * Activity action: Perform a call to any number (emergency or not)
970 * specified by the data.
971 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
972 * tel: URI of an explicit phone number.
973 * <p>Output: nothing.
974 * @hide
975 */
976 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
977 /**
978 * Activity Action: Send a message to someone specified by the data.
979 * <p>Input: {@link #getData} is URI describing the target.
980 * <p>Output: nothing.
981 */
982 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
983 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
984 /**
985 * Activity Action: Deliver some data to someone else. Who the data is
986 * being delivered to is not specified; it is up to the receiver of this
987 * action to ask the user where the data should be sent.
988 * <p>
989 * When launching a SEND intent, you should usually wrap it in a chooser
990 * (through {@link #createChooser}), which will give the proper interface
991 * for the user to pick how to send your data and allow you to specify
992 * a prompt indicating what they are doing.
993 * <p>
994 * Input: {@link #getType} is the MIME type of the data being sent.
995 * get*Extra can have either a {@link #EXTRA_TEXT}
996 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
997 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
998 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
999 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001000 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1001 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1002 * your text with HTML formatting.
1003 * <p>
1004 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1005 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1006 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1007 * content: URIs and other advanced features of {@link ClipData}. If
1008 * using this approach, you still must supply the same data through the
1009 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1010 * for compatibility with old applications. If you don't set a ClipData,
1011 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001012 * <p>
1013 * Optional standard extras, which may be interpreted by some recipients as
1014 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1015 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1016 * <p>
1017 * Output: nothing.
1018 */
1019 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1020 public static final String ACTION_SEND = "android.intent.action.SEND";
1021 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001022 * Activity Action: Deliver multiple data to someone else.
1023 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001024 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001025 * <p>
1026 * Input: {@link #getType} is the MIME type of the data being sent.
1027 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001028 * #EXTRA_STREAM} field, containing the data to be sent. If using
1029 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1030 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001031 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001032 * Multiple types are supported, and receivers should handle mixed types
1033 * whenever possible. The right way for the receiver to check them is to
1034 * use the content resolver on each URI. The intent sender should try to
1035 * put the most concrete mime type in the intent type, but it can fall
1036 * back to {@literal <type>/*} or {@literal *}/* as needed.
1037 * <p>
1038 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1039 * be image/jpg, but if you are sending image/jpg and image/png, then the
1040 * intent's type should be image/*.
1041 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001042 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1043 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1044 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1045 * content: URIs and other advanced features of {@link ClipData}. If
1046 * using this approach, you still must supply the same data through the
1047 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1048 * for compatibility with old applications. If you don't set a ClipData,
1049 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1050 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001051 * Optional standard extras, which may be interpreted by some recipients as
1052 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1053 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1054 * <p>
1055 * Output: nothing.
1056 */
1057 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1058 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1059 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001060 * Activity Action: Handle an incoming phone call.
1061 * <p>Input: nothing.
1062 * <p>Output: nothing.
1063 */
1064 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1065 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1066 /**
1067 * Activity Action: Insert an empty item into the given container.
1068 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1069 * in which to place the data.
1070 * <p>Output: URI of the new data that was created.
1071 */
1072 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1073 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1074 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001075 * Activity Action: Create a new item in the given container, initializing it
1076 * from the current contents of the clipboard.
1077 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1078 * in which to place the data.
1079 * <p>Output: URI of the new data that was created.
1080 */
1081 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1082 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1083 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001084 * Activity Action: Delete the given data from its container.
1085 * <p>Input: {@link #getData} is URI of data to be deleted.
1086 * <p>Output: nothing.
1087 */
1088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1089 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1090 /**
1091 * Activity Action: Run the data, whatever that means.
1092 * <p>Input: ? (Note: this is currently specific to the test harness.)
1093 * <p>Output: nothing.
1094 */
1095 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1096 public static final String ACTION_RUN = "android.intent.action.RUN";
1097 /**
1098 * Activity Action: Perform a data synchronization.
1099 * <p>Input: ?
1100 * <p>Output: ?
1101 */
1102 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1103 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1104 /**
1105 * Activity Action: Pick an activity given an intent, returning the class
1106 * selected.
1107 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1108 * used with {@link PackageManager#queryIntentActivities} to determine the
1109 * set of activities from which to pick.
1110 * <p>Output: Class name of the activity that was selected.
1111 */
1112 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1113 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1114 /**
1115 * Activity Action: Perform a search.
1116 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1117 * is the text to search for. If empty, simply
1118 * enter your search results Activity with the search UI activated.
1119 * <p>Output: nothing.
1120 */
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1122 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1123 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001124 * Activity Action: Start the platform-defined tutorial
1125 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1126 * is the text to search for. If empty, simply
1127 * enter your search results Activity with the search UI activated.
1128 * <p>Output: nothing.
1129 */
1130 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1131 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1132 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001133 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001134 * <p>
1135 * Input: {@link android.app.SearchManager#QUERY
1136 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1137 * a url starts with http or https, the site will be opened. If it is plain
1138 * text, Google search will be applied.
1139 * <p>
1140 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001141 */
1142 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1143 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1144 /**
Jim Miller07994402012-05-02 14:22:27 -07001145 * Activity Action: Perform assist action.
1146 * <p>
1147 * Input: nothing
1148 * Output: nothing.
1149 */
1150 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1151 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1152 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001153 * Activity Action: List all available applications
1154 * <p>Input: Nothing.
1155 * <p>Output: nothing.
1156 */
1157 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1158 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1159 /**
1160 * Activity Action: Show settings for choosing wallpaper
1161 * <p>Input: Nothing.
1162 * <p>Output: Nothing.
1163 */
1164 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1165 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1166
1167 /**
1168 * Activity Action: Show activity for reporting a bug.
1169 * <p>Input: Nothing.
1170 * <p>Output: Nothing.
1171 */
1172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1173 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1174
1175 /**
1176 * Activity Action: Main entry point for factory tests. Only used when
1177 * the device is booting in factory test node. The implementing package
1178 * must be installed in the system image.
1179 * <p>Input: nothing
1180 * <p>Output: nothing
1181 */
1182 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1183
1184 /**
1185 * Activity Action: The user pressed the "call" button to go to the dialer
1186 * or other appropriate UI for placing a call.
1187 * <p>Input: Nothing.
1188 * <p>Output: Nothing.
1189 */
1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1192
1193 /**
1194 * Activity Action: Start Voice Command.
1195 * <p>Input: Nothing.
1196 * <p>Output: Nothing.
1197 */
1198 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1199 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001200
1201 /**
1202 * Activity Action: Start action associated with long pressing on the
1203 * search key.
1204 * <p>Input: Nothing.
1205 * <p>Output: Nothing.
1206 */
1207 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1208 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001209
Jacek Surazski86b6c532009-05-13 14:38:28 +02001210 /**
1211 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1212 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001213 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001214 * <p>Input: No data is specified. The bug report is passed in using
1215 * an {@link #EXTRA_BUG_REPORT} field.
1216 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001217 *
1218 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001219 */
1220 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1221 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001222
1223 /**
1224 * Activity Action: Show power usage information to the user.
1225 * <p>Input: Nothing.
1226 * <p>Output: Nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001230
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001231 /**
1232 * Activity Action: Setup wizard to launch after a platform update. This
1233 * activity should have a string meta-data field associated with it,
1234 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1235 * the platform for setup. The activity will be launched only if
1236 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1237 * same value.
1238 * <p>Input: Nothing.
1239 * <p>Output: Nothing.
1240 * @hide
1241 */
1242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1243 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001244
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001245 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001246 * Activity Action: Show settings for managing network data usage of a
1247 * specific application. Applications should define an activity that offers
1248 * options to control data usage.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_MANAGE_NETWORK_USAGE =
1252 "android.intent.action.MANAGE_NETWORK_USAGE";
1253
1254 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001255 * Activity Action: Launch application installer.
1256 * <p>
1257 * Input: The data must be a content: or file: URI at which the application
1258 * can be retrieved. You can optionally supply
1259 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1260 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1261 * <p>
1262 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1263 * succeeded.
1264 *
1265 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1266 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1267 * @see #EXTRA_RETURN_RESULT
1268 */
1269 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1270 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1271
1272 /**
1273 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1274 * package. Specifies the installer package name; this package will receive the
1275 * {@link #ACTION_APP_ERROR} intent.
1276 */
1277 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1278 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1279
1280 /**
1281 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1282 * package. Specifies that the application being installed should not be
1283 * treated as coming from an unknown source, but as coming from the app
1284 * invoking the Intent. For this to work you must start the installer with
1285 * startActivityForResult().
1286 */
1287 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1288 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1289
1290 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001291 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1292 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001293 * data field originated from.
1294 */
rich cannings706e8ba2012-08-20 13:20:14 -07001295 public static final String EXTRA_ORIGINATING_URI
1296 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001297
1298 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001299 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1300 * {@link #ACTION_VIEW} to indicate the HTTP referrer URI associated with the Intent
1301 * data field or {@link #EXTRA_ORIGINATING_URI}.
rich cannings368ed012012-06-07 15:37:57 -07001302 */
1303 public static final String EXTRA_REFERRER
1304 = "android.intent.extra.REFERRER";
1305
1306 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001307 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1308 * package. Tells the installer UI to skip the confirmation with the user
1309 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001310 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1311 * will no longer show an interstitial message about updating existing
1312 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001313 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001314 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001315 public static final String EXTRA_ALLOW_REPLACE
1316 = "android.intent.extra.ALLOW_REPLACE";
1317
1318 /**
1319 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1320 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1321 * return to the application the result code of the install/uninstall. The returned result
1322 * code will be {@link android.app.Activity#RESULT_OK} on success or
1323 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1324 */
1325 public static final String EXTRA_RETURN_RESULT
1326 = "android.intent.extra.RETURN_RESULT";
1327
1328 /**
1329 * Package manager install result code. @hide because result codes are not
1330 * yet ready to be exposed.
1331 */
1332 public static final String EXTRA_INSTALL_RESULT
1333 = "android.intent.extra.INSTALL_RESULT";
1334
1335 /**
1336 * Activity Action: Launch application uninstaller.
1337 * <p>
1338 * Input: The data must be a package: URI whose scheme specific part is
1339 * the package name of the current installed package to be uninstalled.
1340 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1341 * <p>
1342 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1343 * succeeded.
1344 */
1345 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1346 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1347
1348 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001349 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1350 * describing the last run version of the platform that was setup.
1351 * @hide
1352 */
1353 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1354
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001355 // ---------------------------------------------------------------------
1356 // ---------------------------------------------------------------------
1357 // Standard intent broadcast actions (see action variable).
1358
1359 /**
1360 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001361 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001362 * <p class="note">This is a protected intent that can only be sent
1363 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001364 */
1365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1366 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1367 /**
1368 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001369 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001370 * <p class="note">This is a protected intent that can only be sent
1371 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001372 */
1373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1374 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001375
1376 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001377 * 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 -07001378 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001379 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001380 * <p class="note">This is a protected intent that can only be sent
1381 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001382 */
1383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001384 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001385
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001386 /**
1387 * Broadcast Action: The current time has changed. Sent every
1388 * minute. You can <em>not</em> receive this through components declared
1389 * in manifests, only by exlicitly registering for it with
1390 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1391 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001392 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001393 * <p class="note">This is a protected intent that can only be sent
1394 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001395 */
1396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1397 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1398 /**
1399 * Broadcast Action: The time was set.
1400 */
1401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1402 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1403 /**
1404 * Broadcast Action: The date has changed.
1405 */
1406 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1407 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1408 /**
1409 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1410 * <ul>
1411 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1412 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001413 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001414 * <p class="note">This is a protected intent that can only be sent
1415 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001416 */
1417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1418 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1419 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001420 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1421 * DNS entries should be tossed.
1422 * @hide
1423 */
1424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1425 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1426 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001427 * Alarm Changed Action: This is broadcast when the AlarmClock
1428 * application's alarm is set or unset. It is used by the
1429 * AlarmClock application and the StatusBar service.
1430 * @hide
1431 */
1432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1433 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1434 /**
1435 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1436 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1437 * @hide
1438 */
1439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1440 public static final String ACTION_SYNC_STATE_CHANGED
1441 = "android.intent.action.SYNC_STATE_CHANGED";
1442 /**
1443 * Broadcast Action: This is broadcast once, after the system has finished
1444 * booting. It can be used to perform application-specific initialization,
1445 * such as installing alarms. You must hold the
1446 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1447 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001448 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001449 * <p class="note">This is a protected intent that can only be sent
1450 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001451 */
1452 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1453 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1454 /**
1455 * Broadcast Action: This is broadcast when a user action should request a
1456 * temporary system dialog to dismiss. Some examples of temporary system
1457 * dialogs are the notification window-shade and the recent tasks dialog.
1458 */
1459 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1460 /**
1461 * Broadcast Action: Trigger the download and eventual installation
1462 * of a package.
1463 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001464 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001465 * <p class="note">This is a protected intent that can only be sent
1466 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001467 *
1468 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001469 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001470 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1472 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1473 /**
1474 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001475 * device. The data contains the name of the package. Note that the
1476 * newly installed package does <em>not</em> receive this broadcast.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001477 * <p>My include the following extras:
1478 * <ul>
1479 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1480 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1481 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1482 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001483 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001484 * <p class="note">This is a protected intent that can only be sent
1485 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001486 */
1487 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1488 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1489 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001490 * Broadcast Action: A new version of an application package has been
1491 * installed, replacing an existing version that was previously installed.
1492 * The data contains the name of the package.
1493 * <p>My include the following extras:
1494 * <ul>
1495 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1496 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001497 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001498 * <p class="note">This is a protected intent that can only be sent
1499 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001500 */
1501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1502 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1503 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001504 * Broadcast Action: A new version of your application has been installed
1505 * over an existing one. This is only sent to the application that was
1506 * replaced. It does not contain any additional data; to receive it, just
1507 * use an intent filter for this action.
1508 *
1509 * <p class="note">This is a protected intent that can only be sent
1510 * by the system.
1511 */
1512 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1513 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1514 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001515 * Broadcast Action: An existing application package has been removed from
1516 * the device. The data contains the name of the package. The package
1517 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001518 * <ul>
1519 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1520 * to the package.
1521 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1522 * application -- data and code -- is being removed.
1523 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1524 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1525 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001526 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001527 * <p class="note">This is a protected intent that can only be sent
1528 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001529 */
1530 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1531 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1532 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001533 * Broadcast Action: An existing application package has been completely
1534 * removed from the device. The data contains the name of the package.
1535 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1536 * {@link #EXTRA_DATA_REMOVED} is true and
1537 * {@link #EXTRA_REPLACING} is false of that broadcast.
1538 *
1539 * <ul>
1540 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1541 * to the package.
1542 * </ul>
1543 *
1544 * <p class="note">This is a protected intent that can only be sent
1545 * by the system.
1546 */
1547 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1548 public static final String ACTION_PACKAGE_FULLY_REMOVED
1549 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1550 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001551 * Broadcast Action: An existing application package has been changed (e.g.
1552 * a component has been enabled or disabled). The data contains the name of
1553 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001554 * <ul>
1555 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001556 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
1557 * of the changed components.
1558 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1559 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001560 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001561 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001562 * <p class="note">This is a protected intent that can only be sent
1563 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001564 */
1565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1566 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1567 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001568 * @hide
1569 * Broadcast Action: Ask system services if there is any reason to
1570 * restart the given package. The data contains the name of the
1571 * package.
1572 * <ul>
1573 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1574 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1575 * </ul>
1576 *
1577 * <p class="note">This is a protected intent that can only be sent
1578 * by the system.
1579 */
1580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1581 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1582 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001583 * Broadcast Action: The user has restarted a package, and all of its
1584 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001585 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001586 * be removed. Note that the restarted package does <em>not</em>
1587 * receive this broadcast.
1588 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001589 * <ul>
1590 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1591 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001592 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001593 * <p class="note">This is a protected intent that can only be sent
1594 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001595 */
1596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1597 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1598 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001599 * Broadcast Action: The user has cleared the data of a package. This should
1600 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001601 * its persistent data is erased and this broadcast sent.
1602 * Note that the cleared package does <em>not</em>
1603 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001604 * <ul>
1605 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1606 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001607 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001608 * <p class="note">This is a protected intent that can only be sent
1609 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001610 */
1611 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1612 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1613 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001614 * Broadcast Action: A user ID has been removed from the system. The user
1615 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001616 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001617 * <p class="note">This is a protected intent that can only be sent
1618 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001619 */
1620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1621 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001622
1623 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001624 * Broadcast Action: Sent to the installer package of an application
1625 * when that application is first launched (that is the first time it
1626 * is moved out of the stopped state). The data contains the name of the package.
1627 *
1628 * <p class="note">This is a protected intent that can only be sent
1629 * by the system.
1630 */
1631 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1632 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1633
1634 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001635 * Broadcast Action: Sent to the system package verifier when a package
1636 * needs to be verified. The data contains the package URI.
1637 * <p class="note">
1638 * This is a protected intent that can only be sent by the system.
1639 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001640 */
1641 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1642 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1643
1644 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001645 * Broadcast Action: Resources for a set of packages (which were
1646 * previously unavailable) are currently
1647 * available since the media on which they exist is available.
1648 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1649 * list of packages whose availability changed.
1650 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1651 * list of uids of packages whose availability changed.
1652 * Note that the
1653 * packages in this list do <em>not</em> receive this broadcast.
1654 * The specified set of packages are now available on the system.
1655 * <p>Includes the following extras:
1656 * <ul>
1657 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1658 * whose resources(were previously unavailable) are currently available.
1659 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1660 * packages whose resources(were previously unavailable)
1661 * are currently available.
1662 * </ul>
1663 *
1664 * <p class="note">This is a protected intent that can only be sent
1665 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001666 */
1667 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001668 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1669 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001670
1671 /**
1672 * Broadcast Action: Resources for a set of packages are currently
1673 * unavailable since the media on which they exist is unavailable.
1674 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1675 * list of packages whose availability changed.
1676 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1677 * list of uids of packages whose availability changed.
1678 * The specified set of packages can no longer be
1679 * launched and are practically unavailable on the system.
1680 * <p>Inclues the following extras:
1681 * <ul>
1682 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1683 * whose resources are no longer available.
1684 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1685 * whose resources are no longer available.
1686 * </ul>
1687 *
1688 * <p class="note">This is a protected intent that can only be sent
1689 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001690 */
1691 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001692 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001693 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001694
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001695 /**
1696 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001697 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001698 * This should <em>only</em> be used to determine when the wallpaper
1699 * has changed to show the new wallpaper to the user. You should certainly
1700 * never, in response to this, change the wallpaper or other attributes of
1701 * it such as the suggested size. That would be crazy, right? You'd cause
1702 * all kinds of loops, especially if other apps are doing similar things,
1703 * right? Of course. So please don't do this.
1704 *
1705 * @deprecated Modern applications should use
1706 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1707 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1708 * shown behind their UI, rather than watching for this broadcast and
1709 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001710 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001711 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001712 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1713 /**
1714 * Broadcast Action: The current device {@link android.content.res.Configuration}
1715 * (orientation, locale, etc) has changed. When such a change happens, the
1716 * UIs (view hierarchy) will need to be rebuilt based on this new
1717 * information; for the most part, applications don't need to worry about
1718 * this, because the system will take care of stopping and restarting the
1719 * application to make sure it sees the new changes. Some system code that
1720 * can not be restarted will need to watch for this action and handle it
1721 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001722 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001723 * <p class="note">
1724 * You can <em>not</em> receive this through components declared
1725 * in manifests, only by explicitly registering for it with
1726 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1727 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001728 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001729 * <p class="note">This is a protected intent that can only be sent
1730 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001731 *
1732 * @see android.content.res.Configuration
1733 */
1734 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1735 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1736 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001737 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001738 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001739 * <p class="note">This is a protected intent that can only be sent
1740 * by the system.
1741 */
1742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1743 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1744 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001745 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1746 * charging state, level, and other information about the battery.
1747 * See {@link android.os.BatteryManager} for documentation on the
1748 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001749 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001750 * <p class="note">
1751 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001752 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001753 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001754 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1755 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1756 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1757 * broadcasts that are sent and can be received through manifest
1758 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001759 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001760 * <p class="note">This is a protected intent that can only be sent
1761 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001762 */
1763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1764 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1765 /**
1766 * Broadcast Action: Indicates low battery condition on the device.
1767 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001768 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001769 * <p class="note">This is a protected intent that can only be sent
1770 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001771 */
1772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1773 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1774 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001775 * Broadcast Action: Indicates the battery is now okay after being low.
1776 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1777 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001778 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001779 * <p class="note">This is a protected intent that can only be sent
1780 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001781 */
1782 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1783 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1784 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001785 * Broadcast Action: External power has been connected to the device.
1786 * This is intended for applications that wish to register specifically to this notification.
1787 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1788 * stay active to receive this notification. This action can be used to implement actions
1789 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001790 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001791 * <p class="note">This is a protected intent that can only be sent
1792 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001793 */
1794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001795 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001796 /**
1797 * Broadcast Action: External power has been removed from the device.
1798 * This is intended for applications that wish to register specifically to this notification.
1799 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1800 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001801 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001802 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001803 * <p class="note">This is a protected intent that can only be sent
1804 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001805 */
1806 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001807 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001808 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001809 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001810 * Broadcast Action: Device is shutting down.
1811 * This is broadcast when the device is being shut down (completely turned
1812 * off, not sleeping). Once the broadcast is complete, the final shutdown
1813 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001814 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001815 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001816 * <p class="note">This is a protected intent that can only be sent
1817 * by the system.
Dianne Hackborn55280a92009-05-07 15:53:46 -07001818 */
1819 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001820 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001821 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001822 * Activity Action: Start this activity to request system shutdown.
1823 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1824 * to request confirmation from the user before shutting down.
1825 *
1826 * <p class="note">This is a protected intent that can only be sent
1827 * by the system.
1828 *
1829 * {@hide}
1830 */
1831 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1832 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001833 * Broadcast Action: A sticky broadcast that indicates low memory
1834 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001835 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001836 * <p class="note">This is a protected intent that can only be sent
1837 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001838 */
1839 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1840 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1841 /**
1842 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001843 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001844 * <p class="note">This is a protected intent that can only be sent
1845 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001846 */
1847 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1848 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1849 /**
Jake Hambybb371632010-08-23 18:16:48 -07001850 * Broadcast Action: A sticky broadcast that indicates a memory full
1851 * condition on the device. This is intended for activities that want
1852 * to be able to fill the data partition completely, leaving only
1853 * enough free space to prevent system-wide SQLite failures.
1854 *
1855 * <p class="note">This is a protected intent that can only be sent
1856 * by the system.
1857 *
1858 * {@hide}
1859 */
1860 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1861 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1862 /**
1863 * Broadcast Action: Indicates memory full condition on the device
1864 * no longer exists.
1865 *
1866 * <p class="note">This is a protected intent that can only be sent
1867 * by the system.
1868 *
1869 * {@hide}
1870 */
1871 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1872 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
1873 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001874 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1875 * and package management should be started.
1876 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1877 * notification.
1878 */
1879 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1880 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1881 /**
1882 * Broadcast Action: The device has entered USB Mass Storage mode.
1883 * This is used mainly for the USB Settings panel.
1884 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1885 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001886 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001887 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001888 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001889 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1890
1891 /**
1892 * Broadcast Action: The device has exited USB Mass Storage mode.
1893 * This is used mainly for the USB Settings panel.
1894 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1895 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001896 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001898 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1900
1901 /**
1902 * Broadcast Action: External media has been removed.
1903 * The path to the mount point for the removed media is contained in the Intent.mData field.
1904 */
1905 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1906 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1907
1908 /**
1909 * Broadcast Action: External media is present, but not mounted at its mount point.
1910 * The path to the mount point for the removed media is contained in the Intent.mData field.
1911 */
1912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1913 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
1914
1915 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08001916 * Broadcast Action: External media is present, and being disk-checked
1917 * 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 -08001918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
1921
1922 /**
1923 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
1924 * 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 -08001925 */
1926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1927 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
1928
1929 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001930 * Broadcast Action: External media is present and mounted at its mount point.
1931 * The path to the mount point for the removed media is contained in the Intent.mData field.
1932 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
1933 * media was mounted read only.
1934 */
1935 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1936 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
1937
1938 /**
1939 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001940 * 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 -07001941 */
1942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1943 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
1944
1945 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05001946 * Broadcast Action: External media is no longer being shared via USB mass storage.
1947 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
1948 *
1949 * @hide
1950 */
1951 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
1952
1953 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001954 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
1955 * The path to the mount point for the removed media is contained in the Intent.mData field.
1956 */
1957 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1958 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
1959
1960 /**
1961 * Broadcast Action: External media is present but cannot be mounted.
1962 * The path to the mount point for the removed media is contained in the Intent.mData field.
1963 */
1964 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1965 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
1966
1967 /**
1968 * Broadcast Action: User has expressed the desire to remove the external storage media.
1969 * Applications should close all files they have open within the mount point when they receive this intent.
1970 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
1971 */
1972 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1973 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
1974
1975 /**
1976 * Broadcast Action: The media scanner has started scanning a directory.
1977 * The path to the directory being scanned is contained in the Intent.mData field.
1978 */
1979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
1981
1982 /**
1983 * Broadcast Action: The media scanner has finished scanning a directory.
1984 * The path to the scanned directory is contained in the Intent.mData field.
1985 */
1986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1987 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
1988
1989 /**
1990 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
1991 * The path to the file is contained in the Intent.mData field.
1992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
1995
1996 /**
1997 * Broadcast Action: The "Media Button" was pressed. Includes a single
1998 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
1999 * caused the broadcast.
2000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2003
2004 /**
2005 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2006 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2007 * caused the broadcast.
2008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2011
2012 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2013 // location; they are not general-purpose actions.
2014
2015 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002016 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002017 */
2018 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2019 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2020 "android.intent.action.GTALK_CONNECTED";
2021
2022 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002023 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002024 */
2025 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2026 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2027 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002028
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002029 /**
2030 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002031 */
2032 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2033 public static final String ACTION_INPUT_METHOD_CHANGED =
2034 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035
2036 /**
2037 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2038 * more radios have been turned off or on. The intent will have the following extra value:</p>
2039 * <ul>
2040 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2041 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2042 * turned off</li>
2043 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002044 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002045 * <p class="note">This is a protected intent that can only be sent
2046 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002047 */
2048 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2049 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2050
2051 /**
2052 * Broadcast Action: Some content providers have parts of their namespace
2053 * where they publish new events or items that the user may be especially
2054 * interested in. For these things, they may broadcast this action when the
2055 * set of interesting items change.
2056 *
2057 * For example, GmailProvider sends this notification when the set of unread
2058 * mail in the inbox changes.
2059 *
2060 * <p>The data of the intent identifies which part of which provider
2061 * changed. When queried through the content resolver, the data URI will
2062 * return the data set in question.
2063 *
2064 * <p>The intent will have the following extra values:
2065 * <ul>
2066 * <li><em>count</em> - The number of items in the data set. This is the
2067 * same as the number of items in the cursor returned by querying the
2068 * data URI. </li>
2069 * </ul>
2070 *
2071 * This intent will be sent at boot (if the count is non-zero) and when the
2072 * data set changes. It is possible for the data set to change without the
2073 * count changing (for example, if a new unread message arrives in the same
2074 * sync operation in which a message is archived). The phone should still
2075 * ring/vibrate/etc as normal in this case.
2076 */
2077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2078 public static final String ACTION_PROVIDER_CHANGED =
2079 "android.intent.action.PROVIDER_CHANGED";
2080
2081 /**
2082 * Broadcast Action: Wired Headset plugged in or unplugged.
2083 *
2084 * <p>The intent will have the following extra values:
2085 * <ul>
2086 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2087 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08002088 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002089 * </ul>
2090 * </ul>
2091 */
2092 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2093 public static final String ACTION_HEADSET_PLUG =
2094 "android.intent.action.HEADSET_PLUG";
2095
2096 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002097 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
2098 *
2099 * <p>The intent will have the following extra values:
2100 * <ul>
2101 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2102 * <li><em>name</em> - Headset type, human readable string </li>
2103 * </ul>
2104 * </ul>
2105 * @hide
2106 */
2107 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002108 public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG =
2109 "android.intent.action.ANALOG_AUDIO_DOCK_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002110
2111 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07002112 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002113 *
2114 * <p>The intent will have the following extra values:
2115 * <ul>
2116 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2117 * <li><em>name</em> - Headset type, human readable string </li>
2118 * </ul>
2119 * </ul>
2120 * @hide
2121 */
2122 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002123 public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
2124 "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07002125
2126 /**
2127 * Broadcast Action: A HMDI cable was plugged or unplugged
2128 *
2129 * <p>The intent will have the following extra values:
2130 * <ul>
2131 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2132 * <li><em>name</em> - HDMI cable, human readable string </li>
2133 * </ul>
2134 * </ul>
2135 * @hide
2136 */
2137 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2138 public static final String ACTION_HDMI_AUDIO_PLUG =
2139 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002140
2141 /**
Mike Lockwood9d5a4be2012-04-06 09:41:32 -07002142 * Broadcast Action: A USB audio accessory was plugged in or unplugged.
2143 *
2144 * <p>The intent will have the following extra values:
2145 * <ul>
2146 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2147 * <li><em>card</em> - ALSA card number (integer) </li>
2148 * <li><em>device</em> - ALSA device number (integer) </li>
2149 * </ul>
2150 * </ul>
2151 * @hide
2152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_USB_AUDIO_ACCESSORY_PLUG =
2155 "android.intent.action.USB_AUDIO_ACCESSORY_PLUG";
2156
2157 /**
Eric Laurent59f48272012-04-05 19:42:21 -07002158 * Broadcast Action: A USB audio device was plugged in or unplugged.
2159 *
2160 * <p>The intent will have the following extra values:
2161 * <ul>
2162 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2163 * <li><em>card</em> - ALSA card number (integer) </li>
2164 * <li><em>device</em> - ALSA device number (integer) </li>
2165 * </ul>
2166 * </ul>
2167 * @hide
2168 */
2169 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2170 public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
2171 "android.intent.action.USB_AUDIO_DEVICE_PLUG";
2172
2173 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002174 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2175 * <ul>
2176 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2177 * </ul>
2178 *
2179 * <p class="note">This is a protected intent that can only be sent
2180 * by the system.
2181 *
2182 * @hide
2183 */
2184 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2185 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2186 = "android.intent.action.ADVANCED_SETTINGS";
2187
2188 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002189 * Broadcast Action: An outgoing call is about to be placed.
2190 *
2191 * <p>The Intent will have the following extra value:
2192 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002193 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002194 * the phone number originally intended to be dialed.</li>
2195 * </ul>
2196 * <p>Once the broadcast is finished, the resultData is used as the actual
2197 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002198 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002199 * outgoing call in turn: for example, a parental control application
2200 * might verify that the user is authorized to place the call at that
2201 * time, then a number-rewriting application might add an area code if
2202 * one was not specified.</p>
2203 * <p>For consistency, any receiver whose purpose is to prohibit phone
2204 * calls should have a priority of 0, to ensure it will see the final
2205 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002206 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002207 * should have a positive priority.
2208 * Negative priorities are reserved for the system for this broadcast;
2209 * using them may cause problems.</p>
2210 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2211 * abort the broadcast.</p>
2212 * <p>Emergency calls cannot be intercepted using this mechanism, and
2213 * other calls cannot be modified to call emergency numbers using this
2214 * mechanism.
The Android Open Source Project10592532009-03-18 17:39:46 -07002215 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002216 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2217 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002218 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002219 * <p class="note">This is a protected intent that can only be sent
2220 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002221 */
2222 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2223 public static final String ACTION_NEW_OUTGOING_CALL =
2224 "android.intent.action.NEW_OUTGOING_CALL";
2225
2226 /**
2227 * Broadcast Action: Have the device reboot. This is only for use by
2228 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002229 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002230 * <p class="note">This is a protected intent that can only be sent
2231 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002232 */
2233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2234 public static final String ACTION_REBOOT =
2235 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002236
Wei Huang97ecc9c2009-05-11 17:44:20 -07002237 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002238 * Broadcast Action: A sticky broadcast for changes in the physical
2239 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002240 *
2241 * <p>The intent will have the following extra values:
2242 * <ul>
2243 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002244 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002245 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002246 * <p>This is intended for monitoring the current physical dock state.
2247 * See {@link android.app.UiModeManager} for the normal API dealing with
2248 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002249 */
2250 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2251 public static final String ACTION_DOCK_EVENT =
2252 "android.intent.action.DOCK_EVENT";
2253
2254 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002255 * Broadcast Action: a remote intent is to be broadcasted.
2256 *
2257 * A remote intent is used for remote RPC between devices. The remote intent
2258 * is serialized and sent from one device to another device. The receiving
2259 * device parses the remote intent and broadcasts it. Note that anyone can
2260 * broadcast a remote intent. However, if the intent receiver of the remote intent
2261 * does not trust intent broadcasts from arbitrary intent senders, it should require
2262 * the sender to hold certain permissions so only trusted sender's broadcast will be
2263 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002264 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002265 */
2266 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002267 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002268
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002269 /**
2270 * Broadcast Action: hook for permforming cleanup after a system update.
2271 *
2272 * The broadcast is sent when the system is booting, before the
2273 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2274 * image. A receiver for this should do its work and then disable itself
2275 * so that it does not get run again at the next boot.
2276 * @hide
2277 */
2278 public static final String ACTION_PRE_BOOT_COMPLETED =
2279 "android.intent.action.PRE_BOOT_COMPLETED";
2280
Amith Yamasani13593602012-03-22 16:16:17 -07002281 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002282 * Broadcast sent to the system when a user is added. Carries an extra EXTRA_USER_HANDLE that has the
2283 * userHandle of the new user.
Amith Yamasani13593602012-03-22 16:16:17 -07002284 * @hide
2285 */
2286 public static final String ACTION_USER_ADDED =
2287 "android.intent.action.USER_ADDED";
2288
2289 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002290 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
2291 * the userHandle of the user.
Amith Yamasani13593602012-03-22 16:16:17 -07002292 * @hide
2293 */
2294 public static final String ACTION_USER_REMOVED =
2295 "android.intent.action.USER_REMOVED";
2296
2297 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002298 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
2299 * the userHandle of the user to become the current one.
Amith Yamasani13593602012-03-22 16:16:17 -07002300 * @hide
2301 */
2302 public static final String ACTION_USER_SWITCHED =
2303 "android.intent.action.USER_SWITCHED";
2304
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002305 // ---------------------------------------------------------------------
2306 // ---------------------------------------------------------------------
2307 // Standard intent categories (see addCategory()).
2308
2309 /**
2310 * Set if the activity should be an option for the default action
2311 * (center press) to perform on a piece of data. Setting this will
2312 * hide from the user any activities without it set when performing an
2313 * action on some data. Note that this is normal -not- set in the
2314 * Intent when initiating an action -- it is for use in intent filters
2315 * specified in packages.
2316 */
2317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2318 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2319 /**
2320 * Activities that can be safely invoked from a browser must support this
2321 * category. For example, if the user is viewing a web page or an e-mail
2322 * and clicks on a link in the text, the Intent generated execute that
2323 * link will require the BROWSABLE category, so that only activities
2324 * supporting this category will be considered as possible actions. By
2325 * supporting this category, you are promising that there is nothing
2326 * damaging (without user intervention) that can happen by invoking any
2327 * matching Intent.
2328 */
2329 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2330 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2331 /**
2332 * Set if the activity should be considered as an alternative action to
2333 * the data the user is currently viewing. See also
2334 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2335 * applies to the selection in a list of items.
2336 *
2337 * <p>Supporting this category means that you would like your activity to be
2338 * displayed in the set of alternative things the user can do, usually as
2339 * part of the current activity's options menu. You will usually want to
2340 * include a specific label in the &lt;intent-filter&gt; of this action
2341 * describing to the user what it does.
2342 *
2343 * <p>The action of IntentFilter with this category is important in that it
2344 * describes the specific action the target will perform. This generally
2345 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2346 * a specific name such as "com.android.camera.action.CROP. Only one
2347 * alternative of any particular action will be shown to the user, so using
2348 * a specific action like this makes sure that your alternative will be
2349 * displayed while also allowing other applications to provide their own
2350 * overrides of that particular action.
2351 */
2352 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2353 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2354 /**
2355 * Set if the activity should be considered as an alternative selection
2356 * action to the data the user has currently selected. This is like
2357 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2358 * of items from which the user can select, giving them alternatives to the
2359 * default action that will be performed on it.
2360 */
2361 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2362 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2363 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002364 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002365 */
2366 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2367 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2368 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 * Should be displayed in the top-level launcher.
2370 */
2371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2372 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2373 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002374 * Provides information about the package it is in; typically used if
2375 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2376 * a front-door to the user without having to be shown in the all apps list.
2377 */
2378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2379 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2380 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002381 * This is the home activity, that is the first activity that is displayed
2382 * when the device boots.
2383 */
2384 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2385 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2386 /**
2387 * This activity is a preference panel.
2388 */
2389 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2390 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2391 /**
2392 * This activity is a development preference panel.
2393 */
2394 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2395 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2396 /**
2397 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002398 */
2399 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2400 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2401 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002402 * This activity allows the user to browse and download new applications.
2403 */
2404 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2405 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2406 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002407 * This activity may be exercised by the monkey or other automated test tools.
2408 */
2409 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2410 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2411 /**
2412 * To be used as a test (not part of the normal user experience).
2413 */
2414 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2415 /**
2416 * To be used as a unit test (run through the Test Harness).
2417 */
2418 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2419 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002420 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002421 * experience).
2422 */
2423 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
2424 /**
2425 * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
2426 * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
2427 * when queried, though it is allowable for those columns to be blank.
2428 */
2429 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2430 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2431
2432 /**
2433 * To be used as code under test for framework instrumentation tests.
2434 */
2435 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2436 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002437 /**
2438 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002439 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2440 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002441 */
2442 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2443 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2444 /**
2445 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002446 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2447 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002448 */
2449 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2450 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002451 /**
2452 * An activity to run when device is inserted into a analog (low end) dock.
2453 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2454 * information, see {@link android.app.UiModeManager}.
2455 */
2456 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2457 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2458
2459 /**
2460 * An activity to run when device is inserted into a digital (high end) dock.
2461 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2462 * information, see {@link android.app.UiModeManager}.
2463 */
2464 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2465 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002466
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002467 /**
2468 * Used to indicate that the activity can be used in a car environment.
2469 */
2470 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2471 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2472
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002473 // ---------------------------------------------------------------------
2474 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08002475 // Application launch intent categories (see addCategory()).
2476
2477 /**
2478 * Used with {@link #ACTION_MAIN} to launch the browser application.
2479 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002480 * <p>NOTE: This should not be used as the primary key of an Intent,
2481 * since it will not result in the app launching with the correct
2482 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002483 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002484 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002485 */
2486 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2487 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
2488
2489 /**
2490 * Used with {@link #ACTION_MAIN} to launch the calculator application.
2491 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002492 * <p>NOTE: This should not be used as the primary key of an Intent,
2493 * since it will not result in the app launching with the correct
2494 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002495 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002496 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002497 */
2498 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2499 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
2500
2501 /**
2502 * Used with {@link #ACTION_MAIN} to launch the calendar application.
2503 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002504 * <p>NOTE: This should not be used as the primary key of an Intent,
2505 * since it will not result in the app launching with the correct
2506 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002507 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002508 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002509 */
2510 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2511 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
2512
2513 /**
2514 * Used with {@link #ACTION_MAIN} to launch the contacts application.
2515 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002516 * <p>NOTE: This should not be used as the primary key of an Intent,
2517 * since it will not result in the app launching with the correct
2518 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002519 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002520 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002521 */
2522 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2523 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
2524
2525 /**
2526 * Used with {@link #ACTION_MAIN} to launch the email application.
2527 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002528 * <p>NOTE: This should not be used as the primary key of an Intent,
2529 * since it will not result in the app launching with the correct
2530 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002531 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002532 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002533 */
2534 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2535 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
2536
2537 /**
2538 * Used with {@link #ACTION_MAIN} to launch the gallery application.
2539 * The activity should be able to view and manipulate image and video files
2540 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002541 * <p>NOTE: This should not be used as the primary key of an Intent,
2542 * since it will not result in the app launching with the correct
2543 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002544 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002545 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002546 */
2547 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2548 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
2549
2550 /**
2551 * Used with {@link #ACTION_MAIN} to launch the maps application.
2552 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002553 * <p>NOTE: This should not be used as the primary key of an Intent,
2554 * since it will not result in the app launching with the correct
2555 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002556 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002557 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002558 */
2559 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2560 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
2561
2562 /**
2563 * Used with {@link #ACTION_MAIN} to launch the messaging application.
2564 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002565 * <p>NOTE: This should not be used as the primary key of an Intent,
2566 * since it will not result in the app launching with the correct
2567 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002568 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002569 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002570 */
2571 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2572 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
2573
2574 /**
2575 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002576 * The activity should be able to play, browse, or manipulate music files
2577 * stored on the device.
2578 * <p>NOTE: This should not be used as the primary key of an Intent,
2579 * since it will not result in the app launching with the correct
2580 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002581 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002582 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002583 */
2584 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2585 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
2586
2587 // ---------------------------------------------------------------------
2588 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 // Standard extra data keys.
2590
2591 /**
2592 * The initial data to place in a newly created record. Use with
2593 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2594 * fields as would be given to the underlying ContentProvider.insert()
2595 * call.
2596 */
2597 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2598
2599 /**
2600 * A constant CharSequence that is associated with the Intent, used with
2601 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
2602 * this may be a styled CharSequence, so you must use
2603 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
2604 * retrieve it.
2605 */
2606 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
2607
2608 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07002609 * A constant String that is associated with the Intent, used with
2610 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
2611 * as HTML formatted text. Note that you <em>must</em> also supply
2612 * {@link #EXTRA_TEXT}.
2613 */
2614 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
2615
2616 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002617 * A content: URI holding a stream of data associated with the Intent,
2618 * used with {@link #ACTION_SEND} to supply the data being sent.
2619 */
2620 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
2621
2622 /**
2623 * A String[] holding e-mail addresses that should be delivered to.
2624 */
2625 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
2626
2627 /**
2628 * A String[] holding e-mail addresses that should be carbon copied.
2629 */
2630 public static final String EXTRA_CC = "android.intent.extra.CC";
2631
2632 /**
2633 * A String[] holding e-mail addresses that should be blind carbon copied.
2634 */
2635 public static final String EXTRA_BCC = "android.intent.extra.BCC";
2636
2637 /**
2638 * A constant string holding the desired subject line of a message.
2639 */
2640 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
2641
2642 /**
2643 * An Intent describing the choices you would like shown with
2644 * {@link #ACTION_PICK_ACTIVITY}.
2645 */
2646 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
2647
2648 /**
2649 * A CharSequence dialog title to provide to the user when used with a
2650 * {@link #ACTION_CHOOSER}.
2651 */
2652 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
2653
2654 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07002655 * A Parcelable[] of {@link Intent} or
2656 * {@link android.content.pm.LabeledIntent} objects as set with
2657 * {@link #putExtra(String, Parcelable[])} of additional activities to place
2658 * a the front of the list of choices, when shown to the user with a
2659 * {@link #ACTION_CHOOSER}.
2660 */
2661 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
2662
2663 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002664 * A {@link android.view.KeyEvent} object containing the event that
2665 * triggered the creation of the Intent it is in.
2666 */
2667 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
2668
2669 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002670 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
2671 * before shutting down.
2672 *
2673 * {@hide}
2674 */
2675 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
2676
2677 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002678 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
2680 * of restarting the application.
2681 */
2682 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
2683
2684 /**
2685 * A String holding the phone number originally entered in
2686 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
2687 * number to call in a {@link android.content.Intent#ACTION_CALL}.
2688 */
2689 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002690
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002691 /**
2692 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
2693 * intents to supply the uid the package had been assigned. Also an optional
2694 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
2695 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
2696 * purpose.
2697 */
2698 public static final String EXTRA_UID = "android.intent.extra.UID";
2699
2700 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002701 * @hide String array of package names.
2702 */
2703 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
2704
2705 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002706 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2707 * intents to indicate whether this represents a full uninstall (removing
2708 * both the code and its data) or a partial uninstall (leaving its data,
2709 * implying that this is an update).
2710 */
2711 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002712
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002713 /**
2714 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
2715 * intents to indicate that this is a replacement of the package, so this
2716 * broadcast will immediately be followed by an add broadcast for a
2717 * different version of the same package.
2718 */
2719 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07002720
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002721 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 * Used as an int extra field in {@link android.app.AlarmManager} intents
2723 * to tell the application being invoked how many pending alarms are being
2724 * delievered with the intent. For one-shot alarms this will always be 1.
2725 * For recurring alarms, this might be greater than 1 if the device was
2726 * asleep or powered off at the time an earlier alarm would have been
2727 * delivered.
2728 */
2729 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07002730
Jacek Surazski86b6c532009-05-13 14:38:28 +02002731 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002732 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
2733 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07002734 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
2735 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002736 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
2737 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
2738 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002739 */
2740 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
2741
2742 /**
2743 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2744 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002745 */
2746 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
2747
2748 /**
2749 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2750 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002751 */
2752 public static final int EXTRA_DOCK_STATE_DESK = 1;
2753
2754 /**
2755 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2756 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002757 */
2758 public static final int EXTRA_DOCK_STATE_CAR = 2;
2759
2760 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002761 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2762 * to represent that the phone is in a analog (low end) dock.
2763 */
2764 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
2765
2766 /**
2767 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
2768 * to represent that the phone is in a digital (high end) dock.
2769 */
2770 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
2771
2772 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002773 * Boolean that can be supplied as meta-data with a dock activity, to
2774 * indicate that the dock should take over the home key when it is active.
2775 */
2776 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08002777
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07002778 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02002779 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
2780 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02002781 */
2782 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
2783
2784 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002785 * Used in the extra field in the remote intent. It's astring token passed with the
2786 * remote intent.
2787 */
2788 public static final String EXTRA_REMOTE_INTENT_TOKEN =
2789 "android.intent.extra.remote_intent_token";
2790
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002791 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002792 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002793 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002794 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08002795 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07002796 "android.intent.extra.changed_component_name";
2797
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002798 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002799 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002800 * and contains a string array of all of the components that have changed.
2801 */
2802 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
2803 "android.intent.extra.changed_component_name_list";
2804
2805 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002806 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002807 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2808 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002809 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002810 */
2811 public static final String EXTRA_CHANGED_PACKAGE_LIST =
2812 "android.intent.extra.changed_package_list";
2813
2814 /**
2815 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002816 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
2817 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002818 * and contains an integer array of uids of all of the components
2819 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002820 */
2821 public static final String EXTRA_CHANGED_UID_LIST =
2822 "android.intent.extra.changed_uid_list";
2823
2824 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07002825 * @hide
2826 * Magic extra system code can use when binding, to give a label for
2827 * who it is that has bound to a service. This is an integer giving
2828 * a framework string resource that can be displayed to the user.
2829 */
2830 public static final String EXTRA_CLIENT_LABEL =
2831 "android.intent.extra.client_label";
2832
2833 /**
2834 * @hide
2835 * Magic extra system code can use when binding, to give a PendingIntent object
2836 * that can be launched for the user to disable the system's use of this
2837 * service.
2838 */
2839 public static final String EXTRA_CLIENT_INTENT =
2840 "android.intent.extra.client_intent";
2841
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08002842 /**
2843 * Used to indicate that a {@link #ACTION_GET_CONTENT} intent should only return
2844 * data that is on the local device. This is a boolean extra; the default
2845 * is false. If true, an implementation of ACTION_GET_CONTENT should only allow
2846 * the user to select media that is already on the device, not requiring it
2847 * be downloaded from a remote service when opened. Another way to look
2848 * at it is that such content should generally have a "_data" column to the
2849 * path of the content on local external storage.
2850 */
2851 public static final String EXTRA_LOCAL_ONLY =
2852 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07002853
Amith Yamasani13593602012-03-22 16:16:17 -07002854 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002855 * The userHandle carried with broadcast intents related to addition, removal and switching of users
Amith Yamasani13593602012-03-22 16:16:17 -07002856 * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
2857 * @hide
2858 */
Amith Yamasani2a003292012-08-14 18:25:45 -07002859 public static final String EXTRA_USER_HANDLE =
2860 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07002861
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002862 // ---------------------------------------------------------------------
2863 // ---------------------------------------------------------------------
2864 // Intent flags (see mFlags variable).
2865
2866 /**
2867 * If set, the recipient of this Intent will be granted permission to
Dianne Hackborn21c241e2012-03-08 13:57:23 -08002868 * perform read operations on the Uri in the Intent's data and any URIs
2869 * specified in its ClipData. When applying to an Intent's ClipData,
2870 * all URIs as well as recursive traversals through data or other ClipData
2871 * in Intent items will be granted; only the grant flags of the top-level
2872 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 */
2874 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
2875 /**
2876 * If set, the recipient of this Intent will be granted permission to
Dianne Hackborn21c241e2012-03-08 13:57:23 -08002877 * perform write operations on the Uri in the Intent's data and any URIs
2878 * specified in its ClipData. When applying to an Intent's ClipData,
2879 * all URIs as well as recursive traversals through data or other ClipData
2880 * in Intent items will be granted; only the grant flags of the top-level
2881 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002882 */
2883 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
2884 /**
2885 * Can be set by the caller to indicate that this Intent is coming from
2886 * a background operation, not from direct user interaction.
2887 */
2888 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
2889 /**
2890 * A flag you can enable for debugging: when set, log messages will be
2891 * printed during the resolution of this intent to show you what has
2892 * been found to create the final resolved list.
2893 */
2894 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08002895 /**
2896 * If set, this intent will not match any components in packages that
2897 * are currently stopped. If this is not set, then the default behavior
2898 * is to include such applications in the result.
2899 */
2900 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
2901 /**
2902 * If set, this intent will always match any components in packages that
2903 * are currently stopped. This is the default behavior when
2904 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
2905 * flags are set, this one wins (it allows overriding of exclude for
2906 * places where the framework may automatically set the exclude flag).
2907 */
2908 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002909
2910 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002911 * If set, the new activity is not kept in the history stack. As soon as
2912 * the user navigates away from it, the activity is finished. This may also
2913 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
2914 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002915 */
2916 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
2917 /**
2918 * If set, the activity will not be launched if it is already running
2919 * at the top of the history stack.
2920 */
2921 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
2922 /**
2923 * If set, this activity will become the start of a new task on this
2924 * history stack. A task (from the activity that started it to the
2925 * next task activity) defines an atomic group of activities that the
2926 * user can move to. Tasks can be moved to the foreground and background;
2927 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07002928 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08002929 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2930 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002931 *
2932 * <p>This flag is generally used by activities that want
2933 * to present a "launcher" style behavior: they give the user a list of
2934 * separate things that can be done, which otherwise run completely
2935 * independently of the activity launching them.
2936 *
2937 * <p>When using this flag, if a task is already running for the activity
2938 * you are now starting, then a new activity will not be started; instead,
2939 * the current task will simply be brought to the front of the screen with
2940 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
2941 * to disable this behavior.
2942 *
2943 * <p>This flag can not be used when the caller is requesting a result from
2944 * the activity being launched.
2945 */
2946 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
2947 /**
2948 * <strong>Do not use this flag unless you are implementing your own
2949 * top-level application launcher.</strong> Used in conjunction with
2950 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
2951 * behavior of bringing an existing task to the foreground. When set,
2952 * a new task is <em>always</em> started to host the Activity for the
2953 * Intent, regardless of whether there is already an existing task running
2954 * the same thing.
2955 *
2956 * <p><strong>Because the default system does not include graphical task management,
2957 * you should not use this flag unless you provide some way for a user to
2958 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07002959 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002960 * <p>This flag is ignored if
2961 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
2962 *
Scott Main7aee61f2011-02-08 11:25:01 -08002963 * <p>See
2964 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2965 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002966 */
2967 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
2968 /**
2969 * If set, and the activity being launched is already running in the
2970 * current task, then instead of launching a new instance of that activity,
2971 * all of the other activities on top of it will be closed and this Intent
2972 * will be delivered to the (now on top) old activity as a new Intent.
2973 *
2974 * <p>For example, consider a task consisting of the activities: A, B, C, D.
2975 * If D calls startActivity() with an Intent that resolves to the component
2976 * of activity B, then C and D will be finished and B receive the given
2977 * Intent, resulting in the stack now being: A, B.
2978 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002979 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002980 * either receive the new intent you are starting here in its
2981 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002982 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07002983 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
2984 * the same intent, then it will be finished and re-created; for all other
2985 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
2986 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002987 *
2988 * <p>This launch mode can also be used to good effect in conjunction with
2989 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
2990 * of a task, it will bring any currently running instance of that task
2991 * to the foreground, and then clear it to its root state. This is
2992 * especially useful, for example, when launching an activity from the
2993 * notification manager.
2994 *
Scott Main7aee61f2011-02-08 11:25:01 -08002995 * <p>See
2996 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
2997 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002998 */
2999 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3000 /**
3001 * If set and this intent is being used to launch a new activity from an
3002 * existing one, then the reply target of the existing activity will be
3003 * transfered to the new activity. This way the new activity can call
3004 * {@link android.app.Activity#setResult} and have that result sent back to
3005 * the reply target of the original activity.
3006 */
3007 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3008 /**
3009 * If set and this intent is being used to launch a new activity from an
3010 * existing one, the current activity will not be counted as the top
3011 * activity for deciding whether the new intent should be delivered to
3012 * the top instead of starting a new one. The previous activity will
3013 * be used as the top, with the assumption being that the current activity
3014 * will finish itself immediately.
3015 */
3016 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3017 /**
3018 * If set, the new activity is not kept in the list of recently launched
3019 * activities.
3020 */
3021 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3022 /**
3023 * This flag is not normally set by application code, but set for you by
3024 * the system as described in the
3025 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3026 * launchMode} documentation for the singleTask mode.
3027 */
3028 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3029 /**
3030 * If set, and this activity is either being started in a new task or
3031 * bringing to the top an existing task, then it will be launched as
3032 * the front door of the task. This will result in the application of
3033 * any affinities needed to have that task in the proper state (either
3034 * moving activities to or from it), or simply resetting that task to
3035 * its initial state if needed.
3036 */
3037 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3038 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003039 * This flag is not normally set by application code, but set for you by
3040 * the system if this activity is being launched from history
3041 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003042 */
3043 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003044 /**
3045 * If set, this marks a point in the task's activity stack that should
3046 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07003047 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003048 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
3049 * the user re-launching it from home), this activity and all on top of
3050 * it will be finished so that the user does not return to them, but
3051 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07003052 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003053 * <p>This is useful for cases where you have a logical break in your
3054 * application. For example, an e-mail application may have a command
3055 * to view an attachment, which launches an image view activity to
3056 * display it. This activity should be part of the e-mail application's
3057 * task, since it is a part of the task the user is involved in. However,
3058 * if the user leaves that task, and later selects the e-mail app from
3059 * home, we may like them to return to the conversation they were
3060 * viewing, not the picture attachment, since that is confusing. By
3061 * setting this flag when launching the image viewer, that viewer and
3062 * any activities it starts will be removed the next time the user returns
3063 * to mail.
3064 */
3065 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003066 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003067 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003068 * callback from occurring on the current frontmost activity before it is
3069 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003070 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003071 * <p>Typically, an activity can rely on that callback to indicate that an
3072 * explicit user action has caused their activity to be moved out of the
3073 * foreground. The callback marks an appropriate point in the activity's
3074 * lifecycle for it to dismiss any notifications that it intends to display
3075 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003076 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003077 * <p>If an activity is ever started via any non-user-driven events such as
3078 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3079 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003080 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003081 */
3082 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003083 /**
3084 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3085 * this flag will cause the launched activity to be brought to the front of its
3086 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003087 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003088 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3089 * If D calls startActivity() with an Intent that resolves to the component
3090 * of activity B, then B will be brought to the front of the history stack,
3091 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003092 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003093 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003094 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003095 */
3096 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003097 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003098 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3099 * this flag will prevent the system from applying an activity transition
3100 * animation to go to the next activity state. This doesn't mean an
3101 * animation will never run -- if another activity change happens that doesn't
3102 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003103 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003104 * when you are going to do a series of activity operations but the
3105 * animation seen by the user shouldn't be driven by the first activity
3106 * change but rather a later one.
3107 */
3108 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3109 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003110 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3111 * this flag will cause any existing task that would be associated with the
3112 * activity to be cleared before the activity is started. That is, the activity
3113 * becomes the new root of an otherwise empty task, and any old activities
3114 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3115 */
3116 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3117 /**
3118 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3119 * this flag will cause a newly launching task to be placed on top of the current
3120 * home activity task (if there is one). That is, pressing back from the task
3121 * will always return the user to home even if that was not the last activity they
3122 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3123 */
3124 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3125 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003126 * If set, when sending a broadcast only registered receivers will be
3127 * called -- no BroadcastReceiver components will be launched.
3128 */
3129 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003130 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003131 * If set, when sending a broadcast the new broadcast will replace
3132 * any existing pending broadcast that matches it. Matching is defined
3133 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
3134 * true for the intents of the two broadcasts. When a match is found,
3135 * the new broadcast (and receivers associated with it) will replace the
3136 * existing one in the pending broadcast list, remaining at the same
3137 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08003138 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003139 * <p>This flag is most typically used with sticky broadcasts, which
3140 * only care about delivering the most recent values of the broadcast
3141 * to their receivers.
3142 */
3143 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
3144 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08003145 * If set, when sending a broadcast the recipient is allowed to run at
3146 * foreground priority, with a shorter timeout interval. During normal
3147 * broadcasts the receivers are not automatically hoisted out of the
3148 * background priority class.
3149 */
3150 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
3151 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003152 * If set, when sending a broadcast <i>before boot has completed</i> only
3153 * registered receivers will be called -- no BroadcastReceiver components
3154 * will be launched. Sticky intent state will be recorded properly even
3155 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
3156 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07003157 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003158 * <p>This flag is only for use by system sevices as a convenience to
3159 * avoid having to implement a more complex mechanism around detection
3160 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07003161 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003162 * @hide
3163 */
Christopher Tatef46723b2012-01-26 14:19:24 -08003164 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x08000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003165 /**
3166 * Set when this broadcast is for a boot upgrade, a special mode that
3167 * allows the broadcast to be sent before the system is ready and launches
3168 * the app process with no providers running in it.
3169 * @hide
3170 */
Christopher Tatef46723b2012-01-26 14:19:24 -08003171 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x04000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003172
Dianne Hackbornfa82f222009-09-17 15:14:12 -07003173 /**
3174 * @hide Flags that can't be changed with PendingIntent.
3175 */
3176 public static final int IMMUTABLE_FLAGS =
3177 FLAG_GRANT_READ_URI_PERMISSION
3178 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08003179
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003180 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003181 // ---------------------------------------------------------------------
3182 // toUri() and parseUri() options.
3183
3184 /**
3185 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3186 * always has the "intent:" scheme. This syntax can be used when you want
3187 * to later disambiguate between URIs that are intended to describe an
3188 * Intent vs. all others that should be treated as raw URIs. When used
3189 * with {@link #parseUri}, any other scheme will result in a generic
3190 * VIEW action for that raw URI.
3191 */
3192 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08003193
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003194 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003195
3196 private String mAction;
3197 private Uri mData;
3198 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003199 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003200 private ComponentName mComponent;
3201 private int mFlags;
3202 private HashSet<String> mCategories;
3203 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003204 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003205 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003206 private ClipData mClipData;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003207
3208 // ---------------------------------------------------------------------
3209
3210 /**
3211 * Create an empty intent.
3212 */
3213 public Intent() {
3214 }
3215
3216 /**
3217 * Copy constructor.
3218 */
3219 public Intent(Intent o) {
3220 this.mAction = o.mAction;
3221 this.mData = o.mData;
3222 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003223 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003224 this.mComponent = o.mComponent;
3225 this.mFlags = o.mFlags;
3226 if (o.mCategories != null) {
3227 this.mCategories = new HashSet<String>(o.mCategories);
3228 }
3229 if (o.mExtras != null) {
3230 this.mExtras = new Bundle(o.mExtras);
3231 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003232 if (o.mSourceBounds != null) {
3233 this.mSourceBounds = new Rect(o.mSourceBounds);
3234 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003235 if (o.mSelector != null) {
3236 this.mSelector = new Intent(o.mSelector);
3237 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003238 if (o.mClipData != null) {
3239 this.mClipData = new ClipData(o.mClipData);
3240 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003241 }
3242
3243 @Override
3244 public Object clone() {
3245 return new Intent(this);
3246 }
3247
3248 private Intent(Intent o, boolean all) {
3249 this.mAction = o.mAction;
3250 this.mData = o.mData;
3251 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003252 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003253 this.mComponent = o.mComponent;
3254 if (o.mCategories != null) {
3255 this.mCategories = new HashSet<String>(o.mCategories);
3256 }
3257 }
3258
3259 /**
3260 * Make a clone of only the parts of the Intent that are relevant for
3261 * filter matching: the action, data, type, component, and categories.
3262 */
3263 public Intent cloneFilter() {
3264 return new Intent(this, false);
3265 }
3266
3267 /**
3268 * Create an intent with a given action. All other fields (data, type,
3269 * class) are null. Note that the action <em>must</em> be in a
3270 * namespace because Intents are used globally in the system -- for
3271 * example the system VIEW action is android.intent.action.VIEW; an
3272 * application's custom action would be something like
3273 * com.google.app.myapp.CUSTOM_ACTION.
3274 *
3275 * @param action The Intent action, such as ACTION_VIEW.
3276 */
3277 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003278 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003279 }
3280
3281 /**
3282 * Create an intent with a given action and for a given data url. Note
3283 * that the action <em>must</em> be in a namespace because Intents are
3284 * used globally in the system -- for example the system VIEW action is
3285 * android.intent.action.VIEW; an application's custom action would be
3286 * something like com.google.app.myapp.CUSTOM_ACTION.
3287 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003288 * <p><em>Note: scheme and host name matching in the Android framework is
3289 * case-sensitive, unlike the formal RFC. As a result,
3290 * you should always ensure that you write your Uri with these elements
3291 * using lower case letters, and normalize any Uris you receive from
3292 * outside of Android to ensure the scheme and host is lower case.</em></p>
3293 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003294 * @param action The Intent action, such as ACTION_VIEW.
3295 * @param uri The Intent data URI.
3296 */
3297 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003298 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003299 mData = uri;
3300 }
3301
3302 /**
3303 * Create an intent for a specific component. All other fields (action, data,
3304 * type, class) are null, though they can be modified later with explicit
3305 * calls. This provides a convenient way to create an intent that is
3306 * intended to execute a hard-coded class name, rather than relying on the
3307 * system to find an appropriate class for you; see {@link #setComponent}
3308 * for more information on the repercussions of this.
3309 *
3310 * @param packageContext A Context of the application package implementing
3311 * this class.
3312 * @param cls The component class that is to be used for the intent.
3313 *
3314 * @see #setClass
3315 * @see #setComponent
3316 * @see #Intent(String, android.net.Uri , Context, Class)
3317 */
3318 public Intent(Context packageContext, Class<?> cls) {
3319 mComponent = new ComponentName(packageContext, cls);
3320 }
3321
3322 /**
3323 * Create an intent for a specific component with a specified action and data.
3324 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
3325 * construct the Intent and then calling {@link #setClass} to set its
3326 * class.
3327 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003328 * <p><em>Note: scheme and host name matching in the Android framework is
3329 * case-sensitive, unlike the formal RFC. As a result,
3330 * you should always ensure that you write your Uri with these elements
3331 * using lower case letters, and normalize any Uris you receive from
3332 * outside of Android to ensure the scheme and host is lower case.</em></p>
3333 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003334 * @param action The Intent action, such as ACTION_VIEW.
3335 * @param uri The Intent data URI.
3336 * @param packageContext A Context of the application package implementing
3337 * this class.
3338 * @param cls The component class that is to be used for the intent.
3339 *
3340 * @see #Intent(String, android.net.Uri)
3341 * @see #Intent(Context, Class)
3342 * @see #setClass
3343 * @see #setComponent
3344 */
3345 public Intent(String action, Uri uri,
3346 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003347 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003348 mData = uri;
3349 mComponent = new ComponentName(packageContext, cls);
3350 }
3351
3352 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003353 * Create an intent to launch the main (root) activity of a task. This
3354 * is the Intent that is started when the application's is launched from
3355 * Home. For anything else that wants to launch an application in the
3356 * same way, it is important that they use an Intent structured the same
3357 * way, and can use this function to ensure this is the case.
3358 *
3359 * <p>The returned Intent has the given Activity component as its explicit
3360 * component, {@link #ACTION_MAIN} as its action, and includes the
3361 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3362 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3363 * to do that through {@link #addFlags(int)} on the returned Intent.
3364 *
3365 * @param mainActivity The main activity component that this Intent will
3366 * launch.
3367 * @return Returns a newly created Intent that can be used to launch the
3368 * activity as a main application entry.
3369 *
3370 * @see #setClass
3371 * @see #setComponent
3372 */
3373 public static Intent makeMainActivity(ComponentName mainActivity) {
3374 Intent intent = new Intent(ACTION_MAIN);
3375 intent.setComponent(mainActivity);
3376 intent.addCategory(CATEGORY_LAUNCHER);
3377 return intent;
3378 }
3379
3380 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003381 * Make an Intent for the main activity of an application, without
3382 * specifying a specific activity to run but giving a selector to find
3383 * the activity. This results in a final Intent that is structured
3384 * the same as when the application is launched from
3385 * Home. For anything else that wants to launch an application in the
3386 * same way, it is important that they use an Intent structured the same
3387 * way, and can use this function to ensure this is the case.
3388 *
3389 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
3390 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3391 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3392 * to do that through {@link #addFlags(int)} on the returned Intent.
3393 *
3394 * @param selectorAction The action name of the Intent's selector.
3395 * @param selectorCategory The name of a category to add to the Intent's
3396 * selector.
3397 * @return Returns a newly created Intent that can be used to launch the
3398 * activity as a main application entry.
3399 *
3400 * @see #setSelector(Intent)
3401 */
3402 public static Intent makeMainSelectorActivity(String selectorAction,
3403 String selectorCategory) {
3404 Intent intent = new Intent(ACTION_MAIN);
3405 intent.addCategory(CATEGORY_LAUNCHER);
3406 Intent selector = new Intent();
3407 selector.setAction(selectorAction);
3408 selector.addCategory(selectorCategory);
3409 intent.setSelector(selector);
3410 return intent;
3411 }
3412
3413 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003414 * Make an Intent that can be used to re-launch an application's task
3415 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
3416 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
3417 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
3418 *
3419 * @param mainActivity The activity component that is the root of the
3420 * task; this is the activity that has been published in the application's
3421 * manifest as the main launcher icon.
3422 *
3423 * @return Returns a newly created Intent that can be used to relaunch the
3424 * activity's task in its root state.
3425 */
3426 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
3427 Intent intent = makeMainActivity(mainActivity);
3428 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
3429 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
3430 return intent;
3431 }
3432
3433 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003434 * Call {@link #parseUri} with 0 flags.
3435 * @deprecated Use {@link #parseUri} instead.
3436 */
3437 @Deprecated
3438 public static Intent getIntent(String uri) throws URISyntaxException {
3439 return parseUri(uri, 0);
3440 }
Tom Taylord4a47292009-12-21 13:59:18 -08003441
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003442 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003443 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003444 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07003445 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003446 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003447 *
3448 * <p>The URI given here must not be relative -- that is, it must include
3449 * the scheme and full path.
3450 *
3451 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003452 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003453 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003454 *
3455 * @return Intent The newly created Intent object.
3456 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003457 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
3458 * it bad (as parsed by the Uri class) or the Intent data within the
3459 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08003460 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003461 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003462 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003463 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003464 int i = 0;
3465 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003466 // Validate intent scheme for if requested.
3467 if ((flags&URI_INTENT_SCHEME) != 0) {
3468 if (!uri.startsWith("intent:")) {
3469 Intent intent = new Intent(ACTION_VIEW);
3470 try {
3471 intent.setData(Uri.parse(uri));
3472 } catch (IllegalArgumentException e) {
3473 throw new URISyntaxException(uri, e.getMessage());
3474 }
3475 return intent;
3476 }
3477 }
Tom Taylord4a47292009-12-21 13:59:18 -08003478
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003479 // simple case
3480 i = uri.lastIndexOf("#");
3481 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
3482
3483 // old format Intent URI
3484 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07003485
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003486 // new format
3487 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003488 Intent baseIntent = intent;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003489
3490 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003491 String data = i >= 0 ? uri.substring(0, i) : null;
3492 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003493 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07003494
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003495 // loop over contents of Intent, all name=value;
3496 while (!uri.startsWith("end", i)) {
3497 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003498 if (eq < 0) eq = i-1;
3499 int semi = uri.indexOf(';', i);
3500 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003501
3502 // action
3503 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003504 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003505 }
3506
3507 // categories
3508 else if (uri.startsWith("category=", i)) {
3509 intent.addCategory(value);
3510 }
3511
3512 // type
3513 else if (uri.startsWith("type=", i)) {
3514 intent.mType = value;
3515 }
3516
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003517 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003518 else if (uri.startsWith("launchFlags=", i)) {
3519 intent.mFlags = Integer.decode(value).intValue();
3520 }
3521
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003522 // package
3523 else if (uri.startsWith("package=", i)) {
3524 intent.mPackage = value;
3525 }
3526
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003527 // component
3528 else if (uri.startsWith("component=", i)) {
3529 intent.mComponent = ComponentName.unflattenFromString(value);
3530 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003531
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003532 // scheme
3533 else if (uri.startsWith("scheme=", i)) {
3534 scheme = value;
3535 }
3536
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003537 // source bounds
3538 else if (uri.startsWith("sourceBounds=", i)) {
3539 intent.mSourceBounds = Rect.unflattenFromString(value);
3540 }
3541
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003542 // selector
3543 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
3544 intent = new Intent();
3545 }
3546
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003547 // extra
3548 else {
3549 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003550 // create Bundle if it doesn't already exist
3551 if (intent.mExtras == null) intent.mExtras = new Bundle();
3552 Bundle b = intent.mExtras;
3553 // add EXTRA
3554 if (uri.startsWith("S.", i)) b.putString(key, value);
3555 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
3556 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
3557 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
3558 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
3559 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
3560 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
3561 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
3562 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
3563 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
3564 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003565
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003566 // move to the next item
3567 i = semi + 1;
3568 }
3569
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003570 if (intent != baseIntent) {
3571 // The Intent had a selector; fix it up.
3572 baseIntent.setSelector(intent);
3573 intent = baseIntent;
3574 }
3575
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003576 if (data != null) {
3577 if (data.startsWith("intent:")) {
3578 data = data.substring(7);
3579 if (scheme != null) {
3580 data = scheme + ':' + data;
3581 }
3582 }
Tom Taylord4a47292009-12-21 13:59:18 -08003583
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003584 if (data.length() > 0) {
3585 try {
3586 intent.mData = Uri.parse(data);
3587 } catch (IllegalArgumentException e) {
3588 throw new URISyntaxException(uri, e.getMessage());
3589 }
3590 }
3591 }
Tom Taylord4a47292009-12-21 13:59:18 -08003592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003593 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07003594
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003595 } catch (IndexOutOfBoundsException e) {
3596 throw new URISyntaxException(uri, "illegal Intent URI format", i);
3597 }
3598 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003599
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003600 public static Intent getIntentOld(String uri) throws URISyntaxException {
3601 Intent intent;
3602
3603 int i = uri.lastIndexOf('#');
3604 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003605 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003606 final int intentFragmentStart = i;
3607 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003608
3609 i++;
3610
3611 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003612 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003613 i += 7;
3614 int j = uri.indexOf(')', i);
3615 action = uri.substring(i, j);
3616 i = j + 1;
3617 }
3618
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003619 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003620
3621 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003622 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003623 i += 11;
3624 int j = uri.indexOf(')', i);
3625 while (i < j) {
3626 int sep = uri.indexOf('!', i);
3627 if (sep < 0) sep = j;
3628 if (i < sep) {
3629 intent.addCategory(uri.substring(i, sep));
3630 }
3631 i = sep + 1;
3632 }
3633 i = j + 1;
3634 }
3635
3636 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003637 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003638 i += 5;
3639 int j = uri.indexOf(')', i);
3640 intent.mType = uri.substring(i, j);
3641 i = j + 1;
3642 }
3643
3644 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003645 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003646 i += 12;
3647 int j = uri.indexOf(')', i);
3648 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
3649 i = j + 1;
3650 }
3651
3652 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003653 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003654 i += 10;
3655 int j = uri.indexOf(')', i);
3656 int sep = uri.indexOf('!', i);
3657 if (sep >= 0 && sep < j) {
3658 String pkg = uri.substring(i, sep);
3659 String cls = uri.substring(sep + 1, j);
3660 intent.mComponent = new ComponentName(pkg, cls);
3661 }
3662 i = j + 1;
3663 }
3664
3665 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003666 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003667 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07003668
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003669 final int closeParen = uri.indexOf(')', i);
3670 if (closeParen == -1) throw new URISyntaxException(uri,
3671 "EXTRA missing trailing ')'", i);
3672
3673 while (i < closeParen) {
3674 // fetch the key value
3675 int j = uri.indexOf('=', i);
3676 if (j <= i + 1 || i >= closeParen) {
3677 throw new URISyntaxException(uri, "EXTRA missing '='", i);
3678 }
3679 char type = uri.charAt(i);
3680 i++;
3681 String key = uri.substring(i, j);
3682 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07003683
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003684 // get type-value
3685 j = uri.indexOf('!', i);
3686 if (j == -1 || j >= closeParen) j = closeParen;
3687 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3688 String value = uri.substring(i, j);
3689 i = j;
3690
3691 // create Bundle if it doesn't already exist
3692 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07003693
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003694 // add item to bundle
3695 try {
3696 switch (type) {
3697 case 'S':
3698 intent.mExtras.putString(key, Uri.decode(value));
3699 break;
3700 case 'B':
3701 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
3702 break;
3703 case 'b':
3704 intent.mExtras.putByte(key, Byte.parseByte(value));
3705 break;
3706 case 'c':
3707 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
3708 break;
3709 case 'd':
3710 intent.mExtras.putDouble(key, Double.parseDouble(value));
3711 break;
3712 case 'f':
3713 intent.mExtras.putFloat(key, Float.parseFloat(value));
3714 break;
3715 case 'i':
3716 intent.mExtras.putInt(key, Integer.parseInt(value));
3717 break;
3718 case 'l':
3719 intent.mExtras.putLong(key, Long.parseLong(value));
3720 break;
3721 case 's':
3722 intent.mExtras.putShort(key, Short.parseShort(value));
3723 break;
3724 default:
3725 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
3726 }
3727 } catch (NumberFormatException e) {
3728 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
3729 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003730
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003731 char ch = uri.charAt(i);
3732 if (ch == ')') break;
3733 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
3734 i++;
3735 }
3736 }
3737
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003738 if (isIntentFragment) {
3739 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
3740 } else {
3741 intent.mData = Uri.parse(uri);
3742 }
Tom Taylord4a47292009-12-21 13:59:18 -08003743
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003744 if (intent.mAction == null) {
3745 // By default, if no action is specified, then use VIEW.
3746 intent.mAction = ACTION_VIEW;
3747 }
3748
3749 } else {
3750 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
3751 }
3752
3753 return intent;
3754 }
3755
3756 /**
3757 * Retrieve the general action to be performed, such as
3758 * {@link #ACTION_VIEW}. The action describes the general way the rest of
3759 * the information in the intent should be interpreted -- most importantly,
3760 * what to do with the data returned by {@link #getData}.
3761 *
3762 * @return The action of this intent or null if none is specified.
3763 *
3764 * @see #setAction
3765 */
3766 public String getAction() {
3767 return mAction;
3768 }
3769
3770 /**
3771 * Retrieve data this intent is operating on. This URI specifies the name
3772 * of the data; often it uses the content: scheme, specifying data in a
3773 * content provider. Other schemes may be handled by specific activities,
3774 * such as http: by the web browser.
3775 *
3776 * @return The URI of the data this intent is targeting or null.
3777 *
3778 * @see #getScheme
3779 * @see #setData
3780 */
3781 public Uri getData() {
3782 return mData;
3783 }
3784
3785 /**
3786 * The same as {@link #getData()}, but returns the URI as an encoded
3787 * String.
3788 */
3789 public String getDataString() {
3790 return mData != null ? mData.toString() : null;
3791 }
3792
3793 /**
3794 * Return the scheme portion of the intent's data. If the data is null or
3795 * does not include a scheme, null is returned. Otherwise, the scheme
3796 * prefix without the final ':' is returned, i.e. "http".
3797 *
3798 * <p>This is the same as calling getData().getScheme() (and checking for
3799 * null data).
3800 *
3801 * @return The scheme of this intent.
3802 *
3803 * @see #getData
3804 */
3805 public String getScheme() {
3806 return mData != null ? mData.getScheme() : null;
3807 }
3808
3809 /**
3810 * Retrieve any explicit MIME type included in the intent. This is usually
3811 * null, as the type is determined by the intent data.
3812 *
3813 * @return If a type was manually set, it is returned; else null is
3814 * returned.
3815 *
3816 * @see #resolveType(ContentResolver)
3817 * @see #setType
3818 */
3819 public String getType() {
3820 return mType;
3821 }
3822
3823 /**
3824 * Return the MIME data type of this intent. If the type field is
3825 * explicitly set, that is simply returned. Otherwise, if the data is set,
3826 * the type of that data is returned. If neither fields are set, a null is
3827 * returned.
3828 *
3829 * @return The MIME type of this intent.
3830 *
3831 * @see #getType
3832 * @see #resolveType(ContentResolver)
3833 */
3834 public String resolveType(Context context) {
3835 return resolveType(context.getContentResolver());
3836 }
3837
3838 /**
3839 * Return the MIME data type of this intent. If the type field is
3840 * explicitly set, that is simply returned. Otherwise, if the data is set,
3841 * the type of that data is returned. If neither fields are set, a null is
3842 * returned.
3843 *
3844 * @param resolver A ContentResolver that can be used to determine the MIME
3845 * type of the intent's data.
3846 *
3847 * @return The MIME type of this intent.
3848 *
3849 * @see #getType
3850 * @see #resolveType(Context)
3851 */
3852 public String resolveType(ContentResolver resolver) {
3853 if (mType != null) {
3854 return mType;
3855 }
3856 if (mData != null) {
3857 if ("content".equals(mData.getScheme())) {
3858 return resolver.getType(mData);
3859 }
3860 }
3861 return null;
3862 }
3863
3864 /**
3865 * Return the MIME data type of this intent, only if it will be needed for
3866 * intent resolution. This is not generally useful for application code;
3867 * it is used by the frameworks for communicating with back-end system
3868 * services.
3869 *
3870 * @param resolver A ContentResolver that can be used to determine the MIME
3871 * type of the intent's data.
3872 *
3873 * @return The MIME type of this intent, or null if it is unknown or not
3874 * needed.
3875 */
3876 public String resolveTypeIfNeeded(ContentResolver resolver) {
3877 if (mComponent != null) {
3878 return mType;
3879 }
3880 return resolveType(resolver);
3881 }
3882
3883 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003884 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003885 *
3886 * @param category The category to check.
3887 *
3888 * @return boolean True if the intent contains the category, else false.
3889 *
3890 * @see #getCategories
3891 * @see #addCategory
3892 */
3893 public boolean hasCategory(String category) {
3894 return mCategories != null && mCategories.contains(category);
3895 }
3896
3897 /**
3898 * Return the set of all categories in the intent. If there are no categories,
3899 * returns NULL.
3900 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003901 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003902 *
3903 * @see #hasCategory
3904 * @see #addCategory
3905 */
3906 public Set<String> getCategories() {
3907 return mCategories;
3908 }
3909
3910 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003911 * Return the specific selector associated with this Intent. If there is
3912 * none, returns null. See {@link #setSelector} for more information.
3913 *
3914 * @see #setSelector
3915 */
3916 public Intent getSelector() {
3917 return mSelector;
3918 }
3919
3920 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003921 * Return the {@link ClipData} associated with this Intent. If there is
3922 * none, returns null. See {@link #setClipData} for more information.
3923 *
3924 * @see #setClipData;
3925 */
3926 public ClipData getClipData() {
3927 return mClipData;
3928 }
3929
3930 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003931 * Sets the ClassLoader that will be used when unmarshalling
3932 * any Parcelable values from the extras of this Intent.
3933 *
3934 * @param loader a ClassLoader, or null to use the default loader
3935 * at the time of unmarshalling.
3936 */
3937 public void setExtrasClassLoader(ClassLoader loader) {
3938 if (mExtras != null) {
3939 mExtras.setClassLoader(loader);
3940 }
3941 }
3942
3943 /**
3944 * Returns true if an extra value is associated with the given name.
3945 * @param name the extra's name
3946 * @return true if the given extra is present.
3947 */
3948 public boolean hasExtra(String name) {
3949 return mExtras != null && mExtras.containsKey(name);
3950 }
3951
3952 /**
3953 * Returns true if the Intent's extras contain a parcelled file descriptor.
3954 * @return true if the Intent contains a parcelled file descriptor.
3955 */
3956 public boolean hasFileDescriptors() {
3957 return mExtras != null && mExtras.hasFileDescriptors();
3958 }
The Android Open Source Project10592532009-03-18 17:39:46 -07003959
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04003960 /** @hide */
3961 public void setAllowFds(boolean allowFds) {
3962 if (mExtras != null) {
3963 mExtras.setAllowFds(allowFds);
3964 }
3965 }
3966
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003967 /**
3968 * Retrieve extended data from the intent.
3969 *
3970 * @param name The name of the desired item.
3971 *
3972 * @return the value of an item that previously added with putExtra()
3973 * or null if none was found.
3974 *
3975 * @deprecated
3976 * @hide
3977 */
3978 @Deprecated
3979 public Object getExtra(String name) {
3980 return getExtra(name, null);
3981 }
3982
3983 /**
3984 * Retrieve extended data from the intent.
3985 *
3986 * @param name The name of the desired item.
3987 * @param defaultValue the value to be returned if no value of the desired
3988 * type is stored with the given name.
3989 *
3990 * @return the value of an item that previously added with putExtra()
3991 * or the default value if none was found.
3992 *
3993 * @see #putExtra(String, boolean)
3994 */
3995 public boolean getBooleanExtra(String name, boolean defaultValue) {
3996 return mExtras == null ? defaultValue :
3997 mExtras.getBoolean(name, defaultValue);
3998 }
3999
4000 /**
4001 * Retrieve extended data from the intent.
4002 *
4003 * @param name The name of the desired item.
4004 * @param defaultValue the value to be returned if no value of the desired
4005 * type is stored with the given name.
4006 *
4007 * @return the value of an item that previously added with putExtra()
4008 * or the default value if none was found.
4009 *
4010 * @see #putExtra(String, byte)
4011 */
4012 public byte getByteExtra(String name, byte defaultValue) {
4013 return mExtras == null ? defaultValue :
4014 mExtras.getByte(name, defaultValue);
4015 }
4016
4017 /**
4018 * Retrieve extended data from the intent.
4019 *
4020 * @param name The name of the desired item.
4021 * @param defaultValue the value to be returned if no value of the desired
4022 * type is stored with the given name.
4023 *
4024 * @return the value of an item that previously added with putExtra()
4025 * or the default value if none was found.
4026 *
4027 * @see #putExtra(String, short)
4028 */
4029 public short getShortExtra(String name, short defaultValue) {
4030 return mExtras == null ? defaultValue :
4031 mExtras.getShort(name, defaultValue);
4032 }
4033
4034 /**
4035 * Retrieve extended data from the intent.
4036 *
4037 * @param name The name of the desired item.
4038 * @param defaultValue the value to be returned if no value of the desired
4039 * type is stored with the given name.
4040 *
4041 * @return the value of an item that previously added with putExtra()
4042 * or the default value if none was found.
4043 *
4044 * @see #putExtra(String, char)
4045 */
4046 public char getCharExtra(String name, char defaultValue) {
4047 return mExtras == null ? defaultValue :
4048 mExtras.getChar(name, defaultValue);
4049 }
4050
4051 /**
4052 * Retrieve extended data from the intent.
4053 *
4054 * @param name The name of the desired item.
4055 * @param defaultValue the value to be returned if no value of the desired
4056 * type is stored with the given name.
4057 *
4058 * @return the value of an item that previously added with putExtra()
4059 * or the default value if none was found.
4060 *
4061 * @see #putExtra(String, int)
4062 */
4063 public int getIntExtra(String name, int defaultValue) {
4064 return mExtras == null ? defaultValue :
4065 mExtras.getInt(name, defaultValue);
4066 }
4067
4068 /**
4069 * Retrieve extended data from the intent.
4070 *
4071 * @param name The name of the desired item.
4072 * @param defaultValue the value to be returned if no value of the desired
4073 * type is stored with the given name.
4074 *
4075 * @return the value of an item that previously added with putExtra()
4076 * or the default value if none was found.
4077 *
4078 * @see #putExtra(String, long)
4079 */
4080 public long getLongExtra(String name, long defaultValue) {
4081 return mExtras == null ? defaultValue :
4082 mExtras.getLong(name, defaultValue);
4083 }
4084
4085 /**
4086 * Retrieve extended data from the intent.
4087 *
4088 * @param name The name of the desired item.
4089 * @param defaultValue the value to be returned if no value of the desired
4090 * type is stored with the given name.
4091 *
4092 * @return the value of an item that previously added with putExtra(),
4093 * or the default value if no such item is present
4094 *
4095 * @see #putExtra(String, float)
4096 */
4097 public float getFloatExtra(String name, float defaultValue) {
4098 return mExtras == null ? defaultValue :
4099 mExtras.getFloat(name, defaultValue);
4100 }
4101
4102 /**
4103 * Retrieve extended data from the intent.
4104 *
4105 * @param name The name of the desired item.
4106 * @param defaultValue the value to be returned if no value of the desired
4107 * type is stored with the given name.
4108 *
4109 * @return the value of an item that previously added with putExtra()
4110 * or the default value if none was found.
4111 *
4112 * @see #putExtra(String, double)
4113 */
4114 public double getDoubleExtra(String name, double defaultValue) {
4115 return mExtras == null ? defaultValue :
4116 mExtras.getDouble(name, defaultValue);
4117 }
4118
4119 /**
4120 * Retrieve extended data from the intent.
4121 *
4122 * @param name The name of the desired item.
4123 *
4124 * @return the value of an item that previously added with putExtra()
4125 * or null if no String value was found.
4126 *
4127 * @see #putExtra(String, String)
4128 */
4129 public String getStringExtra(String name) {
4130 return mExtras == null ? null : mExtras.getString(name);
4131 }
4132
4133 /**
4134 * Retrieve extended data from the intent.
4135 *
4136 * @param name The name of the desired item.
4137 *
4138 * @return the value of an item that previously added with putExtra()
4139 * or null if no CharSequence value was found.
4140 *
4141 * @see #putExtra(String, CharSequence)
4142 */
4143 public CharSequence getCharSequenceExtra(String name) {
4144 return mExtras == null ? null : mExtras.getCharSequence(name);
4145 }
4146
4147 /**
4148 * Retrieve extended data from the intent.
4149 *
4150 * @param name The name of the desired item.
4151 *
4152 * @return the value of an item that previously added with putExtra()
4153 * or null if no Parcelable value was found.
4154 *
4155 * @see #putExtra(String, Parcelable)
4156 */
4157 public <T extends Parcelable> T getParcelableExtra(String name) {
4158 return mExtras == null ? null : mExtras.<T>getParcelable(name);
4159 }
4160
4161 /**
4162 * Retrieve extended data from the intent.
4163 *
4164 * @param name The name of the desired item.
4165 *
4166 * @return the value of an item that previously added with putExtra()
4167 * or null if no Parcelable[] value was found.
4168 *
4169 * @see #putExtra(String, Parcelable[])
4170 */
4171 public Parcelable[] getParcelableArrayExtra(String name) {
4172 return mExtras == null ? null : mExtras.getParcelableArray(name);
4173 }
4174
4175 /**
4176 * Retrieve extended data from the intent.
4177 *
4178 * @param name The name of the desired item.
4179 *
4180 * @return the value of an item that previously added with putExtra()
4181 * or null if no ArrayList<Parcelable> value was found.
4182 *
4183 * @see #putParcelableArrayListExtra(String, ArrayList)
4184 */
4185 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
4186 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
4187 }
4188
4189 /**
4190 * Retrieve extended data from the intent.
4191 *
4192 * @param name The name of the desired item.
4193 *
4194 * @return the value of an item that previously added with putExtra()
4195 * or null if no Serializable value was found.
4196 *
4197 * @see #putExtra(String, Serializable)
4198 */
4199 public Serializable getSerializableExtra(String name) {
4200 return mExtras == null ? null : mExtras.getSerializable(name);
4201 }
4202
4203 /**
4204 * Retrieve extended data from the intent.
4205 *
4206 * @param name The name of the desired item.
4207 *
4208 * @return the value of an item that previously added with putExtra()
4209 * or null if no ArrayList<Integer> value was found.
4210 *
4211 * @see #putIntegerArrayListExtra(String, ArrayList)
4212 */
4213 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
4214 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
4215 }
4216
4217 /**
4218 * Retrieve extended data from the intent.
4219 *
4220 * @param name The name of the desired item.
4221 *
4222 * @return the value of an item that previously added with putExtra()
4223 * or null if no ArrayList<String> value was found.
4224 *
4225 * @see #putStringArrayListExtra(String, ArrayList)
4226 */
4227 public ArrayList<String> getStringArrayListExtra(String name) {
4228 return mExtras == null ? null : mExtras.getStringArrayList(name);
4229 }
4230
4231 /**
4232 * Retrieve extended data from the intent.
4233 *
4234 * @param name The name of the desired item.
4235 *
4236 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004237 * or null if no ArrayList<CharSequence> value was found.
4238 *
4239 * @see #putCharSequenceArrayListExtra(String, ArrayList)
4240 */
4241 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
4242 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
4243 }
4244
4245 /**
4246 * Retrieve extended data from the intent.
4247 *
4248 * @param name The name of the desired item.
4249 *
4250 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004251 * or null if no boolean array value was found.
4252 *
4253 * @see #putExtra(String, boolean[])
4254 */
4255 public boolean[] getBooleanArrayExtra(String name) {
4256 return mExtras == null ? null : mExtras.getBooleanArray(name);
4257 }
4258
4259 /**
4260 * Retrieve extended data from the intent.
4261 *
4262 * @param name The name of the desired item.
4263 *
4264 * @return the value of an item that previously added with putExtra()
4265 * or null if no byte array value was found.
4266 *
4267 * @see #putExtra(String, byte[])
4268 */
4269 public byte[] getByteArrayExtra(String name) {
4270 return mExtras == null ? null : mExtras.getByteArray(name);
4271 }
4272
4273 /**
4274 * Retrieve extended data from the intent.
4275 *
4276 * @param name The name of the desired item.
4277 *
4278 * @return the value of an item that previously added with putExtra()
4279 * or null if no short array value was found.
4280 *
4281 * @see #putExtra(String, short[])
4282 */
4283 public short[] getShortArrayExtra(String name) {
4284 return mExtras == null ? null : mExtras.getShortArray(name);
4285 }
4286
4287 /**
4288 * Retrieve extended data from the intent.
4289 *
4290 * @param name The name of the desired item.
4291 *
4292 * @return the value of an item that previously added with putExtra()
4293 * or null if no char array value was found.
4294 *
4295 * @see #putExtra(String, char[])
4296 */
4297 public char[] getCharArrayExtra(String name) {
4298 return mExtras == null ? null : mExtras.getCharArray(name);
4299 }
4300
4301 /**
4302 * Retrieve extended data from the intent.
4303 *
4304 * @param name The name of the desired item.
4305 *
4306 * @return the value of an item that previously added with putExtra()
4307 * or null if no int array value was found.
4308 *
4309 * @see #putExtra(String, int[])
4310 */
4311 public int[] getIntArrayExtra(String name) {
4312 return mExtras == null ? null : mExtras.getIntArray(name);
4313 }
4314
4315 /**
4316 * Retrieve extended data from the intent.
4317 *
4318 * @param name The name of the desired item.
4319 *
4320 * @return the value of an item that previously added with putExtra()
4321 * or null if no long array value was found.
4322 *
4323 * @see #putExtra(String, long[])
4324 */
4325 public long[] getLongArrayExtra(String name) {
4326 return mExtras == null ? null : mExtras.getLongArray(name);
4327 }
4328
4329 /**
4330 * Retrieve extended data from the intent.
4331 *
4332 * @param name The name of the desired item.
4333 *
4334 * @return the value of an item that previously added with putExtra()
4335 * or null if no float array value was found.
4336 *
4337 * @see #putExtra(String, float[])
4338 */
4339 public float[] getFloatArrayExtra(String name) {
4340 return mExtras == null ? null : mExtras.getFloatArray(name);
4341 }
4342
4343 /**
4344 * Retrieve extended data from the intent.
4345 *
4346 * @param name The name of the desired item.
4347 *
4348 * @return the value of an item that previously added with putExtra()
4349 * or null if no double array value was found.
4350 *
4351 * @see #putExtra(String, double[])
4352 */
4353 public double[] getDoubleArrayExtra(String name) {
4354 return mExtras == null ? null : mExtras.getDoubleArray(name);
4355 }
4356
4357 /**
4358 * Retrieve extended data from the intent.
4359 *
4360 * @param name The name of the desired item.
4361 *
4362 * @return the value of an item that previously added with putExtra()
4363 * or null if no String array value was found.
4364 *
4365 * @see #putExtra(String, String[])
4366 */
4367 public String[] getStringArrayExtra(String name) {
4368 return mExtras == null ? null : mExtras.getStringArray(name);
4369 }
4370
4371 /**
4372 * Retrieve extended data from the intent.
4373 *
4374 * @param name The name of the desired item.
4375 *
4376 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004377 * or null if no CharSequence array value was found.
4378 *
4379 * @see #putExtra(String, CharSequence[])
4380 */
4381 public CharSequence[] getCharSequenceArrayExtra(String name) {
4382 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
4383 }
4384
4385 /**
4386 * Retrieve extended data from the intent.
4387 *
4388 * @param name The name of the desired item.
4389 *
4390 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004391 * or null if no Bundle value was found.
4392 *
4393 * @see #putExtra(String, Bundle)
4394 */
4395 public Bundle getBundleExtra(String name) {
4396 return mExtras == null ? null : mExtras.getBundle(name);
4397 }
4398
4399 /**
4400 * Retrieve extended data from the intent.
4401 *
4402 * @param name The name of the desired item.
4403 *
4404 * @return the value of an item that previously added with putExtra()
4405 * or null if no IBinder value was found.
4406 *
4407 * @see #putExtra(String, IBinder)
4408 *
4409 * @deprecated
4410 * @hide
4411 */
4412 @Deprecated
4413 public IBinder getIBinderExtra(String name) {
4414 return mExtras == null ? null : mExtras.getIBinder(name);
4415 }
4416
4417 /**
4418 * Retrieve extended data from the intent.
4419 *
4420 * @param name The name of the desired item.
4421 * @param defaultValue The default value to return in case no item is
4422 * associated with the key 'name'
4423 *
4424 * @return the value of an item that previously added with putExtra()
4425 * or defaultValue if none was found.
4426 *
4427 * @see #putExtra
4428 *
4429 * @deprecated
4430 * @hide
4431 */
4432 @Deprecated
4433 public Object getExtra(String name, Object defaultValue) {
4434 Object result = defaultValue;
4435 if (mExtras != null) {
4436 Object result2 = mExtras.get(name);
4437 if (result2 != null) {
4438 result = result2;
4439 }
4440 }
4441
4442 return result;
4443 }
4444
4445 /**
4446 * Retrieves a map of extended data from the intent.
4447 *
4448 * @return the map of all extras previously added with putExtra(),
4449 * or null if none have been added.
4450 */
4451 public Bundle getExtras() {
4452 return (mExtras != null)
4453 ? new Bundle(mExtras)
4454 : null;
4455 }
4456
4457 /**
4458 * Retrieve any special flags associated with this intent. You will
4459 * normally just set them with {@link #setFlags} and let the system
4460 * take the appropriate action with them.
4461 *
4462 * @return int The currently set flags.
4463 *
4464 * @see #setFlags
4465 */
4466 public int getFlags() {
4467 return mFlags;
4468 }
4469
Dianne Hackborne7f97212011-02-24 14:40:20 -08004470 /** @hide */
4471 public boolean isExcludingStopped() {
4472 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4473 == FLAG_EXCLUDE_STOPPED_PACKAGES;
4474 }
4475
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004476 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004477 * Retrieve the application package name this Intent is limited to. When
4478 * resolving an Intent, if non-null this limits the resolution to only
4479 * components in the given application package.
4480 *
4481 * @return The name of the application package for the Intent.
4482 *
4483 * @see #resolveActivity
4484 * @see #setPackage
4485 */
4486 public String getPackage() {
4487 return mPackage;
4488 }
4489
4490 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004491 * Retrieve the concrete component associated with the intent. When receiving
4492 * an intent, this is the component that was found to best handle it (that is,
4493 * yourself) and will always be non-null; in all other cases it will be
4494 * null unless explicitly set.
4495 *
4496 * @return The name of the application component to handle the intent.
4497 *
4498 * @see #resolveActivity
4499 * @see #setComponent
4500 */
4501 public ComponentName getComponent() {
4502 return mComponent;
4503 }
4504
4505 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004506 * Get the bounds of the sender of this intent, in screen coordinates. This can be
4507 * used as a hint to the receiver for animations and the like. Null means that there
4508 * is no source bounds.
4509 */
4510 public Rect getSourceBounds() {
4511 return mSourceBounds;
4512 }
4513
4514 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004515 * Return the Activity component that should be used to handle this intent.
4516 * The appropriate component is determined based on the information in the
4517 * intent, evaluated as follows:
4518 *
4519 * <p>If {@link #getComponent} returns an explicit class, that is returned
4520 * without any further consideration.
4521 *
4522 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
4523 * category to be considered.
4524 *
4525 * <p>If {@link #getAction} is non-NULL, the activity must handle this
4526 * action.
4527 *
4528 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
4529 * this type.
4530 *
4531 * <p>If {@link #addCategory} has added any categories, the activity must
4532 * handle ALL of the categories specified.
4533 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004534 * <p>If {@link #getPackage} is non-NULL, only activity components in
4535 * that application package will be considered.
4536 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004537 * <p>If there are no activities that satisfy all of these conditions, a
4538 * null string is returned.
4539 *
4540 * <p>If multiple activities are found to satisfy the intent, the one with
4541 * the highest priority will be used. If there are multiple activities
4542 * with the same priority, the system will either pick the best activity
4543 * based on user preference, or resolve to a system class that will allow
4544 * the user to pick an activity and forward from there.
4545 *
4546 * <p>This method is implemented simply by calling
4547 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
4548 * true.</p>
4549 * <p> This API is called for you as part of starting an activity from an
4550 * intent. You do not normally need to call it yourself.</p>
4551 *
4552 * @param pm The package manager with which to resolve the Intent.
4553 *
4554 * @return Name of the component implementing an activity that can
4555 * display the intent.
4556 *
4557 * @see #setComponent
4558 * @see #getComponent
4559 * @see #resolveActivityInfo
4560 */
4561 public ComponentName resolveActivity(PackageManager pm) {
4562 if (mComponent != null) {
4563 return mComponent;
4564 }
4565
4566 ResolveInfo info = pm.resolveActivity(
4567 this, PackageManager.MATCH_DEFAULT_ONLY);
4568 if (info != null) {
4569 return new ComponentName(
4570 info.activityInfo.applicationInfo.packageName,
4571 info.activityInfo.name);
4572 }
4573
4574 return null;
4575 }
4576
4577 /**
4578 * Resolve the Intent into an {@link ActivityInfo}
4579 * describing the activity that should execute the intent. Resolution
4580 * follows the same rules as described for {@link #resolveActivity}, but
4581 * you get back the completely information about the resolved activity
4582 * instead of just its class name.
4583 *
4584 * @param pm The package manager with which to resolve the Intent.
4585 * @param flags Addition information to retrieve as per
4586 * {@link PackageManager#getActivityInfo(ComponentName, int)
4587 * PackageManager.getActivityInfo()}.
4588 *
4589 * @return PackageManager.ActivityInfo
4590 *
4591 * @see #resolveActivity
4592 */
4593 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
4594 ActivityInfo ai = null;
4595 if (mComponent != null) {
4596 try {
4597 ai = pm.getActivityInfo(mComponent, flags);
4598 } catch (PackageManager.NameNotFoundException e) {
4599 // ignore
4600 }
4601 } else {
4602 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004603 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004604 if (info != null) {
4605 ai = info.activityInfo;
4606 }
4607 }
4608
4609 return ai;
4610 }
4611
4612 /**
4613 * Set the general action to be performed.
4614 *
4615 * @param action An action name, such as ACTION_VIEW. Application-specific
4616 * actions should be prefixed with the vendor's package name.
4617 *
4618 * @return Returns the same Intent object, for chaining multiple calls
4619 * into a single statement.
4620 *
4621 * @see #getAction
4622 */
4623 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004624 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004625 return this;
4626 }
4627
4628 /**
4629 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08004630 * clears any type that was previously set by {@link #setType} or
4631 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004632 *
Nick Pellyccae4122012-01-09 14:12:58 -08004633 * <p><em>Note: scheme matching in the Android framework is
4634 * case-sensitive, unlike the formal RFC. As a result,
4635 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004636 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08004637 * {@link #setDataAndNormalize}
4638 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004639 *
Nick Pellyccae4122012-01-09 14:12:58 -08004640 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004641 *
4642 * @return Returns the same Intent object, for chaining multiple calls
4643 * into a single statement.
4644 *
4645 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08004646 * @see #setDataAndNormalize
4647 * @see android.net.Intent#normalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004648 */
4649 public Intent setData(Uri data) {
4650 mData = data;
4651 mType = null;
4652 return this;
4653 }
4654
4655 /**
Nick Pellyccae4122012-01-09 14:12:58 -08004656 * Normalize and set the data this intent is operating on.
4657 *
4658 * <p>This method automatically clears any type that was
4659 * previously set (for example, by {@link #setType}).
4660 *
4661 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004662 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08004663 * so really this is just a convenience method for
4664 * <pre>
4665 * setData(data.normalize())
4666 * </pre>
4667 *
4668 * @param data The Uri of the data this intent is now targeting.
4669 *
4670 * @return Returns the same Intent object, for chaining multiple calls
4671 * into a single statement.
4672 *
4673 * @see #getData
4674 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004675 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08004676 */
4677 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004678 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08004679 }
4680
4681 /**
4682 * Set an explicit MIME data type.
4683 *
4684 * <p>This is used to create intents that only specify a type and not data,
4685 * for example to indicate the type of data to return.
4686 *
4687 * <p>This method automatically clears any data that was
4688 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07004689 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004690 * <p><em>Note: MIME type matching in the Android framework is
4691 * case-sensitive, unlike formal RFC MIME types. As a result,
4692 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08004693 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
4694 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004695 *
4696 * @param type The MIME type of the data being handled by this intent.
4697 *
4698 * @return Returns the same Intent object, for chaining multiple calls
4699 * into a single statement.
4700 *
4701 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08004702 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004703 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08004704 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004705 */
4706 public Intent setType(String type) {
4707 mData = null;
4708 mType = type;
4709 return this;
4710 }
4711
4712 /**
Nick Pellyccae4122012-01-09 14:12:58 -08004713 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004714 *
Nick Pellyccae4122012-01-09 14:12:58 -08004715 * <p>This is used to create intents that only specify a type and not data,
4716 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004717 *
Nick Pellyccae4122012-01-09 14:12:58 -08004718 * <p>This method automatically clears any data that was
4719 * previously set (for example by {@link #setData}).
4720 *
4721 * <p>The MIME type is normalized using
4722 * {@link #normalizeMimeType} before it is set,
4723 * so really this is just a convenience method for
4724 * <pre>
4725 * setType(Intent.normalizeMimeType(type))
4726 * </pre>
4727 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004728 * @param type The MIME type of the data being handled by this intent.
4729 *
4730 * @return Returns the same Intent object, for chaining multiple calls
4731 * into a single statement.
4732 *
Nick Pellyccae4122012-01-09 14:12:58 -08004733 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004734 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08004735 * @see #normalizeMimeType
4736 */
4737 public Intent setTypeAndNormalize(String type) {
4738 return setType(normalizeMimeType(type));
4739 }
4740
4741 /**
4742 * (Usually optional) Set the data for the intent along with an explicit
4743 * MIME data type. This method should very rarely be used -- it allows you
4744 * to override the MIME type that would ordinarily be inferred from the
4745 * data with your own type given here.
4746 *
4747 * <p><em>Note: MIME type and Uri scheme matching in the
4748 * Android framework is case-sensitive, unlike the formal RFC definitions.
4749 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004750 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08004751 * {@link #setDataAndTypeAndNormalize}
4752 * to ensure that they are converted to lower case.</em>
4753 *
4754 * @param data The Uri of the data this intent is now targeting.
4755 * @param type The MIME type of the data being handled by this intent.
4756 *
4757 * @return Returns the same Intent object, for chaining multiple calls
4758 * into a single statement.
4759 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004760 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08004761 * @see #setData
4762 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004763 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08004764 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004765 */
4766 public Intent setDataAndType(Uri data, String type) {
4767 mData = data;
4768 mType = type;
4769 return this;
4770 }
4771
4772 /**
Nick Pellyccae4122012-01-09 14:12:58 -08004773 * (Usually optional) Normalize and set both the data Uri and an explicit
4774 * MIME data type. This method should very rarely be used -- it allows you
4775 * to override the MIME type that would ordinarily be inferred from the
4776 * data with your own type given here.
4777 *
4778 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004779 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08004780 * before they are set, so really this is just a convenience method for
4781 * <pre>
4782 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
4783 * </pre>
4784 *
4785 * @param data The Uri of the data this intent is now targeting.
4786 * @param type The MIME type of the data being handled by this intent.
4787 *
4788 * @return Returns the same Intent object, for chaining multiple calls
4789 * into a single statement.
4790 *
4791 * @see #setType
4792 * @see #setData
4793 * @see #setDataAndType
4794 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004795 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08004796 */
4797 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04004798 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08004799 }
4800
4801 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004802 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004803 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004804 * activities that provide <em>all</em> of the requested categories will be
4805 * used.
4806 *
4807 * @param category The desired category. This can be either one of the
4808 * predefined Intent categories, or a custom category in your own
4809 * namespace.
4810 *
4811 * @return Returns the same Intent object, for chaining multiple calls
4812 * into a single statement.
4813 *
4814 * @see #hasCategory
4815 * @see #removeCategory
4816 */
4817 public Intent addCategory(String category) {
4818 if (mCategories == null) {
4819 mCategories = new HashSet<String>();
4820 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08004821 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004822 return this;
4823 }
4824
4825 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004826 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004827 *
4828 * @param category The category to remove.
4829 *
4830 * @see #addCategory
4831 */
4832 public void removeCategory(String category) {
4833 if (mCategories != null) {
4834 mCategories.remove(category);
4835 if (mCategories.size() == 0) {
4836 mCategories = null;
4837 }
4838 }
4839 }
4840
4841 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004842 * Set a selector for this Intent. This is a modification to the kinds of
4843 * things the Intent will match. If the selector is set, it will be used
4844 * when trying to find entities that can handle the Intent, instead of the
4845 * main contents of the Intent. This allows you build an Intent containing
4846 * a generic protocol while targeting it more specifically.
4847 *
4848 * <p>An example of where this may be used is with things like
4849 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
4850 * Intent that will launch the Browser application. However, the correct
4851 * main entry point of an application is actually {@link #ACTION_MAIN}
4852 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
4853 * used to specify the actual Activity to launch. If you launch the browser
4854 * with something different, undesired behavior may happen if the user has
4855 * previously or later launches it the normal way, since they do not match.
4856 * Instead, you can build an Intent with the MAIN action (but no ComponentName
4857 * yet specified) and set a selector with {@link #ACTION_MAIN} and
4858 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
4859 *
4860 * <p>Setting a selector does not impact the behavior of
4861 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
4862 * desired behavior of a selector -- it does not impact the base meaning
4863 * of the Intent, just what kinds of things will be matched against it
4864 * when determining who can handle it.</p>
4865 *
4866 * <p>You can not use both a selector and {@link #setPackage(String)} on
4867 * the same base Intent.</p>
4868 *
4869 * @param selector The desired selector Intent; set to null to not use
4870 * a special selector.
4871 */
4872 public void setSelector(Intent selector) {
4873 if (selector == this) {
4874 throw new IllegalArgumentException(
4875 "Intent being set as a selector of itself");
4876 }
4877 if (selector != null && mPackage != null) {
4878 throw new IllegalArgumentException(
4879 "Can't set selector when package name is already set");
4880 }
4881 mSelector = selector;
4882 }
4883
4884 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004885 * Set a {@link ClipData} associated with this Intent. This replaces any
4886 * previously set ClipData.
4887 *
4888 * <p>The ClipData in an intent is not used for Intent matching or other
4889 * such operations. Semantically it is like extras, used to transmit
4890 * additional data with the Intent. The main feature of using this over
4891 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
4892 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
4893 * items included in the clip data. This is useful, in particular, if
4894 * you want to transmit an Intent containing multiple <code>content:</code>
4895 * URIs for which the recipient may not have global permission to access the
4896 * content provider.
4897 *
4898 * <p>If the ClipData contains items that are themselves Intents, any
4899 * grant flags in those Intents will be ignored. Only the top-level flags
4900 * of the main Intent are respected, and will be applied to all Uri or
4901 * Intent items in the clip (or sub-items of the clip).
4902 *
4903 * <p>The MIME type, label, and icon in the ClipData object are not
4904 * directly used by Intent. Applications should generally rely on the
4905 * MIME type of the Intent itself, not what it may find in the ClipData.
4906 * A common practice is to construct a ClipData for use with an Intent
4907 * with a MIME type of "*\/*".
4908 *
4909 * @param clip The new clip to set. May be null to clear the current clip.
4910 */
4911 public void setClipData(ClipData clip) {
4912 mClipData = clip;
4913 }
4914
4915 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004916 * Add extended data to the intent. The name must include a package
4917 * prefix, for example the app com.android.contacts would use names
4918 * like "com.android.contacts.ShowAll".
4919 *
4920 * @param name The name of the extra data, with package prefix.
4921 * @param value The boolean data value.
4922 *
4923 * @return Returns the same Intent object, for chaining multiple calls
4924 * into a single statement.
4925 *
4926 * @see #putExtras
4927 * @see #removeExtra
4928 * @see #getBooleanExtra(String, boolean)
4929 */
4930 public Intent putExtra(String name, boolean value) {
4931 if (mExtras == null) {
4932 mExtras = new Bundle();
4933 }
4934 mExtras.putBoolean(name, value);
4935 return this;
4936 }
4937
4938 /**
4939 * Add extended data to the intent. The name must include a package
4940 * prefix, for example the app com.android.contacts would use names
4941 * like "com.android.contacts.ShowAll".
4942 *
4943 * @param name The name of the extra data, with package prefix.
4944 * @param value The byte data value.
4945 *
4946 * @return Returns the same Intent object, for chaining multiple calls
4947 * into a single statement.
4948 *
4949 * @see #putExtras
4950 * @see #removeExtra
4951 * @see #getByteExtra(String, byte)
4952 */
4953 public Intent putExtra(String name, byte value) {
4954 if (mExtras == null) {
4955 mExtras = new Bundle();
4956 }
4957 mExtras.putByte(name, value);
4958 return this;
4959 }
4960
4961 /**
4962 * Add extended data to the intent. The name must include a package
4963 * prefix, for example the app com.android.contacts would use names
4964 * like "com.android.contacts.ShowAll".
4965 *
4966 * @param name The name of the extra data, with package prefix.
4967 * @param value The char data value.
4968 *
4969 * @return Returns the same Intent object, for chaining multiple calls
4970 * into a single statement.
4971 *
4972 * @see #putExtras
4973 * @see #removeExtra
4974 * @see #getCharExtra(String, char)
4975 */
4976 public Intent putExtra(String name, char value) {
4977 if (mExtras == null) {
4978 mExtras = new Bundle();
4979 }
4980 mExtras.putChar(name, value);
4981 return this;
4982 }
4983
4984 /**
4985 * Add extended data to the intent. The name must include a package
4986 * prefix, for example the app com.android.contacts would use names
4987 * like "com.android.contacts.ShowAll".
4988 *
4989 * @param name The name of the extra data, with package prefix.
4990 * @param value The short data value.
4991 *
4992 * @return Returns the same Intent object, for chaining multiple calls
4993 * into a single statement.
4994 *
4995 * @see #putExtras
4996 * @see #removeExtra
4997 * @see #getShortExtra(String, short)
4998 */
4999 public Intent putExtra(String name, short value) {
5000 if (mExtras == null) {
5001 mExtras = new Bundle();
5002 }
5003 mExtras.putShort(name, value);
5004 return this;
5005 }
5006
5007 /**
5008 * Add extended data to the intent. The name must include a package
5009 * prefix, for example the app com.android.contacts would use names
5010 * like "com.android.contacts.ShowAll".
5011 *
5012 * @param name The name of the extra data, with package prefix.
5013 * @param value The integer data value.
5014 *
5015 * @return Returns the same Intent object, for chaining multiple calls
5016 * into a single statement.
5017 *
5018 * @see #putExtras
5019 * @see #removeExtra
5020 * @see #getIntExtra(String, int)
5021 */
5022 public Intent putExtra(String name, int value) {
5023 if (mExtras == null) {
5024 mExtras = new Bundle();
5025 }
5026 mExtras.putInt(name, value);
5027 return this;
5028 }
5029
5030 /**
5031 * Add extended data to the intent. The name must include a package
5032 * prefix, for example the app com.android.contacts would use names
5033 * like "com.android.contacts.ShowAll".
5034 *
5035 * @param name The name of the extra data, with package prefix.
5036 * @param value The long data value.
5037 *
5038 * @return Returns the same Intent object, for chaining multiple calls
5039 * into a single statement.
5040 *
5041 * @see #putExtras
5042 * @see #removeExtra
5043 * @see #getLongExtra(String, long)
5044 */
5045 public Intent putExtra(String name, long value) {
5046 if (mExtras == null) {
5047 mExtras = new Bundle();
5048 }
5049 mExtras.putLong(name, value);
5050 return this;
5051 }
5052
5053 /**
5054 * Add extended data to the intent. The name must include a package
5055 * prefix, for example the app com.android.contacts would use names
5056 * like "com.android.contacts.ShowAll".
5057 *
5058 * @param name The name of the extra data, with package prefix.
5059 * @param value The float data value.
5060 *
5061 * @return Returns the same Intent object, for chaining multiple calls
5062 * into a single statement.
5063 *
5064 * @see #putExtras
5065 * @see #removeExtra
5066 * @see #getFloatExtra(String, float)
5067 */
5068 public Intent putExtra(String name, float value) {
5069 if (mExtras == null) {
5070 mExtras = new Bundle();
5071 }
5072 mExtras.putFloat(name, value);
5073 return this;
5074 }
5075
5076 /**
5077 * Add extended data to the intent. The name must include a package
5078 * prefix, for example the app com.android.contacts would use names
5079 * like "com.android.contacts.ShowAll".
5080 *
5081 * @param name The name of the extra data, with package prefix.
5082 * @param value The double data value.
5083 *
5084 * @return Returns the same Intent object, for chaining multiple calls
5085 * into a single statement.
5086 *
5087 * @see #putExtras
5088 * @see #removeExtra
5089 * @see #getDoubleExtra(String, double)
5090 */
5091 public Intent putExtra(String name, double value) {
5092 if (mExtras == null) {
5093 mExtras = new Bundle();
5094 }
5095 mExtras.putDouble(name, value);
5096 return this;
5097 }
5098
5099 /**
5100 * Add extended data to the intent. The name must include a package
5101 * prefix, for example the app com.android.contacts would use names
5102 * like "com.android.contacts.ShowAll".
5103 *
5104 * @param name The name of the extra data, with package prefix.
5105 * @param value The String data value.
5106 *
5107 * @return Returns the same Intent object, for chaining multiple calls
5108 * into a single statement.
5109 *
5110 * @see #putExtras
5111 * @see #removeExtra
5112 * @see #getStringExtra(String)
5113 */
5114 public Intent putExtra(String name, String value) {
5115 if (mExtras == null) {
5116 mExtras = new Bundle();
5117 }
5118 mExtras.putString(name, value);
5119 return this;
5120 }
5121
5122 /**
5123 * Add extended data to the intent. The name must include a package
5124 * prefix, for example the app com.android.contacts would use names
5125 * like "com.android.contacts.ShowAll".
5126 *
5127 * @param name The name of the extra data, with package prefix.
5128 * @param value The CharSequence data value.
5129 *
5130 * @return Returns the same Intent object, for chaining multiple calls
5131 * into a single statement.
5132 *
5133 * @see #putExtras
5134 * @see #removeExtra
5135 * @see #getCharSequenceExtra(String)
5136 */
5137 public Intent putExtra(String name, CharSequence value) {
5138 if (mExtras == null) {
5139 mExtras = new Bundle();
5140 }
5141 mExtras.putCharSequence(name, value);
5142 return this;
5143 }
5144
5145 /**
5146 * Add extended data to the intent. The name must include a package
5147 * prefix, for example the app com.android.contacts would use names
5148 * like "com.android.contacts.ShowAll".
5149 *
5150 * @param name The name of the extra data, with package prefix.
5151 * @param value The Parcelable data value.
5152 *
5153 * @return Returns the same Intent object, for chaining multiple calls
5154 * into a single statement.
5155 *
5156 * @see #putExtras
5157 * @see #removeExtra
5158 * @see #getParcelableExtra(String)
5159 */
5160 public Intent putExtra(String name, Parcelable value) {
5161 if (mExtras == null) {
5162 mExtras = new Bundle();
5163 }
5164 mExtras.putParcelable(name, value);
5165 return this;
5166 }
5167
5168 /**
5169 * Add extended data to the intent. The name must include a package
5170 * prefix, for example the app com.android.contacts would use names
5171 * like "com.android.contacts.ShowAll".
5172 *
5173 * @param name The name of the extra data, with package prefix.
5174 * @param value The Parcelable[] data value.
5175 *
5176 * @return Returns the same Intent object, for chaining multiple calls
5177 * into a single statement.
5178 *
5179 * @see #putExtras
5180 * @see #removeExtra
5181 * @see #getParcelableArrayExtra(String)
5182 */
5183 public Intent putExtra(String name, Parcelable[] value) {
5184 if (mExtras == null) {
5185 mExtras = new Bundle();
5186 }
5187 mExtras.putParcelableArray(name, value);
5188 return this;
5189 }
5190
5191 /**
5192 * Add extended data to the intent. The name must include a package
5193 * prefix, for example the app com.android.contacts would use names
5194 * like "com.android.contacts.ShowAll".
5195 *
5196 * @param name The name of the extra data, with package prefix.
5197 * @param value The ArrayList<Parcelable> data value.
5198 *
5199 * @return Returns the same Intent object, for chaining multiple calls
5200 * into a single statement.
5201 *
5202 * @see #putExtras
5203 * @see #removeExtra
5204 * @see #getParcelableArrayListExtra(String)
5205 */
5206 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
5207 if (mExtras == null) {
5208 mExtras = new Bundle();
5209 }
5210 mExtras.putParcelableArrayList(name, value);
5211 return this;
5212 }
5213
5214 /**
5215 * Add extended data to the intent. The name must include a package
5216 * prefix, for example the app com.android.contacts would use names
5217 * like "com.android.contacts.ShowAll".
5218 *
5219 * @param name The name of the extra data, with package prefix.
5220 * @param value The ArrayList<Integer> data value.
5221 *
5222 * @return Returns the same Intent object, for chaining multiple calls
5223 * into a single statement.
5224 *
5225 * @see #putExtras
5226 * @see #removeExtra
5227 * @see #getIntegerArrayListExtra(String)
5228 */
5229 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
5230 if (mExtras == null) {
5231 mExtras = new Bundle();
5232 }
5233 mExtras.putIntegerArrayList(name, value);
5234 return this;
5235 }
5236
5237 /**
5238 * Add extended data to the intent. The name must include a package
5239 * prefix, for example the app com.android.contacts would use names
5240 * like "com.android.contacts.ShowAll".
5241 *
5242 * @param name The name of the extra data, with package prefix.
5243 * @param value The ArrayList<String> data value.
5244 *
5245 * @return Returns the same Intent object, for chaining multiple calls
5246 * into a single statement.
5247 *
5248 * @see #putExtras
5249 * @see #removeExtra
5250 * @see #getStringArrayListExtra(String)
5251 */
5252 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
5253 if (mExtras == null) {
5254 mExtras = new Bundle();
5255 }
5256 mExtras.putStringArrayList(name, value);
5257 return this;
5258 }
5259
5260 /**
5261 * Add extended data to the intent. The name must include a package
5262 * prefix, for example the app com.android.contacts would use names
5263 * like "com.android.contacts.ShowAll".
5264 *
5265 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005266 * @param value The ArrayList<CharSequence> data value.
5267 *
5268 * @return Returns the same Intent object, for chaining multiple calls
5269 * into a single statement.
5270 *
5271 * @see #putExtras
5272 * @see #removeExtra
5273 * @see #getCharSequenceArrayListExtra(String)
5274 */
5275 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
5276 if (mExtras == null) {
5277 mExtras = new Bundle();
5278 }
5279 mExtras.putCharSequenceArrayList(name, value);
5280 return this;
5281 }
5282
5283 /**
5284 * Add extended data to the intent. The name must include a package
5285 * prefix, for example the app com.android.contacts would use names
5286 * like "com.android.contacts.ShowAll".
5287 *
5288 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005289 * @param value The Serializable data value.
5290 *
5291 * @return Returns the same Intent object, for chaining multiple calls
5292 * into a single statement.
5293 *
5294 * @see #putExtras
5295 * @see #removeExtra
5296 * @see #getSerializableExtra(String)
5297 */
5298 public Intent putExtra(String name, Serializable value) {
5299 if (mExtras == null) {
5300 mExtras = new Bundle();
5301 }
5302 mExtras.putSerializable(name, value);
5303 return this;
5304 }
5305
5306 /**
5307 * Add extended data to the intent. The name must include a package
5308 * prefix, for example the app com.android.contacts would use names
5309 * like "com.android.contacts.ShowAll".
5310 *
5311 * @param name The name of the extra data, with package prefix.
5312 * @param value The boolean array data value.
5313 *
5314 * @return Returns the same Intent object, for chaining multiple calls
5315 * into a single statement.
5316 *
5317 * @see #putExtras
5318 * @see #removeExtra
5319 * @see #getBooleanArrayExtra(String)
5320 */
5321 public Intent putExtra(String name, boolean[] value) {
5322 if (mExtras == null) {
5323 mExtras = new Bundle();
5324 }
5325 mExtras.putBooleanArray(name, value);
5326 return this;
5327 }
5328
5329 /**
5330 * Add extended data to the intent. The name must include a package
5331 * prefix, for example the app com.android.contacts would use names
5332 * like "com.android.contacts.ShowAll".
5333 *
5334 * @param name The name of the extra data, with package prefix.
5335 * @param value The byte array data value.
5336 *
5337 * @return Returns the same Intent object, for chaining multiple calls
5338 * into a single statement.
5339 *
5340 * @see #putExtras
5341 * @see #removeExtra
5342 * @see #getByteArrayExtra(String)
5343 */
5344 public Intent putExtra(String name, byte[] value) {
5345 if (mExtras == null) {
5346 mExtras = new Bundle();
5347 }
5348 mExtras.putByteArray(name, value);
5349 return this;
5350 }
5351
5352 /**
5353 * Add extended data to the intent. The name must include a package
5354 * prefix, for example the app com.android.contacts would use names
5355 * like "com.android.contacts.ShowAll".
5356 *
5357 * @param name The name of the extra data, with package prefix.
5358 * @param value The short array data value.
5359 *
5360 * @return Returns the same Intent object, for chaining multiple calls
5361 * into a single statement.
5362 *
5363 * @see #putExtras
5364 * @see #removeExtra
5365 * @see #getShortArrayExtra(String)
5366 */
5367 public Intent putExtra(String name, short[] value) {
5368 if (mExtras == null) {
5369 mExtras = new Bundle();
5370 }
5371 mExtras.putShortArray(name, value);
5372 return this;
5373 }
5374
5375 /**
5376 * Add extended data to the intent. The name must include a package
5377 * prefix, for example the app com.android.contacts would use names
5378 * like "com.android.contacts.ShowAll".
5379 *
5380 * @param name The name of the extra data, with package prefix.
5381 * @param value The char array data value.
5382 *
5383 * @return Returns the same Intent object, for chaining multiple calls
5384 * into a single statement.
5385 *
5386 * @see #putExtras
5387 * @see #removeExtra
5388 * @see #getCharArrayExtra(String)
5389 */
5390 public Intent putExtra(String name, char[] value) {
5391 if (mExtras == null) {
5392 mExtras = new Bundle();
5393 }
5394 mExtras.putCharArray(name, value);
5395 return this;
5396 }
5397
5398 /**
5399 * Add extended data to the intent. The name must include a package
5400 * prefix, for example the app com.android.contacts would use names
5401 * like "com.android.contacts.ShowAll".
5402 *
5403 * @param name The name of the extra data, with package prefix.
5404 * @param value The int array data value.
5405 *
5406 * @return Returns the same Intent object, for chaining multiple calls
5407 * into a single statement.
5408 *
5409 * @see #putExtras
5410 * @see #removeExtra
5411 * @see #getIntArrayExtra(String)
5412 */
5413 public Intent putExtra(String name, int[] value) {
5414 if (mExtras == null) {
5415 mExtras = new Bundle();
5416 }
5417 mExtras.putIntArray(name, value);
5418 return this;
5419 }
5420
5421 /**
5422 * Add extended data to the intent. The name must include a package
5423 * prefix, for example the app com.android.contacts would use names
5424 * like "com.android.contacts.ShowAll".
5425 *
5426 * @param name The name of the extra data, with package prefix.
5427 * @param value The byte array data value.
5428 *
5429 * @return Returns the same Intent object, for chaining multiple calls
5430 * into a single statement.
5431 *
5432 * @see #putExtras
5433 * @see #removeExtra
5434 * @see #getLongArrayExtra(String)
5435 */
5436 public Intent putExtra(String name, long[] value) {
5437 if (mExtras == null) {
5438 mExtras = new Bundle();
5439 }
5440 mExtras.putLongArray(name, value);
5441 return this;
5442 }
5443
5444 /**
5445 * Add extended data to the intent. The name must include a package
5446 * prefix, for example the app com.android.contacts would use names
5447 * like "com.android.contacts.ShowAll".
5448 *
5449 * @param name The name of the extra data, with package prefix.
5450 * @param value The float array data value.
5451 *
5452 * @return Returns the same Intent object, for chaining multiple calls
5453 * into a single statement.
5454 *
5455 * @see #putExtras
5456 * @see #removeExtra
5457 * @see #getFloatArrayExtra(String)
5458 */
5459 public Intent putExtra(String name, float[] value) {
5460 if (mExtras == null) {
5461 mExtras = new Bundle();
5462 }
5463 mExtras.putFloatArray(name, value);
5464 return this;
5465 }
5466
5467 /**
5468 * Add extended data to the intent. The name must include a package
5469 * prefix, for example the app com.android.contacts would use names
5470 * like "com.android.contacts.ShowAll".
5471 *
5472 * @param name The name of the extra data, with package prefix.
5473 * @param value The double array data value.
5474 *
5475 * @return Returns the same Intent object, for chaining multiple calls
5476 * into a single statement.
5477 *
5478 * @see #putExtras
5479 * @see #removeExtra
5480 * @see #getDoubleArrayExtra(String)
5481 */
5482 public Intent putExtra(String name, double[] value) {
5483 if (mExtras == null) {
5484 mExtras = new Bundle();
5485 }
5486 mExtras.putDoubleArray(name, value);
5487 return this;
5488 }
5489
5490 /**
5491 * Add extended data to the intent. The name must include a package
5492 * prefix, for example the app com.android.contacts would use names
5493 * like "com.android.contacts.ShowAll".
5494 *
5495 * @param name The name of the extra data, with package prefix.
5496 * @param value The String array data value.
5497 *
5498 * @return Returns the same Intent object, for chaining multiple calls
5499 * into a single statement.
5500 *
5501 * @see #putExtras
5502 * @see #removeExtra
5503 * @see #getStringArrayExtra(String)
5504 */
5505 public Intent putExtra(String name, String[] value) {
5506 if (mExtras == null) {
5507 mExtras = new Bundle();
5508 }
5509 mExtras.putStringArray(name, value);
5510 return this;
5511 }
5512
5513 /**
5514 * Add extended data to the intent. The name must include a package
5515 * prefix, for example the app com.android.contacts would use names
5516 * like "com.android.contacts.ShowAll".
5517 *
5518 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005519 * @param value The CharSequence array data value.
5520 *
5521 * @return Returns the same Intent object, for chaining multiple calls
5522 * into a single statement.
5523 *
5524 * @see #putExtras
5525 * @see #removeExtra
5526 * @see #getCharSequenceArrayExtra(String)
5527 */
5528 public Intent putExtra(String name, CharSequence[] value) {
5529 if (mExtras == null) {
5530 mExtras = new Bundle();
5531 }
5532 mExtras.putCharSequenceArray(name, value);
5533 return this;
5534 }
5535
5536 /**
5537 * Add extended data to the intent. The name must include a package
5538 * prefix, for example the app com.android.contacts would use names
5539 * like "com.android.contacts.ShowAll".
5540 *
5541 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005542 * @param value The Bundle data value.
5543 *
5544 * @return Returns the same Intent object, for chaining multiple calls
5545 * into a single statement.
5546 *
5547 * @see #putExtras
5548 * @see #removeExtra
5549 * @see #getBundleExtra(String)
5550 */
5551 public Intent putExtra(String name, Bundle value) {
5552 if (mExtras == null) {
5553 mExtras = new Bundle();
5554 }
5555 mExtras.putBundle(name, value);
5556 return this;
5557 }
5558
5559 /**
5560 * Add extended data to the intent. The name must include a package
5561 * prefix, for example the app com.android.contacts would use names
5562 * like "com.android.contacts.ShowAll".
5563 *
5564 * @param name The name of the extra data, with package prefix.
5565 * @param value The IBinder data value.
5566 *
5567 * @return Returns the same Intent object, for chaining multiple calls
5568 * into a single statement.
5569 *
5570 * @see #putExtras
5571 * @see #removeExtra
5572 * @see #getIBinderExtra(String)
5573 *
5574 * @deprecated
5575 * @hide
5576 */
5577 @Deprecated
5578 public Intent putExtra(String name, IBinder value) {
5579 if (mExtras == null) {
5580 mExtras = new Bundle();
5581 }
5582 mExtras.putIBinder(name, value);
5583 return this;
5584 }
5585
5586 /**
5587 * Copy all extras in 'src' in to this intent.
5588 *
5589 * @param src Contains the extras to copy.
5590 *
5591 * @see #putExtra
5592 */
5593 public Intent putExtras(Intent src) {
5594 if (src.mExtras != null) {
5595 if (mExtras == null) {
5596 mExtras = new Bundle(src.mExtras);
5597 } else {
5598 mExtras.putAll(src.mExtras);
5599 }
5600 }
5601 return this;
5602 }
5603
5604 /**
5605 * Add a set of extended data to the intent. The keys must include a package
5606 * prefix, for example the app com.android.contacts would use names
5607 * like "com.android.contacts.ShowAll".
5608 *
5609 * @param extras The Bundle of extras to add to this intent.
5610 *
5611 * @see #putExtra
5612 * @see #removeExtra
5613 */
5614 public Intent putExtras(Bundle extras) {
5615 if (mExtras == null) {
5616 mExtras = new Bundle();
5617 }
5618 mExtras.putAll(extras);
5619 return this;
5620 }
5621
5622 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005623 * Completely replace the extras in the Intent with the extras in the
5624 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07005625 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005626 * @param src The exact extras contained in this Intent are copied
5627 * into the target intent, replacing any that were previously there.
5628 */
5629 public Intent replaceExtras(Intent src) {
5630 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
5631 return this;
5632 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005633
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005634 /**
5635 * Completely replace the extras in the Intent with the given Bundle of
5636 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07005637 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005638 * @param extras The new set of extras in the Intent, or null to erase
5639 * all extras.
5640 */
5641 public Intent replaceExtras(Bundle extras) {
5642 mExtras = extras != null ? new Bundle(extras) : null;
5643 return this;
5644 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005645
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005646 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005647 * Remove extended data from the intent.
5648 *
5649 * @see #putExtra
5650 */
5651 public void removeExtra(String name) {
5652 if (mExtras != null) {
5653 mExtras.remove(name);
5654 if (mExtras.size() == 0) {
5655 mExtras = null;
5656 }
5657 }
5658 }
5659
5660 /**
5661 * Set special flags controlling how this intent is handled. Most values
5662 * here depend on the type of component being executed by the Intent,
5663 * specifically the FLAG_ACTIVITY_* flags are all for use with
5664 * {@link Context#startActivity Context.startActivity()} and the
5665 * FLAG_RECEIVER_* flags are all for use with
5666 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
5667 *
Scott Main7aee61f2011-02-08 11:25:01 -08005668 * <p>See the
5669 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5670 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005671 * the behavior of your application.
5672 *
5673 * @param flags The desired flags.
5674 *
5675 * @return Returns the same Intent object, for chaining multiple calls
5676 * into a single statement.
5677 *
5678 * @see #getFlags
5679 * @see #addFlags
5680 *
5681 * @see #FLAG_GRANT_READ_URI_PERMISSION
5682 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
5683 * @see #FLAG_DEBUG_LOG_RESOLUTION
5684 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005685 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005686 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005687 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005688 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005689 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
5690 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005691 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005692 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5693 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005694 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005695 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005696 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005697 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
5698 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005699 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005700 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005701 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005702 * @see #FLAG_RECEIVER_REGISTERED_ONLY
5703 */
5704 public Intent setFlags(int flags) {
5705 mFlags = flags;
5706 return this;
5707 }
5708
5709 /**
5710 * Add additional flags to the intent (or with existing flags
5711 * value).
5712 *
5713 * @param flags The new flags to set.
5714 *
5715 * @return Returns the same Intent object, for chaining multiple calls
5716 * into a single statement.
5717 *
5718 * @see #setFlags
5719 */
5720 public Intent addFlags(int flags) {
5721 mFlags |= flags;
5722 return this;
5723 }
5724
5725 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005726 * (Usually optional) Set an explicit application package name that limits
5727 * the components this Intent will resolve to. If left to the default
5728 * value of null, all components in all applications will considered.
5729 * If non-null, the Intent can only match the components in the given
5730 * application package.
5731 *
5732 * @param packageName The name of the application package to handle the
5733 * intent, or null to allow any application package.
5734 *
5735 * @return Returns the same Intent object, for chaining multiple calls
5736 * into a single statement.
5737 *
5738 * @see #getPackage
5739 * @see #resolveActivity
5740 */
5741 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005742 if (packageName != null && mSelector != null) {
5743 throw new IllegalArgumentException(
5744 "Can't set package name when selector is already set");
5745 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005746 mPackage = packageName;
5747 return this;
5748 }
5749
5750 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005751 * (Usually optional) Explicitly set the component to handle the intent.
5752 * If left with the default value of null, the system will determine the
5753 * appropriate class to use based on the other fields (action, data,
5754 * type, categories) in the Intent. If this class is defined, the
5755 * specified class will always be used regardless of the other fields. You
5756 * should only set this value when you know you absolutely want a specific
5757 * class to be used; otherwise it is better to let the system find the
5758 * appropriate class so that you will respect the installed applications
5759 * and user preferences.
5760 *
5761 * @param component The name of the application component to handle the
5762 * intent, or null to let the system find one for you.
5763 *
5764 * @return Returns the same Intent object, for chaining multiple calls
5765 * into a single statement.
5766 *
5767 * @see #setClass
5768 * @see #setClassName(Context, String)
5769 * @see #setClassName(String, String)
5770 * @see #getComponent
5771 * @see #resolveActivity
5772 */
5773 public Intent setComponent(ComponentName component) {
5774 mComponent = component;
5775 return this;
5776 }
5777
5778 /**
5779 * Convenience for calling {@link #setComponent} with an
5780 * explicit class name.
5781 *
5782 * @param packageContext A Context of the application package implementing
5783 * this class.
5784 * @param className The name of a class inside of the application package
5785 * that will be used as the component for this Intent.
5786 *
5787 * @return Returns the same Intent object, for chaining multiple calls
5788 * into a single statement.
5789 *
5790 * @see #setComponent
5791 * @see #setClass
5792 */
5793 public Intent setClassName(Context packageContext, String className) {
5794 mComponent = new ComponentName(packageContext, className);
5795 return this;
5796 }
5797
5798 /**
5799 * Convenience for calling {@link #setComponent} with an
5800 * explicit application package name and class name.
5801 *
5802 * @param packageName The name of the package implementing the desired
5803 * component.
5804 * @param className The name of a class inside of the application package
5805 * that will be used as the component for this Intent.
5806 *
5807 * @return Returns the same Intent object, for chaining multiple calls
5808 * into a single statement.
5809 *
5810 * @see #setComponent
5811 * @see #setClass
5812 */
5813 public Intent setClassName(String packageName, String className) {
5814 mComponent = new ComponentName(packageName, className);
5815 return this;
5816 }
5817
5818 /**
5819 * Convenience for calling {@link #setComponent(ComponentName)} with the
5820 * name returned by a {@link Class} object.
5821 *
5822 * @param packageContext A Context of the application package implementing
5823 * this class.
5824 * @param cls The class name to set, equivalent to
5825 * <code>setClassName(context, cls.getName())</code>.
5826 *
5827 * @return Returns the same Intent object, for chaining multiple calls
5828 * into a single statement.
5829 *
5830 * @see #setComponent
5831 */
5832 public Intent setClass(Context packageContext, Class<?> cls) {
5833 mComponent = new ComponentName(packageContext, cls);
5834 return this;
5835 }
5836
5837 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005838 * Set the bounds of the sender of this intent, in screen coordinates. This can be
5839 * used as a hint to the receiver for animations and the like. Null means that there
5840 * is no source bounds.
5841 */
5842 public void setSourceBounds(Rect r) {
5843 if (r != null) {
5844 mSourceBounds = new Rect(r);
5845 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005846 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005847 }
5848 }
5849
5850 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005851 * Use with {@link #fillIn} to allow the current action value to be
5852 * overwritten, even if it is already set.
5853 */
5854 public static final int FILL_IN_ACTION = 1<<0;
5855
5856 /**
5857 * Use with {@link #fillIn} to allow the current data or type value
5858 * overwritten, even if it is already set.
5859 */
5860 public static final int FILL_IN_DATA = 1<<1;
5861
5862 /**
5863 * Use with {@link #fillIn} to allow the current categories to be
5864 * overwritten, even if they are already set.
5865 */
5866 public static final int FILL_IN_CATEGORIES = 1<<2;
5867
5868 /**
5869 * Use with {@link #fillIn} to allow the current component value to be
5870 * overwritten, even if it is already set.
5871 */
5872 public static final int FILL_IN_COMPONENT = 1<<3;
5873
5874 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005875 * Use with {@link #fillIn} to allow the current package value to be
5876 * overwritten, even if it is already set.
5877 */
5878 public static final int FILL_IN_PACKAGE = 1<<4;
5879
5880 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005881 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005882 * overwritten, even if it is already set.
5883 */
5884 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
5885
5886 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005887 * Use with {@link #fillIn} to allow the current selector to be
5888 * overwritten, even if it is already set.
5889 */
5890 public static final int FILL_IN_SELECTOR = 1<<6;
5891
5892 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005893 * Use with {@link #fillIn} to allow the current ClipData to be
5894 * overwritten, even if it is already set.
5895 */
5896 public static final int FILL_IN_CLIP_DATA = 1<<7;
5897
5898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899 * Copy the contents of <var>other</var> in to this object, but only
5900 * where fields are not defined by this object. For purposes of a field
5901 * being defined, the following pieces of data in the Intent are
5902 * considered to be separate fields:
5903 *
5904 * <ul>
5905 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08005906 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005907 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
5908 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005909 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005910 * <li> component, as set by {@link #setComponent(ComponentName)} or
5911 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005912 * <li> source bounds, as set by {@link #setSourceBounds}.
5913 * <li> selector, as set by {@link #setSelector(Intent)}.
5914 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005915 * <li> each top-level name in the associated extras.
5916 * </ul>
5917 *
5918 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005919 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005920 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
5921 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
5922 * the restriction where the corresponding field will not be replaced if
5923 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005924 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005925 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
5926 * is explicitly specified. The selector will only be copied if
5927 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07005928 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005929 * <p>For example, consider Intent A with {data="foo", categories="bar"}
5930 * and Intent B with {action="gotit", data-type="some/thing",
5931 * categories="one","two"}.
5932 *
5933 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
5934 * containing: {action="gotit", data-type="some/thing",
5935 * categories="bar"}.
5936 *
5937 * @param other Another Intent whose values are to be used to fill in
5938 * the current one.
5939 * @param flags Options to control which fields can be filled in.
5940 *
5941 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005942 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005943 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, and
5944 * {@link #FILL_IN_SELECTOR} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005945 */
5946 public int fillIn(Intent other, int flags) {
5947 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005948 if (other.mAction != null
5949 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005950 mAction = other.mAction;
5951 changes |= FILL_IN_ACTION;
5952 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005953 if ((other.mData != null || other.mType != null)
5954 && ((mData == null && mType == null)
5955 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005956 mData = other.mData;
5957 mType = other.mType;
5958 changes |= FILL_IN_DATA;
5959 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005960 if (other.mCategories != null
5961 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005962 if (other.mCategories != null) {
5963 mCategories = new HashSet<String>(other.mCategories);
5964 }
5965 changes |= FILL_IN_CATEGORIES;
5966 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005967 if (other.mPackage != null
5968 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005969 // Only do this if mSelector is not set.
5970 if (mSelector == null) {
5971 mPackage = other.mPackage;
5972 changes |= FILL_IN_PACKAGE;
5973 }
5974 }
5975 // Selector is special: it can only be set if explicitly allowed,
5976 // for the same reason as the component name.
5977 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
5978 if (mPackage == null) {
5979 mSelector = new Intent(other.mSelector);
5980 mPackage = null;
5981 changes |= FILL_IN_SELECTOR;
5982 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005983 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005984 if (other.mClipData != null
5985 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
5986 mClipData = other.mClipData;
5987 changes |= FILL_IN_CLIP_DATA;
5988 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005989 // Component is special: it can -only- be set if explicitly allowed,
5990 // since otherwise the sender could force the intent somewhere the
5991 // originator didn't intend.
5992 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005993 mComponent = other.mComponent;
5994 changes |= FILL_IN_COMPONENT;
5995 }
5996 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005997 if (other.mSourceBounds != null
5998 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
5999 mSourceBounds = new Rect(other.mSourceBounds);
6000 changes |= FILL_IN_SOURCE_BOUNDS;
6001 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006002 if (mExtras == null) {
6003 if (other.mExtras != null) {
6004 mExtras = new Bundle(other.mExtras);
6005 }
6006 } else if (other.mExtras != null) {
6007 try {
6008 Bundle newb = new Bundle(other.mExtras);
6009 newb.putAll(mExtras);
6010 mExtras = newb;
6011 } catch (RuntimeException e) {
6012 // Modifying the extras can cause us to unparcel the contents
6013 // of the bundle, and if we do this in the system process that
6014 // may fail. We really should handle this (i.e., the Bundle
6015 // impl shouldn't be on top of a plain map), but for now just
6016 // ignore it and keep the original contents. :(
6017 Log.w("Intent", "Failure filling in extras", e);
6018 }
6019 }
6020 return changes;
6021 }
6022
6023 /**
6024 * Wrapper class holding an Intent and implementing comparisons on it for
6025 * the purpose of filtering. The class implements its
6026 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
6027 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
6028 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
6029 * on the wrapped Intent.
6030 */
6031 public static final class FilterComparison {
6032 private final Intent mIntent;
6033 private final int mHashCode;
6034
6035 public FilterComparison(Intent intent) {
6036 mIntent = intent;
6037 mHashCode = intent.filterHashCode();
6038 }
6039
6040 /**
6041 * Return the Intent that this FilterComparison represents.
6042 * @return Returns the Intent held by the FilterComparison. Do
6043 * not modify!
6044 */
6045 public Intent getIntent() {
6046 return mIntent;
6047 }
6048
6049 @Override
6050 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006051 if (obj instanceof FilterComparison) {
6052 Intent other = ((FilterComparison)obj).mIntent;
6053 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006054 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006055 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006056 }
6057
6058 @Override
6059 public int hashCode() {
6060 return mHashCode;
6061 }
6062 }
6063
6064 /**
6065 * Determine if two intents are the same for the purposes of intent
6066 * resolution (filtering). That is, if their action, data, type,
6067 * class, and categories are the same. This does <em>not</em> compare
6068 * any extra data included in the intents.
6069 *
6070 * @param other The other Intent to compare against.
6071 *
6072 * @return Returns true if action, data, type, class, and categories
6073 * are the same.
6074 */
6075 public boolean filterEquals(Intent other) {
6076 if (other == null) {
6077 return false;
6078 }
6079 if (mAction != other.mAction) {
6080 if (mAction != null) {
6081 if (!mAction.equals(other.mAction)) {
6082 return false;
6083 }
6084 } else {
6085 if (!other.mAction.equals(mAction)) {
6086 return false;
6087 }
6088 }
6089 }
6090 if (mData != other.mData) {
6091 if (mData != null) {
6092 if (!mData.equals(other.mData)) {
6093 return false;
6094 }
6095 } else {
6096 if (!other.mData.equals(mData)) {
6097 return false;
6098 }
6099 }
6100 }
6101 if (mType != other.mType) {
6102 if (mType != null) {
6103 if (!mType.equals(other.mType)) {
6104 return false;
6105 }
6106 } else {
6107 if (!other.mType.equals(mType)) {
6108 return false;
6109 }
6110 }
6111 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006112 if (mPackage != other.mPackage) {
6113 if (mPackage != null) {
6114 if (!mPackage.equals(other.mPackage)) {
6115 return false;
6116 }
6117 } else {
6118 if (!other.mPackage.equals(mPackage)) {
6119 return false;
6120 }
6121 }
6122 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006123 if (mComponent != other.mComponent) {
6124 if (mComponent != null) {
6125 if (!mComponent.equals(other.mComponent)) {
6126 return false;
6127 }
6128 } else {
6129 if (!other.mComponent.equals(mComponent)) {
6130 return false;
6131 }
6132 }
6133 }
6134 if (mCategories != other.mCategories) {
6135 if (mCategories != null) {
6136 if (!mCategories.equals(other.mCategories)) {
6137 return false;
6138 }
6139 } else {
6140 if (!other.mCategories.equals(mCategories)) {
6141 return false;
6142 }
6143 }
6144 }
6145
6146 return true;
6147 }
6148
6149 /**
6150 * Generate hash code that matches semantics of filterEquals().
6151 *
6152 * @return Returns the hash value of the action, data, type, class, and
6153 * categories.
6154 *
6155 * @see #filterEquals
6156 */
6157 public int filterHashCode() {
6158 int code = 0;
6159 if (mAction != null) {
6160 code += mAction.hashCode();
6161 }
6162 if (mData != null) {
6163 code += mData.hashCode();
6164 }
6165 if (mType != null) {
6166 code += mType.hashCode();
6167 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006168 if (mPackage != null) {
6169 code += mPackage.hashCode();
6170 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006171 if (mComponent != null) {
6172 code += mComponent.hashCode();
6173 }
6174 if (mCategories != null) {
6175 code += mCategories.hashCode();
6176 }
6177 return code;
6178 }
6179
6180 @Override
6181 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006182 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006183
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006184 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006185 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006186 b.append(" }");
6187
6188 return b.toString();
6189 }
6190
6191 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006192 public String toInsecureString() {
6193 StringBuilder b = new StringBuilder(128);
6194
6195 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006196 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006197 b.append(" }");
6198
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006199 return b.toString();
6200 }
Romain Guy4969af72009-06-17 10:53:19 -07006201
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006202 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006203 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006204 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006205
6206 b.append("Intent { ");
6207 toShortString(b, false, true, true, true);
6208 b.append(" }");
6209
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006210 return b.toString();
6211 }
6212
6213 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006214 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
6215 StringBuilder b = new StringBuilder(128);
6216 toShortString(b, secure, comp, extras, clip);
6217 return b.toString();
6218 }
6219
6220 /** @hide */
6221 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
6222 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006223 boolean first = true;
6224 if (mAction != null) {
6225 b.append("act=").append(mAction);
6226 first = false;
6227 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006228 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006229 if (!first) {
6230 b.append(' ');
6231 }
6232 first = false;
6233 b.append("cat=[");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006234 Iterator<String> i = mCategories.iterator();
6235 boolean didone = false;
6236 while (i.hasNext()) {
6237 if (didone) b.append(",");
6238 didone = true;
6239 b.append(i.next());
6240 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006241 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006242 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006243 if (mData != null) {
6244 if (!first) {
6245 b.append(' ');
6246 }
6247 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07006248 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006249 if (secure) {
6250 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07006251 } else {
6252 b.append(mData);
6253 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006254 }
6255 if (mType != null) {
6256 if (!first) {
6257 b.append(' ');
6258 }
6259 first = false;
6260 b.append("typ=").append(mType);
6261 }
6262 if (mFlags != 0) {
6263 if (!first) {
6264 b.append(' ');
6265 }
6266 first = false;
6267 b.append("flg=0x").append(Integer.toHexString(mFlags));
6268 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006269 if (mPackage != null) {
6270 if (!first) {
6271 b.append(' ');
6272 }
6273 first = false;
6274 b.append("pkg=").append(mPackage);
6275 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006276 if (comp && mComponent != null) {
6277 if (!first) {
6278 b.append(' ');
6279 }
6280 first = false;
6281 b.append("cmp=").append(mComponent.flattenToShortString());
6282 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006283 if (mSourceBounds != null) {
6284 if (!first) {
6285 b.append(' ');
6286 }
6287 first = false;
6288 b.append("bnds=").append(mSourceBounds.toShortString());
6289 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006290 if (mClipData != null) {
6291 if (!first) {
6292 b.append(' ');
6293 }
6294 first = false;
6295 if (clip) {
6296 b.append("clip={");
6297 mClipData.toShortString(b);
6298 b.append('}');
6299 } else {
6300 b.append("(has clip)");
6301 }
6302 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006303 if (extras && mExtras != null) {
6304 if (!first) {
6305 b.append(' ');
6306 }
6307 first = false;
6308 b.append("(has extras)");
6309 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006310 if (mSelector != null) {
6311 b.append(" sel={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006312 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006313 b.append("}");
6314 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006315 }
6316
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006317 /**
6318 * Call {@link #toUri} with 0 flags.
6319 * @deprecated Use {@link #toUri} instead.
6320 */
6321 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006322 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006323 return toUri(0);
6324 }
6325
6326 /**
6327 * Convert this Intent into a String holding a URI representation of it.
6328 * The returned URI string has been properly URI encoded, so it can be
6329 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
6330 * Intent's data as the base URI, with an additional fragment describing
6331 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08006332 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006333 * <p>You can convert the returned string back to an Intent with
6334 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08006335 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006336 * @param flags Additional operating flags. Either 0 or
6337 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08006338 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006339 * @return Returns a URI encoding URI string describing the entire contents
6340 * of the Intent.
6341 */
6342 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006343 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006344 String scheme = null;
6345 if (mData != null) {
6346 String data = mData.toString();
6347 if ((flags&URI_INTENT_SCHEME) != 0) {
6348 final int N = data.length();
6349 for (int i=0; i<N; i++) {
6350 char c = data.charAt(i);
6351 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
6352 || c == '.' || c == '-') {
6353 continue;
6354 }
6355 if (c == ':' && i > 0) {
6356 // Valid scheme.
6357 scheme = data.substring(0, i);
6358 uri.append("intent:");
6359 data = data.substring(i+1);
6360 break;
6361 }
Tom Taylord4a47292009-12-21 13:59:18 -08006362
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006363 // No scheme.
6364 break;
6365 }
6366 }
6367 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08006368
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006369 } else if ((flags&URI_INTENT_SCHEME) != 0) {
6370 uri.append("intent:");
6371 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006372
6373 uri.append("#Intent;");
6374
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006375 toUriInner(uri, scheme, flags);
6376 if (mSelector != null) {
6377 uri.append("SEL;");
6378 // Note that for now we are not going to try to handle the
6379 // data part; not clear how to represent this as a URI, and
6380 // not much utility in it.
6381 mSelector.toUriInner(uri, null, flags);
6382 }
6383
6384 uri.append("end");
6385
6386 return uri.toString();
6387 }
6388
6389 private void toUriInner(StringBuilder uri, String scheme, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006390 if (scheme != null) {
6391 uri.append("scheme=").append(scheme).append(';');
6392 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006393 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006394 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006395 }
6396 if (mCategories != null) {
6397 for (String category : mCategories) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006398 uri.append("category=").append(Uri.encode(category)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006399 }
6400 }
6401 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006402 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006403 }
6404 if (mFlags != 0) {
6405 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
6406 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006407 if (mPackage != null) {
6408 uri.append("package=").append(Uri.encode(mPackage)).append(';');
6409 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006410 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006411 uri.append("component=").append(Uri.encode(
6412 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006413 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006414 if (mSourceBounds != null) {
6415 uri.append("sourceBounds=")
6416 .append(Uri.encode(mSourceBounds.flattenToString()))
6417 .append(';');
6418 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006419 if (mExtras != null) {
6420 for (String key : mExtras.keySet()) {
6421 final Object value = mExtras.get(key);
6422 char entryType =
6423 value instanceof String ? 'S' :
6424 value instanceof Boolean ? 'B' :
6425 value instanceof Byte ? 'b' :
6426 value instanceof Character ? 'c' :
6427 value instanceof Double ? 'd' :
6428 value instanceof Float ? 'f' :
6429 value instanceof Integer ? 'i' :
6430 value instanceof Long ? 'l' :
6431 value instanceof Short ? 's' :
6432 '\0';
6433
6434 if (entryType != '\0') {
6435 uri.append(entryType);
6436 uri.append('.');
6437 uri.append(Uri.encode(key));
6438 uri.append('=');
6439 uri.append(Uri.encode(value.toString()));
6440 uri.append(';');
6441 }
6442 }
6443 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006444 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006445
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006446 public int describeContents() {
6447 return (mExtras != null) ? mExtras.describeContents() : 0;
6448 }
6449
6450 public void writeToParcel(Parcel out, int flags) {
6451 out.writeString(mAction);
6452 Uri.writeToParcel(out, mData);
6453 out.writeString(mType);
6454 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006455 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006456 ComponentName.writeToParcel(mComponent, out);
6457
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006458 if (mSourceBounds != null) {
6459 out.writeInt(1);
6460 mSourceBounds.writeToParcel(out, flags);
6461 } else {
6462 out.writeInt(0);
6463 }
6464
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006465 if (mCategories != null) {
6466 out.writeInt(mCategories.size());
6467 for (String category : mCategories) {
6468 out.writeString(category);
6469 }
6470 } else {
6471 out.writeInt(0);
6472 }
6473
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006474 if (mSelector != null) {
6475 out.writeInt(1);
6476 mSelector.writeToParcel(out, flags);
6477 } else {
6478 out.writeInt(0);
6479 }
6480
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006481 if (mClipData != null) {
6482 out.writeInt(1);
6483 mClipData.writeToParcel(out, flags);
6484 } else {
6485 out.writeInt(0);
6486 }
6487
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006488 out.writeBundle(mExtras);
6489 }
6490
6491 public static final Parcelable.Creator<Intent> CREATOR
6492 = new Parcelable.Creator<Intent>() {
6493 public Intent createFromParcel(Parcel in) {
6494 return new Intent(in);
6495 }
6496 public Intent[] newArray(int size) {
6497 return new Intent[size];
6498 }
6499 };
6500
Dianne Hackborneb034652009-09-07 00:49:58 -07006501 /** @hide */
6502 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006503 readFromParcel(in);
6504 }
6505
6506 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006507 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006508 mData = Uri.CREATOR.createFromParcel(in);
6509 mType = in.readString();
6510 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006511 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006512 mComponent = ComponentName.readFromParcel(in);
6513
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006514 if (in.readInt() != 0) {
6515 mSourceBounds = Rect.CREATOR.createFromParcel(in);
6516 }
6517
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006518 int N = in.readInt();
6519 if (N > 0) {
6520 mCategories = new HashSet<String>();
6521 int i;
6522 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006523 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006524 }
6525 } else {
6526 mCategories = null;
6527 }
6528
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006529 if (in.readInt() != 0) {
6530 mSelector = new Intent(in);
6531 }
6532
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006533 if (in.readInt() != 0) {
6534 mClipData = new ClipData(in);
6535 }
6536
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006537 mExtras = in.readBundle();
6538 }
6539
6540 /**
6541 * Parses the "intent" element (and its children) from XML and instantiates
6542 * an Intent object. The given XML parser should be located at the tag
6543 * where parsing should start (often named "intent"), from which the
6544 * basic action, data, type, and package and class name will be
6545 * retrieved. The function will then parse in to any child elements,
6546 * looking for <category android:name="xxx"> tags to add categories and
6547 * <extra android:name="xxx" android:value="yyy"> to attach extra data
6548 * to the intent.
6549 *
6550 * @param resources The Resources to use when inflating resources.
6551 * @param parser The XML parser pointing at an "intent" tag.
6552 * @param attrs The AttributeSet interface for retrieving extended
6553 * attribute data at the current <var>parser</var> location.
6554 * @return An Intent object matching the XML data.
6555 * @throws XmlPullParserException If there was an XML parsing error.
6556 * @throws IOException If there was an I/O error.
6557 */
6558 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
6559 throws XmlPullParserException, IOException {
6560 Intent intent = new Intent();
6561
6562 TypedArray sa = resources.obtainAttributes(attrs,
6563 com.android.internal.R.styleable.Intent);
6564
6565 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
6566
6567 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
6568 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
6569 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
6570
6571 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
6572 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
6573 if (packageName != null && className != null) {
6574 intent.setComponent(new ComponentName(packageName, className));
6575 }
6576
6577 sa.recycle();
6578
6579 int outerDepth = parser.getDepth();
6580 int type;
6581 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
6582 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
6583 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
6584 continue;
6585 }
6586
6587 String nodeName = parser.getName();
6588 if (nodeName.equals("category")) {
6589 sa = resources.obtainAttributes(attrs,
6590 com.android.internal.R.styleable.IntentCategory);
6591 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
6592 sa.recycle();
6593
6594 if (cat != null) {
6595 intent.addCategory(cat);
6596 }
6597 XmlUtils.skipCurrentTag(parser);
6598
6599 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006600 if (intent.mExtras == null) {
6601 intent.mExtras = new Bundle();
6602 }
6603 resources.parseBundleExtra("extra", attrs, intent.mExtras);
6604 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006605
6606 } else {
6607 XmlUtils.skipCurrentTag(parser);
6608 }
6609 }
6610
6611 return intent;
6612 }
Nick Pellyccae4122012-01-09 14:12:58 -08006613
6614 /**
6615 * Normalize a MIME data type.
6616 *
6617 * <p>A normalized MIME type has white-space trimmed,
6618 * content-type parameters removed, and is lower-case.
6619 * This aligns the type with Android best practices for
6620 * intent filtering.
6621 *
6622 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
6623 * "text/x-vCard" becomes "text/x-vcard".
6624 *
6625 * <p>All MIME types received from outside Android (such as user input,
6626 * or external sources like Bluetooth, NFC, or the Internet) should
6627 * be normalized before they are used to create an Intent.
6628 *
6629 * @param type MIME data type to normalize
6630 * @return normalized MIME data type, or null if the input was null
6631 * @see {@link #setType}
6632 * @see {@link #setTypeAndNormalize}
6633 */
6634 public static String normalizeMimeType(String type) {
6635 if (type == null) {
6636 return null;
6637 }
6638
6639 type = type.trim().toLowerCase(Locale.US);
6640
6641 final int semicolonIndex = type.indexOf(';');
6642 if (semicolonIndex != -1) {
6643 type = type.substring(0, semicolonIndex);
6644 }
6645 return type;
6646 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006647
6648 /**
6649 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006650 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
6651 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006652 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006653 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006654 * @hide
6655 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006656 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006657 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006658 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006659
6660 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006661 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006662
6663 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006664 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkey1c297002012-05-18 13:55:47 -07006665 try {
6666 // Inspect target intent to see if we need to migrate
6667 final Intent target = getParcelableExtra(EXTRA_INTENT);
6668 if (target != null && target.migrateExtraStreamToClipData()) {
6669 // Since we migrated in child, we need to promote ClipData
6670 // and flags to ourselves to grant.
6671 setClipData(target.getClipData());
6672 addFlags(target.getFlags()
6673 & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION));
6674 return true;
6675 } else {
6676 return false;
6677 }
6678 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006679 }
6680
6681 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006682 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006683 final Uri stream = getParcelableExtra(EXTRA_STREAM);
6684 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
6685 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
6686 if (stream != null || text != null || htmlText != null) {
6687 final ClipData clipData = new ClipData(
6688 null, new String[] { getType() },
6689 new ClipData.Item(text, htmlText, null, stream));
6690 setClipData(clipData);
6691 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006692 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006693 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006694 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006695 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006696
6697 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006698 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006699 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
6700 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
6701 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
6702 int num = -1;
6703 if (streams != null) {
6704 num = streams.size();
6705 }
6706 if (texts != null) {
6707 if (num >= 0 && num != texts.size()) {
6708 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006709 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006710 }
6711 num = texts.size();
6712 }
6713 if (htmlTexts != null) {
6714 if (num >= 0 && num != htmlTexts.size()) {
6715 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006716 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006717 }
6718 num = htmlTexts.size();
6719 }
6720 if (num > 0) {
6721 final ClipData clipData = new ClipData(
6722 null, new String[] { getType() },
6723 makeClipItem(streams, texts, htmlTexts, 0));
6724
6725 for (int i = 1; i < num; i++) {
6726 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
6727 }
6728
6729 setClipData(clipData);
6730 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006731 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07006732 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006733 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07006734 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006735 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07006736
6737 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07006738 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07006739
6740 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
6741 ArrayList<String> htmlTexts, int which) {
6742 Uri uri = streams != null ? streams.get(which) : null;
6743 CharSequence text = texts != null ? texts.get(which) : null;
6744 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
6745 return new ClipData.Item(text, htmlText, null, uri);
6746 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006747}