blob: 11ac15fbe0a4420d907323021a9ab71b5d9d7e35 [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
Dianne Hackborn221ea892013-08-04 16:50:16 -070019import android.content.pm.ApplicationInfo;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070020import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import org.xmlpull.v1.XmlPullParser;
22import org.xmlpull.v1.XmlPullParserException;
23
24import android.annotation.SdkConstant;
25import android.annotation.SdkConstant.SdkConstantType;
26import android.content.pm.ActivityInfo;
27import android.content.pm.PackageManager;
28import android.content.pm.ResolveInfo;
29import android.content.res.Resources;
30import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080031import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.net.Uri;
33import android.os.Bundle;
34import android.os.IBinder;
35import android.os.Parcel;
36import android.os.Parcelable;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070037import android.os.StrictMode;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070038import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070039import android.provider.DocumentsProvider;
40import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.util.AttributeSet;
42import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080043
44import com.android.internal.util.XmlUtils;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070045
46import java.io.IOException;
47import java.io.Serializable;
48import java.net.URISyntaxException;
49import java.util.ArrayList;
Dianne Hackborn221ea892013-08-04 16:50:16 -070050import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080051import java.util.Locale;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052import java.util.Set;
53
54/**
55 * An intent is an abstract description of an operation to be performed. It
56 * can be used with {@link Context#startActivity(Intent) startActivity} to
57 * launch an {@link android.app.Activity},
58 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
59 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
60 * and {@link android.content.Context#startService} or
61 * {@link android.content.Context#bindService} to communicate with a
62 * background {@link android.app.Service}.
63 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070064 * <p>An Intent provides a facility for performing late runtime binding between the code in
65 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070066 * can be thought of as the glue between activities. It is basically a passive data structure
67 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070068 *
69 * <div class="special reference">
70 * <h3>Developer Guides</h3>
71 * <p>For information about how to create and resolve intents, read the
72 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
73 * developer guide.</p>
74 * </div>
75 *
76 * <a name="IntentStructure"></a>
77 * <h3>Intent Structure</h3>
78 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070079 *
80 * <ul>
81 * <li> <p><b>action</b> -- The general action to be performed, such as
82 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
83 * etc.</p>
84 * </li>
85 * <li> <p><b>data</b> -- The data to operate on, such as a person record
86 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
87 * </li>
88 * </ul>
89 *
90 *
91 * <p>Some examples of action/data pairs are:</p>
92 *
93 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070094 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070095 * information about the person whose identifier is "1".</p>
96 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -070097 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 * the phone dialer with the person filled in.</p>
99 * </li>
100 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
101 * the phone dialer with the given number filled in. Note how the
102 * VIEW action does what what is considered the most reasonable thing for
103 * a particular URI.</p>
104 * </li>
105 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
106 * the phone dialer with the given number filled in.</p>
107 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700108 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700109 * information about the person whose identifier is "1".</p>
110 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700111 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700112 * a list of people, which the user can browse through. This example is a
113 * typical top-level entry into the Contacts application, showing you the
114 * list of people. Selecting a particular person to view would result in a
115 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
116 * being used to start an activity to display that person.</p>
117 * </li>
118 * </ul>
119 *
120 * <p>In addition to these primary attributes, there are a number of secondary
121 * attributes that you can also include with an intent:</p>
122 *
123 * <ul>
124 * <li> <p><b>category</b> -- Gives additional information about the action
125 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
126 * appear in the Launcher as a top-level application, while
127 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
128 * of alternative actions the user can perform on a piece of data.</p>
129 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
130 * intent data. Normally the type is inferred from the data itself.
131 * By setting this attribute, you disable that evaluation and force
132 * an explicit type.</p>
133 * <li> <p><b>component</b> -- Specifies an explicit name of a component
134 * class to use for the intent. Normally this is determined by looking
135 * at the other information in the intent (the action, data/type, and
136 * categories) and matching that with a component that can handle it.
137 * If this attribute is set then none of the evaluation is performed,
138 * and this component is used exactly as is. By specifying this attribute,
139 * all of the other Intent attributes become optional.</p>
140 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
141 * This can be used to provide extended information to the component.
142 * For example, if we have a action to send an e-mail message, we could
143 * also include extra pieces of data here to supply a subject, body,
144 * etc.</p>
145 * </ul>
146 *
147 * <p>Here are some examples of other operations you can specify as intents
148 * using these additional parameters:</p>
149 *
150 * <ul>
151 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
152 * Launch the home screen.</p>
153 * </li>
154 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
155 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
156 * vnd.android.cursor.item/phone}</i></b>
157 * -- Display the list of people's phone numbers, allowing the user to
158 * browse through them and pick one and return it to the parent activity.</p>
159 * </li>
160 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
161 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
162 * -- Display all pickers for data that can be opened with
163 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
164 * allowing the user to pick one of them and then some data inside of it
165 * and returning the resulting URI to the caller. This can be used,
166 * for example, in an e-mail application to allow the user to pick some
167 * data to include as an attachment.</p>
168 * </li>
169 * </ul>
170 *
171 * <p>There are a variety of standard Intent action and category constants
172 * defined in the Intent class, but applications can also define their own.
173 * These strings use java style scoping, to ensure they are unique -- for
174 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700175 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700176 *
177 * <p>Put together, the set of actions, data types, categories, and extra data
178 * defines a language for the system allowing for the expression of phrases
179 * such as "call john smith's cell". As applications are added to the system,
180 * they can extend this language by adding new actions, types, and categories, or
181 * they can modify the behavior of existing phrases by supplying their own
182 * activities that handle them.</p>
183 *
184 * <a name="IntentResolution"></a>
185 * <h3>Intent Resolution</h3>
186 *
187 * <p>There are two primary forms of intents you will use.
188 *
189 * <ul>
190 * <li> <p><b>Explicit Intents</b> have specified a component (via
191 * {@link #setComponent} or {@link #setClass}), which provides the exact
192 * class to be run. Often these will not include any other information,
193 * simply being a way for an application to launch various internal
194 * activities it has as the user interacts with the application.
195 *
196 * <li> <p><b>Implicit Intents</b> have not specified a component;
197 * instead, they must include enough information for the system to
198 * determine which of the available components is best to run for that
199 * intent.
200 * </ul>
201 *
202 * <p>When using implicit intents, given such an arbitrary intent we need to
203 * know what to do with it. This is handled by the process of <em>Intent
204 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
205 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
206 * more activities/receivers) that can handle it.</p>
207 *
208 * <p>The intent resolution mechanism basically revolves around matching an
209 * Intent against all of the &lt;intent-filter&gt; descriptions in the
210 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
211 * objects explicitly registered with {@link Context#registerReceiver}.) More
212 * details on this can be found in the documentation on the {@link
213 * IntentFilter} class.</p>
214 *
215 * <p>There are three pieces of information in the Intent that are used for
216 * resolution: the action, type, and category. Using this information, a query
217 * is done on the {@link PackageManager} for a component that can handle the
218 * intent. The appropriate component is determined based on the intent
219 * information supplied in the <code>AndroidManifest.xml</code> file as
220 * follows:</p>
221 *
222 * <ul>
223 * <li> <p>The <b>action</b>, if given, must be listed by the component as
224 * one it handles.</p>
225 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
226 * already supplied in the Intent. Like the action, if a type is
227 * included in the intent (either explicitly or implicitly in its
228 * data), then this must be listed by the component as one it handles.</p>
229 * <li> For data that is not a <code>content:</code> URI and where no explicit
230 * type is included in the Intent, instead the <b>scheme</b> of the
231 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
232 * considered. Again like the action, if we are matching a scheme it
233 * must be listed by the component as one it can handle.
234 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
235 * by the activity as categories it handles. That is, if you include
236 * the categories {@link #CATEGORY_LAUNCHER} and
237 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
238 * with an intent that lists <em>both</em> of those categories.
239 * Activities will very often need to support the
240 * {@link #CATEGORY_DEFAULT} so that they can be found by
241 * {@link Context#startActivity Context.startActivity()}.</p>
242 * </ul>
243 *
244 * <p>For example, consider the Note Pad sample application that
245 * allows user to browse through a list of notes data and view details about
246 * individual items. Text in italics indicate places were you would replace a
247 * name with one specific to your own package.</p>
248 *
249 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
250 * package="<i>com.android.notepad</i>"&gt;
251 * &lt;application android:icon="@drawable/app_notes"
252 * android:label="@string/app_name"&gt;
253 *
254 * &lt;provider class=".NotePadProvider"
255 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
256 *
257 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
258 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700259 * &lt;action android:name="android.intent.action.MAIN" /&gt;
260 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700261 * &lt;/intent-filter&gt;
262 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700263 * &lt;action android:name="android.intent.action.VIEW" /&gt;
264 * &lt;action android:name="android.intent.action.EDIT" /&gt;
265 * &lt;action android:name="android.intent.action.PICK" /&gt;
266 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
267 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700268 * &lt;/intent-filter&gt;
269 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700270 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
271 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
272 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700273 * &lt;/intent-filter&gt;
274 * &lt;/activity&gt;
275 *
276 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
277 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.VIEW" /&gt;
279 * &lt;action android:name="android.intent.action.EDIT" /&gt;
280 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
281 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 * &lt;/intent-filter&gt;
283 *
284 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700285 * &lt;action android:name="android.intent.action.INSERT" /&gt;
286 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
287 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700288 * &lt;/intent-filter&gt;
289 *
290 * &lt;/activity&gt;
291 *
292 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
293 * android:theme="@android:style/Theme.Dialog"&gt;
294 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700295 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
298 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 * &lt;/activity&gt;
302 *
303 * &lt;/application&gt;
304 * &lt;/manifest&gt;</pre>
305 *
306 * <p>The first activity,
307 * <code>com.android.notepad.NotesList</code>, serves as our main
308 * entry into the app. It can do three things as described by its three intent
309 * templates:
310 * <ol>
311 * <li><pre>
312 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
314 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700315 * &lt;/intent-filter&gt;</pre>
316 * <p>This provides a top-level entry into the NotePad application: the standard
317 * MAIN action is a main entry point (not requiring any other information in
318 * the Intent), and the LAUNCHER category says that this entry point should be
319 * listed in the application launcher.</p>
320 * <li><pre>
321 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700322 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
323 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
324 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
325 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
326 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700327 * &lt;/intent-filter&gt;</pre>
328 * <p>This declares the things that the activity can do on a directory of
329 * notes. The type being supported is given with the &lt;type&gt; tag, where
330 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
331 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
332 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
333 * The activity allows the user to view or edit the directory of data (via
334 * the VIEW and EDIT actions), or to pick a particular note and return it
335 * to the caller (via the PICK action). Note also the DEFAULT category
336 * supplied here: this is <em>required</em> for the
337 * {@link Context#startActivity Context.startActivity} method to resolve your
338 * activity when its component name is not explicitly specified.</p>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
342 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
343 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700344 * &lt;/intent-filter&gt;</pre>
345 * <p>This filter describes the ability return to the caller a note selected by
346 * the user without needing to know where it came from. The data type
347 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
348 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
349 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
350 * The GET_CONTENT action is similar to the PICK action, where the activity
351 * will return to its caller a piece of data selected by the user. Here,
352 * however, the caller specifies the type of data they desire instead of
353 * the type of data the user will be picking from.</p>
354 * </ol>
355 *
356 * <p>Given these capabilities, the following intents will resolve to the
357 * NotesList activity:</p>
358 *
359 * <ul>
360 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
361 * activities that can be used as top-level entry points into an
362 * application.</p>
363 * <li> <p><b>{ action=android.app.action.MAIN,
364 * category=android.app.category.LAUNCHER }</b> is the actual intent
365 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700366 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700367 * data=content://com.google.provider.NotePad/notes }</b>
368 * displays a list of all the notes under
369 * "content://com.google.provider.NotePad/notes", which
370 * the user can browse through and see the details on.</p>
371 * <li> <p><b>{ action=android.app.action.PICK
372 * data=content://com.google.provider.NotePad/notes }</b>
373 * provides a list of the notes under
374 * "content://com.google.provider.NotePad/notes", from which
375 * the user can pick a note whose data URL is returned back to the caller.</p>
376 * <li> <p><b>{ action=android.app.action.GET_CONTENT
377 * type=vnd.android.cursor.item/vnd.google.note }</b>
378 * is similar to the pick action, but allows the caller to specify the
379 * kind of data they want back so that the system can find the appropriate
380 * activity to pick something of that data type.</p>
381 * </ul>
382 *
383 * <p>The second activity,
384 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
385 * note entry and allows them to edit it. It can do two things as described
386 * by its two intent templates:
387 * <ol>
388 * <li><pre>
389 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700390 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
391 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
392 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
393 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700394 * &lt;/intent-filter&gt;</pre>
395 * <p>The first, primary, purpose of this activity is to let the user interact
396 * with a single note, as decribed by the MIME type
397 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
398 * either VIEW a note or allow the user to EDIT it. Again we support the
399 * DEFAULT category to allow the activity to be launched without explicitly
400 * specifying its component.</p>
401 * <li><pre>
402 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700403 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
404 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
405 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700406 * &lt;/intent-filter&gt;</pre>
407 * <p>The secondary use of this activity is to insert a new note entry into
408 * an existing directory of notes. This is used when the user creates a new
409 * note: the INSERT action is executed on the directory of notes, causing
410 * this activity to run and have the user create the new note data which
411 * it then adds to the content provider.</p>
412 * </ol>
413 *
414 * <p>Given these capabilities, the following intents will resolve to the
415 * NoteEditor activity:</p>
416 *
417 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700418 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700419 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
420 * shows the user the content of note <var>{ID}</var>.</p>
421 * <li> <p><b>{ action=android.app.action.EDIT
422 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
423 * allows the user to edit the content of note <var>{ID}</var>.</p>
424 * <li> <p><b>{ action=android.app.action.INSERT
425 * data=content://com.google.provider.NotePad/notes }</b>
426 * creates a new, empty note in the notes list at
427 * "content://com.google.provider.NotePad/notes"
428 * and allows the user to edit it. If they keep their changes, the URI
429 * of the newly created note is returned to the caller.</p>
430 * </ul>
431 *
432 * <p>The last activity,
433 * <code>com.android.notepad.TitleEditor</code>, allows the user to
434 * edit the title of a note. This could be implemented as a class that the
435 * application directly invokes (by explicitly setting its component in
436 * the Intent), but here we show a way you can publish alternative
437 * operations on existing data:</p>
438 *
439 * <pre>
440 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700441 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
442 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
443 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
444 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
445 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700446 * &lt;/intent-filter&gt;</pre>
447 *
448 * <p>In the single intent template here, we
449 * have created our own private action called
450 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
451 * edit the title of a note. It must be invoked on a specific note
452 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
453 * view and edit actions, but here displays and edits the title contained
454 * in the note data.
455 *
456 * <p>In addition to supporting the default category as usual, our title editor
457 * also supports two other standard categories: ALTERNATIVE and
458 * SELECTED_ALTERNATIVE. Implementing
459 * these categories allows others to find the special action it provides
460 * without directly knowing about it, through the
461 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
462 * more often to build dynamic menu items with
463 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
464 * template here was also supply an explicit name for the template
465 * (via <code>android:label="@string/resolve_title"</code>) to better control
466 * what the user sees when presented with this activity as an alternative
467 * action to the data they are viewing.
468 *
469 * <p>Given these capabilities, the following intent will resolve to the
470 * TitleEditor activity:</p>
471 *
472 * <ul>
473 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
474 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
475 * displays and allows the user to edit the title associated
476 * with note <var>{ID}</var>.</p>
477 * </ul>
478 *
479 * <h3>Standard Activity Actions</h3>
480 *
481 * <p>These are the current standard actions that Intent defines for launching
482 * activities (usually through {@link Context#startActivity}. The most
483 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
484 * {@link #ACTION_EDIT}.
485 *
486 * <ul>
487 * <li> {@link #ACTION_MAIN}
488 * <li> {@link #ACTION_VIEW}
489 * <li> {@link #ACTION_ATTACH_DATA}
490 * <li> {@link #ACTION_EDIT}
491 * <li> {@link #ACTION_PICK}
492 * <li> {@link #ACTION_CHOOSER}
493 * <li> {@link #ACTION_GET_CONTENT}
494 * <li> {@link #ACTION_DIAL}
495 * <li> {@link #ACTION_CALL}
496 * <li> {@link #ACTION_SEND}
497 * <li> {@link #ACTION_SENDTO}
498 * <li> {@link #ACTION_ANSWER}
499 * <li> {@link #ACTION_INSERT}
500 * <li> {@link #ACTION_DELETE}
501 * <li> {@link #ACTION_RUN}
502 * <li> {@link #ACTION_SYNC}
503 * <li> {@link #ACTION_PICK_ACTIVITY}
504 * <li> {@link #ACTION_SEARCH}
505 * <li> {@link #ACTION_WEB_SEARCH}
506 * <li> {@link #ACTION_FACTORY_TEST}
507 * </ul>
508 *
509 * <h3>Standard Broadcast Actions</h3>
510 *
511 * <p>These are the current standard actions that Intent defines for receiving
512 * broadcasts (usually through {@link Context#registerReceiver} or a
513 * &lt;receiver&gt; tag in a manifest).
514 *
515 * <ul>
516 * <li> {@link #ACTION_TIME_TICK}
517 * <li> {@link #ACTION_TIME_CHANGED}
518 * <li> {@link #ACTION_TIMEZONE_CHANGED}
519 * <li> {@link #ACTION_BOOT_COMPLETED}
520 * <li> {@link #ACTION_PACKAGE_ADDED}
521 * <li> {@link #ACTION_PACKAGE_CHANGED}
522 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800523 * <li> {@link #ACTION_PACKAGE_RESTARTED}
524 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700525 * <li> {@link #ACTION_UID_REMOVED}
526 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700527 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700528 * <li> {@link #ACTION_POWER_DISCONNECTED}
529 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700530 * </ul>
531 *
532 * <h3>Standard Categories</h3>
533 *
534 * <p>These are the current standard categories that can be used to further
535 * clarify an Intent via {@link #addCategory}.
536 *
537 * <ul>
538 * <li> {@link #CATEGORY_DEFAULT}
539 * <li> {@link #CATEGORY_BROWSABLE}
540 * <li> {@link #CATEGORY_TAB}
541 * <li> {@link #CATEGORY_ALTERNATIVE}
542 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
543 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700545 * <li> {@link #CATEGORY_HOME}
546 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700547 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400548 * <li> {@link #CATEGORY_CAR_DOCK}
549 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500550 * <li> {@link #CATEGORY_LE_DESK_DOCK}
551 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200552 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700553 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700554 * </ul>
555 *
556 * <h3>Standard Extra Data</h3>
557 *
558 * <p>These are the current standard fields that can be used as extra data via
559 * {@link #putExtra}.
560 *
561 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800562 * <li> {@link #EXTRA_ALARM_COUNT}
563 * <li> {@link #EXTRA_BCC}
564 * <li> {@link #EXTRA_CC}
565 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
566 * <li> {@link #EXTRA_DATA_REMOVED}
567 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500568 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
569 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800570 * <li> {@link #EXTRA_DOCK_STATE_CAR}
571 * <li> {@link #EXTRA_DOCK_STATE_DESK}
572 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
573 * <li> {@link #EXTRA_DONT_KILL_APP}
574 * <li> {@link #EXTRA_EMAIL}
575 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800577 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700578 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800579 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700580 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800581 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
582 * <li> {@link #EXTRA_REPLACING}
583 * <li> {@link #EXTRA_SHORTCUT_ICON}
584 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
585 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700586 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800587 * <li> {@link #EXTRA_SHORTCUT_NAME}
588 * <li> {@link #EXTRA_SUBJECT}
589 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700590 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_TITLE}
592 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700593 * </ul>
594 *
595 * <h3>Flags</h3>
596 *
597 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800598 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
599 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700600 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800601public class Intent implements Parcelable, Cloneable {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 // ---------------------------------------------------------------------
603 // ---------------------------------------------------------------------
604 // Standard intent activity actions (see action variable).
605
606 /**
607 * Activity Action: Start as a main entry point, does not expect to
608 * receive data.
609 * <p>Input: nothing
610 * <p>Output: nothing
611 */
612 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
613 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800614
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 /**
616 * Activity Action: Display the data to the user. This is the most common
617 * action performed on data -- it is the generic action you can use on
618 * a piece of data to get the most reasonable thing to occur. For example,
619 * when used on a contacts entry it will view the entry; when used on a
620 * mailto: URI it will bring up a compose window filled with the information
621 * supplied by the URI; when used with a tel: URI it will invoke the
622 * dialer.
623 * <p>Input: {@link #getData} is URI from which to retrieve data.
624 * <p>Output: nothing.
625 */
626 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
627 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800628
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700629 /**
630 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
631 * performed on a piece of data.
632 */
633 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800634
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700635 /**
636 * Used to indicate that some piece of data should be attached to some other
637 * place. For example, image data could be attached to a contact. It is up
638 * to the recipient to decide where the data should be attached; the intent
639 * does not specify the ultimate destination.
640 * <p>Input: {@link #getData} is URI of data to be attached.
641 * <p>Output: nothing.
642 */
643 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
644 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700646 /**
647 * Activity Action: Provide explicit editable access to the given data.
648 * <p>Input: {@link #getData} is URI of data to be edited.
649 * <p>Output: nothing.
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
656 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
657 * The extras can contain type specific data to pass through to the editing/creating
658 * activity.
659 * <p>Output: The URI of the item that was picked. This must be a content:
660 * URI so that any receiver can access it.
661 */
662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
663 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
666 * Activity Action: Pick an item from the data, returning what was selected.
667 * <p>Input: {@link #getData} is URI containing a directory of data
668 * (vnd.android.cursor.dir/*) from which to pick an item.
669 * <p>Output: The URI of the item that was picked.
670 */
671 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
672 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700674 /**
675 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800676 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700677 * <p>Output: An Intent representing the shortcut. The intent must contain three
678 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
679 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800680 * (value: ShortcutIconResource).</p>
681 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700682 * @see #EXTRA_SHORTCUT_INTENT
683 * @see #EXTRA_SHORTCUT_NAME
684 * @see #EXTRA_SHORTCUT_ICON
685 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
686 * @see android.content.Intent.ShortcutIconResource
687 */
688 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
689 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
690
691 /**
692 * The name of the extra used to define the Intent of a shortcut.
693 *
694 * @see #ACTION_CREATE_SHORTCUT
695 */
696 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
697 /**
698 * The name of the extra used to define the name of a shortcut.
699 *
700 * @see #ACTION_CREATE_SHORTCUT
701 */
702 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
703 /**
704 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
705 *
706 * @see #ACTION_CREATE_SHORTCUT
707 */
708 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
709 /**
710 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
711 *
712 * @see #ACTION_CREATE_SHORTCUT
713 * @see android.content.Intent.ShortcutIconResource
714 */
715 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
716 "android.intent.extra.shortcut.ICON_RESOURCE";
717
718 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700720 *
721 * @see Intent#ACTION_CREATE_SHORTCUT
722 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
724 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 */
726 public static class ShortcutIconResource implements Parcelable {
727 /**
728 * The package name of the application containing the icon.
729 */
730 public String packageName;
731
732 /**
733 * The resource name of the icon, including package, name and type.
734 */
735 public String resourceName;
736
737 /**
738 * Creates a new ShortcutIconResource for the specified context and resource
739 * identifier.
740 *
741 * @param context The context of the application.
742 * @param resourceId The resource idenfitier for the icon.
743 * @return A new ShortcutIconResource with the specified's context package name
744 * and icon resource idenfitier.
745 */
746 public static ShortcutIconResource fromContext(Context context, int resourceId) {
747 ShortcutIconResource icon = new ShortcutIconResource();
748 icon.packageName = context.getPackageName();
749 icon.resourceName = context.getResources().getResourceName(resourceId);
750 return icon;
751 }
752
753 /**
754 * Used to read a ShortcutIconResource from a Parcel.
755 */
756 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
757 new Parcelable.Creator<ShortcutIconResource>() {
758
759 public ShortcutIconResource createFromParcel(Parcel source) {
760 ShortcutIconResource icon = new ShortcutIconResource();
761 icon.packageName = source.readString();
762 icon.resourceName = source.readString();
763 return icon;
764 }
765
766 public ShortcutIconResource[] newArray(int size) {
767 return new ShortcutIconResource[size];
768 }
769 };
770
771 /**
772 * No special parcel contents.
773 */
774 public int describeContents() {
775 return 0;
776 }
777
778 public void writeToParcel(Parcel dest, int flags) {
779 dest.writeString(packageName);
780 dest.writeString(resourceName);
781 }
782
783 @Override
784 public String toString() {
785 return resourceName;
786 }
787 }
788
789 /**
790 * Activity Action: Display an activity chooser, allowing the user to pick
791 * what they want to before proceeding. This can be used as an alternative
792 * to the standard activity picker that is displayed by the system when
793 * you try to start an activity with multiple possible matches, with these
794 * differences in behavior:
795 * <ul>
796 * <li>You can specify the title that will appear in the activity chooser.
797 * <li>The user does not have the option to make one of the matching
798 * activities a preferred activity, and all possible activities will
799 * always be shown even if one of them is currently marked as the
800 * preferred activity.
801 * </ul>
802 * <p>
803 * This action should be used when the user will naturally expect to
804 * select an activity in order to proceed. An example if when not to use
805 * it is when the user clicks on a "mailto:" link. They would naturally
806 * expect to go directly to their mail app, so startActivity() should be
807 * called directly: it will
808 * either launch the current preferred app, or put up a dialog allowing the
809 * user to pick an app to use and optionally marking that as preferred.
810 * <p>
811 * In contrast, if the user is selecting a menu item to send a picture
812 * they are viewing to someone else, there are many different things they
813 * may want to do at this point: send it through e-mail, upload it to a
814 * web service, etc. In this case the CHOOSER action should be used, to
815 * always present to the user a list of the things they can do, with a
816 * nice title given by the caller such as "Send this photo with:".
817 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700818 * If you need to grant URI permissions through a chooser, you must specify
819 * the permissions to be granted on the ACTION_CHOOSER Intent
820 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
821 * {@link #setClipData} to specify the URIs to be granted as well as
822 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
823 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
824 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 * As a convenience, an Intent of this form can be created with the
826 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700827 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700828 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700829 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
830 * and can optionally have a {@link #EXTRA_TITLE} field containing the
831 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700832 * <p>
833 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700834 */
835 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
836 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
837
838 /**
839 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
840 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700841 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
842 * target intent, also optionally supplying a title. If the target
843 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
844 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
845 * set in the returned chooser intent, with its ClipData set appropriately:
846 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500847 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700848 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700849 * @param target The Intent that the user will be selecting an activity
850 * to perform.
851 * @param title Optional title that will be displayed in the chooser.
852 * @return Return a new Intent object that you can hand to
853 * {@link Context#startActivity(Intent) Context.startActivity()} and
854 * related methods.
855 */
856 public static Intent createChooser(Intent target, CharSequence title) {
857 Intent intent = new Intent(ACTION_CHOOSER);
858 intent.putExtra(EXTRA_INTENT, target);
859 if (title != null) {
860 intent.putExtra(EXTRA_TITLE, title);
861 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700862
863 // Migrate any clip data and flags from target.
Dianne Hackborne302a162012-05-15 14:58:32 -0700864 int permFlags = target.getFlags()
865 & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION);
866 if (permFlags != 0) {
867 ClipData targetClipData = target.getClipData();
868 if (targetClipData == null && target.getData() != null) {
869 ClipData.Item item = new ClipData.Item(target.getData());
870 String[] mimeTypes;
871 if (target.getType() != null) {
872 mimeTypes = new String[] { target.getType() };
873 } else {
874 mimeTypes = new String[] { };
875 }
876 targetClipData = new ClipData(null, mimeTypes, item);
877 }
878 if (targetClipData != null) {
879 intent.setClipData(targetClipData);
880 intent.addFlags(permFlags);
881 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700882 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700883
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700884 return intent;
885 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700886
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700887 /**
888 * Activity Action: Allow the user to select a particular kind of data and
889 * return it. This is different than {@link #ACTION_PICK} in that here we
890 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800891 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700892 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900893 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700894 * etc.
895 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900896 * 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 -0700897 * of data, such as a person contact, you set the MIME type to the kind of
898 * data you want and launch it with {@link Context#startActivity(Intent)}.
899 * The system will then launch the best application to select that kind
900 * of data for you.
901 * <p>
902 * You may also be interested in any of a set of types of content the user
903 * can pick. For example, an e-mail application that wants to allow the
904 * user to add an attachment to an e-mail message can use this action to
905 * bring up a list of all of the types of content the user can attach.
906 * <p>
907 * In this case, you should wrap the GET_CONTENT intent with a chooser
908 * (through {@link #createChooser}), which will give the proper interface
909 * for the user to pick how to send your data and allow you to specify
910 * a prompt indicating what they are doing. You will usually specify a
911 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
912 * broad range of content types the user can select from.
913 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900914 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700915 * only pick from data that can be represented as a stream. This is
916 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
917 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800918 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900919 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800920 * is locally available on the device. For example, if this extra is set
921 * to true then an image picker should not show any pictures that are available
922 * from a remote server but not already on the local device (thus requiring
923 * they be downloaded when opened).
924 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800925 * If the caller can handle multiple returned items (the user performing
926 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
927 * to indicate this.
928 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700929 * Input: {@link #getType} is the desired MIME type to retrieve. Note
930 * that no URI is supplied in the intent, as there are no constraints on
931 * where the returned data originally comes from. You may also include the
932 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800933 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800934 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
935 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700936 * <p>
937 * Output: The URI of the item that was picked. This must be a content:
938 * URI so that any receiver can access it.
939 */
940 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
941 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
942 /**
943 * Activity Action: Dial a number as specified by the data. This shows a
944 * UI with the number being dialed, allowing the user to explicitly
945 * initiate the call.
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 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
952 public static final String ACTION_DIAL = "android.intent.action.DIAL";
953 /**
954 * Activity Action: Perform a call to someone specified by the data.
955 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
956 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
957 * number.
958 * <p>Output: nothing.
959 *
960 * <p>Note: there will be restrictions on which applications can initiate a
961 * call; most applications should use the {@link #ACTION_DIAL}.
962 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
963 * numbers. Applications can <strong>dial</strong> emergency numbers using
964 * {@link #ACTION_DIAL}, however.
965 */
966 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
967 public static final String ACTION_CALL = "android.intent.action.CALL";
968 /**
969 * Activity Action: Perform a call to an emergency number specified by the
970 * 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_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
977 /**
978 * Activity action: Perform a call to any number (emergency or not)
979 * specified by the data.
980 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
981 * tel: URI of an explicit phone number.
982 * <p>Output: nothing.
983 * @hide
984 */
985 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
986 /**
987 * Activity Action: Send a message to someone specified by the data.
988 * <p>Input: {@link #getData} is URI describing the target.
989 * <p>Output: nothing.
990 */
991 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
992 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
993 /**
994 * Activity Action: Deliver some data to someone else. Who the data is
995 * being delivered to is not specified; it is up to the receiver of this
996 * action to ask the user where the data should be sent.
997 * <p>
998 * When launching a SEND intent, you should usually wrap it in a chooser
999 * (through {@link #createChooser}), which will give the proper interface
1000 * for the user to pick how to send your data and allow you to specify
1001 * a prompt indicating what they are doing.
1002 * <p>
1003 * Input: {@link #getType} is the MIME type of the data being sent.
1004 * get*Extra can have either a {@link #EXTRA_TEXT}
1005 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1006 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1007 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1008 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001009 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1010 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1011 * your text with HTML formatting.
1012 * <p>
1013 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1014 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1015 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1016 * content: URIs and other advanced features of {@link ClipData}. If
1017 * using this approach, you still must supply the same data through the
1018 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1019 * for compatibility with old applications. If you don't set a ClipData,
1020 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001021 * <p>
1022 * Optional standard extras, which may be interpreted by some recipients as
1023 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1024 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1025 * <p>
1026 * Output: nothing.
1027 */
1028 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1029 public static final String ACTION_SEND = "android.intent.action.SEND";
1030 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001031 * Activity Action: Deliver multiple data to someone else.
1032 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001033 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001034 * <p>
1035 * Input: {@link #getType} is the MIME type of the data being sent.
1036 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001037 * #EXTRA_STREAM} field, containing the data to be sent. If using
1038 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1039 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001040 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001041 * Multiple types are supported, and receivers should handle mixed types
1042 * whenever possible. The right way for the receiver to check them is to
1043 * use the content resolver on each URI. The intent sender should try to
1044 * put the most concrete mime type in the intent type, but it can fall
1045 * back to {@literal <type>/*} or {@literal *}/* as needed.
1046 * <p>
1047 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1048 * be image/jpg, but if you are sending image/jpg and image/png, then the
1049 * intent's type should be image/*.
1050 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001051 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1052 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1053 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1054 * content: URIs and other advanced features of {@link ClipData}. If
1055 * using this approach, you still must supply the same data through the
1056 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1057 * for compatibility with old applications. If you don't set a ClipData,
1058 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1059 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001060 * Optional standard extras, which may be interpreted by some recipients as
1061 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1062 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1063 * <p>
1064 * Output: nothing.
1065 */
1066 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1067 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1068 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001069 * Activity Action: Handle an incoming phone call.
1070 * <p>Input: nothing.
1071 * <p>Output: nothing.
1072 */
1073 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1074 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1075 /**
1076 * Activity Action: Insert an empty item into the given container.
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_INSERT = "android.intent.action.INSERT";
1083 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001084 * Activity Action: Create a new item in the given container, initializing it
1085 * from the current contents of the clipboard.
1086 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1087 * in which to place the data.
1088 * <p>Output: URI of the new data that was created.
1089 */
1090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1091 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1092 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001093 * Activity Action: Delete the given data from its container.
1094 * <p>Input: {@link #getData} is URI of data to be deleted.
1095 * <p>Output: nothing.
1096 */
1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1098 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1099 /**
1100 * Activity Action: Run the data, whatever that means.
1101 * <p>Input: ? (Note: this is currently specific to the test harness.)
1102 * <p>Output: nothing.
1103 */
1104 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1105 public static final String ACTION_RUN = "android.intent.action.RUN";
1106 /**
1107 * Activity Action: Perform a data synchronization.
1108 * <p>Input: ?
1109 * <p>Output: ?
1110 */
1111 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1112 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1113 /**
1114 * Activity Action: Pick an activity given an intent, returning the class
1115 * selected.
1116 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1117 * used with {@link PackageManager#queryIntentActivities} to determine the
1118 * set of activities from which to pick.
1119 * <p>Output: Class name of the activity that was selected.
1120 */
1121 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1122 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1123 /**
1124 * Activity Action: Perform a search.
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_SEARCH = "android.intent.action.SEARCH";
1132 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001133 * Activity Action: Start the platform-defined tutorial
1134 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1135 * is the text to search for. If empty, simply
1136 * enter your search results Activity with the search UI activated.
1137 * <p>Output: nothing.
1138 */
1139 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1140 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1141 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001142 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001143 * <p>
1144 * Input: {@link android.app.SearchManager#QUERY
1145 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1146 * a url starts with http or https, the site will be opened. If it is plain
1147 * text, Google search will be applied.
1148 * <p>
1149 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001150 */
1151 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1152 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001153
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001154 /**
Jim Miller07994402012-05-02 14:22:27 -07001155 * Activity Action: Perform assist action.
1156 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001157 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1158 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001159 * requested the assist.
Jim Miller07994402012-05-02 14:22:27 -07001160 * Output: nothing.
1161 */
1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001164
1165 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001166 * Activity Action: Perform voice assist action.
1167 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001168 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1169 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001170 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001171 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001172 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001173 */
1174 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1175 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1176
1177 /**
Adam Skory7140a252013-09-11 12:04:58 +01001178 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1179 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001180 */
1181 public static final String EXTRA_ASSIST_PACKAGE
1182 = "android.intent.extra.ASSIST_PACKAGE";
1183
1184 /**
Adam Skory7140a252013-09-11 12:04:58 +01001185 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1186 * information supplied by the current foreground app at the time of the assist request.
1187 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001188 */
1189 public static final String EXTRA_ASSIST_CONTEXT
1190 = "android.intent.extra.ASSIST_CONTEXT";
1191
Jim Miller07994402012-05-02 14:22:27 -07001192 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001193 * Activity Action: List all available applications
1194 * <p>Input: Nothing.
1195 * <p>Output: nothing.
1196 */
1197 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1198 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1199 /**
1200 * Activity Action: Show settings for choosing wallpaper
1201 * <p>Input: Nothing.
1202 * <p>Output: Nothing.
1203 */
1204 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1205 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1206
1207 /**
1208 * Activity Action: Show activity for reporting a bug.
1209 * <p>Input: Nothing.
1210 * <p>Output: Nothing.
1211 */
1212 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1213 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1214
1215 /**
1216 * Activity Action: Main entry point for factory tests. Only used when
1217 * the device is booting in factory test node. The implementing package
1218 * must be installed in the system image.
1219 * <p>Input: nothing
1220 * <p>Output: nothing
1221 */
1222 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1223
1224 /**
1225 * Activity Action: The user pressed the "call" button to go to the dialer
1226 * or other appropriate UI for placing a call.
1227 * <p>Input: Nothing.
1228 * <p>Output: Nothing.
1229 */
1230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1231 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1232
1233 /**
1234 * Activity Action: Start Voice Command.
1235 * <p>Input: Nothing.
1236 * <p>Output: Nothing.
1237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001240
1241 /**
1242 * Activity Action: Start action associated with long pressing on the
1243 * search key.
1244 * <p>Input: Nothing.
1245 * <p>Output: Nothing.
1246 */
1247 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1248 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001249
Jacek Surazski86b6c532009-05-13 14:38:28 +02001250 /**
1251 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1252 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001253 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001254 * <p>Input: No data is specified. The bug report is passed in using
1255 * an {@link #EXTRA_BUG_REPORT} field.
1256 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001257 *
1258 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001259 */
1260 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1261 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001262
1263 /**
1264 * Activity Action: Show power usage information to the user.
1265 * <p>Input: Nothing.
1266 * <p>Output: Nothing.
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001270
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001271 /**
1272 * Activity Action: Setup wizard to launch after a platform update. This
1273 * activity should have a string meta-data field associated with it,
1274 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1275 * the platform for setup. The activity will be launched only if
1276 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1277 * same value.
1278 * <p>Input: Nothing.
1279 * <p>Output: Nothing.
1280 * @hide
1281 */
1282 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1283 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001284
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001285 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001286 * Activity Action: Show settings for managing network data usage of a
1287 * specific application. Applications should define an activity that offers
1288 * options to control data usage.
1289 */
1290 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1291 public static final String ACTION_MANAGE_NETWORK_USAGE =
1292 "android.intent.action.MANAGE_NETWORK_USAGE";
1293
1294 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001295 * Activity Action: Launch application installer.
1296 * <p>
1297 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001298 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1299 * you can also use "package:<package-name>" to install an application for the
1300 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001301 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1302 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1303 * <p>
1304 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1305 * succeeded.
1306 *
1307 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1308 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1309 * @see #EXTRA_RETURN_RESULT
1310 */
1311 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1313
1314 /**
1315 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1316 * package. Specifies the installer package name; this package will receive the
1317 * {@link #ACTION_APP_ERROR} intent.
1318 */
1319 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1320 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1321
1322 /**
1323 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1324 * package. Specifies that the application being installed should not be
1325 * treated as coming from an unknown source, but as coming from the app
1326 * invoking the Intent. For this to work you must start the installer with
1327 * startActivityForResult().
1328 */
1329 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1330 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1331
1332 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001333 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1334 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001335 * data field originated from.
1336 */
rich cannings706e8ba2012-08-20 13:20:14 -07001337 public static final String EXTRA_ORIGINATING_URI
1338 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001339
1340 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001341 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1342 * {@link #ACTION_VIEW} to indicate the HTTP referrer URI associated with the Intent
1343 * data field or {@link #EXTRA_ORIGINATING_URI}.
rich cannings368ed012012-06-07 15:37:57 -07001344 */
1345 public static final String EXTRA_REFERRER
1346 = "android.intent.extra.REFERRER";
1347
1348 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001349 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1350 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1351 * @hide
1352 */
1353 public static final String EXTRA_ORIGINATING_UID
1354 = "android.intent.extra.ORIGINATING_UID";
1355
1356 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001357 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1358 * package. Tells the installer UI to skip the confirmation with the user
1359 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001360 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1361 * will no longer show an interstitial message about updating existing
1362 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001363 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001364 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001365 public static final String EXTRA_ALLOW_REPLACE
1366 = "android.intent.extra.ALLOW_REPLACE";
1367
1368 /**
1369 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1370 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1371 * return to the application the result code of the install/uninstall. The returned result
1372 * code will be {@link android.app.Activity#RESULT_OK} on success or
1373 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1374 */
1375 public static final String EXTRA_RETURN_RESULT
1376 = "android.intent.extra.RETURN_RESULT";
1377
1378 /**
1379 * Package manager install result code. @hide because result codes are not
1380 * yet ready to be exposed.
1381 */
1382 public static final String EXTRA_INSTALL_RESULT
1383 = "android.intent.extra.INSTALL_RESULT";
1384
1385 /**
1386 * Activity Action: Launch application uninstaller.
1387 * <p>
1388 * Input: The data must be a package: URI whose scheme specific part is
1389 * the package name of the current installed package to be uninstalled.
1390 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1391 * <p>
1392 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1393 * succeeded.
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1397
1398 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001399 * Specify whether the package should be uninstalled for all users.
1400 * @hide because these should not be part of normal application flow.
1401 */
1402 public static final String EXTRA_UNINSTALL_ALL_USERS
1403 = "android.intent.extra.UNINSTALL_ALL_USERS";
1404
1405 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001406 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1407 * describing the last run version of the platform that was setup.
1408 * @hide
1409 */
1410 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1411
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001412 // ---------------------------------------------------------------------
1413 // ---------------------------------------------------------------------
1414 // Standard intent broadcast actions (see action variable).
1415
1416 /**
1417 * Broadcast Action: Sent after the screen turns off.
Tom Taylord4a47292009-12-21 13:59:18 -08001418 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001419 * <p class="note">This is a protected intent that can only be sent
1420 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001421 */
1422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1423 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
1424 /**
1425 * Broadcast Action: Sent after the screen turns on.
Tom Taylord4a47292009-12-21 13:59:18 -08001426 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001427 * <p class="note">This is a protected intent that can only be sent
1428 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001429 */
1430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1431 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001432
1433 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001434 * Broadcast Action: Sent after the system stops dreaming.
1435 *
1436 * <p class="note">This is a protected intent that can only be sent by the system.
1437 * It is only sent to registered receivers.</p>
1438 */
1439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1440 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1441
1442 /**
1443 * Broadcast Action: Sent after the system starts dreaming.
1444 *
1445 * <p class="note">This is a protected intent that can only be sent by the system.
1446 * It is only sent to registered receivers.</p>
1447 */
1448 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1449 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1450
1451 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001452 * 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 -07001453 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001454 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001455 * <p class="note">This is a protected intent that can only be sent
1456 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001457 */
1458 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001459 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001460
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001461 /**
1462 * Broadcast Action: The current time has changed. Sent every
1463 * minute. You can <em>not</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001464 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001465 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1466 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001467 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001468 * <p class="note">This is a protected intent that can only be sent
1469 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001470 */
1471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1472 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1473 /**
1474 * Broadcast Action: The time was set.
1475 */
1476 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1477 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1478 /**
1479 * Broadcast Action: The date has changed.
1480 */
1481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1482 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1483 /**
1484 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1485 * <ul>
1486 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1487 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001488 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001489 * <p class="note">This is a protected intent that can only be sent
1490 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001491 */
1492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1493 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1494 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001495 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1496 * DNS entries should be tossed.
1497 * @hide
1498 */
1499 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1500 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1501 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001502 * Alarm Changed Action: This is broadcast when the AlarmClock
1503 * application's alarm is set or unset. It is used by the
1504 * AlarmClock application and the StatusBar service.
1505 * @hide
1506 */
1507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1508 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1509 /**
1510 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1511 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1512 * @hide
1513 */
1514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1515 public static final String ACTION_SYNC_STATE_CHANGED
1516 = "android.intent.action.SYNC_STATE_CHANGED";
1517 /**
1518 * Broadcast Action: This is broadcast once, after the system has finished
1519 * booting. It can be used to perform application-specific initialization,
1520 * such as installing alarms. You must hold the
1521 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1522 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001523 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001524 * <p class="note">This is a protected intent that can only be sent
1525 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001526 */
1527 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1528 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1529 /**
1530 * Broadcast Action: This is broadcast when a user action should request a
1531 * temporary system dialog to dismiss. Some examples of temporary system
1532 * dialogs are the notification window-shade and the recent tasks dialog.
1533 */
1534 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1535 /**
1536 * Broadcast Action: Trigger the download and eventual installation
1537 * of a package.
1538 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001539 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001540 * <p class="note">This is a protected intent that can only be sent
1541 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001542 *
1543 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001544 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001545 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001546 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1547 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1548 /**
1549 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001550 * device. The data contains the name of the package. Note that the
1551 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001552 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001553 * <ul>
1554 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1555 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1556 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1557 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001558 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001559 * <p class="note">This is a protected intent that can only be sent
1560 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001561 */
1562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1563 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1564 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001565 * Broadcast Action: A new version of an application package has been
1566 * installed, replacing an existing version that was previously installed.
1567 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001568 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001569 * <ul>
1570 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1571 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001572 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001573 * <p class="note">This is a protected intent that can only be sent
1574 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001575 */
1576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1577 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1578 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001579 * Broadcast Action: A new version of your application has been installed
1580 * over an existing one. This is only sent to the application that was
1581 * replaced. It does not contain any additional data; to receive it, just
1582 * use an intent filter for this action.
1583 *
1584 * <p class="note">This is a protected intent that can only be sent
1585 * by the system.
1586 */
1587 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1588 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1589 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001590 * Broadcast Action: An existing application package has been removed from
1591 * the device. The data contains the name of the package. The package
1592 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001593 * <ul>
1594 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1595 * to the package.
1596 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1597 * application -- data and code -- is being removed.
1598 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1599 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1600 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001601 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001602 * <p class="note">This is a protected intent that can only be sent
1603 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001604 */
1605 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1606 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1607 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001608 * Broadcast Action: An existing application package has been completely
1609 * removed from the device. The data contains the name of the package.
1610 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1611 * {@link #EXTRA_DATA_REMOVED} is true and
1612 * {@link #EXTRA_REPLACING} is false of that broadcast.
1613 *
1614 * <ul>
1615 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1616 * to the package.
1617 * </ul>
1618 *
1619 * <p class="note">This is a protected intent that can only be sent
1620 * by the system.
1621 */
1622 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1623 public static final String ACTION_PACKAGE_FULLY_REMOVED
1624 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1625 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001626 * Broadcast Action: An existing application package has been changed (e.g.
1627 * a component has been enabled or disabled). The data contains the name of
1628 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001629 * <ul>
1630 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001631 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001632 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001633 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1634 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001635 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001636 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001637 * <p class="note">This is a protected intent that can only be sent
1638 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001639 */
1640 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1641 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1642 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001643 * @hide
1644 * Broadcast Action: Ask system services if there is any reason to
1645 * restart the given package. The data contains the name of the
1646 * package.
1647 * <ul>
1648 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1649 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1650 * </ul>
1651 *
1652 * <p class="note">This is a protected intent that can only be sent
1653 * by the system.
1654 */
1655 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1656 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1657 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001658 * Broadcast Action: The user has restarted a package, and all of its
1659 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001660 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001661 * be removed. Note that the restarted package does <em>not</em>
1662 * receive this broadcast.
1663 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001664 * <ul>
1665 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1666 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001667 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001668 * <p class="note">This is a protected intent that can only be sent
1669 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001670 */
1671 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1672 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1673 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001674 * Broadcast Action: The user has cleared the data of a package. This should
1675 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001676 * its persistent data is erased and this broadcast sent.
1677 * Note that the cleared package does <em>not</em>
1678 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001679 * <ul>
1680 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1681 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001682 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001683 * <p class="note">This is a protected intent that can only be sent
1684 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001685 */
1686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1687 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1688 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001689 * Broadcast Action: A user ID has been removed from the system. The user
1690 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001691 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001692 * <p class="note">This is a protected intent that can only be sent
1693 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001694 */
1695 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1696 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001697
1698 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001699 * Broadcast Action: Sent to the installer package of an application
1700 * when that application is first launched (that is the first time it
1701 * is moved out of the stopped state). The data contains the name of the package.
1702 *
1703 * <p class="note">This is a protected intent that can only be sent
1704 * by the system.
1705 */
1706 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1707 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1708
1709 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001710 * Broadcast Action: Sent to the system package verifier when a package
1711 * needs to be verified. The data contains the package URI.
1712 * <p class="note">
1713 * This is a protected intent that can only be sent by the system.
1714 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001715 */
1716 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1717 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1718
1719 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001720 * Broadcast Action: Sent to the system package verifier when a package is
1721 * verified. The data contains the package URI.
1722 * <p class="note">
1723 * This is a protected intent that can only be sent by the system.
1724 */
1725 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1726 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1727
1728 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001729 * Broadcast Action: Resources for a set of packages (which were
1730 * previously unavailable) are currently
1731 * available since the media on which they exist is available.
1732 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1733 * list of packages whose availability changed.
1734 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1735 * list of uids of packages whose availability changed.
1736 * Note that the
1737 * packages in this list do <em>not</em> receive this broadcast.
1738 * The specified set of packages are now available on the system.
1739 * <p>Includes the following extras:
1740 * <ul>
1741 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1742 * whose resources(were previously unavailable) are currently available.
1743 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1744 * packages whose resources(were previously unavailable)
1745 * are currently available.
1746 * </ul>
1747 *
1748 * <p class="note">This is a protected intent that can only be sent
1749 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001750 */
1751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001752 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1753 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001754
1755 /**
1756 * Broadcast Action: Resources for a set of packages are currently
1757 * unavailable since the media on which they exist is unavailable.
1758 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1759 * list of packages whose availability changed.
1760 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1761 * list of uids of packages whose availability changed.
1762 * The specified set of packages can no longer be
1763 * launched and are practically unavailable on the system.
1764 * <p>Inclues the following extras:
1765 * <ul>
1766 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1767 * whose resources are no longer available.
1768 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1769 * whose resources are no longer available.
1770 * </ul>
1771 *
1772 * <p class="note">This is a protected intent that can only be sent
1773 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001774 */
1775 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001776 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001777 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001778
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001779 /**
1780 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001781 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001782 * This should <em>only</em> be used to determine when the wallpaper
1783 * has changed to show the new wallpaper to the user. You should certainly
1784 * never, in response to this, change the wallpaper or other attributes of
1785 * it such as the suggested size. That would be crazy, right? You'd cause
1786 * all kinds of loops, especially if other apps are doing similar things,
1787 * right? Of course. So please don't do this.
1788 *
1789 * @deprecated Modern applications should use
1790 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1791 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1792 * shown behind their UI, rather than watching for this broadcast and
1793 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001794 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001795 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001796 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1797 /**
1798 * Broadcast Action: The current device {@link android.content.res.Configuration}
1799 * (orientation, locale, etc) has changed. When such a change happens, the
1800 * UIs (view hierarchy) will need to be rebuilt based on this new
1801 * information; for the most part, applications don't need to worry about
1802 * this, because the system will take care of stopping and restarting the
1803 * application to make sure it sees the new changes. Some system code that
1804 * can not be restarted will need to watch for this action and handle it
1805 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001806 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001807 * <p class="note">
1808 * You can <em>not</em> receive this through components declared
1809 * in manifests, only by explicitly registering for it with
1810 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1811 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001812 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001813 * <p class="note">This is a protected intent that can only be sent
1814 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001815 *
1816 * @see android.content.res.Configuration
1817 */
1818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1819 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1820 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001821 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001822 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001823 * <p class="note">This is a protected intent that can only be sent
1824 * by the system.
1825 */
1826 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1827 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1828 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001829 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1830 * charging state, level, and other information about the battery.
1831 * See {@link android.os.BatteryManager} for documentation on the
1832 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001833 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001834 * <p class="note">
1835 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001836 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001837 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001838 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1839 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1840 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1841 * broadcasts that are sent and can be received through manifest
1842 * receivers.
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_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1849 /**
1850 * Broadcast Action: Indicates low battery condition on the device.
1851 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001852 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001853 * <p class="note">This is a protected intent that can only be sent
1854 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001855 */
1856 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1857 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1858 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001859 * Broadcast Action: Indicates the battery is now okay after being low.
1860 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1861 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001862 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001863 * <p class="note">This is a protected intent that can only be sent
1864 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001865 */
1866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1867 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1868 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001869 * Broadcast Action: External power has been connected to the device.
1870 * This is intended for applications that wish to register specifically to this notification.
1871 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1872 * stay active to receive this notification. This action can be used to implement actions
1873 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001874 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001875 * <p class="note">This is a protected intent that can only be sent
1876 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001877 */
1878 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001879 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001880 /**
1881 * Broadcast Action: External power has been removed from the device.
1882 * This is intended for applications that wish to register specifically to this notification.
1883 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1884 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001885 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001886 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001887 * <p class="note">This is a protected intent that can only be sent
1888 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001889 */
1890 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001891 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001892 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001893 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001894 * Broadcast Action: Device is shutting down.
1895 * This is broadcast when the device is being shut down (completely turned
1896 * off, not sleeping). Once the broadcast is complete, the final shutdown
1897 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001898 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001899 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001900 * <p class="note">This is a protected intent that can only be sent
1901 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07001902 * <p>May include the following extras:
1903 * <ul>
1904 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
1905 * shutdown is only for userspace processes. If not set, assumed to be false.
1906 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07001907 */
1908 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001909 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001910 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001911 * Activity Action: Start this activity to request system shutdown.
1912 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1913 * to request confirmation from the user before shutting down.
1914 *
1915 * <p class="note">This is a protected intent that can only be sent
1916 * by the system.
1917 *
1918 * {@hide}
1919 */
1920 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1921 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001922 * Broadcast Action: A sticky broadcast that indicates low memory
1923 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001924 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001925 * <p class="note">This is a protected intent that can only be sent
1926 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001927 */
1928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1929 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1930 /**
1931 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001932 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001933 * <p class="note">This is a protected intent that can only be sent
1934 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001935 */
1936 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1937 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1938 /**
Jake Hambybb371632010-08-23 18:16:48 -07001939 * Broadcast Action: A sticky broadcast that indicates a memory full
1940 * condition on the device. This is intended for activities that want
1941 * to be able to fill the data partition completely, leaving only
1942 * enough free space to prevent system-wide SQLite failures.
1943 *
1944 * <p class="note">This is a protected intent that can only be sent
1945 * by the system.
1946 *
1947 * {@hide}
1948 */
1949 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1950 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1951 /**
1952 * Broadcast Action: Indicates memory full condition on the device
1953 * no longer exists.
1954 *
1955 * <p class="note">This is a protected intent that can only be sent
1956 * by the system.
1957 *
1958 * {@hide}
1959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
1962 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001963 * Broadcast Action: Indicates low memory condition notification acknowledged by user
1964 * and package management should be started.
1965 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
1966 * notification.
1967 */
1968 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1969 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
1970 /**
1971 * Broadcast Action: The device has entered USB Mass Storage mode.
1972 * This is used mainly for the USB Settings panel.
1973 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1974 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001975 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001976 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001977 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001978 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
1979
1980 /**
1981 * Broadcast Action: The device has exited USB Mass Storage mode.
1982 * This is used mainly for the USB Settings panel.
1983 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
1984 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07001985 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001986 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07001987 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001988 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
1989
1990 /**
1991 * Broadcast Action: External media has been removed.
1992 * The path to the mount point for the removed media is contained in the Intent.mData field.
1993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
1996
1997 /**
1998 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08001999 * The path to the mount point for the unmounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002000 */
2001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2002 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2003
2004 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002005 * Broadcast Action: External media is present, and being disk-checked
2006 * 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 -08002007 */
2008 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2009 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2010
2011 /**
2012 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2013 * 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 -08002014 */
2015 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2016 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2017
2018 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002019 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002020 * The path to the mount point for the mounted media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2022 * media was mounted read only.
2023 */
2024 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2025 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2026
2027 /**
2028 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002029 * 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 -07002030 */
2031 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2032 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2033
2034 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002035 * Broadcast Action: External media is no longer being shared via USB mass storage.
2036 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2037 *
2038 * @hide
2039 */
2040 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2041
2042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002043 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2044 * The path to the mount point for the removed media is contained in the Intent.mData field.
2045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2048
2049 /**
2050 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002051 * The path to the mount point for the unmountable media is contained in the Intent.mData field.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2054 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2055
2056 /**
2057 * Broadcast Action: User has expressed the desire to remove the external storage media.
2058 * Applications should close all files they have open within the mount point when they receive this intent.
2059 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2060 */
2061 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2062 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2063
2064 /**
2065 * Broadcast Action: The media scanner has started scanning a directory.
2066 * The path to the directory being scanned is contained in the Intent.mData field.
2067 */
2068 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2069 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2070
2071 /**
2072 * Broadcast Action: The media scanner has finished scanning a directory.
2073 * The path to the scanned directory is contained in the Intent.mData field.
2074 */
2075 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2076 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2077
2078 /**
2079 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2080 * The path to the file is contained in the Intent.mData field.
2081 */
2082 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2083 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2084
2085 /**
2086 * Broadcast Action: The "Media Button" was pressed. Includes a single
2087 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2088 * caused the broadcast.
2089 */
2090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2091 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2092
2093 /**
2094 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2095 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2096 * caused the broadcast.
2097 */
2098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2099 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2100
2101 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2102 // location; they are not general-purpose actions.
2103
2104 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002105 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002106 */
2107 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2108 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2109 "android.intent.action.GTALK_CONNECTED";
2110
2111 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002112 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 */
2114 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2115 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2116 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002117
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002118 /**
2119 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002120 */
2121 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2122 public static final String ACTION_INPUT_METHOD_CHANGED =
2123 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002124
2125 /**
2126 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2127 * more radios have been turned off or on. The intent will have the following extra value:</p>
2128 * <ul>
2129 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2130 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2131 * turned off</li>
2132 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002133 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002134 * <p class="note">This is a protected intent that can only be sent
2135 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002136 */
2137 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2138 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2139
2140 /**
2141 * Broadcast Action: Some content providers have parts of their namespace
2142 * where they publish new events or items that the user may be especially
2143 * interested in. For these things, they may broadcast this action when the
2144 * set of interesting items change.
2145 *
2146 * For example, GmailProvider sends this notification when the set of unread
2147 * mail in the inbox changes.
2148 *
2149 * <p>The data of the intent identifies which part of which provider
2150 * changed. When queried through the content resolver, the data URI will
2151 * return the data set in question.
2152 *
2153 * <p>The intent will have the following extra values:
2154 * <ul>
2155 * <li><em>count</em> - The number of items in the data set. This is the
2156 * same as the number of items in the cursor returned by querying the
2157 * data URI. </li>
2158 * </ul>
2159 *
2160 * This intent will be sent at boot (if the count is non-zero) and when the
2161 * data set changes. It is possible for the data set to change without the
2162 * count changing (for example, if a new unread message arrives in the same
2163 * sync operation in which a message is archived). The phone should still
2164 * ring/vibrate/etc as normal in this case.
2165 */
2166 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2167 public static final String ACTION_PROVIDER_CHANGED =
2168 "android.intent.action.PROVIDER_CHANGED";
2169
2170 /**
2171 * Broadcast Action: Wired Headset plugged in or unplugged.
2172 *
2173 * <p>The intent will have the following extra values:
2174 * <ul>
2175 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2176 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08002177 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002178 * </ul>
2179 * </ul>
2180 */
2181 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2182 public static final String ACTION_HEADSET_PLUG =
2183 "android.intent.action.HEADSET_PLUG";
2184
2185 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002186 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
2187 *
2188 * <p>The intent will have the following extra values:
2189 * <ul>
2190 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2191 * <li><em>name</em> - Headset type, human readable string </li>
2192 * </ul>
2193 * </ul>
2194 * @hide
2195 */
2196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002197 public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG =
2198 "android.intent.action.ANALOG_AUDIO_DOCK_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002199
2200 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07002201 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002202 *
2203 * <p>The intent will have the following extra values:
2204 * <ul>
2205 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2206 * <li><em>name</em> - Headset type, human readable string </li>
2207 * </ul>
2208 * </ul>
2209 * @hide
2210 */
2211 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002212 public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
2213 "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07002214
2215 /**
2216 * Broadcast Action: A HMDI cable was plugged or unplugged
2217 *
2218 * <p>The intent will have the following extra values:
2219 * <ul>
2220 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2221 * <li><em>name</em> - HDMI cable, human readable string </li>
2222 * </ul>
2223 * </ul>
2224 * @hide
2225 */
2226 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2227 public static final String ACTION_HDMI_AUDIO_PLUG =
2228 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002229
2230 /**
Mike Lockwood9d5a4be2012-04-06 09:41:32 -07002231 * Broadcast Action: A USB audio accessory was plugged in or unplugged.
2232 *
2233 * <p>The intent will have the following extra values:
2234 * <ul>
2235 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2236 * <li><em>card</em> - ALSA card number (integer) </li>
2237 * <li><em>device</em> - ALSA device number (integer) </li>
2238 * </ul>
2239 * </ul>
2240 * @hide
2241 */
2242 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2243 public static final String ACTION_USB_AUDIO_ACCESSORY_PLUG =
2244 "android.intent.action.USB_AUDIO_ACCESSORY_PLUG";
2245
2246 /**
Eric Laurent59f48272012-04-05 19:42:21 -07002247 * Broadcast Action: A USB audio device was plugged in or unplugged.
2248 *
2249 * <p>The intent will have the following extra values:
2250 * <ul>
2251 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2252 * <li><em>card</em> - ALSA card number (integer) </li>
2253 * <li><em>device</em> - ALSA device number (integer) </li>
2254 * </ul>
2255 * </ul>
2256 * @hide
2257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2259 public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
2260 "android.intent.action.USB_AUDIO_DEVICE_PLUG";
2261
2262 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002263 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2264 * <ul>
2265 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2266 * </ul>
2267 *
2268 * <p class="note">This is a protected intent that can only be sent
2269 * by the system.
2270 *
2271 * @hide
2272 */
2273 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2275 = "android.intent.action.ADVANCED_SETTINGS";
2276
2277 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002278 * Broadcast Action: An outgoing call is about to be placed.
2279 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002280 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002281 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002282 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002283 * the phone number originally intended to be dialed.</li>
2284 * </ul>
2285 * <p>Once the broadcast is finished, the resultData is used as the actual
2286 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002287 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002288 * outgoing call in turn: for example, a parental control application
2289 * might verify that the user is authorized to place the call at that
2290 * time, then a number-rewriting application might add an area code if
2291 * one was not specified.</p>
2292 * <p>For consistency, any receiver whose purpose is to prohibit phone
2293 * calls should have a priority of 0, to ensure it will see the final
2294 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002295 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002296 * should have a positive priority.
2297 * Negative priorities are reserved for the system for this broadcast;
2298 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002299 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2300 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002301 * <p>Emergency calls cannot be intercepted using this mechanism, and
2302 * other calls cannot be modified to call emergency numbers using this
2303 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002304 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2305 * call to use their own service instead. Those apps should first prevent
2306 * the call from being placed by setting resultData to <code>null</code>
2307 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002308 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002309 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2310 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002311 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002312 * <p class="note">This is a protected intent that can only be sent
2313 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002314 */
2315 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2316 public static final String ACTION_NEW_OUTGOING_CALL =
2317 "android.intent.action.NEW_OUTGOING_CALL";
2318
2319 /**
2320 * Broadcast Action: Have the device reboot. This is only for use by
2321 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002322 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002323 * <p class="note">This is a protected intent that can only be sent
2324 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002325 */
2326 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2327 public static final String ACTION_REBOOT =
2328 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002329
Wei Huang97ecc9c2009-05-11 17:44:20 -07002330 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002331 * Broadcast Action: A sticky broadcast for changes in the physical
2332 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002333 *
2334 * <p>The intent will have the following extra values:
2335 * <ul>
2336 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002337 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002338 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002339 * <p>This is intended for monitoring the current physical dock state.
2340 * See {@link android.app.UiModeManager} for the normal API dealing with
2341 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002342 */
2343 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2344 public static final String ACTION_DOCK_EVENT =
2345 "android.intent.action.DOCK_EVENT";
2346
2347 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002348 * Broadcast Action: A broadcast when idle maintenance can be started.
2349 * This means that the user is not interacting with the device and is
2350 * not expected to do so soon. Typical use of the idle maintenance is
2351 * to perform somehow expensive tasks that can be postponed at a moment
2352 * when they will not degrade user experience.
2353 * <p>
2354 * <p class="note">In order to keep the device responsive in case of an
2355 * unexpected user interaction, implementations of a maintenance task
2356 * should be interruptible. In such a scenario a broadcast with action
2357 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2358 * should not do the maintenance work in
2359 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2360 * maintenance service by {@link Context#startService(Intent)}. Also
2361 * you should hold a wake lock while your maintenance service is running
2362 * to prevent the device going to sleep.
2363 * </p>
2364 * <p>
2365 * <p class="note">This is a protected intent that can only be sent by
2366 * the system.
2367 * </p>
2368 *
2369 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002370 *
2371 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002372 */
2373 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2374 public static final String ACTION_IDLE_MAINTENANCE_START =
2375 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2376
2377 /**
2378 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2379 * This means that the user was not interacting with the device as a result
2380 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2381 * was sent and now the user started interacting with the device. Typical
2382 * use of the idle maintenance is to perform somehow expensive tasks that
2383 * can be postponed at a moment when they will not degrade user experience.
2384 * <p>
2385 * <p class="note">In order to keep the device responsive in case of an
2386 * unexpected user interaction, implementations of a maintenance task
2387 * should be interruptible. Hence, on receiving a broadcast with this
2388 * action, the maintenance task should be interrupted as soon as possible.
2389 * In other words, you should not do the maintenance work in
2390 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2391 * maintenance service that was started on receiving of
2392 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2393 * lock you acquired when your maintenance service started.
2394 * </p>
2395 * <p class="note">This is a protected intent that can only be sent
2396 * by the system.
2397 *
2398 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002399 *
2400 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002401 */
2402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2403 public static final String ACTION_IDLE_MAINTENANCE_END =
2404 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2405
2406 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002407 * Broadcast Action: a remote intent is to be broadcasted.
2408 *
2409 * A remote intent is used for remote RPC between devices. The remote intent
2410 * is serialized and sent from one device to another device. The receiving
2411 * device parses the remote intent and broadcasts it. Note that anyone can
2412 * broadcast a remote intent. However, if the intent receiver of the remote intent
2413 * does not trust intent broadcasts from arbitrary intent senders, it should require
2414 * the sender to hold certain permissions so only trusted sender's broadcast will be
2415 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002416 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002417 */
2418 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002419 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002420
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002421 /**
2422 * Broadcast Action: hook for permforming cleanup after a system update.
2423 *
2424 * The broadcast is sent when the system is booting, before the
2425 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2426 * image. A receiver for this should do its work and then disable itself
2427 * so that it does not get run again at the next boot.
2428 * @hide
2429 */
2430 public static final String ACTION_PRE_BOOT_COMPLETED =
2431 "android.intent.action.PRE_BOOT_COMPLETED";
2432
Amith Yamasani13593602012-03-22 16:16:17 -07002433 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002434 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002435 * on restricted users. The broadcast intent contains an extra
2436 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2437 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2438 * String[] depending on the restriction type.<p/>
2439 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002440 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2441 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2442 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002443 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2444 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002445 * @see RestrictionEntry
2446 */
2447 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2448 "android.intent.action.GET_RESTRICTION_ENTRIES";
2449
2450 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002451 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002452 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002453 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2454 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2455 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002456 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2457 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2458 * challenge.<p/>
2459 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002460 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002461 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002462 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2463 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002464
2465 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002466 * Sent the first time a user is starting, to allow system apps to
2467 * perform one time initialization. (This will not be seen by third
2468 * party applications because a newly initialized user does not have any
2469 * third party applications installed for it.) This is sent early in
2470 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002471 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2472 * broadcast, since it is part of a visible user interaction; be as quick
2473 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002474 */
2475 public static final String ACTION_USER_INITIALIZE =
2476 "android.intent.action.USER_INITIALIZE";
2477
2478 /**
2479 * Sent when a user switch is happening, causing the process's user to be
2480 * brought to the foreground. This is only sent to receivers registered
2481 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2482 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002483 * foreground. This is sent as a foreground
2484 * broadcast, since it is part of a visible user interaction; be as quick
2485 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002486 */
2487 public static final String ACTION_USER_FOREGROUND =
2488 "android.intent.action.USER_FOREGROUND";
2489
2490 /**
2491 * Sent when a user switch is happening, causing the process's user to be
2492 * sent to the background. This is only sent to receivers registered
2493 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2494 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002495 * background. This is sent as a foreground
2496 * broadcast, since it is part of a visible user interaction; be as quick
2497 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002498 */
2499 public static final String ACTION_USER_BACKGROUND =
2500 "android.intent.action.USER_BACKGROUND";
2501
2502 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002503 * Broadcast sent to the system when a user is added. Carries an extra
2504 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2505 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002506 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002507 * @hide
2508 */
2509 public static final String ACTION_USER_ADDED =
2510 "android.intent.action.USER_ADDED";
2511
2512 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002513 * Broadcast sent by the system when a user is started. Carries an extra
2514 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002515 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002516 * that has been started. This is sent as a foreground
2517 * broadcast, since it is part of a visible user interaction; be as quick
2518 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002519 * @hide
2520 */
2521 public static final String ACTION_USER_STARTED =
2522 "android.intent.action.USER_STARTED";
2523
2524 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002525 * Broadcast sent when a user is in the process of starting. Carries an extra
2526 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2527 * sent to registered receivers, not manifest receivers. It is sent to all
2528 * users (including the one that is being started). You must hold
2529 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2530 * this broadcast. This is sent as a background broadcast, since
2531 * its result is not part of the primary UX flow; to safely keep track of
2532 * started/stopped state of a user you can use this in conjunction with
2533 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2534 * other user state broadcasts since those are foreground broadcasts so can
2535 * execute in a different order.
2536 * @hide
2537 */
2538 public static final String ACTION_USER_STARTING =
2539 "android.intent.action.USER_STARTING";
2540
2541 /**
2542 * Broadcast sent when a user is going to be stopped. Carries an extra
2543 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2544 * sent to registered receivers, not manifest receivers. It is sent to all
2545 * users (including the one that is being stopped). You must hold
2546 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2547 * this broadcast. The user will not stop until all receivers have
2548 * handled the broadcast. This is sent as a background broadcast, since
2549 * its result is not part of the primary UX flow; to safely keep track of
2550 * started/stopped state of a user you can use this in conjunction with
2551 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2552 * other user state broadcasts since those are foreground broadcasts so can
2553 * execute in a different order.
2554 * @hide
2555 */
2556 public static final String ACTION_USER_STOPPING =
2557 "android.intent.action.USER_STOPPING";
2558
2559 /**
2560 * Broadcast sent to the system when a user is stopped. Carries an extra
2561 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2562 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2563 * specific package. This is only sent to registered receivers, not manifest
2564 * receivers. It is sent to all running users <em>except</em> the one that
2565 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002566 * @hide
2567 */
2568 public static final String ACTION_USER_STOPPED =
2569 "android.intent.action.USER_STOPPED";
2570
2571 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002572 * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002573 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002574 * one that has been removed. The user will not be completely removed until all receivers have
2575 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002576 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002577 * @hide
2578 */
2579 public static final String ACTION_USER_REMOVED =
2580 "android.intent.action.USER_REMOVED";
2581
2582 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002583 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002584 * the userHandle of the user to become the current one. This is only sent to
2585 * registered receivers, not manifest receivers. It is sent to all running users.
2586 * You must hold
2587 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002588 * @hide
2589 */
2590 public static final String ACTION_USER_SWITCHED =
2591 "android.intent.action.USER_SWITCHED";
2592
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002593 /**
2594 * Broadcast sent to the system when a user's information changes. Carries an extra
2595 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002596 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002597 * @hide
2598 */
2599 public static final String ACTION_USER_INFO_CHANGED =
2600 "android.intent.action.USER_INFO_CHANGED";
2601
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002602 /**
2603 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2604 */
2605 public static final String ACTION_QUICK_CLOCK =
2606 "android.intent.action.QUICK_CLOCK";
2607
Michael Wright0087a142013-02-05 16:29:39 -08002608 /**
2609 * Broadcast Action: This is broadcast when a user action should request the
2610 * brightness setting dialog.
2611 * @hide
2612 */
2613 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2614 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2615
Justin Kohd378ad72013-04-01 12:18:26 -07002616 /**
2617 * Broadcast Action: A global button was pressed. Includes a single
2618 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2619 * caused the broadcast.
2620 * @hide
2621 */
2622 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2623
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002624 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002625 * Activity Action: Allow the user to select and return one or more existing
2626 * documents. When invoked, the system will display the various
2627 * {@link DocumentsProvider} instances installed on the device, letting the
2628 * user interactively navigate through them. These documents include local
2629 * media, such as photos and video, and documents provided by installed
2630 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002631 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002632 * Each document is represented as a {@code content://} URI backed by a
2633 * {@link DocumentsProvider}, which can be opened as a stream with
2634 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2635 * {@link android.provider.DocumentsContract.Document} metadata.
2636 * <p>
2637 * All selected documents are returned to the calling application with
2638 * persistable read and write permission grants. If you want to maintain
2639 * access to the documents across device reboots, you need to explicitly
2640 * take the persistable permissions using
2641 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2642 * <p>
2643 * Callers can restrict document selection to a specific kind of data, such
2644 * as photos, by setting one or more MIME types in
2645 * {@link #EXTRA_MIME_TYPES}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002646 * <p>
2647 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002648 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2649 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002650 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002651 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2652 * returned URIs can be opened with
2653 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002654 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002655 * Output: The URI of the item that was picked. This must be a
2656 * {@code content://} URI so that any receiver can access it. If multiple
2657 * documents were selected, they are returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002658 *
2659 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002660 * @see #ACTION_CREATE_DOCUMENT
2661 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002662 */
2663 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2664 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2665
2666 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002667 * Activity Action: Allow the user to create a new document. When invoked,
2668 * the system will display the various {@link DocumentsProvider} instances
2669 * installed on the device, letting the user navigate through them. The
2670 * returned document may be a newly created document with no content, or it
2671 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002672 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002673 * Each document is represented as a {@code content://} URI backed by a
2674 * {@link DocumentsProvider}, which can be opened as a stream with
2675 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2676 * {@link android.provider.DocumentsContract.Document} metadata.
2677 * <p>
2678 * Callers must indicate the concrete MIME type of the document being
2679 * created by setting {@link #setType(String)}. This MIME type cannot be
2680 * changed after the document is created.
2681 * <p>
2682 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2683 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002684 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002685 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2686 * returned URIs can be opened with
2687 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002688 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002689 * Output: The URI of the item that was created. This must be a
2690 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002691 *
2692 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002693 * @see #ACTION_OPEN_DOCUMENT
2694 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002695 */
2696 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2697 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002699 // ---------------------------------------------------------------------
2700 // ---------------------------------------------------------------------
2701 // Standard intent categories (see addCategory()).
2702
2703 /**
2704 * Set if the activity should be an option for the default action
2705 * (center press) to perform on a piece of data. Setting this will
2706 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002707 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002708 * Intent when initiating an action -- it is for use in intent filters
2709 * specified in packages.
2710 */
2711 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2712 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2713 /**
2714 * Activities that can be safely invoked from a browser must support this
2715 * category. For example, if the user is viewing a web page or an e-mail
2716 * and clicks on a link in the text, the Intent generated execute that
2717 * link will require the BROWSABLE category, so that only activities
2718 * supporting this category will be considered as possible actions. By
2719 * supporting this category, you are promising that there is nothing
2720 * damaging (without user intervention) that can happen by invoking any
2721 * matching Intent.
2722 */
2723 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2724 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2725 /**
2726 * Set if the activity should be considered as an alternative action to
2727 * the data the user is currently viewing. See also
2728 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2729 * applies to the selection in a list of items.
2730 *
2731 * <p>Supporting this category means that you would like your activity to be
2732 * displayed in the set of alternative things the user can do, usually as
2733 * part of the current activity's options menu. You will usually want to
2734 * include a specific label in the &lt;intent-filter&gt; of this action
2735 * describing to the user what it does.
2736 *
2737 * <p>The action of IntentFilter with this category is important in that it
2738 * describes the specific action the target will perform. This generally
2739 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2740 * a specific name such as "com.android.camera.action.CROP. Only one
2741 * alternative of any particular action will be shown to the user, so using
2742 * a specific action like this makes sure that your alternative will be
2743 * displayed while also allowing other applications to provide their own
2744 * overrides of that particular action.
2745 */
2746 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2747 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2748 /**
2749 * Set if the activity should be considered as an alternative selection
2750 * action to the data the user has currently selected. This is like
2751 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2752 * of items from which the user can select, giving them alternatives to the
2753 * default action that will be performed on it.
2754 */
2755 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2756 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2757 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002758 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002759 */
2760 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2761 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2762 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002763 * Should be displayed in the top-level launcher.
2764 */
2765 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2766 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2767 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002768 * Provides information about the package it is in; typically used if
2769 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2770 * a front-door to the user without having to be shown in the all apps list.
2771 */
2772 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2773 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2774 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002775 * This is the home activity, that is the first activity that is displayed
2776 * when the device boots.
2777 */
2778 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2779 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2780 /**
2781 * This activity is a preference panel.
2782 */
2783 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2784 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2785 /**
2786 * This activity is a development preference panel.
2787 */
2788 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2789 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2790 /**
2791 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002792 */
2793 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2794 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2795 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002796 * This activity allows the user to browse and download new applications.
2797 */
2798 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2799 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2800 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002801 * This activity may be exercised by the monkey or other automated test tools.
2802 */
2803 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2804 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2805 /**
2806 * To be used as a test (not part of the normal user experience).
2807 */
2808 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2809 /**
2810 * To be used as a unit test (run through the Test Harness).
2811 */
2812 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2813 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002814 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002815 * experience).
2816 */
2817 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002818
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002819 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002820 * Used to indicate that an intent only wants URIs that can be opened with
2821 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
2822 * must support at least the columns defined in {@link OpenableColumns} when
2823 * queried.
2824 *
2825 * @see #ACTION_GET_CONTENT
2826 * @see #ACTION_OPEN_DOCUMENT
2827 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002828 */
2829 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2830 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2831
2832 /**
2833 * To be used as code under test for framework instrumentation tests.
2834 */
2835 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2836 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002837 /**
2838 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002839 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2840 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002841 */
2842 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2843 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2844 /**
2845 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002846 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2847 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002848 */
2849 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2850 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002851 /**
2852 * An activity to run when device is inserted into a analog (low end) dock.
2853 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2854 * information, see {@link android.app.UiModeManager}.
2855 */
2856 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2857 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2858
2859 /**
2860 * An activity to run when device is inserted into a digital (high end) dock.
2861 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2862 * information, see {@link android.app.UiModeManager}.
2863 */
2864 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2865 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002866
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002867 /**
2868 * Used to indicate that the activity can be used in a car environment.
2869 */
2870 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2871 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2872
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002873 // ---------------------------------------------------------------------
2874 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08002875 // Application launch intent categories (see addCategory()).
2876
2877 /**
2878 * Used with {@link #ACTION_MAIN} to launch the browser application.
2879 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002880 * <p>NOTE: This should not be used as the primary key of an Intent,
2881 * since it will not result in the app launching with the correct
2882 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002883 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002884 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002885 */
2886 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2887 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
2888
2889 /**
2890 * Used with {@link #ACTION_MAIN} to launch the calculator application.
2891 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002892 * <p>NOTE: This should not be used as the primary key of an Intent,
2893 * since it will not result in the app launching with the correct
2894 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002895 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002896 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002897 */
2898 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2899 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
2900
2901 /**
2902 * Used with {@link #ACTION_MAIN} to launch the calendar application.
2903 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002904 * <p>NOTE: This should not be used as the primary key of an Intent,
2905 * since it will not result in the app launching with the correct
2906 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002907 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002908 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002909 */
2910 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2911 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
2912
2913 /**
2914 * Used with {@link #ACTION_MAIN} to launch the contacts application.
2915 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002916 * <p>NOTE: This should not be used as the primary key of an Intent,
2917 * since it will not result in the app launching with the correct
2918 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002919 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002920 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002921 */
2922 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2923 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
2924
2925 /**
2926 * Used with {@link #ACTION_MAIN} to launch the email application.
2927 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002928 * <p>NOTE: This should not be used as the primary key of an Intent,
2929 * since it will not result in the app launching with the correct
2930 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002931 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002932 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002933 */
2934 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2935 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
2936
2937 /**
2938 * Used with {@link #ACTION_MAIN} to launch the gallery application.
2939 * The activity should be able to view and manipulate image and video files
2940 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002941 * <p>NOTE: This should not be used as the primary key of an Intent,
2942 * since it will not result in the app launching with the correct
2943 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002944 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002945 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002946 */
2947 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2948 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
2949
2950 /**
2951 * Used with {@link #ACTION_MAIN} to launch the maps application.
2952 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002953 * <p>NOTE: This should not be used as the primary key of an Intent,
2954 * since it will not result in the app launching with the correct
2955 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002956 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002957 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002958 */
2959 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2960 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
2961
2962 /**
2963 * Used with {@link #ACTION_MAIN} to launch the messaging application.
2964 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002965 * <p>NOTE: This should not be used as the primary key of an Intent,
2966 * since it will not result in the app launching with the correct
2967 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002968 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002969 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002970 */
2971 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2972 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
2973
2974 /**
2975 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002976 * The activity should be able to play, browse, or manipulate music files
2977 * stored on the device.
2978 * <p>NOTE: This should not be used as the primary key of an Intent,
2979 * since it will not result in the app launching with the correct
2980 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002981 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002982 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08002983 */
2984 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2985 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
2986
2987 // ---------------------------------------------------------------------
2988 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002989 // Standard extra data keys.
2990
2991 /**
2992 * The initial data to place in a newly created record. Use with
2993 * {@link #ACTION_INSERT}. The data here is a Map containing the same
2994 * fields as would be given to the underlying ContentProvider.insert()
2995 * call.
2996 */
2997 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
2998
2999 /**
3000 * A constant CharSequence that is associated with the Intent, used with
3001 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3002 * this may be a styled CharSequence, so you must use
3003 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3004 * retrieve it.
3005 */
3006 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3007
3008 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003009 * A constant String that is associated with the Intent, used with
3010 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3011 * as HTML formatted text. Note that you <em>must</em> also supply
3012 * {@link #EXTRA_TEXT}.
3013 */
3014 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3015
3016 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003017 * A content: URI holding a stream of data associated with the Intent,
3018 * used with {@link #ACTION_SEND} to supply the data being sent.
3019 */
3020 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3021
3022 /**
3023 * A String[] holding e-mail addresses that should be delivered to.
3024 */
3025 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3026
3027 /**
3028 * A String[] holding e-mail addresses that should be carbon copied.
3029 */
3030 public static final String EXTRA_CC = "android.intent.extra.CC";
3031
3032 /**
3033 * A String[] holding e-mail addresses that should be blind carbon copied.
3034 */
3035 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3036
3037 /**
3038 * A constant string holding the desired subject line of a message.
3039 */
3040 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3041
3042 /**
3043 * An Intent describing the choices you would like shown with
3044 * {@link #ACTION_PICK_ACTIVITY}.
3045 */
3046 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3047
3048 /**
3049 * A CharSequence dialog title to provide to the user when used with a
3050 * {@link #ACTION_CHOOSER}.
3051 */
3052 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3053
3054 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003055 * A Parcelable[] of {@link Intent} or
3056 * {@link android.content.pm.LabeledIntent} objects as set with
3057 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3058 * a the front of the list of choices, when shown to the user with a
3059 * {@link #ACTION_CHOOSER}.
3060 */
3061 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3062
3063 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003064 * A {@link android.view.KeyEvent} object containing the event that
3065 * triggered the creation of the Intent it is in.
3066 */
3067 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3068
3069 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003070 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3071 * before shutting down.
3072 *
3073 * {@hide}
3074 */
3075 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3076
3077 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003078 * 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 -07003079 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3080 * of restarting the application.
3081 */
3082 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3083
3084 /**
3085 * A String holding the phone number originally entered in
3086 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3087 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3088 */
3089 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003090
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003091 /**
3092 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3093 * intents to supply the uid the package had been assigned. Also an optional
3094 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3095 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3096 * purpose.
3097 */
3098 public static final String EXTRA_UID = "android.intent.extra.UID";
3099
3100 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003101 * @hide String array of package names.
3102 */
3103 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3104
3105 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003106 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3107 * intents to indicate whether this represents a full uninstall (removing
3108 * both the code and its data) or a partial uninstall (leaving its data,
3109 * implying that this is an update).
3110 */
3111 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003112
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003113 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003114 * @hide
3115 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3116 * intents to indicate that at this point the package has been removed for
3117 * all users on the device.
3118 */
3119 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3120 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3121
3122 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003123 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3124 * intents to indicate that this is a replacement of the package, so this
3125 * broadcast will immediately be followed by an add broadcast for a
3126 * different version of the same package.
3127 */
3128 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003129
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003130 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003131 * Used as an int extra field in {@link android.app.AlarmManager} intents
3132 * to tell the application being invoked how many pending alarms are being
3133 * delievered with the intent. For one-shot alarms this will always be 1.
3134 * For recurring alarms, this might be greater than 1 if the device was
3135 * asleep or powered off at the time an earlier alarm would have been
3136 * delivered.
3137 */
3138 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003139
Jacek Surazski86b6c532009-05-13 14:38:28 +02003140 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003141 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3142 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003143 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3144 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003145 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3146 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3147 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003148 */
3149 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3150
3151 /**
3152 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3153 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003154 */
3155 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3156
3157 /**
3158 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3159 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003160 */
3161 public static final int EXTRA_DOCK_STATE_DESK = 1;
3162
3163 /**
3164 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3165 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003166 */
3167 public static final int EXTRA_DOCK_STATE_CAR = 2;
3168
3169 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003170 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3171 * to represent that the phone is in a analog (low end) dock.
3172 */
3173 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3174
3175 /**
3176 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3177 * to represent that the phone is in a digital (high end) dock.
3178 */
3179 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3180
3181 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003182 * Boolean that can be supplied as meta-data with a dock activity, to
3183 * indicate that the dock should take over the home key when it is active.
3184 */
3185 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003186
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003187 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003188 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3189 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003190 */
3191 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3192
3193 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003194 * Used in the extra field in the remote intent. It's astring token passed with the
3195 * remote intent.
3196 */
3197 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3198 "android.intent.extra.remote_intent_token";
3199
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003200 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003201 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003202 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003203 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003204 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003205 "android.intent.extra.changed_component_name";
3206
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003207 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003208 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003209 * and contains a string array of all of the components that have changed. If
3210 * the state of the overall package has changed, then it will contain an entry
3211 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003212 */
3213 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3214 "android.intent.extra.changed_component_name_list";
3215
3216 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003217 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003218 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3219 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003220 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003221 */
3222 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3223 "android.intent.extra.changed_package_list";
3224
3225 /**
3226 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003227 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3228 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003229 * and contains an integer array of uids of all of the components
3230 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003231 */
3232 public static final String EXTRA_CHANGED_UID_LIST =
3233 "android.intent.extra.changed_uid_list";
3234
3235 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003236 * @hide
3237 * Magic extra system code can use when binding, to give a label for
3238 * who it is that has bound to a service. This is an integer giving
3239 * a framework string resource that can be displayed to the user.
3240 */
3241 public static final String EXTRA_CLIENT_LABEL =
3242 "android.intent.extra.client_label";
3243
3244 /**
3245 * @hide
3246 * Magic extra system code can use when binding, to give a PendingIntent object
3247 * that can be launched for the user to disable the system's use of this
3248 * service.
3249 */
3250 public static final String EXTRA_CLIENT_INTENT =
3251 "android.intent.extra.client_intent";
3252
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003253 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003254 * Extra used to indicate that an intent should only return data that is on
3255 * the local device. This is a boolean extra; the default is false. If true,
3256 * an implementation should only allow the user to select data that is
3257 * already on the device, not requiring it be downloaded from a remote
3258 * service when opened.
3259 *
3260 * @see #ACTION_GET_CONTENT
3261 * @see #ACTION_OPEN_DOCUMENT
3262 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003263 */
3264 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003265 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003266
Amith Yamasani13593602012-03-22 16:16:17 -07003267 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003268 * Extra used to indicate that an intent can allow the user to select and
3269 * return multiple items. This is a boolean extra; the default is false. If
3270 * true, an implementation is allowed to present the user with a UI where
3271 * they can pick multiple items that are all returned to the caller. When
3272 * this happens, they should be returned as the {@link #getClipData()} part
3273 * of the result Intent.
3274 *
3275 * @see #ACTION_GET_CONTENT
3276 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003277 */
3278 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003279 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003280
3281 /**
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003282 * The userHandle carried with broadcast intents related to addition, removal and switching of
3283 * users
Amith Yamasani13593602012-03-22 16:16:17 -07003284 * - {@link #ACTION_USER_ADDED}, {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3285 * @hide
3286 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003287 public static final String EXTRA_USER_HANDLE =
3288 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003289
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003290 /**
3291 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003292 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3293 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003294 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003295 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3296
3297 /**
3298 * Extra sent in the intent to the BroadcastReceiver that handles
3299 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3300 * the restrictions as key/value pairs.
3301 */
3302 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3303 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003304
Amith Yamasani86118ba2013-03-28 14:33:16 -07003305 /**
3306 * Extra used in the response from a BroadcastReceiver that handles
3307 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3308 */
3309 public static final String EXTRA_RESTRICTIONS_INTENT =
3310 "android.intent.extra.restrictions_intent";
3311
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003312 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003313 * Extra used to communicate a set of acceptable MIME types. The type of the
3314 * extra is {@code String[]}. Values may be a combination of concrete MIME
3315 * types (such as "image/png") and/or partial MIME types (such as
3316 * "audio/*").
3317 *
3318 * @see #ACTION_GET_CONTENT
3319 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003320 */
3321 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3322
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003323 /**
3324 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3325 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003326 * When this is true, hardware devices can use this information to determine that
3327 * they shouldn't do a complete shutdown of their device since this is not a
3328 * complete shutdown down to the kernel, but only user space restarting.
3329 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003330 */
3331 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3332 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3333
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003334 // ---------------------------------------------------------------------
3335 // ---------------------------------------------------------------------
3336 // Intent flags (see mFlags variable).
3337
3338 /**
3339 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003340 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003341 * specified in its ClipData. When applying to an Intent's ClipData,
3342 * all URIs as well as recursive traversals through data or other ClipData
3343 * in Intent items will be granted; only the grant flags of the top-level
3344 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003345 */
3346 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3347 /**
3348 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003349 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003350 * specified in its ClipData. When applying to an Intent's ClipData,
3351 * all URIs as well as recursive traversals through data or other ClipData
3352 * in Intent items will be granted; only the grant flags of the top-level
3353 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003354 */
3355 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3356 /**
3357 * Can be set by the caller to indicate that this Intent is coming from
3358 * a background operation, not from direct user interaction.
3359 */
3360 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3361 /**
3362 * A flag you can enable for debugging: when set, log messages will be
3363 * printed during the resolution of this intent to show you what has
3364 * been found to create the final resolved list.
3365 */
3366 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003367 /**
3368 * If set, this intent will not match any components in packages that
3369 * are currently stopped. If this is not set, then the default behavior
3370 * is to include such applications in the result.
3371 */
3372 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3373 /**
3374 * If set, this intent will always match any components in packages that
3375 * are currently stopped. This is the default behavior when
3376 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3377 * flags are set, this one wins (it allows overriding of exclude for
3378 * places where the framework may automatically set the exclude flag).
3379 */
3380 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003381
3382 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003383 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003384 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003385 * persisted across device reboots until explicitly revoked with
3386 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3387 * grant for possible persisting; the receiving application must call
3388 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3389 * actually persist.
3390 *
3391 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3392 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3393 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003394 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003395 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003396 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003397
3398 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003399 * If set, the new activity is not kept in the history stack. As soon as
3400 * the user navigates away from it, the activity is finished. This may also
3401 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3402 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003403 */
3404 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3405 /**
3406 * If set, the activity will not be launched if it is already running
3407 * at the top of the history stack.
3408 */
3409 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3410 /**
3411 * If set, this activity will become the start of a new task on this
3412 * history stack. A task (from the activity that started it to the
3413 * next task activity) defines an atomic group of activities that the
3414 * user can move to. Tasks can be moved to the foreground and background;
3415 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003416 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003417 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3418 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003419 *
3420 * <p>This flag is generally used by activities that want
3421 * to present a "launcher" style behavior: they give the user a list of
3422 * separate things that can be done, which otherwise run completely
3423 * independently of the activity launching them.
3424 *
3425 * <p>When using this flag, if a task is already running for the activity
3426 * you are now starting, then a new activity will not be started; instead,
3427 * the current task will simply be brought to the front of the screen with
3428 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3429 * to disable this behavior.
3430 *
3431 * <p>This flag can not be used when the caller is requesting a result from
3432 * the activity being launched.
3433 */
3434 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3435 /**
3436 * <strong>Do not use this flag unless you are implementing your own
3437 * top-level application launcher.</strong> Used in conjunction with
3438 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3439 * behavior of bringing an existing task to the foreground. When set,
3440 * a new task is <em>always</em> started to host the Activity for the
3441 * Intent, regardless of whether there is already an existing task running
3442 * the same thing.
3443 *
3444 * <p><strong>Because the default system does not include graphical task management,
3445 * you should not use this flag unless you provide some way for a user to
3446 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003447 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003448 * <p>This flag is ignored if
3449 * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
3450 *
Scott Main7aee61f2011-02-08 11:25:01 -08003451 * <p>See
3452 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3453 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003454 */
3455 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3456 /**
3457 * If set, and the activity being launched is already running in the
3458 * current task, then instead of launching a new instance of that activity,
3459 * all of the other activities on top of it will be closed and this Intent
3460 * will be delivered to the (now on top) old activity as a new Intent.
3461 *
3462 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3463 * If D calls startActivity() with an Intent that resolves to the component
3464 * of activity B, then C and D will be finished and B receive the given
3465 * Intent, resulting in the stack now being: A, B.
3466 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003467 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003468 * either receive the new intent you are starting here in its
3469 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003470 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003471 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3472 * the same intent, then it will be finished and re-created; for all other
3473 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3474 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003475 *
3476 * <p>This launch mode can also be used to good effect in conjunction with
3477 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3478 * of a task, it will bring any currently running instance of that task
3479 * to the foreground, and then clear it to its root state. This is
3480 * especially useful, for example, when launching an activity from the
3481 * notification manager.
3482 *
Scott Main7aee61f2011-02-08 11:25:01 -08003483 * <p>See
3484 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3485 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003486 */
3487 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3488 /**
3489 * If set and this intent is being used to launch a new activity from an
3490 * existing one, then the reply target of the existing activity will be
3491 * transfered to the new activity. This way the new activity can call
3492 * {@link android.app.Activity#setResult} and have that result sent back to
3493 * the reply target of the original activity.
3494 */
3495 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3496 /**
3497 * If set and this intent is being used to launch a new activity from an
3498 * existing one, the current activity will not be counted as the top
3499 * activity for deciding whether the new intent should be delivered to
3500 * the top instead of starting a new one. The previous activity will
3501 * be used as the top, with the assumption being that the current activity
3502 * will finish itself immediately.
3503 */
3504 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3505 /**
3506 * If set, the new activity is not kept in the list of recently launched
3507 * activities.
3508 */
3509 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3510 /**
3511 * This flag is not normally set by application code, but set for you by
3512 * the system as described in the
3513 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3514 * launchMode} documentation for the singleTask mode.
3515 */
3516 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3517 /**
3518 * If set, and this activity is either being started in a new task or
3519 * bringing to the top an existing task, then it will be launched as
3520 * the front door of the task. This will result in the application of
3521 * any affinities needed to have that task in the proper state (either
3522 * moving activities to or from it), or simply resetting that task to
3523 * its initial state if needed.
3524 */
3525 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3526 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003527 * This flag is not normally set by application code, but set for you by
3528 * the system if this activity is being launched from history
3529 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003530 */
3531 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003532 /**
3533 * If set, this marks a point in the task's activity stack that should
3534 * be cleared when the task is reset. That is, the next time the task
Marco Nelissenc53fc4e2009-05-11 12:15:31 -07003535 * is brought to the foreground with
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003536 * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
3537 * the user re-launching it from home), this activity and all on top of
3538 * it will be finished so that the user does not return to them, but
3539 * instead returns to whatever activity preceeded it.
The Android Open Source Project10592532009-03-18 17:39:46 -07003540 *
Craig Mautnere1f3fa22014-01-24 18:02:10 -08003541 * <p>When this flag is assigned to the root activity all activities up
3542 * to, but not including the root activity, will be cleared. This prevents
3543 * this flag from being used to finish all activities in a task and thereby
3544 * ending the task.
3545 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003546 * <p>This is useful for cases where you have a logical break in your
3547 * application. For example, an e-mail application may have a command
3548 * to view an attachment, which launches an image view activity to
3549 * display it. This activity should be part of the e-mail application's
3550 * task, since it is a part of the task the user is involved in. However,
3551 * if the user leaves that task, and later selects the e-mail app from
3552 * home, we may like them to return to the conversation they were
3553 * viewing, not the picture attachment, since that is confusing. By
3554 * setting this flag when launching the image viewer, that viewer and
3555 * any activities it starts will be removed the next time the user returns
3556 * to mail.
3557 */
3558 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003559 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003560 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003561 * callback from occurring on the current frontmost activity before it is
3562 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003563 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003564 * <p>Typically, an activity can rely on that callback to indicate that an
3565 * explicit user action has caused their activity to be moved out of the
3566 * foreground. The callback marks an appropriate point in the activity's
3567 * lifecycle for it to dismiss any notifications that it intends to display
3568 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003569 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003570 * <p>If an activity is ever started via any non-user-driven events such as
3571 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3572 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003573 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003574 */
3575 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003576 /**
3577 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3578 * this flag will cause the launched activity to be brought to the front of its
3579 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003580 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003581 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3582 * If D calls startActivity() with an Intent that resolves to the component
3583 * of activity B, then B will be brought to the front of the history stack,
3584 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003585 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003586 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003587 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003588 */
3589 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003590 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003591 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3592 * this flag will prevent the system from applying an activity transition
3593 * animation to go to the next activity state. This doesn't mean an
3594 * animation will never run -- if another activity change happens that doesn't
3595 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003596 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003597 * when you are going to do a series of activity operations but the
3598 * animation seen by the user shouldn't be driven by the first activity
3599 * change but rather a later one.
3600 */
3601 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3602 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003603 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3604 * this flag will cause any existing task that would be associated with the
3605 * activity to be cleared before the activity is started. That is, the activity
3606 * becomes the new root of an otherwise empty task, and any old activities
3607 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3608 */
3609 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3610 /**
3611 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3612 * this flag will cause a newly launching task to be placed on top of the current
3613 * home activity task (if there is one). That is, pressing back from the task
3614 * will always return the user to home even if that was not the last activity they
3615 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3616 */
3617 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3618 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003619 * If set, when sending a broadcast only registered receivers will be
3620 * called -- no BroadcastReceiver components will be launched.
3621 */
3622 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003623 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003624 * If set, when sending a broadcast the new broadcast will replace
3625 * any existing pending broadcast that matches it. Matching is defined
3626 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
3627 * true for the intents of the two broadcasts. When a match is found,
3628 * the new broadcast (and receivers associated with it) will replace the
3629 * existing one in the pending broadcast list, remaining at the same
3630 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08003631 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003632 * <p>This flag is most typically used with sticky broadcasts, which
3633 * only care about delivering the most recent values of the broadcast
3634 * to their receivers.
3635 */
3636 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
3637 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08003638 * If set, when sending a broadcast the recipient is allowed to run at
3639 * foreground priority, with a shorter timeout interval. During normal
3640 * broadcasts the receivers are not automatically hoisted out of the
3641 * background priority class.
3642 */
3643 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
3644 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07003645 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
3646 * They can still propagate results through to later receivers, but they can not prevent
3647 * later receivers from seeing the broadcast.
3648 */
3649 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
3650 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003651 * If set, when sending a broadcast <i>before boot has completed</i> only
3652 * registered receivers will be called -- no BroadcastReceiver components
3653 * will be launched. Sticky intent state will be recorded properly even
3654 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
3655 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07003656 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003657 * <p>This flag is only for use by system sevices as a convenience to
3658 * avoid having to implement a more complex mechanism around detection
3659 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07003660 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003661 * @hide
3662 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003663 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003664 /**
3665 * Set when this broadcast is for a boot upgrade, a special mode that
3666 * allows the broadcast to be sent before the system is ready and launches
3667 * the app process with no providers running in it.
3668 * @hide
3669 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003670 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003671
Dianne Hackbornfa82f222009-09-17 15:14:12 -07003672 /**
3673 * @hide Flags that can't be changed with PendingIntent.
3674 */
3675 public static final int IMMUTABLE_FLAGS =
3676 FLAG_GRANT_READ_URI_PERMISSION
3677 | FLAG_GRANT_WRITE_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08003678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003679 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003680 // ---------------------------------------------------------------------
3681 // toUri() and parseUri() options.
3682
3683 /**
3684 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3685 * always has the "intent:" scheme. This syntax can be used when you want
3686 * to later disambiguate between URIs that are intended to describe an
3687 * Intent vs. all others that should be treated as raw URIs. When used
3688 * with {@link #parseUri}, any other scheme will result in a generic
3689 * VIEW action for that raw URI.
3690 */
3691 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08003692
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003693 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003694
3695 private String mAction;
3696 private Uri mData;
3697 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003698 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003699 private ComponentName mComponent;
3700 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003701 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003702 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003703 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003704 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003705 private ClipData mClipData;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003706
3707 // ---------------------------------------------------------------------
3708
3709 /**
3710 * Create an empty intent.
3711 */
3712 public Intent() {
3713 }
3714
3715 /**
3716 * Copy constructor.
3717 */
3718 public Intent(Intent o) {
3719 this.mAction = o.mAction;
3720 this.mData = o.mData;
3721 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003722 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003723 this.mComponent = o.mComponent;
3724 this.mFlags = o.mFlags;
3725 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003726 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003727 }
3728 if (o.mExtras != null) {
3729 this.mExtras = new Bundle(o.mExtras);
3730 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003731 if (o.mSourceBounds != null) {
3732 this.mSourceBounds = new Rect(o.mSourceBounds);
3733 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003734 if (o.mSelector != null) {
3735 this.mSelector = new Intent(o.mSelector);
3736 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003737 if (o.mClipData != null) {
3738 this.mClipData = new ClipData(o.mClipData);
3739 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003740 }
3741
3742 @Override
3743 public Object clone() {
3744 return new Intent(this);
3745 }
3746
3747 private Intent(Intent o, boolean all) {
3748 this.mAction = o.mAction;
3749 this.mData = o.mData;
3750 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003751 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003752 this.mComponent = o.mComponent;
3753 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003754 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003755 }
3756 }
3757
3758 /**
3759 * Make a clone of only the parts of the Intent that are relevant for
3760 * filter matching: the action, data, type, component, and categories.
3761 */
3762 public Intent cloneFilter() {
3763 return new Intent(this, false);
3764 }
3765
3766 /**
3767 * Create an intent with a given action. All other fields (data, type,
3768 * class) are null. Note that the action <em>must</em> be in a
3769 * namespace because Intents are used globally in the system -- for
3770 * example the system VIEW action is android.intent.action.VIEW; an
3771 * application's custom action would be something like
3772 * com.google.app.myapp.CUSTOM_ACTION.
3773 *
3774 * @param action The Intent action, such as ACTION_VIEW.
3775 */
3776 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003777 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003778 }
3779
3780 /**
3781 * Create an intent with a given action and for a given data url. Note
3782 * that the action <em>must</em> be in a namespace because Intents are
3783 * used globally in the system -- for example the system VIEW action is
3784 * android.intent.action.VIEW; an application's custom action would be
3785 * something like com.google.app.myapp.CUSTOM_ACTION.
3786 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003787 * <p><em>Note: scheme and host name matching in the Android framework is
3788 * case-sensitive, unlike the formal RFC. As a result,
3789 * you should always ensure that you write your Uri with these elements
3790 * using lower case letters, and normalize any Uris you receive from
3791 * outside of Android to ensure the scheme and host is lower case.</em></p>
3792 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003793 * @param action The Intent action, such as ACTION_VIEW.
3794 * @param uri The Intent data URI.
3795 */
3796 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003797 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003798 mData = uri;
3799 }
3800
3801 /**
3802 * Create an intent for a specific component. All other fields (action, data,
3803 * type, class) are null, though they can be modified later with explicit
3804 * calls. This provides a convenient way to create an intent that is
3805 * intended to execute a hard-coded class name, rather than relying on the
3806 * system to find an appropriate class for you; see {@link #setComponent}
3807 * for more information on the repercussions of this.
3808 *
3809 * @param packageContext A Context of the application package implementing
3810 * this class.
3811 * @param cls The component class that is to be used for the intent.
3812 *
3813 * @see #setClass
3814 * @see #setComponent
3815 * @see #Intent(String, android.net.Uri , Context, Class)
3816 */
3817 public Intent(Context packageContext, Class<?> cls) {
3818 mComponent = new ComponentName(packageContext, cls);
3819 }
3820
3821 /**
3822 * Create an intent for a specific component with a specified action and data.
3823 * This is equivalent using {@link #Intent(String, android.net.Uri)} to
3824 * construct the Intent and then calling {@link #setClass} to set its
3825 * class.
3826 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07003827 * <p><em>Note: scheme and host name matching in the Android framework is
3828 * case-sensitive, unlike the formal RFC. As a result,
3829 * you should always ensure that you write your Uri with these elements
3830 * using lower case letters, and normalize any Uris you receive from
3831 * outside of Android to ensure the scheme and host is lower case.</em></p>
3832 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003833 * @param action The Intent action, such as ACTION_VIEW.
3834 * @param uri The Intent data URI.
3835 * @param packageContext A Context of the application package implementing
3836 * this class.
3837 * @param cls The component class that is to be used for the intent.
3838 *
3839 * @see #Intent(String, android.net.Uri)
3840 * @see #Intent(Context, Class)
3841 * @see #setClass
3842 * @see #setComponent
3843 */
3844 public Intent(String action, Uri uri,
3845 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08003846 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003847 mData = uri;
3848 mComponent = new ComponentName(packageContext, cls);
3849 }
3850
3851 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003852 * Create an intent to launch the main (root) activity of a task. This
3853 * is the Intent that is started when the application's is launched from
3854 * Home. For anything else that wants to launch an application in the
3855 * same way, it is important that they use an Intent structured the same
3856 * way, and can use this function to ensure this is the case.
3857 *
3858 * <p>The returned Intent has the given Activity component as its explicit
3859 * component, {@link #ACTION_MAIN} as its action, and includes the
3860 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3861 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3862 * to do that through {@link #addFlags(int)} on the returned Intent.
3863 *
3864 * @param mainActivity The main activity component that this Intent will
3865 * launch.
3866 * @return Returns a newly created Intent that can be used to launch the
3867 * activity as a main application entry.
3868 *
3869 * @see #setClass
3870 * @see #setComponent
3871 */
3872 public static Intent makeMainActivity(ComponentName mainActivity) {
3873 Intent intent = new Intent(ACTION_MAIN);
3874 intent.setComponent(mainActivity);
3875 intent.addCategory(CATEGORY_LAUNCHER);
3876 return intent;
3877 }
3878
3879 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003880 * Make an Intent for the main activity of an application, without
3881 * specifying a specific activity to run but giving a selector to find
3882 * the activity. This results in a final Intent that is structured
3883 * the same as when the application is launched from
3884 * Home. For anything else that wants to launch an application in the
3885 * same way, it is important that they use an Intent structured the same
3886 * way, and can use this function to ensure this is the case.
3887 *
3888 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
3889 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
3890 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
3891 * to do that through {@link #addFlags(int)} on the returned Intent.
3892 *
3893 * @param selectorAction The action name of the Intent's selector.
3894 * @param selectorCategory The name of a category to add to the Intent's
3895 * selector.
3896 * @return Returns a newly created Intent that can be used to launch the
3897 * activity as a main application entry.
3898 *
3899 * @see #setSelector(Intent)
3900 */
3901 public static Intent makeMainSelectorActivity(String selectorAction,
3902 String selectorCategory) {
3903 Intent intent = new Intent(ACTION_MAIN);
3904 intent.addCategory(CATEGORY_LAUNCHER);
3905 Intent selector = new Intent();
3906 selector.setAction(selectorAction);
3907 selector.addCategory(selectorCategory);
3908 intent.setSelector(selector);
3909 return intent;
3910 }
3911
3912 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08003913 * Make an Intent that can be used to re-launch an application's task
3914 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
3915 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
3916 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
3917 *
3918 * @param mainActivity The activity component that is the root of the
3919 * task; this is the activity that has been published in the application's
3920 * manifest as the main launcher icon.
3921 *
3922 * @return Returns a newly created Intent that can be used to relaunch the
3923 * activity's task in its root state.
3924 */
3925 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
3926 Intent intent = makeMainActivity(mainActivity);
3927 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
3928 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
3929 return intent;
3930 }
3931
3932 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003933 * Call {@link #parseUri} with 0 flags.
3934 * @deprecated Use {@link #parseUri} instead.
3935 */
3936 @Deprecated
3937 public static Intent getIntent(String uri) throws URISyntaxException {
3938 return parseUri(uri, 0);
3939 }
Tom Taylord4a47292009-12-21 13:59:18 -08003940
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003941 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003942 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003943 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07003944 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003945 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003946 *
3947 * <p>The URI given here must not be relative -- that is, it must include
3948 * the scheme and full path.
3949 *
3950 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003951 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07003952 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003953 *
3954 * @return Intent The newly created Intent object.
3955 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003956 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
3957 * it bad (as parsed by the Uri class) or the Intent data within the
3958 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08003959 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003960 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003961 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003962 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003963 int i = 0;
3964 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003965 // Validate intent scheme for if requested.
3966 if ((flags&URI_INTENT_SCHEME) != 0) {
3967 if (!uri.startsWith("intent:")) {
3968 Intent intent = new Intent(ACTION_VIEW);
3969 try {
3970 intent.setData(Uri.parse(uri));
3971 } catch (IllegalArgumentException e) {
3972 throw new URISyntaxException(uri, e.getMessage());
3973 }
3974 return intent;
3975 }
3976 }
Tom Taylord4a47292009-12-21 13:59:18 -08003977
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003978 // simple case
3979 i = uri.lastIndexOf("#");
3980 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
3981
3982 // old format Intent URI
3983 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07003984
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003985 // new format
3986 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003987 Intent baseIntent = intent;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003988
3989 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003990 String data = i >= 0 ? uri.substring(0, i) : null;
3991 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003992 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07003993
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003994 // loop over contents of Intent, all name=value;
3995 while (!uri.startsWith("end", i)) {
3996 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003997 if (eq < 0) eq = i-1;
3998 int semi = uri.indexOf(';', i);
3999 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004000
4001 // action
4002 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004003 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004004 }
4005
4006 // categories
4007 else if (uri.startsWith("category=", i)) {
4008 intent.addCategory(value);
4009 }
4010
4011 // type
4012 else if (uri.startsWith("type=", i)) {
4013 intent.mType = value;
4014 }
4015
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004016 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004017 else if (uri.startsWith("launchFlags=", i)) {
4018 intent.mFlags = Integer.decode(value).intValue();
4019 }
4020
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004021 // package
4022 else if (uri.startsWith("package=", i)) {
4023 intent.mPackage = value;
4024 }
4025
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004026 // component
4027 else if (uri.startsWith("component=", i)) {
4028 intent.mComponent = ComponentName.unflattenFromString(value);
4029 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004030
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004031 // scheme
4032 else if (uri.startsWith("scheme=", i)) {
4033 scheme = value;
4034 }
4035
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004036 // source bounds
4037 else if (uri.startsWith("sourceBounds=", i)) {
4038 intent.mSourceBounds = Rect.unflattenFromString(value);
4039 }
4040
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004041 // selector
4042 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4043 intent = new Intent();
4044 }
4045
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004046 // extra
4047 else {
4048 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004049 // create Bundle if it doesn't already exist
4050 if (intent.mExtras == null) intent.mExtras = new Bundle();
4051 Bundle b = intent.mExtras;
4052 // add EXTRA
4053 if (uri.startsWith("S.", i)) b.putString(key, value);
4054 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4055 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4056 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4057 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4058 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4059 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4060 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4061 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4062 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4063 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004064
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004065 // move to the next item
4066 i = semi + 1;
4067 }
4068
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004069 if (intent != baseIntent) {
4070 // The Intent had a selector; fix it up.
4071 baseIntent.setSelector(intent);
4072 intent = baseIntent;
4073 }
4074
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004075 if (data != null) {
4076 if (data.startsWith("intent:")) {
4077 data = data.substring(7);
4078 if (scheme != null) {
4079 data = scheme + ':' + data;
4080 }
4081 }
Tom Taylord4a47292009-12-21 13:59:18 -08004082
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004083 if (data.length() > 0) {
4084 try {
4085 intent.mData = Uri.parse(data);
4086 } catch (IllegalArgumentException e) {
4087 throw new URISyntaxException(uri, e.getMessage());
4088 }
4089 }
4090 }
Tom Taylord4a47292009-12-21 13:59:18 -08004091
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004092 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004093
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004094 } catch (IndexOutOfBoundsException e) {
4095 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4096 }
4097 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004098
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004099 public static Intent getIntentOld(String uri) throws URISyntaxException {
4100 Intent intent;
4101
4102 int i = uri.lastIndexOf('#');
4103 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004104 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004105 final int intentFragmentStart = i;
4106 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004107
4108 i++;
4109
4110 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004111 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004112 i += 7;
4113 int j = uri.indexOf(')', i);
4114 action = uri.substring(i, j);
4115 i = j + 1;
4116 }
4117
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004118 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004119
4120 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004121 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004122 i += 11;
4123 int j = uri.indexOf(')', i);
4124 while (i < j) {
4125 int sep = uri.indexOf('!', i);
4126 if (sep < 0) sep = j;
4127 if (i < sep) {
4128 intent.addCategory(uri.substring(i, sep));
4129 }
4130 i = sep + 1;
4131 }
4132 i = j + 1;
4133 }
4134
4135 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004136 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004137 i += 5;
4138 int j = uri.indexOf(')', i);
4139 intent.mType = uri.substring(i, j);
4140 i = j + 1;
4141 }
4142
4143 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004144 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004145 i += 12;
4146 int j = uri.indexOf(')', i);
4147 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
4148 i = j + 1;
4149 }
4150
4151 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004152 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004153 i += 10;
4154 int j = uri.indexOf(')', i);
4155 int sep = uri.indexOf('!', i);
4156 if (sep >= 0 && sep < j) {
4157 String pkg = uri.substring(i, sep);
4158 String cls = uri.substring(sep + 1, j);
4159 intent.mComponent = new ComponentName(pkg, cls);
4160 }
4161 i = j + 1;
4162 }
4163
4164 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004165 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004166 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004167
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004168 final int closeParen = uri.indexOf(')', i);
4169 if (closeParen == -1) throw new URISyntaxException(uri,
4170 "EXTRA missing trailing ')'", i);
4171
4172 while (i < closeParen) {
4173 // fetch the key value
4174 int j = uri.indexOf('=', i);
4175 if (j <= i + 1 || i >= closeParen) {
4176 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4177 }
4178 char type = uri.charAt(i);
4179 i++;
4180 String key = uri.substring(i, j);
4181 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004182
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004183 // get type-value
4184 j = uri.indexOf('!', i);
4185 if (j == -1 || j >= closeParen) j = closeParen;
4186 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4187 String value = uri.substring(i, j);
4188 i = j;
4189
4190 // create Bundle if it doesn't already exist
4191 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004192
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004193 // add item to bundle
4194 try {
4195 switch (type) {
4196 case 'S':
4197 intent.mExtras.putString(key, Uri.decode(value));
4198 break;
4199 case 'B':
4200 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4201 break;
4202 case 'b':
4203 intent.mExtras.putByte(key, Byte.parseByte(value));
4204 break;
4205 case 'c':
4206 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4207 break;
4208 case 'd':
4209 intent.mExtras.putDouble(key, Double.parseDouble(value));
4210 break;
4211 case 'f':
4212 intent.mExtras.putFloat(key, Float.parseFloat(value));
4213 break;
4214 case 'i':
4215 intent.mExtras.putInt(key, Integer.parseInt(value));
4216 break;
4217 case 'l':
4218 intent.mExtras.putLong(key, Long.parseLong(value));
4219 break;
4220 case 's':
4221 intent.mExtras.putShort(key, Short.parseShort(value));
4222 break;
4223 default:
4224 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4225 }
4226 } catch (NumberFormatException e) {
4227 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4228 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004229
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004230 char ch = uri.charAt(i);
4231 if (ch == ')') break;
4232 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4233 i++;
4234 }
4235 }
4236
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004237 if (isIntentFragment) {
4238 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4239 } else {
4240 intent.mData = Uri.parse(uri);
4241 }
Tom Taylord4a47292009-12-21 13:59:18 -08004242
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004243 if (intent.mAction == null) {
4244 // By default, if no action is specified, then use VIEW.
4245 intent.mAction = ACTION_VIEW;
4246 }
4247
4248 } else {
4249 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4250 }
4251
4252 return intent;
4253 }
4254
4255 /**
4256 * Retrieve the general action to be performed, such as
4257 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4258 * the information in the intent should be interpreted -- most importantly,
4259 * what to do with the data returned by {@link #getData}.
4260 *
4261 * @return The action of this intent or null if none is specified.
4262 *
4263 * @see #setAction
4264 */
4265 public String getAction() {
4266 return mAction;
4267 }
4268
4269 /**
4270 * Retrieve data this intent is operating on. This URI specifies the name
4271 * of the data; often it uses the content: scheme, specifying data in a
4272 * content provider. Other schemes may be handled by specific activities,
4273 * such as http: by the web browser.
4274 *
4275 * @return The URI of the data this intent is targeting or null.
4276 *
4277 * @see #getScheme
4278 * @see #setData
4279 */
4280 public Uri getData() {
4281 return mData;
4282 }
4283
4284 /**
4285 * The same as {@link #getData()}, but returns the URI as an encoded
4286 * String.
4287 */
4288 public String getDataString() {
4289 return mData != null ? mData.toString() : null;
4290 }
4291
4292 /**
4293 * Return the scheme portion of the intent's data. If the data is null or
4294 * does not include a scheme, null is returned. Otherwise, the scheme
4295 * prefix without the final ':' is returned, i.e. "http".
4296 *
4297 * <p>This is the same as calling getData().getScheme() (and checking for
4298 * null data).
4299 *
4300 * @return The scheme of this intent.
4301 *
4302 * @see #getData
4303 */
4304 public String getScheme() {
4305 return mData != null ? mData.getScheme() : null;
4306 }
4307
4308 /**
4309 * Retrieve any explicit MIME type included in the intent. This is usually
4310 * null, as the type is determined by the intent data.
4311 *
4312 * @return If a type was manually set, it is returned; else null is
4313 * returned.
4314 *
4315 * @see #resolveType(ContentResolver)
4316 * @see #setType
4317 */
4318 public String getType() {
4319 return mType;
4320 }
4321
4322 /**
4323 * Return the MIME data type of this intent. If the type field is
4324 * explicitly set, that is simply returned. Otherwise, if the data is set,
4325 * the type of that data is returned. If neither fields are set, a null is
4326 * returned.
4327 *
4328 * @return The MIME type of this intent.
4329 *
4330 * @see #getType
4331 * @see #resolveType(ContentResolver)
4332 */
4333 public String resolveType(Context context) {
4334 return resolveType(context.getContentResolver());
4335 }
4336
4337 /**
4338 * Return the MIME data type of this intent. If the type field is
4339 * explicitly set, that is simply returned. Otherwise, if the data is set,
4340 * the type of that data is returned. If neither fields are set, a null is
4341 * returned.
4342 *
4343 * @param resolver A ContentResolver that can be used to determine the MIME
4344 * type of the intent's data.
4345 *
4346 * @return The MIME type of this intent.
4347 *
4348 * @see #getType
4349 * @see #resolveType(Context)
4350 */
4351 public String resolveType(ContentResolver resolver) {
4352 if (mType != null) {
4353 return mType;
4354 }
4355 if (mData != null) {
4356 if ("content".equals(mData.getScheme())) {
4357 return resolver.getType(mData);
4358 }
4359 }
4360 return null;
4361 }
4362
4363 /**
4364 * Return the MIME data type of this intent, only if it will be needed for
4365 * intent resolution. This is not generally useful for application code;
4366 * it is used by the frameworks for communicating with back-end system
4367 * services.
4368 *
4369 * @param resolver A ContentResolver that can be used to determine the MIME
4370 * type of the intent's data.
4371 *
4372 * @return The MIME type of this intent, or null if it is unknown or not
4373 * needed.
4374 */
4375 public String resolveTypeIfNeeded(ContentResolver resolver) {
4376 if (mComponent != null) {
4377 return mType;
4378 }
4379 return resolveType(resolver);
4380 }
4381
4382 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004383 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004384 *
4385 * @param category The category to check.
4386 *
4387 * @return boolean True if the intent contains the category, else false.
4388 *
4389 * @see #getCategories
4390 * @see #addCategory
4391 */
4392 public boolean hasCategory(String category) {
4393 return mCategories != null && mCategories.contains(category);
4394 }
4395
4396 /**
4397 * Return the set of all categories in the intent. If there are no categories,
4398 * returns NULL.
4399 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004400 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004401 *
4402 * @see #hasCategory
4403 * @see #addCategory
4404 */
4405 public Set<String> getCategories() {
4406 return mCategories;
4407 }
4408
4409 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004410 * Return the specific selector associated with this Intent. If there is
4411 * none, returns null. See {@link #setSelector} for more information.
4412 *
4413 * @see #setSelector
4414 */
4415 public Intent getSelector() {
4416 return mSelector;
4417 }
4418
4419 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004420 * Return the {@link ClipData} associated with this Intent. If there is
4421 * none, returns null. See {@link #setClipData} for more information.
4422 *
John Spurlock125d1332013-11-25 11:58:37 -05004423 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004424 */
4425 public ClipData getClipData() {
4426 return mClipData;
4427 }
4428
4429 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004430 * Sets the ClassLoader that will be used when unmarshalling
4431 * any Parcelable values from the extras of this Intent.
4432 *
4433 * @param loader a ClassLoader, or null to use the default loader
4434 * at the time of unmarshalling.
4435 */
4436 public void setExtrasClassLoader(ClassLoader loader) {
4437 if (mExtras != null) {
4438 mExtras.setClassLoader(loader);
4439 }
4440 }
4441
4442 /**
4443 * Returns true if an extra value is associated with the given name.
4444 * @param name the extra's name
4445 * @return true if the given extra is present.
4446 */
4447 public boolean hasExtra(String name) {
4448 return mExtras != null && mExtras.containsKey(name);
4449 }
4450
4451 /**
4452 * Returns true if the Intent's extras contain a parcelled file descriptor.
4453 * @return true if the Intent contains a parcelled file descriptor.
4454 */
4455 public boolean hasFileDescriptors() {
4456 return mExtras != null && mExtras.hasFileDescriptors();
4457 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004458
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04004459 /** @hide */
4460 public void setAllowFds(boolean allowFds) {
4461 if (mExtras != null) {
4462 mExtras.setAllowFds(allowFds);
4463 }
4464 }
4465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004466 /**
4467 * Retrieve extended data from the intent.
4468 *
4469 * @param name The name of the desired item.
4470 *
4471 * @return the value of an item that previously added with putExtra()
4472 * or null if none was found.
4473 *
4474 * @deprecated
4475 * @hide
4476 */
4477 @Deprecated
4478 public Object getExtra(String name) {
4479 return getExtra(name, null);
4480 }
4481
4482 /**
4483 * Retrieve extended data from the intent.
4484 *
4485 * @param name The name of the desired item.
4486 * @param defaultValue the value to be returned if no value of the desired
4487 * type is stored with the given name.
4488 *
4489 * @return the value of an item that previously added with putExtra()
4490 * or the default value if none was found.
4491 *
4492 * @see #putExtra(String, boolean)
4493 */
4494 public boolean getBooleanExtra(String name, boolean defaultValue) {
4495 return mExtras == null ? defaultValue :
4496 mExtras.getBoolean(name, defaultValue);
4497 }
4498
4499 /**
4500 * Retrieve extended data from the intent.
4501 *
4502 * @param name The name of the desired item.
4503 * @param defaultValue the value to be returned if no value of the desired
4504 * type is stored with the given name.
4505 *
4506 * @return the value of an item that previously added with putExtra()
4507 * or the default value if none was found.
4508 *
4509 * @see #putExtra(String, byte)
4510 */
4511 public byte getByteExtra(String name, byte defaultValue) {
4512 return mExtras == null ? defaultValue :
4513 mExtras.getByte(name, defaultValue);
4514 }
4515
4516 /**
4517 * Retrieve extended data from the intent.
4518 *
4519 * @param name The name of the desired item.
4520 * @param defaultValue the value to be returned if no value of the desired
4521 * type is stored with the given name.
4522 *
4523 * @return the value of an item that previously added with putExtra()
4524 * or the default value if none was found.
4525 *
4526 * @see #putExtra(String, short)
4527 */
4528 public short getShortExtra(String name, short defaultValue) {
4529 return mExtras == null ? defaultValue :
4530 mExtras.getShort(name, defaultValue);
4531 }
4532
4533 /**
4534 * Retrieve extended data from the intent.
4535 *
4536 * @param name The name of the desired item.
4537 * @param defaultValue the value to be returned if no value of the desired
4538 * type is stored with the given name.
4539 *
4540 * @return the value of an item that previously added with putExtra()
4541 * or the default value if none was found.
4542 *
4543 * @see #putExtra(String, char)
4544 */
4545 public char getCharExtra(String name, char defaultValue) {
4546 return mExtras == null ? defaultValue :
4547 mExtras.getChar(name, defaultValue);
4548 }
4549
4550 /**
4551 * Retrieve extended data from the intent.
4552 *
4553 * @param name The name of the desired item.
4554 * @param defaultValue the value to be returned if no value of the desired
4555 * type is stored with the given name.
4556 *
4557 * @return the value of an item that previously added with putExtra()
4558 * or the default value if none was found.
4559 *
4560 * @see #putExtra(String, int)
4561 */
4562 public int getIntExtra(String name, int defaultValue) {
4563 return mExtras == null ? defaultValue :
4564 mExtras.getInt(name, defaultValue);
4565 }
4566
4567 /**
4568 * Retrieve extended data from the intent.
4569 *
4570 * @param name The name of the desired item.
4571 * @param defaultValue the value to be returned if no value of the desired
4572 * type is stored with the given name.
4573 *
4574 * @return the value of an item that previously added with putExtra()
4575 * or the default value if none was found.
4576 *
4577 * @see #putExtra(String, long)
4578 */
4579 public long getLongExtra(String name, long defaultValue) {
4580 return mExtras == null ? defaultValue :
4581 mExtras.getLong(name, defaultValue);
4582 }
4583
4584 /**
4585 * Retrieve extended data from the intent.
4586 *
4587 * @param name The name of the desired item.
4588 * @param defaultValue the value to be returned if no value of the desired
4589 * type is stored with the given name.
4590 *
4591 * @return the value of an item that previously added with putExtra(),
4592 * or the default value if no such item is present
4593 *
4594 * @see #putExtra(String, float)
4595 */
4596 public float getFloatExtra(String name, float defaultValue) {
4597 return mExtras == null ? defaultValue :
4598 mExtras.getFloat(name, defaultValue);
4599 }
4600
4601 /**
4602 * Retrieve extended data from the intent.
4603 *
4604 * @param name The name of the desired item.
4605 * @param defaultValue the value to be returned if no value of the desired
4606 * type is stored with the given name.
4607 *
4608 * @return the value of an item that previously added with putExtra()
4609 * or the default value if none was found.
4610 *
4611 * @see #putExtra(String, double)
4612 */
4613 public double getDoubleExtra(String name, double defaultValue) {
4614 return mExtras == null ? defaultValue :
4615 mExtras.getDouble(name, defaultValue);
4616 }
4617
4618 /**
4619 * Retrieve extended data from the intent.
4620 *
4621 * @param name The name of the desired item.
4622 *
4623 * @return the value of an item that previously added with putExtra()
4624 * or null if no String value was found.
4625 *
4626 * @see #putExtra(String, String)
4627 */
4628 public String getStringExtra(String name) {
4629 return mExtras == null ? null : mExtras.getString(name);
4630 }
4631
4632 /**
4633 * Retrieve extended data from the intent.
4634 *
4635 * @param name The name of the desired item.
4636 *
4637 * @return the value of an item that previously added with putExtra()
4638 * or null if no CharSequence value was found.
4639 *
4640 * @see #putExtra(String, CharSequence)
4641 */
4642 public CharSequence getCharSequenceExtra(String name) {
4643 return mExtras == null ? null : mExtras.getCharSequence(name);
4644 }
4645
4646 /**
4647 * Retrieve extended data from the intent.
4648 *
4649 * @param name The name of the desired item.
4650 *
4651 * @return the value of an item that previously added with putExtra()
4652 * or null if no Parcelable value was found.
4653 *
4654 * @see #putExtra(String, Parcelable)
4655 */
4656 public <T extends Parcelable> T getParcelableExtra(String name) {
4657 return mExtras == null ? null : mExtras.<T>getParcelable(name);
4658 }
4659
4660 /**
4661 * Retrieve extended data from the intent.
4662 *
4663 * @param name The name of the desired item.
4664 *
4665 * @return the value of an item that previously added with putExtra()
4666 * or null if no Parcelable[] value was found.
4667 *
4668 * @see #putExtra(String, Parcelable[])
4669 */
4670 public Parcelable[] getParcelableArrayExtra(String name) {
4671 return mExtras == null ? null : mExtras.getParcelableArray(name);
4672 }
4673
4674 /**
4675 * Retrieve extended data from the intent.
4676 *
4677 * @param name The name of the desired item.
4678 *
4679 * @return the value of an item that previously added with putExtra()
4680 * or null if no ArrayList<Parcelable> value was found.
4681 *
4682 * @see #putParcelableArrayListExtra(String, ArrayList)
4683 */
4684 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
4685 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
4686 }
4687
4688 /**
4689 * Retrieve extended data from the intent.
4690 *
4691 * @param name The name of the desired item.
4692 *
4693 * @return the value of an item that previously added with putExtra()
4694 * or null if no Serializable value was found.
4695 *
4696 * @see #putExtra(String, Serializable)
4697 */
4698 public Serializable getSerializableExtra(String name) {
4699 return mExtras == null ? null : mExtras.getSerializable(name);
4700 }
4701
4702 /**
4703 * Retrieve extended data from the intent.
4704 *
4705 * @param name The name of the desired item.
4706 *
4707 * @return the value of an item that previously added with putExtra()
4708 * or null if no ArrayList<Integer> value was found.
4709 *
4710 * @see #putIntegerArrayListExtra(String, ArrayList)
4711 */
4712 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
4713 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
4714 }
4715
4716 /**
4717 * Retrieve extended data from the intent.
4718 *
4719 * @param name The name of the desired item.
4720 *
4721 * @return the value of an item that previously added with putExtra()
4722 * or null if no ArrayList<String> value was found.
4723 *
4724 * @see #putStringArrayListExtra(String, ArrayList)
4725 */
4726 public ArrayList<String> getStringArrayListExtra(String name) {
4727 return mExtras == null ? null : mExtras.getStringArrayList(name);
4728 }
4729
4730 /**
4731 * Retrieve extended data from the intent.
4732 *
4733 * @param name The name of the desired item.
4734 *
4735 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004736 * or null if no ArrayList<CharSequence> value was found.
4737 *
4738 * @see #putCharSequenceArrayListExtra(String, ArrayList)
4739 */
4740 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
4741 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
4742 }
4743
4744 /**
4745 * Retrieve extended data from the intent.
4746 *
4747 * @param name The name of the desired item.
4748 *
4749 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 * or null if no boolean array value was found.
4751 *
4752 * @see #putExtra(String, boolean[])
4753 */
4754 public boolean[] getBooleanArrayExtra(String name) {
4755 return mExtras == null ? null : mExtras.getBooleanArray(name);
4756 }
4757
4758 /**
4759 * Retrieve extended data from the intent.
4760 *
4761 * @param name The name of the desired item.
4762 *
4763 * @return the value of an item that previously added with putExtra()
4764 * or null if no byte array value was found.
4765 *
4766 * @see #putExtra(String, byte[])
4767 */
4768 public byte[] getByteArrayExtra(String name) {
4769 return mExtras == null ? null : mExtras.getByteArray(name);
4770 }
4771
4772 /**
4773 * Retrieve extended data from the intent.
4774 *
4775 * @param name The name of the desired item.
4776 *
4777 * @return the value of an item that previously added with putExtra()
4778 * or null if no short array value was found.
4779 *
4780 * @see #putExtra(String, short[])
4781 */
4782 public short[] getShortArrayExtra(String name) {
4783 return mExtras == null ? null : mExtras.getShortArray(name);
4784 }
4785
4786 /**
4787 * Retrieve extended data from the intent.
4788 *
4789 * @param name The name of the desired item.
4790 *
4791 * @return the value of an item that previously added with putExtra()
4792 * or null if no char array value was found.
4793 *
4794 * @see #putExtra(String, char[])
4795 */
4796 public char[] getCharArrayExtra(String name) {
4797 return mExtras == null ? null : mExtras.getCharArray(name);
4798 }
4799
4800 /**
4801 * Retrieve extended data from the intent.
4802 *
4803 * @param name The name of the desired item.
4804 *
4805 * @return the value of an item that previously added with putExtra()
4806 * or null if no int array value was found.
4807 *
4808 * @see #putExtra(String, int[])
4809 */
4810 public int[] getIntArrayExtra(String name) {
4811 return mExtras == null ? null : mExtras.getIntArray(name);
4812 }
4813
4814 /**
4815 * Retrieve extended data from the intent.
4816 *
4817 * @param name The name of the desired item.
4818 *
4819 * @return the value of an item that previously added with putExtra()
4820 * or null if no long array value was found.
4821 *
4822 * @see #putExtra(String, long[])
4823 */
4824 public long[] getLongArrayExtra(String name) {
4825 return mExtras == null ? null : mExtras.getLongArray(name);
4826 }
4827
4828 /**
4829 * Retrieve extended data from the intent.
4830 *
4831 * @param name The name of the desired item.
4832 *
4833 * @return the value of an item that previously added with putExtra()
4834 * or null if no float array value was found.
4835 *
4836 * @see #putExtra(String, float[])
4837 */
4838 public float[] getFloatArrayExtra(String name) {
4839 return mExtras == null ? null : mExtras.getFloatArray(name);
4840 }
4841
4842 /**
4843 * Retrieve extended data from the intent.
4844 *
4845 * @param name The name of the desired item.
4846 *
4847 * @return the value of an item that previously added with putExtra()
4848 * or null if no double array value was found.
4849 *
4850 * @see #putExtra(String, double[])
4851 */
4852 public double[] getDoubleArrayExtra(String name) {
4853 return mExtras == null ? null : mExtras.getDoubleArray(name);
4854 }
4855
4856 /**
4857 * Retrieve extended data from the intent.
4858 *
4859 * @param name The name of the desired item.
4860 *
4861 * @return the value of an item that previously added with putExtra()
4862 * or null if no String array value was found.
4863 *
4864 * @see #putExtra(String, String[])
4865 */
4866 public String[] getStringArrayExtra(String name) {
4867 return mExtras == null ? null : mExtras.getStringArray(name);
4868 }
4869
4870 /**
4871 * Retrieve extended data from the intent.
4872 *
4873 * @param name The name of the desired item.
4874 *
4875 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004876 * or null if no CharSequence array value was found.
4877 *
4878 * @see #putExtra(String, CharSequence[])
4879 */
4880 public CharSequence[] getCharSequenceArrayExtra(String name) {
4881 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
4882 }
4883
4884 /**
4885 * Retrieve extended data from the intent.
4886 *
4887 * @param name The name of the desired item.
4888 *
4889 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004890 * or null if no Bundle value was found.
4891 *
4892 * @see #putExtra(String, Bundle)
4893 */
4894 public Bundle getBundleExtra(String name) {
4895 return mExtras == null ? null : mExtras.getBundle(name);
4896 }
4897
4898 /**
4899 * Retrieve extended data from the intent.
4900 *
4901 * @param name The name of the desired item.
4902 *
4903 * @return the value of an item that previously added with putExtra()
4904 * or null if no IBinder value was found.
4905 *
4906 * @see #putExtra(String, IBinder)
4907 *
4908 * @deprecated
4909 * @hide
4910 */
4911 @Deprecated
4912 public IBinder getIBinderExtra(String name) {
4913 return mExtras == null ? null : mExtras.getIBinder(name);
4914 }
4915
4916 /**
4917 * Retrieve extended data from the intent.
4918 *
4919 * @param name The name of the desired item.
4920 * @param defaultValue The default value to return in case no item is
4921 * associated with the key 'name'
4922 *
4923 * @return the value of an item that previously added with putExtra()
4924 * or defaultValue if none was found.
4925 *
4926 * @see #putExtra
4927 *
4928 * @deprecated
4929 * @hide
4930 */
4931 @Deprecated
4932 public Object getExtra(String name, Object defaultValue) {
4933 Object result = defaultValue;
4934 if (mExtras != null) {
4935 Object result2 = mExtras.get(name);
4936 if (result2 != null) {
4937 result = result2;
4938 }
4939 }
4940
4941 return result;
4942 }
4943
4944 /**
4945 * Retrieves a map of extended data from the intent.
4946 *
4947 * @return the map of all extras previously added with putExtra(),
4948 * or null if none have been added.
4949 */
4950 public Bundle getExtras() {
4951 return (mExtras != null)
4952 ? new Bundle(mExtras)
4953 : null;
4954 }
4955
4956 /**
4957 * Retrieve any special flags associated with this intent. You will
4958 * normally just set them with {@link #setFlags} and let the system
4959 * take the appropriate action with them.
4960 *
4961 * @return int The currently set flags.
4962 *
4963 * @see #setFlags
4964 */
4965 public int getFlags() {
4966 return mFlags;
4967 }
4968
Dianne Hackborne7f97212011-02-24 14:40:20 -08004969 /** @hide */
4970 public boolean isExcludingStopped() {
4971 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
4972 == FLAG_EXCLUDE_STOPPED_PACKAGES;
4973 }
4974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004975 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004976 * Retrieve the application package name this Intent is limited to. When
4977 * resolving an Intent, if non-null this limits the resolution to only
4978 * components in the given application package.
4979 *
4980 * @return The name of the application package for the Intent.
4981 *
4982 * @see #resolveActivity
4983 * @see #setPackage
4984 */
4985 public String getPackage() {
4986 return mPackage;
4987 }
4988
4989 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004990 * Retrieve the concrete component associated with the intent. When receiving
4991 * an intent, this is the component that was found to best handle it (that is,
4992 * yourself) and will always be non-null; in all other cases it will be
4993 * null unless explicitly set.
4994 *
4995 * @return The name of the application component to handle the intent.
4996 *
4997 * @see #resolveActivity
4998 * @see #setComponent
4999 */
5000 public ComponentName getComponent() {
5001 return mComponent;
5002 }
5003
5004 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005005 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5006 * used as a hint to the receiver for animations and the like. Null means that there
5007 * is no source bounds.
5008 */
5009 public Rect getSourceBounds() {
5010 return mSourceBounds;
5011 }
5012
5013 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 * Return the Activity component that should be used to handle this intent.
5015 * The appropriate component is determined based on the information in the
5016 * intent, evaluated as follows:
5017 *
5018 * <p>If {@link #getComponent} returns an explicit class, that is returned
5019 * without any further consideration.
5020 *
5021 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5022 * category to be considered.
5023 *
5024 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5025 * action.
5026 *
5027 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5028 * this type.
5029 *
5030 * <p>If {@link #addCategory} has added any categories, the activity must
5031 * handle ALL of the categories specified.
5032 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005033 * <p>If {@link #getPackage} is non-NULL, only activity components in
5034 * that application package will be considered.
5035 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005036 * <p>If there are no activities that satisfy all of these conditions, a
5037 * null string is returned.
5038 *
5039 * <p>If multiple activities are found to satisfy the intent, the one with
5040 * the highest priority will be used. If there are multiple activities
5041 * with the same priority, the system will either pick the best activity
5042 * based on user preference, or resolve to a system class that will allow
5043 * the user to pick an activity and forward from there.
5044 *
5045 * <p>This method is implemented simply by calling
5046 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5047 * true.</p>
5048 * <p> This API is called for you as part of starting an activity from an
5049 * intent. You do not normally need to call it yourself.</p>
5050 *
5051 * @param pm The package manager with which to resolve the Intent.
5052 *
5053 * @return Name of the component implementing an activity that can
5054 * display the intent.
5055 *
5056 * @see #setComponent
5057 * @see #getComponent
5058 * @see #resolveActivityInfo
5059 */
5060 public ComponentName resolveActivity(PackageManager pm) {
5061 if (mComponent != null) {
5062 return mComponent;
5063 }
5064
5065 ResolveInfo info = pm.resolveActivity(
5066 this, PackageManager.MATCH_DEFAULT_ONLY);
5067 if (info != null) {
5068 return new ComponentName(
5069 info.activityInfo.applicationInfo.packageName,
5070 info.activityInfo.name);
5071 }
5072
5073 return null;
5074 }
5075
5076 /**
5077 * Resolve the Intent into an {@link ActivityInfo}
5078 * describing the activity that should execute the intent. Resolution
5079 * follows the same rules as described for {@link #resolveActivity}, but
5080 * you get back the completely information about the resolved activity
5081 * instead of just its class name.
5082 *
5083 * @param pm The package manager with which to resolve the Intent.
5084 * @param flags Addition information to retrieve as per
5085 * {@link PackageManager#getActivityInfo(ComponentName, int)
5086 * PackageManager.getActivityInfo()}.
5087 *
5088 * @return PackageManager.ActivityInfo
5089 *
5090 * @see #resolveActivity
5091 */
5092 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5093 ActivityInfo ai = null;
5094 if (mComponent != null) {
5095 try {
5096 ai = pm.getActivityInfo(mComponent, flags);
5097 } catch (PackageManager.NameNotFoundException e) {
5098 // ignore
5099 }
5100 } else {
5101 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005102 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005103 if (info != null) {
5104 ai = info.activityInfo;
5105 }
5106 }
5107
5108 return ai;
5109 }
5110
5111 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005112 * Special function for use by the system to resolve service
5113 * intents to system apps. Throws an exception if there are
5114 * multiple potential matches to the Intent. Returns null if
5115 * there are no matches.
5116 * @hide
5117 */
5118 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5119 if (mComponent != null) {
5120 return mComponent;
5121 }
5122
5123 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5124 if (results == null) {
5125 return null;
5126 }
5127 ComponentName comp = null;
5128 for (int i=0; i<results.size(); i++) {
5129 ResolveInfo ri = results.get(i);
5130 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5131 continue;
5132 }
5133 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5134 ri.serviceInfo.name);
5135 if (comp != null) {
5136 throw new IllegalStateException("Multiple system services handle " + this
5137 + ": " + comp + ", " + foundComp);
5138 }
5139 comp = foundComp;
5140 }
5141 return comp;
5142 }
5143
5144 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005145 * Set the general action to be performed.
5146 *
5147 * @param action An action name, such as ACTION_VIEW. Application-specific
5148 * actions should be prefixed with the vendor's package name.
5149 *
5150 * @return Returns the same Intent object, for chaining multiple calls
5151 * into a single statement.
5152 *
5153 * @see #getAction
5154 */
5155 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005156 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005157 return this;
5158 }
5159
5160 /**
5161 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005162 * clears any type that was previously set by {@link #setType} or
5163 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005164 *
Nick Pellyccae4122012-01-09 14:12:58 -08005165 * <p><em>Note: scheme matching in the Android framework is
5166 * case-sensitive, unlike the formal RFC. As a result,
5167 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005168 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005169 * {@link #setDataAndNormalize}
5170 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005171 *
Nick Pellyccae4122012-01-09 14:12:58 -08005172 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005173 *
5174 * @return Returns the same Intent object, for chaining multiple calls
5175 * into a single statement.
5176 *
5177 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005178 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005179 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005180 */
5181 public Intent setData(Uri data) {
5182 mData = data;
5183 mType = null;
5184 return this;
5185 }
5186
5187 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005188 * Normalize and set the data this intent is operating on.
5189 *
5190 * <p>This method automatically clears any type that was
5191 * previously set (for example, by {@link #setType}).
5192 *
5193 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005194 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005195 * so really this is just a convenience method for
5196 * <pre>
5197 * setData(data.normalize())
5198 * </pre>
5199 *
5200 * @param data The Uri of the data this intent is now targeting.
5201 *
5202 * @return Returns the same Intent object, for chaining multiple calls
5203 * into a single statement.
5204 *
5205 * @see #getData
5206 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005207 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005208 */
5209 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005210 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005211 }
5212
5213 /**
5214 * Set an explicit MIME data type.
5215 *
5216 * <p>This is used to create intents that only specify a type and not data,
5217 * for example to indicate the type of data to return.
5218 *
5219 * <p>This method automatically clears any data that was
5220 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005221 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005222 * <p><em>Note: MIME type matching in the Android framework is
5223 * case-sensitive, unlike formal RFC MIME types. As a result,
5224 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005225 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5226 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005227 *
5228 * @param type The MIME type of the data being handled by this intent.
5229 *
5230 * @return Returns the same Intent object, for chaining multiple calls
5231 * into a single statement.
5232 *
5233 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005234 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005235 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005236 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005237 */
5238 public Intent setType(String type) {
5239 mData = null;
5240 mType = type;
5241 return this;
5242 }
5243
5244 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005245 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005246 *
Nick Pellyccae4122012-01-09 14:12:58 -08005247 * <p>This is used to create intents that only specify a type and not data,
5248 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005249 *
Nick Pellyccae4122012-01-09 14:12:58 -08005250 * <p>This method automatically clears any data that was
5251 * previously set (for example by {@link #setData}).
5252 *
5253 * <p>The MIME type is normalized using
5254 * {@link #normalizeMimeType} before it is set,
5255 * so really this is just a convenience method for
5256 * <pre>
5257 * setType(Intent.normalizeMimeType(type))
5258 * </pre>
5259 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005260 * @param type The MIME type of the data being handled by this intent.
5261 *
5262 * @return Returns the same Intent object, for chaining multiple calls
5263 * into a single statement.
5264 *
Nick Pellyccae4122012-01-09 14:12:58 -08005265 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005266 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005267 * @see #normalizeMimeType
5268 */
5269 public Intent setTypeAndNormalize(String type) {
5270 return setType(normalizeMimeType(type));
5271 }
5272
5273 /**
5274 * (Usually optional) Set the data for the intent along with an explicit
5275 * MIME data type. This method should very rarely be used -- it allows you
5276 * to override the MIME type that would ordinarily be inferred from the
5277 * data with your own type given here.
5278 *
5279 * <p><em>Note: MIME type and Uri scheme matching in the
5280 * Android framework is case-sensitive, unlike the formal RFC definitions.
5281 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005282 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005283 * {@link #setDataAndTypeAndNormalize}
5284 * to ensure that they are converted to lower case.</em>
5285 *
5286 * @param data The Uri of the data this intent is now targeting.
5287 * @param type The MIME type of the data being handled by this intent.
5288 *
5289 * @return Returns the same Intent object, for chaining multiple calls
5290 * into a single statement.
5291 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005292 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005293 * @see #setData
5294 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005295 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005296 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 */
5298 public Intent setDataAndType(Uri data, String type) {
5299 mData = data;
5300 mType = type;
5301 return this;
5302 }
5303
5304 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005305 * (Usually optional) Normalize and set both the data Uri and an explicit
5306 * MIME data type. This method should very rarely be used -- it allows you
5307 * to override the MIME type that would ordinarily be inferred from the
5308 * data with your own type given here.
5309 *
5310 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005311 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005312 * before they are set, so really this is just a convenience method for
5313 * <pre>
5314 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5315 * </pre>
5316 *
5317 * @param data The Uri of the data this intent is now targeting.
5318 * @param type The MIME type of the data being handled by this intent.
5319 *
5320 * @return Returns the same Intent object, for chaining multiple calls
5321 * into a single statement.
5322 *
5323 * @see #setType
5324 * @see #setData
5325 * @see #setDataAndType
5326 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005327 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005328 */
5329 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005330 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005331 }
5332
5333 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005334 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005335 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005336 * activities that provide <em>all</em> of the requested categories will be
5337 * used.
5338 *
5339 * @param category The desired category. This can be either one of the
5340 * predefined Intent categories, or a custom category in your own
5341 * namespace.
5342 *
5343 * @return Returns the same Intent object, for chaining multiple calls
5344 * into a single statement.
5345 *
5346 * @see #hasCategory
5347 * @see #removeCategory
5348 */
5349 public Intent addCategory(String category) {
5350 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005351 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005352 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08005353 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005354 return this;
5355 }
5356
5357 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005358 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005359 *
5360 * @param category The category to remove.
5361 *
5362 * @see #addCategory
5363 */
5364 public void removeCategory(String category) {
5365 if (mCategories != null) {
5366 mCategories.remove(category);
5367 if (mCategories.size() == 0) {
5368 mCategories = null;
5369 }
5370 }
5371 }
5372
5373 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005374 * Set a selector for this Intent. This is a modification to the kinds of
5375 * things the Intent will match. If the selector is set, it will be used
5376 * when trying to find entities that can handle the Intent, instead of the
5377 * main contents of the Intent. This allows you build an Intent containing
5378 * a generic protocol while targeting it more specifically.
5379 *
5380 * <p>An example of where this may be used is with things like
5381 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
5382 * Intent that will launch the Browser application. However, the correct
5383 * main entry point of an application is actually {@link #ACTION_MAIN}
5384 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
5385 * used to specify the actual Activity to launch. If you launch the browser
5386 * with something different, undesired behavior may happen if the user has
5387 * previously or later launches it the normal way, since they do not match.
5388 * Instead, you can build an Intent with the MAIN action (but no ComponentName
5389 * yet specified) and set a selector with {@link #ACTION_MAIN} and
5390 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
5391 *
5392 * <p>Setting a selector does not impact the behavior of
5393 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
5394 * desired behavior of a selector -- it does not impact the base meaning
5395 * of the Intent, just what kinds of things will be matched against it
5396 * when determining who can handle it.</p>
5397 *
5398 * <p>You can not use both a selector and {@link #setPackage(String)} on
5399 * the same base Intent.</p>
5400 *
5401 * @param selector The desired selector Intent; set to null to not use
5402 * a special selector.
5403 */
5404 public void setSelector(Intent selector) {
5405 if (selector == this) {
5406 throw new IllegalArgumentException(
5407 "Intent being set as a selector of itself");
5408 }
5409 if (selector != null && mPackage != null) {
5410 throw new IllegalArgumentException(
5411 "Can't set selector when package name is already set");
5412 }
5413 mSelector = selector;
5414 }
5415
5416 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005417 * Set a {@link ClipData} associated with this Intent. This replaces any
5418 * previously set ClipData.
5419 *
5420 * <p>The ClipData in an intent is not used for Intent matching or other
5421 * such operations. Semantically it is like extras, used to transmit
5422 * additional data with the Intent. The main feature of using this over
5423 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
5424 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
5425 * items included in the clip data. This is useful, in particular, if
5426 * you want to transmit an Intent containing multiple <code>content:</code>
5427 * URIs for which the recipient may not have global permission to access the
5428 * content provider.
5429 *
5430 * <p>If the ClipData contains items that are themselves Intents, any
5431 * grant flags in those Intents will be ignored. Only the top-level flags
5432 * of the main Intent are respected, and will be applied to all Uri or
5433 * Intent items in the clip (or sub-items of the clip).
5434 *
5435 * <p>The MIME type, label, and icon in the ClipData object are not
5436 * directly used by Intent. Applications should generally rely on the
5437 * MIME type of the Intent itself, not what it may find in the ClipData.
5438 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05005439 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005440 *
5441 * @param clip The new clip to set. May be null to clear the current clip.
5442 */
5443 public void setClipData(ClipData clip) {
5444 mClipData = clip;
5445 }
5446
5447 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005448 * Add extended data to the intent. The name must include a package
5449 * prefix, for example the app com.android.contacts would use names
5450 * like "com.android.contacts.ShowAll".
5451 *
5452 * @param name The name of the extra data, with package prefix.
5453 * @param value The boolean data value.
5454 *
5455 * @return Returns the same Intent object, for chaining multiple calls
5456 * into a single statement.
5457 *
5458 * @see #putExtras
5459 * @see #removeExtra
5460 * @see #getBooleanExtra(String, boolean)
5461 */
5462 public Intent putExtra(String name, boolean value) {
5463 if (mExtras == null) {
5464 mExtras = new Bundle();
5465 }
5466 mExtras.putBoolean(name, value);
5467 return this;
5468 }
5469
5470 /**
5471 * Add extended data to the intent. The name must include a package
5472 * prefix, for example the app com.android.contacts would use names
5473 * like "com.android.contacts.ShowAll".
5474 *
5475 * @param name The name of the extra data, with package prefix.
5476 * @param value The byte data value.
5477 *
5478 * @return Returns the same Intent object, for chaining multiple calls
5479 * into a single statement.
5480 *
5481 * @see #putExtras
5482 * @see #removeExtra
5483 * @see #getByteExtra(String, byte)
5484 */
5485 public Intent putExtra(String name, byte value) {
5486 if (mExtras == null) {
5487 mExtras = new Bundle();
5488 }
5489 mExtras.putByte(name, value);
5490 return this;
5491 }
5492
5493 /**
5494 * Add extended data to the intent. The name must include a package
5495 * prefix, for example the app com.android.contacts would use names
5496 * like "com.android.contacts.ShowAll".
5497 *
5498 * @param name The name of the extra data, with package prefix.
5499 * @param value The char data value.
5500 *
5501 * @return Returns the same Intent object, for chaining multiple calls
5502 * into a single statement.
5503 *
5504 * @see #putExtras
5505 * @see #removeExtra
5506 * @see #getCharExtra(String, char)
5507 */
5508 public Intent putExtra(String name, char value) {
5509 if (mExtras == null) {
5510 mExtras = new Bundle();
5511 }
5512 mExtras.putChar(name, value);
5513 return this;
5514 }
5515
5516 /**
5517 * Add extended data to the intent. The name must include a package
5518 * prefix, for example the app com.android.contacts would use names
5519 * like "com.android.contacts.ShowAll".
5520 *
5521 * @param name The name of the extra data, with package prefix.
5522 * @param value The short data value.
5523 *
5524 * @return Returns the same Intent object, for chaining multiple calls
5525 * into a single statement.
5526 *
5527 * @see #putExtras
5528 * @see #removeExtra
5529 * @see #getShortExtra(String, short)
5530 */
5531 public Intent putExtra(String name, short value) {
5532 if (mExtras == null) {
5533 mExtras = new Bundle();
5534 }
5535 mExtras.putShort(name, value);
5536 return this;
5537 }
5538
5539 /**
5540 * Add extended data to the intent. The name must include a package
5541 * prefix, for example the app com.android.contacts would use names
5542 * like "com.android.contacts.ShowAll".
5543 *
5544 * @param name The name of the extra data, with package prefix.
5545 * @param value The integer data value.
5546 *
5547 * @return Returns the same Intent object, for chaining multiple calls
5548 * into a single statement.
5549 *
5550 * @see #putExtras
5551 * @see #removeExtra
5552 * @see #getIntExtra(String, int)
5553 */
5554 public Intent putExtra(String name, int value) {
5555 if (mExtras == null) {
5556 mExtras = new Bundle();
5557 }
5558 mExtras.putInt(name, value);
5559 return this;
5560 }
5561
5562 /**
5563 * Add extended data to the intent. The name must include a package
5564 * prefix, for example the app com.android.contacts would use names
5565 * like "com.android.contacts.ShowAll".
5566 *
5567 * @param name The name of the extra data, with package prefix.
5568 * @param value The long data value.
5569 *
5570 * @return Returns the same Intent object, for chaining multiple calls
5571 * into a single statement.
5572 *
5573 * @see #putExtras
5574 * @see #removeExtra
5575 * @see #getLongExtra(String, long)
5576 */
5577 public Intent putExtra(String name, long value) {
5578 if (mExtras == null) {
5579 mExtras = new Bundle();
5580 }
5581 mExtras.putLong(name, value);
5582 return this;
5583 }
5584
5585 /**
5586 * Add extended data to the intent. The name must include a package
5587 * prefix, for example the app com.android.contacts would use names
5588 * like "com.android.contacts.ShowAll".
5589 *
5590 * @param name The name of the extra data, with package prefix.
5591 * @param value The float data value.
5592 *
5593 * @return Returns the same Intent object, for chaining multiple calls
5594 * into a single statement.
5595 *
5596 * @see #putExtras
5597 * @see #removeExtra
5598 * @see #getFloatExtra(String, float)
5599 */
5600 public Intent putExtra(String name, float value) {
5601 if (mExtras == null) {
5602 mExtras = new Bundle();
5603 }
5604 mExtras.putFloat(name, value);
5605 return this;
5606 }
5607
5608 /**
5609 * Add extended data to the intent. The name must include a package
5610 * prefix, for example the app com.android.contacts would use names
5611 * like "com.android.contacts.ShowAll".
5612 *
5613 * @param name The name of the extra data, with package prefix.
5614 * @param value The double data value.
5615 *
5616 * @return Returns the same Intent object, for chaining multiple calls
5617 * into a single statement.
5618 *
5619 * @see #putExtras
5620 * @see #removeExtra
5621 * @see #getDoubleExtra(String, double)
5622 */
5623 public Intent putExtra(String name, double value) {
5624 if (mExtras == null) {
5625 mExtras = new Bundle();
5626 }
5627 mExtras.putDouble(name, value);
5628 return this;
5629 }
5630
5631 /**
5632 * Add extended data to the intent. The name must include a package
5633 * prefix, for example the app com.android.contacts would use names
5634 * like "com.android.contacts.ShowAll".
5635 *
5636 * @param name The name of the extra data, with package prefix.
5637 * @param value The String data value.
5638 *
5639 * @return Returns the same Intent object, for chaining multiple calls
5640 * into a single statement.
5641 *
5642 * @see #putExtras
5643 * @see #removeExtra
5644 * @see #getStringExtra(String)
5645 */
5646 public Intent putExtra(String name, String value) {
5647 if (mExtras == null) {
5648 mExtras = new Bundle();
5649 }
5650 mExtras.putString(name, value);
5651 return this;
5652 }
5653
5654 /**
5655 * Add extended data to the intent. The name must include a package
5656 * prefix, for example the app com.android.contacts would use names
5657 * like "com.android.contacts.ShowAll".
5658 *
5659 * @param name The name of the extra data, with package prefix.
5660 * @param value The CharSequence data value.
5661 *
5662 * @return Returns the same Intent object, for chaining multiple calls
5663 * into a single statement.
5664 *
5665 * @see #putExtras
5666 * @see #removeExtra
5667 * @see #getCharSequenceExtra(String)
5668 */
5669 public Intent putExtra(String name, CharSequence value) {
5670 if (mExtras == null) {
5671 mExtras = new Bundle();
5672 }
5673 mExtras.putCharSequence(name, value);
5674 return this;
5675 }
5676
5677 /**
5678 * Add extended data to the intent. The name must include a package
5679 * prefix, for example the app com.android.contacts would use names
5680 * like "com.android.contacts.ShowAll".
5681 *
5682 * @param name The name of the extra data, with package prefix.
5683 * @param value The Parcelable data value.
5684 *
5685 * @return Returns the same Intent object, for chaining multiple calls
5686 * into a single statement.
5687 *
5688 * @see #putExtras
5689 * @see #removeExtra
5690 * @see #getParcelableExtra(String)
5691 */
5692 public Intent putExtra(String name, Parcelable value) {
5693 if (mExtras == null) {
5694 mExtras = new Bundle();
5695 }
5696 mExtras.putParcelable(name, value);
5697 return this;
5698 }
5699
5700 /**
5701 * Add extended data to the intent. The name must include a package
5702 * prefix, for example the app com.android.contacts would use names
5703 * like "com.android.contacts.ShowAll".
5704 *
5705 * @param name The name of the extra data, with package prefix.
5706 * @param value The Parcelable[] data value.
5707 *
5708 * @return Returns the same Intent object, for chaining multiple calls
5709 * into a single statement.
5710 *
5711 * @see #putExtras
5712 * @see #removeExtra
5713 * @see #getParcelableArrayExtra(String)
5714 */
5715 public Intent putExtra(String name, Parcelable[] value) {
5716 if (mExtras == null) {
5717 mExtras = new Bundle();
5718 }
5719 mExtras.putParcelableArray(name, value);
5720 return this;
5721 }
5722
5723 /**
5724 * Add extended data to the intent. The name must include a package
5725 * prefix, for example the app com.android.contacts would use names
5726 * like "com.android.contacts.ShowAll".
5727 *
5728 * @param name The name of the extra data, with package prefix.
5729 * @param value The ArrayList<Parcelable> data value.
5730 *
5731 * @return Returns the same Intent object, for chaining multiple calls
5732 * into a single statement.
5733 *
5734 * @see #putExtras
5735 * @see #removeExtra
5736 * @see #getParcelableArrayListExtra(String)
5737 */
5738 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
5739 if (mExtras == null) {
5740 mExtras = new Bundle();
5741 }
5742 mExtras.putParcelableArrayList(name, value);
5743 return this;
5744 }
5745
5746 /**
5747 * Add extended data to the intent. The name must include a package
5748 * prefix, for example the app com.android.contacts would use names
5749 * like "com.android.contacts.ShowAll".
5750 *
5751 * @param name The name of the extra data, with package prefix.
5752 * @param value The ArrayList<Integer> data value.
5753 *
5754 * @return Returns the same Intent object, for chaining multiple calls
5755 * into a single statement.
5756 *
5757 * @see #putExtras
5758 * @see #removeExtra
5759 * @see #getIntegerArrayListExtra(String)
5760 */
5761 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
5762 if (mExtras == null) {
5763 mExtras = new Bundle();
5764 }
5765 mExtras.putIntegerArrayList(name, value);
5766 return this;
5767 }
5768
5769 /**
5770 * Add extended data to the intent. The name must include a package
5771 * prefix, for example the app com.android.contacts would use names
5772 * like "com.android.contacts.ShowAll".
5773 *
5774 * @param name The name of the extra data, with package prefix.
5775 * @param value The ArrayList<String> data value.
5776 *
5777 * @return Returns the same Intent object, for chaining multiple calls
5778 * into a single statement.
5779 *
5780 * @see #putExtras
5781 * @see #removeExtra
5782 * @see #getStringArrayListExtra(String)
5783 */
5784 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
5785 if (mExtras == null) {
5786 mExtras = new Bundle();
5787 }
5788 mExtras.putStringArrayList(name, value);
5789 return this;
5790 }
5791
5792 /**
5793 * Add extended data to the intent. The name must include a package
5794 * prefix, for example the app com.android.contacts would use names
5795 * like "com.android.contacts.ShowAll".
5796 *
5797 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005798 * @param value The ArrayList<CharSequence> data value.
5799 *
5800 * @return Returns the same Intent object, for chaining multiple calls
5801 * into a single statement.
5802 *
5803 * @see #putExtras
5804 * @see #removeExtra
5805 * @see #getCharSequenceArrayListExtra(String)
5806 */
5807 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
5808 if (mExtras == null) {
5809 mExtras = new Bundle();
5810 }
5811 mExtras.putCharSequenceArrayList(name, value);
5812 return this;
5813 }
5814
5815 /**
5816 * Add extended data to the intent. The name must include a package
5817 * prefix, for example the app com.android.contacts would use names
5818 * like "com.android.contacts.ShowAll".
5819 *
5820 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005821 * @param value The Serializable data value.
5822 *
5823 * @return Returns the same Intent object, for chaining multiple calls
5824 * into a single statement.
5825 *
5826 * @see #putExtras
5827 * @see #removeExtra
5828 * @see #getSerializableExtra(String)
5829 */
5830 public Intent putExtra(String name, Serializable value) {
5831 if (mExtras == null) {
5832 mExtras = new Bundle();
5833 }
5834 mExtras.putSerializable(name, value);
5835 return this;
5836 }
5837
5838 /**
5839 * Add extended data to the intent. The name must include a package
5840 * prefix, for example the app com.android.contacts would use names
5841 * like "com.android.contacts.ShowAll".
5842 *
5843 * @param name The name of the extra data, with package prefix.
5844 * @param value The boolean array data value.
5845 *
5846 * @return Returns the same Intent object, for chaining multiple calls
5847 * into a single statement.
5848 *
5849 * @see #putExtras
5850 * @see #removeExtra
5851 * @see #getBooleanArrayExtra(String)
5852 */
5853 public Intent putExtra(String name, boolean[] value) {
5854 if (mExtras == null) {
5855 mExtras = new Bundle();
5856 }
5857 mExtras.putBooleanArray(name, value);
5858 return this;
5859 }
5860
5861 /**
5862 * Add extended data to the intent. The name must include a package
5863 * prefix, for example the app com.android.contacts would use names
5864 * like "com.android.contacts.ShowAll".
5865 *
5866 * @param name The name of the extra data, with package prefix.
5867 * @param value The byte array data value.
5868 *
5869 * @return Returns the same Intent object, for chaining multiple calls
5870 * into a single statement.
5871 *
5872 * @see #putExtras
5873 * @see #removeExtra
5874 * @see #getByteArrayExtra(String)
5875 */
5876 public Intent putExtra(String name, byte[] value) {
5877 if (mExtras == null) {
5878 mExtras = new Bundle();
5879 }
5880 mExtras.putByteArray(name, value);
5881 return this;
5882 }
5883
5884 /**
5885 * Add extended data to the intent. The name must include a package
5886 * prefix, for example the app com.android.contacts would use names
5887 * like "com.android.contacts.ShowAll".
5888 *
5889 * @param name The name of the extra data, with package prefix.
5890 * @param value The short array data value.
5891 *
5892 * @return Returns the same Intent object, for chaining multiple calls
5893 * into a single statement.
5894 *
5895 * @see #putExtras
5896 * @see #removeExtra
5897 * @see #getShortArrayExtra(String)
5898 */
5899 public Intent putExtra(String name, short[] value) {
5900 if (mExtras == null) {
5901 mExtras = new Bundle();
5902 }
5903 mExtras.putShortArray(name, value);
5904 return this;
5905 }
5906
5907 /**
5908 * Add extended data to the intent. The name must include a package
5909 * prefix, for example the app com.android.contacts would use names
5910 * like "com.android.contacts.ShowAll".
5911 *
5912 * @param name The name of the extra data, with package prefix.
5913 * @param value The char array data value.
5914 *
5915 * @return Returns the same Intent object, for chaining multiple calls
5916 * into a single statement.
5917 *
5918 * @see #putExtras
5919 * @see #removeExtra
5920 * @see #getCharArrayExtra(String)
5921 */
5922 public Intent putExtra(String name, char[] value) {
5923 if (mExtras == null) {
5924 mExtras = new Bundle();
5925 }
5926 mExtras.putCharArray(name, value);
5927 return this;
5928 }
5929
5930 /**
5931 * Add extended data to the intent. The name must include a package
5932 * prefix, for example the app com.android.contacts would use names
5933 * like "com.android.contacts.ShowAll".
5934 *
5935 * @param name The name of the extra data, with package prefix.
5936 * @param value The int array data value.
5937 *
5938 * @return Returns the same Intent object, for chaining multiple calls
5939 * into a single statement.
5940 *
5941 * @see #putExtras
5942 * @see #removeExtra
5943 * @see #getIntArrayExtra(String)
5944 */
5945 public Intent putExtra(String name, int[] value) {
5946 if (mExtras == null) {
5947 mExtras = new Bundle();
5948 }
5949 mExtras.putIntArray(name, value);
5950 return this;
5951 }
5952
5953 /**
5954 * Add extended data to the intent. The name must include a package
5955 * prefix, for example the app com.android.contacts would use names
5956 * like "com.android.contacts.ShowAll".
5957 *
5958 * @param name The name of the extra data, with package prefix.
5959 * @param value The byte array data value.
5960 *
5961 * @return Returns the same Intent object, for chaining multiple calls
5962 * into a single statement.
5963 *
5964 * @see #putExtras
5965 * @see #removeExtra
5966 * @see #getLongArrayExtra(String)
5967 */
5968 public Intent putExtra(String name, long[] value) {
5969 if (mExtras == null) {
5970 mExtras = new Bundle();
5971 }
5972 mExtras.putLongArray(name, value);
5973 return this;
5974 }
5975
5976 /**
5977 * Add extended data to the intent. The name must include a package
5978 * prefix, for example the app com.android.contacts would use names
5979 * like "com.android.contacts.ShowAll".
5980 *
5981 * @param name The name of the extra data, with package prefix.
5982 * @param value The float array data value.
5983 *
5984 * @return Returns the same Intent object, for chaining multiple calls
5985 * into a single statement.
5986 *
5987 * @see #putExtras
5988 * @see #removeExtra
5989 * @see #getFloatArrayExtra(String)
5990 */
5991 public Intent putExtra(String name, float[] value) {
5992 if (mExtras == null) {
5993 mExtras = new Bundle();
5994 }
5995 mExtras.putFloatArray(name, value);
5996 return this;
5997 }
5998
5999 /**
6000 * Add extended data to the intent. The name must include a package
6001 * prefix, for example the app com.android.contacts would use names
6002 * like "com.android.contacts.ShowAll".
6003 *
6004 * @param name The name of the extra data, with package prefix.
6005 * @param value The double array data value.
6006 *
6007 * @return Returns the same Intent object, for chaining multiple calls
6008 * into a single statement.
6009 *
6010 * @see #putExtras
6011 * @see #removeExtra
6012 * @see #getDoubleArrayExtra(String)
6013 */
6014 public Intent putExtra(String name, double[] value) {
6015 if (mExtras == null) {
6016 mExtras = new Bundle();
6017 }
6018 mExtras.putDoubleArray(name, value);
6019 return this;
6020 }
6021
6022 /**
6023 * Add extended data to the intent. The name must include a package
6024 * prefix, for example the app com.android.contacts would use names
6025 * like "com.android.contacts.ShowAll".
6026 *
6027 * @param name The name of the extra data, with package prefix.
6028 * @param value The String array data value.
6029 *
6030 * @return Returns the same Intent object, for chaining multiple calls
6031 * into a single statement.
6032 *
6033 * @see #putExtras
6034 * @see #removeExtra
6035 * @see #getStringArrayExtra(String)
6036 */
6037 public Intent putExtra(String name, String[] value) {
6038 if (mExtras == null) {
6039 mExtras = new Bundle();
6040 }
6041 mExtras.putStringArray(name, value);
6042 return this;
6043 }
6044
6045 /**
6046 * Add extended data to the intent. The name must include a package
6047 * prefix, for example the app com.android.contacts would use names
6048 * like "com.android.contacts.ShowAll".
6049 *
6050 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006051 * @param value The CharSequence array data value.
6052 *
6053 * @return Returns the same Intent object, for chaining multiple calls
6054 * into a single statement.
6055 *
6056 * @see #putExtras
6057 * @see #removeExtra
6058 * @see #getCharSequenceArrayExtra(String)
6059 */
6060 public Intent putExtra(String name, CharSequence[] value) {
6061 if (mExtras == null) {
6062 mExtras = new Bundle();
6063 }
6064 mExtras.putCharSequenceArray(name, value);
6065 return this;
6066 }
6067
6068 /**
6069 * Add extended data to the intent. The name must include a package
6070 * prefix, for example the app com.android.contacts would use names
6071 * like "com.android.contacts.ShowAll".
6072 *
6073 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006074 * @param value The Bundle data value.
6075 *
6076 * @return Returns the same Intent object, for chaining multiple calls
6077 * into a single statement.
6078 *
6079 * @see #putExtras
6080 * @see #removeExtra
6081 * @see #getBundleExtra(String)
6082 */
6083 public Intent putExtra(String name, Bundle value) {
6084 if (mExtras == null) {
6085 mExtras = new Bundle();
6086 }
6087 mExtras.putBundle(name, value);
6088 return this;
6089 }
6090
6091 /**
6092 * Add extended data to the intent. The name must include a package
6093 * prefix, for example the app com.android.contacts would use names
6094 * like "com.android.contacts.ShowAll".
6095 *
6096 * @param name The name of the extra data, with package prefix.
6097 * @param value The IBinder data value.
6098 *
6099 * @return Returns the same Intent object, for chaining multiple calls
6100 * into a single statement.
6101 *
6102 * @see #putExtras
6103 * @see #removeExtra
6104 * @see #getIBinderExtra(String)
6105 *
6106 * @deprecated
6107 * @hide
6108 */
6109 @Deprecated
6110 public Intent putExtra(String name, IBinder value) {
6111 if (mExtras == null) {
6112 mExtras = new Bundle();
6113 }
6114 mExtras.putIBinder(name, value);
6115 return this;
6116 }
6117
6118 /**
6119 * Copy all extras in 'src' in to this intent.
6120 *
6121 * @param src Contains the extras to copy.
6122 *
6123 * @see #putExtra
6124 */
6125 public Intent putExtras(Intent src) {
6126 if (src.mExtras != null) {
6127 if (mExtras == null) {
6128 mExtras = new Bundle(src.mExtras);
6129 } else {
6130 mExtras.putAll(src.mExtras);
6131 }
6132 }
6133 return this;
6134 }
6135
6136 /**
6137 * Add a set of extended data to the intent. The keys must include a package
6138 * prefix, for example the app com.android.contacts would use names
6139 * like "com.android.contacts.ShowAll".
6140 *
6141 * @param extras The Bundle of extras to add to this intent.
6142 *
6143 * @see #putExtra
6144 * @see #removeExtra
6145 */
6146 public Intent putExtras(Bundle extras) {
6147 if (mExtras == null) {
6148 mExtras = new Bundle();
6149 }
6150 mExtras.putAll(extras);
6151 return this;
6152 }
6153
6154 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006155 * Completely replace the extras in the Intent with the extras in the
6156 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006157 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006158 * @param src The exact extras contained in this Intent are copied
6159 * into the target intent, replacing any that were previously there.
6160 */
6161 public Intent replaceExtras(Intent src) {
6162 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6163 return this;
6164 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006165
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006166 /**
6167 * Completely replace the extras in the Intent with the given Bundle of
6168 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006169 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006170 * @param extras The new set of extras in the Intent, or null to erase
6171 * all extras.
6172 */
6173 public Intent replaceExtras(Bundle extras) {
6174 mExtras = extras != null ? new Bundle(extras) : null;
6175 return this;
6176 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006177
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006178 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006179 * Remove extended data from the intent.
6180 *
6181 * @see #putExtra
6182 */
6183 public void removeExtra(String name) {
6184 if (mExtras != null) {
6185 mExtras.remove(name);
6186 if (mExtras.size() == 0) {
6187 mExtras = null;
6188 }
6189 }
6190 }
6191
6192 /**
6193 * Set special flags controlling how this intent is handled. Most values
6194 * here depend on the type of component being executed by the Intent,
6195 * specifically the FLAG_ACTIVITY_* flags are all for use with
6196 * {@link Context#startActivity Context.startActivity()} and the
6197 * FLAG_RECEIVER_* flags are all for use with
6198 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6199 *
Scott Main7aee61f2011-02-08 11:25:01 -08006200 * <p>See the
6201 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6202 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006203 * the behavior of your application.
6204 *
6205 * @param flags The desired flags.
6206 *
6207 * @return Returns the same Intent object, for chaining multiple calls
6208 * into a single statement.
6209 *
6210 * @see #getFlags
6211 * @see #addFlags
6212 *
6213 * @see #FLAG_GRANT_READ_URI_PERMISSION
6214 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
6215 * @see #FLAG_DEBUG_LOG_RESOLUTION
6216 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006217 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006218 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006219 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006220 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006221 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6222 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006223 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006224 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6225 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006226 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006227 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006228 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006229 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6230 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006231 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006232 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006233 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006234 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6235 */
6236 public Intent setFlags(int flags) {
6237 mFlags = flags;
6238 return this;
6239 }
6240
6241 /**
6242 * Add additional flags to the intent (or with existing flags
6243 * value).
6244 *
6245 * @param flags The new flags to set.
6246 *
6247 * @return Returns the same Intent object, for chaining multiple calls
6248 * into a single statement.
6249 *
6250 * @see #setFlags
6251 */
6252 public Intent addFlags(int flags) {
6253 mFlags |= flags;
6254 return this;
6255 }
6256
6257 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006258 * (Usually optional) Set an explicit application package name that limits
6259 * the components this Intent will resolve to. If left to the default
6260 * value of null, all components in all applications will considered.
6261 * If non-null, the Intent can only match the components in the given
6262 * application package.
6263 *
6264 * @param packageName The name of the application package to handle the
6265 * intent, or null to allow any application package.
6266 *
6267 * @return Returns the same Intent object, for chaining multiple calls
6268 * into a single statement.
6269 *
6270 * @see #getPackage
6271 * @see #resolveActivity
6272 */
6273 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006274 if (packageName != null && mSelector != null) {
6275 throw new IllegalArgumentException(
6276 "Can't set package name when selector is already set");
6277 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006278 mPackage = packageName;
6279 return this;
6280 }
6281
6282 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006283 * (Usually optional) Explicitly set the component to handle the intent.
6284 * If left with the default value of null, the system will determine the
6285 * appropriate class to use based on the other fields (action, data,
6286 * type, categories) in the Intent. If this class is defined, the
6287 * specified class will always be used regardless of the other fields. You
6288 * should only set this value when you know you absolutely want a specific
6289 * class to be used; otherwise it is better to let the system find the
6290 * appropriate class so that you will respect the installed applications
6291 * and user preferences.
6292 *
6293 * @param component The name of the application component to handle the
6294 * intent, or null to let the system find one for you.
6295 *
6296 * @return Returns the same Intent object, for chaining multiple calls
6297 * into a single statement.
6298 *
6299 * @see #setClass
6300 * @see #setClassName(Context, String)
6301 * @see #setClassName(String, String)
6302 * @see #getComponent
6303 * @see #resolveActivity
6304 */
6305 public Intent setComponent(ComponentName component) {
6306 mComponent = component;
6307 return this;
6308 }
6309
6310 /**
6311 * Convenience for calling {@link #setComponent} with an
6312 * explicit class name.
6313 *
6314 * @param packageContext A Context of the application package implementing
6315 * this class.
6316 * @param className The name of a class inside of the application package
6317 * that will be used as the component for this Intent.
6318 *
6319 * @return Returns the same Intent object, for chaining multiple calls
6320 * into a single statement.
6321 *
6322 * @see #setComponent
6323 * @see #setClass
6324 */
6325 public Intent setClassName(Context packageContext, String className) {
6326 mComponent = new ComponentName(packageContext, className);
6327 return this;
6328 }
6329
6330 /**
6331 * Convenience for calling {@link #setComponent} with an
6332 * explicit application package name and class name.
6333 *
6334 * @param packageName The name of the package implementing the desired
6335 * component.
6336 * @param className The name of a class inside of the application package
6337 * that will be used as the component for this Intent.
6338 *
6339 * @return Returns the same Intent object, for chaining multiple calls
6340 * into a single statement.
6341 *
6342 * @see #setComponent
6343 * @see #setClass
6344 */
6345 public Intent setClassName(String packageName, String className) {
6346 mComponent = new ComponentName(packageName, className);
6347 return this;
6348 }
6349
6350 /**
6351 * Convenience for calling {@link #setComponent(ComponentName)} with the
6352 * name returned by a {@link Class} object.
6353 *
6354 * @param packageContext A Context of the application package implementing
6355 * this class.
6356 * @param cls The class name to set, equivalent to
6357 * <code>setClassName(context, cls.getName())</code>.
6358 *
6359 * @return Returns the same Intent object, for chaining multiple calls
6360 * into a single statement.
6361 *
6362 * @see #setComponent
6363 */
6364 public Intent setClass(Context packageContext, Class<?> cls) {
6365 mComponent = new ComponentName(packageContext, cls);
6366 return this;
6367 }
6368
6369 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006370 * Set the bounds of the sender of this intent, in screen coordinates. This can be
6371 * used as a hint to the receiver for animations and the like. Null means that there
6372 * is no source bounds.
6373 */
6374 public void setSourceBounds(Rect r) {
6375 if (r != null) {
6376 mSourceBounds = new Rect(r);
6377 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07006378 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006379 }
6380 }
6381
6382 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006383 * Use with {@link #fillIn} to allow the current action value to be
6384 * overwritten, even if it is already set.
6385 */
6386 public static final int FILL_IN_ACTION = 1<<0;
6387
6388 /**
6389 * Use with {@link #fillIn} to allow the current data or type value
6390 * overwritten, even if it is already set.
6391 */
6392 public static final int FILL_IN_DATA = 1<<1;
6393
6394 /**
6395 * Use with {@link #fillIn} to allow the current categories to be
6396 * overwritten, even if they are already set.
6397 */
6398 public static final int FILL_IN_CATEGORIES = 1<<2;
6399
6400 /**
6401 * Use with {@link #fillIn} to allow the current component value to be
6402 * overwritten, even if it is already set.
6403 */
6404 public static final int FILL_IN_COMPONENT = 1<<3;
6405
6406 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006407 * Use with {@link #fillIn} to allow the current package value to be
6408 * overwritten, even if it is already set.
6409 */
6410 public static final int FILL_IN_PACKAGE = 1<<4;
6411
6412 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006413 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006414 * overwritten, even if it is already set.
6415 */
6416 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
6417
6418 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006419 * Use with {@link #fillIn} to allow the current selector to be
6420 * overwritten, even if it is already set.
6421 */
6422 public static final int FILL_IN_SELECTOR = 1<<6;
6423
6424 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006425 * Use with {@link #fillIn} to allow the current ClipData to be
6426 * overwritten, even if it is already set.
6427 */
6428 public static final int FILL_IN_CLIP_DATA = 1<<7;
6429
6430 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006431 * Copy the contents of <var>other</var> in to this object, but only
6432 * where fields are not defined by this object. For purposes of a field
6433 * being defined, the following pieces of data in the Intent are
6434 * considered to be separate fields:
6435 *
6436 * <ul>
6437 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08006438 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006439 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
6440 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006441 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006442 * <li> component, as set by {@link #setComponent(ComponentName)} or
6443 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006444 * <li> source bounds, as set by {@link #setSourceBounds}.
6445 * <li> selector, as set by {@link #setSelector(Intent)}.
6446 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006447 * <li> each top-level name in the associated extras.
6448 * </ul>
6449 *
6450 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006451 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006452 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6453 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
6454 * the restriction where the corresponding field will not be replaced if
6455 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006456 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006457 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
6458 * is explicitly specified. The selector will only be copied if
6459 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07006460 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006461 * <p>For example, consider Intent A with {data="foo", categories="bar"}
6462 * and Intent B with {action="gotit", data-type="some/thing",
6463 * categories="one","two"}.
6464 *
6465 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
6466 * containing: {action="gotit", data-type="some/thing",
6467 * categories="bar"}.
6468 *
6469 * @param other Another Intent whose values are to be used to fill in
6470 * the current one.
6471 * @param flags Options to control which fields can be filled in.
6472 *
6473 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006474 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006475 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, and
6476 * {@link #FILL_IN_SELECTOR} indicating which fields were changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006477 */
6478 public int fillIn(Intent other, int flags) {
6479 int changes = 0;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006480 if (other.mAction != null
6481 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006482 mAction = other.mAction;
6483 changes |= FILL_IN_ACTION;
6484 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006485 if ((other.mData != null || other.mType != null)
6486 && ((mData == null && mType == null)
6487 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006488 mData = other.mData;
6489 mType = other.mType;
6490 changes |= FILL_IN_DATA;
6491 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006492 if (other.mCategories != null
6493 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006494 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006495 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006496 }
6497 changes |= FILL_IN_CATEGORIES;
6498 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006499 if (other.mPackage != null
6500 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006501 // Only do this if mSelector is not set.
6502 if (mSelector == null) {
6503 mPackage = other.mPackage;
6504 changes |= FILL_IN_PACKAGE;
6505 }
6506 }
6507 // Selector is special: it can only be set if explicitly allowed,
6508 // for the same reason as the component name.
6509 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
6510 if (mPackage == null) {
6511 mSelector = new Intent(other.mSelector);
6512 mPackage = null;
6513 changes |= FILL_IN_SELECTOR;
6514 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006515 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006516 if (other.mClipData != null
6517 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
6518 mClipData = other.mClipData;
6519 changes |= FILL_IN_CLIP_DATA;
6520 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006521 // Component is special: it can -only- be set if explicitly allowed,
6522 // since otherwise the sender could force the intent somewhere the
6523 // originator didn't intend.
6524 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006525 mComponent = other.mComponent;
6526 changes |= FILL_IN_COMPONENT;
6527 }
6528 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006529 if (other.mSourceBounds != null
6530 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
6531 mSourceBounds = new Rect(other.mSourceBounds);
6532 changes |= FILL_IN_SOURCE_BOUNDS;
6533 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006534 if (mExtras == null) {
6535 if (other.mExtras != null) {
6536 mExtras = new Bundle(other.mExtras);
6537 }
6538 } else if (other.mExtras != null) {
6539 try {
6540 Bundle newb = new Bundle(other.mExtras);
6541 newb.putAll(mExtras);
6542 mExtras = newb;
6543 } catch (RuntimeException e) {
6544 // Modifying the extras can cause us to unparcel the contents
6545 // of the bundle, and if we do this in the system process that
6546 // may fail. We really should handle this (i.e., the Bundle
6547 // impl shouldn't be on top of a plain map), but for now just
6548 // ignore it and keep the original contents. :(
6549 Log.w("Intent", "Failure filling in extras", e);
6550 }
6551 }
6552 return changes;
6553 }
6554
6555 /**
6556 * Wrapper class holding an Intent and implementing comparisons on it for
6557 * the purpose of filtering. The class implements its
6558 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
6559 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
6560 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
6561 * on the wrapped Intent.
6562 */
6563 public static final class FilterComparison {
6564 private final Intent mIntent;
6565 private final int mHashCode;
6566
6567 public FilterComparison(Intent intent) {
6568 mIntent = intent;
6569 mHashCode = intent.filterHashCode();
6570 }
6571
6572 /**
6573 * Return the Intent that this FilterComparison represents.
6574 * @return Returns the Intent held by the FilterComparison. Do
6575 * not modify!
6576 */
6577 public Intent getIntent() {
6578 return mIntent;
6579 }
6580
6581 @Override
6582 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006583 if (obj instanceof FilterComparison) {
6584 Intent other = ((FilterComparison)obj).mIntent;
6585 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006586 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006587 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006588 }
6589
6590 @Override
6591 public int hashCode() {
6592 return mHashCode;
6593 }
6594 }
6595
6596 /**
6597 * Determine if two intents are the same for the purposes of intent
6598 * resolution (filtering). That is, if their action, data, type,
6599 * class, and categories are the same. This does <em>not</em> compare
6600 * any extra data included in the intents.
6601 *
6602 * @param other The other Intent to compare against.
6603 *
6604 * @return Returns true if action, data, type, class, and categories
6605 * are the same.
6606 */
6607 public boolean filterEquals(Intent other) {
6608 if (other == null) {
6609 return false;
6610 }
6611 if (mAction != other.mAction) {
6612 if (mAction != null) {
6613 if (!mAction.equals(other.mAction)) {
6614 return false;
6615 }
6616 } else {
6617 if (!other.mAction.equals(mAction)) {
6618 return false;
6619 }
6620 }
6621 }
6622 if (mData != other.mData) {
6623 if (mData != null) {
6624 if (!mData.equals(other.mData)) {
6625 return false;
6626 }
6627 } else {
6628 if (!other.mData.equals(mData)) {
6629 return false;
6630 }
6631 }
6632 }
6633 if (mType != other.mType) {
6634 if (mType != null) {
6635 if (!mType.equals(other.mType)) {
6636 return false;
6637 }
6638 } else {
6639 if (!other.mType.equals(mType)) {
6640 return false;
6641 }
6642 }
6643 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006644 if (mPackage != other.mPackage) {
6645 if (mPackage != null) {
6646 if (!mPackage.equals(other.mPackage)) {
6647 return false;
6648 }
6649 } else {
6650 if (!other.mPackage.equals(mPackage)) {
6651 return false;
6652 }
6653 }
6654 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006655 if (mComponent != other.mComponent) {
6656 if (mComponent != null) {
6657 if (!mComponent.equals(other.mComponent)) {
6658 return false;
6659 }
6660 } else {
6661 if (!other.mComponent.equals(mComponent)) {
6662 return false;
6663 }
6664 }
6665 }
6666 if (mCategories != other.mCategories) {
6667 if (mCategories != null) {
6668 if (!mCategories.equals(other.mCategories)) {
6669 return false;
6670 }
6671 } else {
6672 if (!other.mCategories.equals(mCategories)) {
6673 return false;
6674 }
6675 }
6676 }
6677
6678 return true;
6679 }
6680
6681 /**
6682 * Generate hash code that matches semantics of filterEquals().
6683 *
6684 * @return Returns the hash value of the action, data, type, class, and
6685 * categories.
6686 *
6687 * @see #filterEquals
6688 */
6689 public int filterHashCode() {
6690 int code = 0;
6691 if (mAction != null) {
6692 code += mAction.hashCode();
6693 }
6694 if (mData != null) {
6695 code += mData.hashCode();
6696 }
6697 if (mType != null) {
6698 code += mType.hashCode();
6699 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006700 if (mPackage != null) {
6701 code += mPackage.hashCode();
6702 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006703 if (mComponent != null) {
6704 code += mComponent.hashCode();
6705 }
6706 if (mCategories != null) {
6707 code += mCategories.hashCode();
6708 }
6709 return code;
6710 }
6711
6712 @Override
6713 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006714 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006715
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006716 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006717 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006718 b.append(" }");
6719
6720 return b.toString();
6721 }
6722
6723 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006724 public String toInsecureString() {
6725 StringBuilder b = new StringBuilder(128);
6726
6727 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006728 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006729 b.append(" }");
6730
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006731 return b.toString();
6732 }
Romain Guy4969af72009-06-17 10:53:19 -07006733
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006734 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006735 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006736 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006737
6738 b.append("Intent { ");
6739 toShortString(b, false, true, true, true);
6740 b.append(" }");
6741
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006742 return b.toString();
6743 }
6744
6745 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006746 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
6747 StringBuilder b = new StringBuilder(128);
6748 toShortString(b, secure, comp, extras, clip);
6749 return b.toString();
6750 }
6751
6752 /** @hide */
6753 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
6754 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006755 boolean first = true;
6756 if (mAction != null) {
6757 b.append("act=").append(mAction);
6758 first = false;
6759 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006760 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006761 if (!first) {
6762 b.append(' ');
6763 }
6764 first = false;
6765 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006766 for (int i=0; i<mCategories.size(); i++) {
6767 if (i > 0) b.append(',');
6768 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006769 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006770 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006771 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006772 if (mData != null) {
6773 if (!first) {
6774 b.append(' ');
6775 }
6776 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07006777 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006778 if (secure) {
6779 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07006780 } else {
6781 b.append(mData);
6782 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006783 }
6784 if (mType != null) {
6785 if (!first) {
6786 b.append(' ');
6787 }
6788 first = false;
6789 b.append("typ=").append(mType);
6790 }
6791 if (mFlags != 0) {
6792 if (!first) {
6793 b.append(' ');
6794 }
6795 first = false;
6796 b.append("flg=0x").append(Integer.toHexString(mFlags));
6797 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006798 if (mPackage != null) {
6799 if (!first) {
6800 b.append(' ');
6801 }
6802 first = false;
6803 b.append("pkg=").append(mPackage);
6804 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006805 if (comp && mComponent != null) {
6806 if (!first) {
6807 b.append(' ');
6808 }
6809 first = false;
6810 b.append("cmp=").append(mComponent.flattenToShortString());
6811 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006812 if (mSourceBounds != null) {
6813 if (!first) {
6814 b.append(' ');
6815 }
6816 first = false;
6817 b.append("bnds=").append(mSourceBounds.toShortString());
6818 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006819 if (mClipData != null) {
6820 if (!first) {
6821 b.append(' ');
6822 }
6823 first = false;
6824 if (clip) {
6825 b.append("clip={");
6826 mClipData.toShortString(b);
6827 b.append('}');
6828 } else {
6829 b.append("(has clip)");
6830 }
6831 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006832 if (extras && mExtras != null) {
6833 if (!first) {
6834 b.append(' ');
6835 }
6836 first = false;
6837 b.append("(has extras)");
6838 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006839 if (mSelector != null) {
6840 b.append(" sel={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006841 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006842 b.append("}");
6843 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006844 }
6845
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006846 /**
6847 * Call {@link #toUri} with 0 flags.
6848 * @deprecated Use {@link #toUri} instead.
6849 */
6850 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006851 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006852 return toUri(0);
6853 }
6854
6855 /**
6856 * Convert this Intent into a String holding a URI representation of it.
6857 * The returned URI string has been properly URI encoded, so it can be
6858 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
6859 * Intent's data as the base URI, with an additional fragment describing
6860 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08006861 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006862 * <p>You can convert the returned string back to an Intent with
6863 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08006864 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006865 * @param flags Additional operating flags. Either 0 or
6866 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08006867 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006868 * @return Returns a URI encoding URI string describing the entire contents
6869 * of the Intent.
6870 */
6871 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006872 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006873 String scheme = null;
6874 if (mData != null) {
6875 String data = mData.toString();
6876 if ((flags&URI_INTENT_SCHEME) != 0) {
6877 final int N = data.length();
6878 for (int i=0; i<N; i++) {
6879 char c = data.charAt(i);
6880 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
6881 || c == '.' || c == '-') {
6882 continue;
6883 }
6884 if (c == ':' && i > 0) {
6885 // Valid scheme.
6886 scheme = data.substring(0, i);
6887 uri.append("intent:");
6888 data = data.substring(i+1);
6889 break;
6890 }
Tom Taylord4a47292009-12-21 13:59:18 -08006891
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006892 // No scheme.
6893 break;
6894 }
6895 }
6896 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08006897
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006898 } else if ((flags&URI_INTENT_SCHEME) != 0) {
6899 uri.append("intent:");
6900 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006901
6902 uri.append("#Intent;");
6903
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006904 toUriInner(uri, scheme, flags);
6905 if (mSelector != null) {
6906 uri.append("SEL;");
6907 // Note that for now we are not going to try to handle the
6908 // data part; not clear how to represent this as a URI, and
6909 // not much utility in it.
6910 mSelector.toUriInner(uri, null, flags);
6911 }
6912
6913 uri.append("end");
6914
6915 return uri.toString();
6916 }
6917
6918 private void toUriInner(StringBuilder uri, String scheme, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006919 if (scheme != null) {
6920 uri.append("scheme=").append(scheme).append(';');
6921 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006922 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006923 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 }
6925 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006926 for (int i=0; i<mCategories.size(); i++) {
6927 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006928 }
6929 }
6930 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006931 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006932 }
6933 if (mFlags != 0) {
6934 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
6935 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006936 if (mPackage != null) {
6937 uri.append("package=").append(Uri.encode(mPackage)).append(';');
6938 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006939 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006940 uri.append("component=").append(Uri.encode(
6941 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006942 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006943 if (mSourceBounds != null) {
6944 uri.append("sourceBounds=")
6945 .append(Uri.encode(mSourceBounds.flattenToString()))
6946 .append(';');
6947 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006948 if (mExtras != null) {
6949 for (String key : mExtras.keySet()) {
6950 final Object value = mExtras.get(key);
6951 char entryType =
6952 value instanceof String ? 'S' :
6953 value instanceof Boolean ? 'B' :
6954 value instanceof Byte ? 'b' :
6955 value instanceof Character ? 'c' :
6956 value instanceof Double ? 'd' :
6957 value instanceof Float ? 'f' :
6958 value instanceof Integer ? 'i' :
6959 value instanceof Long ? 'l' :
6960 value instanceof Short ? 's' :
6961 '\0';
6962
6963 if (entryType != '\0') {
6964 uri.append(entryType);
6965 uri.append('.');
6966 uri.append(Uri.encode(key));
6967 uri.append('=');
6968 uri.append(Uri.encode(value.toString()));
6969 uri.append(';');
6970 }
6971 }
6972 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006973 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006975 public int describeContents() {
6976 return (mExtras != null) ? mExtras.describeContents() : 0;
6977 }
6978
6979 public void writeToParcel(Parcel out, int flags) {
6980 out.writeString(mAction);
6981 Uri.writeToParcel(out, mData);
6982 out.writeString(mType);
6983 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006984 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006985 ComponentName.writeToParcel(mComponent, out);
6986
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006987 if (mSourceBounds != null) {
6988 out.writeInt(1);
6989 mSourceBounds.writeToParcel(out, flags);
6990 } else {
6991 out.writeInt(0);
6992 }
6993
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006994 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006995 final int N = mCategories.size();
6996 out.writeInt(N);
6997 for (int i=0; i<N; i++) {
6998 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006999 }
7000 } else {
7001 out.writeInt(0);
7002 }
7003
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007004 if (mSelector != null) {
7005 out.writeInt(1);
7006 mSelector.writeToParcel(out, flags);
7007 } else {
7008 out.writeInt(0);
7009 }
7010
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007011 if (mClipData != null) {
7012 out.writeInt(1);
7013 mClipData.writeToParcel(out, flags);
7014 } else {
7015 out.writeInt(0);
7016 }
7017
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007018 out.writeBundle(mExtras);
7019 }
7020
7021 public static final Parcelable.Creator<Intent> CREATOR
7022 = new Parcelable.Creator<Intent>() {
7023 public Intent createFromParcel(Parcel in) {
7024 return new Intent(in);
7025 }
7026 public Intent[] newArray(int size) {
7027 return new Intent[size];
7028 }
7029 };
7030
Dianne Hackborneb034652009-09-07 00:49:58 -07007031 /** @hide */
7032 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007033 readFromParcel(in);
7034 }
7035
7036 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007037 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007038 mData = Uri.CREATOR.createFromParcel(in);
7039 mType = in.readString();
7040 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007041 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007042 mComponent = ComponentName.readFromParcel(in);
7043
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007044 if (in.readInt() != 0) {
7045 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7046 }
7047
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007048 int N = in.readInt();
7049 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007050 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007051 int i;
7052 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007053 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007054 }
7055 } else {
7056 mCategories = null;
7057 }
7058
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007059 if (in.readInt() != 0) {
7060 mSelector = new Intent(in);
7061 }
7062
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007063 if (in.readInt() != 0) {
7064 mClipData = new ClipData(in);
7065 }
7066
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007067 mExtras = in.readBundle();
7068 }
7069
7070 /**
7071 * Parses the "intent" element (and its children) from XML and instantiates
7072 * an Intent object. The given XML parser should be located at the tag
7073 * where parsing should start (often named "intent"), from which the
7074 * basic action, data, type, and package and class name will be
7075 * retrieved. The function will then parse in to any child elements,
7076 * looking for <category android:name="xxx"> tags to add categories and
7077 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7078 * to the intent.
7079 *
7080 * @param resources The Resources to use when inflating resources.
7081 * @param parser The XML parser pointing at an "intent" tag.
7082 * @param attrs The AttributeSet interface for retrieving extended
7083 * attribute data at the current <var>parser</var> location.
7084 * @return An Intent object matching the XML data.
7085 * @throws XmlPullParserException If there was an XML parsing error.
7086 * @throws IOException If there was an I/O error.
7087 */
7088 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7089 throws XmlPullParserException, IOException {
7090 Intent intent = new Intent();
7091
7092 TypedArray sa = resources.obtainAttributes(attrs,
7093 com.android.internal.R.styleable.Intent);
7094
7095 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7096
7097 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7098 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7099 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7100
7101 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7102 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7103 if (packageName != null && className != null) {
7104 intent.setComponent(new ComponentName(packageName, className));
7105 }
7106
7107 sa.recycle();
7108
7109 int outerDepth = parser.getDepth();
7110 int type;
7111 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7112 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7113 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7114 continue;
7115 }
7116
7117 String nodeName = parser.getName();
7118 if (nodeName.equals("category")) {
7119 sa = resources.obtainAttributes(attrs,
7120 com.android.internal.R.styleable.IntentCategory);
7121 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7122 sa.recycle();
7123
7124 if (cat != null) {
7125 intent.addCategory(cat);
7126 }
7127 XmlUtils.skipCurrentTag(parser);
7128
7129 } else if (nodeName.equals("extra")) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007130 if (intent.mExtras == null) {
7131 intent.mExtras = new Bundle();
7132 }
7133 resources.parseBundleExtra("extra", attrs, intent.mExtras);
7134 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007135
7136 } else {
7137 XmlUtils.skipCurrentTag(parser);
7138 }
7139 }
7140
7141 return intent;
7142 }
Nick Pellyccae4122012-01-09 14:12:58 -08007143
7144 /**
7145 * Normalize a MIME data type.
7146 *
7147 * <p>A normalized MIME type has white-space trimmed,
7148 * content-type parameters removed, and is lower-case.
7149 * This aligns the type with Android best practices for
7150 * intent filtering.
7151 *
7152 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7153 * "text/x-vCard" becomes "text/x-vcard".
7154 *
7155 * <p>All MIME types received from outside Android (such as user input,
7156 * or external sources like Bluetooth, NFC, or the Internet) should
7157 * be normalized before they are used to create an Intent.
7158 *
7159 * @param type MIME data type to normalize
7160 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007161 * @see #setType
7162 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007163 */
7164 public static String normalizeMimeType(String type) {
7165 if (type == null) {
7166 return null;
7167 }
7168
Elliott Hughescb64d432013-08-02 10:00:44 -07007169 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007170
7171 final int semicolonIndex = type.indexOf(';');
7172 if (semicolonIndex != -1) {
7173 type = type.substring(0, semicolonIndex);
7174 }
7175 return type;
7176 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007177
7178 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007179 * Prepare this {@link Intent} to leave an app process.
7180 *
7181 * @hide
7182 */
7183 public void prepareToLeaveProcess() {
7184 setAllowFds(false);
7185
7186 if (mSelector != null) {
7187 mSelector.prepareToLeaveProcess();
7188 }
7189 if (mClipData != null) {
7190 mClipData.prepareToLeaveProcess();
7191 }
7192
7193 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7194 // There are several ACTION_MEDIA_* broadcasts that send file://
7195 // Uris, so only check common actions.
7196 if (ACTION_VIEW.equals(mAction) ||
7197 ACTION_EDIT.equals(mAction) ||
7198 ACTION_ATTACH_DATA.equals(mAction)) {
7199 mData.checkFileUriExposed("Intent.getData()");
7200 }
7201 }
7202 }
7203
7204 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007205 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007206 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
7207 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007208 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007209 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007210 * @hide
7211 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007212 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007213 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007214 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007215
7216 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007217 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007218
7219 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007220 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkey1c297002012-05-18 13:55:47 -07007221 try {
7222 // Inspect target intent to see if we need to migrate
7223 final Intent target = getParcelableExtra(EXTRA_INTENT);
7224 if (target != null && target.migrateExtraStreamToClipData()) {
7225 // Since we migrated in child, we need to promote ClipData
7226 // and flags to ourselves to grant.
7227 setClipData(target.getClipData());
7228 addFlags(target.getFlags()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07007229 & (FLAG_GRANT_READ_URI_PERMISSION | FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkeye66c1772013-09-20 14:30:59 -07007230 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION));
Jeff Sharkey1c297002012-05-18 13:55:47 -07007231 return true;
7232 } else {
7233 return false;
7234 }
7235 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007236 }
7237
7238 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007239 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007240 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7241 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
7242 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
7243 if (stream != null || text != null || htmlText != null) {
7244 final ClipData clipData = new ClipData(
7245 null, new String[] { getType() },
7246 new ClipData.Item(text, htmlText, null, stream));
7247 setClipData(clipData);
7248 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007249 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007250 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007251 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007252 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007253
7254 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007255 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007256 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7257 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
7258 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
7259 int num = -1;
7260 if (streams != null) {
7261 num = streams.size();
7262 }
7263 if (texts != null) {
7264 if (num >= 0 && num != texts.size()) {
7265 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007266 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007267 }
7268 num = texts.size();
7269 }
7270 if (htmlTexts != null) {
7271 if (num >= 0 && num != htmlTexts.size()) {
7272 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007273 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007274 }
7275 num = htmlTexts.size();
7276 }
7277 if (num > 0) {
7278 final ClipData clipData = new ClipData(
7279 null, new String[] { getType() },
7280 makeClipItem(streams, texts, htmlTexts, 0));
7281
7282 for (int i = 1; i < num; i++) {
7283 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
7284 }
7285
7286 setClipData(clipData);
7287 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007288 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007289 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007290 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007291 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007292 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007293
7294 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007295 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07007296
7297 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
7298 ArrayList<String> htmlTexts, int which) {
7299 Uri uri = streams != null ? streams.get(which) : null;
7300 CharSequence text = texts != null ? texts.get(which) : null;
7301 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
7302 return new ClipData.Item(text, htmlText, null, uri);
7303 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007304}