blob: ae6047614a7e91980070df19ce7a020186cf740c [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;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010020import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070021import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070023import org.xmlpull.v1.XmlPullParser;
24import org.xmlpull.v1.XmlPullParserException;
25
Tor Norbyed9273d62013-05-30 15:59:53 -070026import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.annotation.SdkConstant;
28import android.annotation.SdkConstant.SdkConstantType;
29import android.content.pm.ActivityInfo;
Nicolas Prevotd85fc722014-04-16 19:52:08 +010030import static android.content.ContentProvider.maybeAddUserId;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.content.pm.PackageManager;
32import android.content.pm.ResolveInfo;
33import android.content.res.Resources;
34import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080035import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070036import android.net.Uri;
37import android.os.Bundle;
38import android.os.IBinder;
39import android.os.Parcel;
40import android.os.Parcelable;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070041import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010042import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070043import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.DocumentsProvider;
45import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070046import android.util.AttributeSet;
47import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080048
49import com.android.internal.util.XmlUtils;
Craig Mautner21d24a22014-04-23 11:45:37 -070050import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070051
52import java.io.IOException;
53import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070054import java.lang.annotation.Retention;
55import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070056import java.net.URISyntaxException;
57import java.util.ArrayList;
Dianne Hackborn221ea892013-08-04 16:50:16 -070058import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080059import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070060import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070061import java.util.Set;
62
63/**
64 * An intent is an abstract description of an operation to be performed. It
65 * can be used with {@link Context#startActivity(Intent) startActivity} to
66 * launch an {@link android.app.Activity},
67 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
68 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
69 * and {@link android.content.Context#startService} or
70 * {@link android.content.Context#bindService} to communicate with a
71 * background {@link android.app.Service}.
72 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070073 * <p>An Intent provides a facility for performing late runtime binding between the code in
74 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070075 * can be thought of as the glue between activities. It is basically a passive data structure
76 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070077 *
78 * <div class="special reference">
79 * <h3>Developer Guides</h3>
80 * <p>For information about how to create and resolve intents, read the
81 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
82 * developer guide.</p>
83 * </div>
84 *
85 * <a name="IntentStructure"></a>
86 * <h3>Intent Structure</h3>
87 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070088 *
89 * <ul>
90 * <li> <p><b>action</b> -- The general action to be performed, such as
91 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
92 * etc.</p>
93 * </li>
94 * <li> <p><b>data</b> -- The data to operate on, such as a person record
95 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
96 * </li>
97 * </ul>
98 *
99 *
100 * <p>Some examples of action/data pairs are:</p>
101 *
102 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700103 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700104 * information about the person whose identifier is "1".</p>
105 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700106 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700107 * the phone dialer with the person filled in.</p>
108 * </li>
109 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
110 * the phone dialer with the given number filled in. Note how the
111 * VIEW action does what what is considered the most reasonable thing for
112 * a particular URI.</p>
113 * </li>
114 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
115 * the phone dialer with the given number filled in.</p>
116 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700117 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700118 * information about the person whose identifier is "1".</p>
119 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700120 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * a list of people, which the user can browse through. This example is a
122 * typical top-level entry into the Contacts application, showing you the
123 * list of people. Selecting a particular person to view would result in a
124 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
125 * being used to start an activity to display that person.</p>
126 * </li>
127 * </ul>
128 *
129 * <p>In addition to these primary attributes, there are a number of secondary
130 * attributes that you can also include with an intent:</p>
131 *
132 * <ul>
133 * <li> <p><b>category</b> -- Gives additional information about the action
134 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
135 * appear in the Launcher as a top-level application, while
136 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
137 * of alternative actions the user can perform on a piece of data.</p>
138 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
139 * intent data. Normally the type is inferred from the data itself.
140 * By setting this attribute, you disable that evaluation and force
141 * an explicit type.</p>
142 * <li> <p><b>component</b> -- Specifies an explicit name of a component
143 * class to use for the intent. Normally this is determined by looking
144 * at the other information in the intent (the action, data/type, and
145 * categories) and matching that with a component that can handle it.
146 * If this attribute is set then none of the evaluation is performed,
147 * and this component is used exactly as is. By specifying this attribute,
148 * all of the other Intent attributes become optional.</p>
149 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
150 * This can be used to provide extended information to the component.
151 * For example, if we have a action to send an e-mail message, we could
152 * also include extra pieces of data here to supply a subject, body,
153 * etc.</p>
154 * </ul>
155 *
156 * <p>Here are some examples of other operations you can specify as intents
157 * using these additional parameters:</p>
158 *
159 * <ul>
160 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
161 * Launch the home screen.</p>
162 * </li>
163 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
164 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
165 * vnd.android.cursor.item/phone}</i></b>
166 * -- Display the list of people's phone numbers, allowing the user to
167 * browse through them and pick one and return it to the parent activity.</p>
168 * </li>
169 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
170 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
171 * -- Display all pickers for data that can be opened with
172 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
173 * allowing the user to pick one of them and then some data inside of it
174 * and returning the resulting URI to the caller. This can be used,
175 * for example, in an e-mail application to allow the user to pick some
176 * data to include as an attachment.</p>
177 * </li>
178 * </ul>
179 *
180 * <p>There are a variety of standard Intent action and category constants
181 * defined in the Intent class, but applications can also define their own.
182 * These strings use java style scoping, to ensure they are unique -- for
183 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700184 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700185 *
186 * <p>Put together, the set of actions, data types, categories, and extra data
187 * defines a language for the system allowing for the expression of phrases
188 * such as "call john smith's cell". As applications are added to the system,
189 * they can extend this language by adding new actions, types, and categories, or
190 * they can modify the behavior of existing phrases by supplying their own
191 * activities that handle them.</p>
192 *
193 * <a name="IntentResolution"></a>
194 * <h3>Intent Resolution</h3>
195 *
196 * <p>There are two primary forms of intents you will use.
197 *
198 * <ul>
199 * <li> <p><b>Explicit Intents</b> have specified a component (via
200 * {@link #setComponent} or {@link #setClass}), which provides the exact
201 * class to be run. Often these will not include any other information,
202 * simply being a way for an application to launch various internal
203 * activities it has as the user interacts with the application.
204 *
205 * <li> <p><b>Implicit Intents</b> have not specified a component;
206 * instead, they must include enough information for the system to
207 * determine which of the available components is best to run for that
208 * intent.
209 * </ul>
210 *
211 * <p>When using implicit intents, given such an arbitrary intent we need to
212 * know what to do with it. This is handled by the process of <em>Intent
213 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
214 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
215 * more activities/receivers) that can handle it.</p>
216 *
217 * <p>The intent resolution mechanism basically revolves around matching an
218 * Intent against all of the &lt;intent-filter&gt; descriptions in the
219 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
220 * objects explicitly registered with {@link Context#registerReceiver}.) More
221 * details on this can be found in the documentation on the {@link
222 * IntentFilter} class.</p>
223 *
224 * <p>There are three pieces of information in the Intent that are used for
225 * resolution: the action, type, and category. Using this information, a query
226 * is done on the {@link PackageManager} for a component that can handle the
227 * intent. The appropriate component is determined based on the intent
228 * information supplied in the <code>AndroidManifest.xml</code> file as
229 * follows:</p>
230 *
231 * <ul>
232 * <li> <p>The <b>action</b>, if given, must be listed by the component as
233 * one it handles.</p>
234 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
235 * already supplied in the Intent. Like the action, if a type is
236 * included in the intent (either explicitly or implicitly in its
237 * data), then this must be listed by the component as one it handles.</p>
238 * <li> For data that is not a <code>content:</code> URI and where no explicit
239 * type is included in the Intent, instead the <b>scheme</b> of the
240 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
241 * considered. Again like the action, if we are matching a scheme it
242 * must be listed by the component as one it can handle.
243 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
244 * by the activity as categories it handles. That is, if you include
245 * the categories {@link #CATEGORY_LAUNCHER} and
246 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
247 * with an intent that lists <em>both</em> of those categories.
248 * Activities will very often need to support the
249 * {@link #CATEGORY_DEFAULT} so that they can be found by
250 * {@link Context#startActivity Context.startActivity()}.</p>
251 * </ul>
252 *
253 * <p>For example, consider the Note Pad sample application that
254 * allows user to browse through a list of notes data and view details about
255 * individual items. Text in italics indicate places were you would replace a
256 * name with one specific to your own package.</p>
257 *
258 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
259 * package="<i>com.android.notepad</i>"&gt;
260 * &lt;application android:icon="@drawable/app_notes"
261 * android:label="@string/app_name"&gt;
262 *
263 * &lt;provider class=".NotePadProvider"
264 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
265 *
266 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
267 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700268 * &lt;action android:name="android.intent.action.MAIN" /&gt;
269 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700270 * &lt;/intent-filter&gt;
271 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700272 * &lt;action android:name="android.intent.action.VIEW" /&gt;
273 * &lt;action android:name="android.intent.action.EDIT" /&gt;
274 * &lt;action android:name="android.intent.action.PICK" /&gt;
275 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
276 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700277 * &lt;/intent-filter&gt;
278 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700279 * &lt;action android:name="android.intent.action.GET_CONTENT" /&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 * &lt;/activity&gt;
284 *
285 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
286 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700287 * &lt;action android:name="android.intent.action.VIEW" /&gt;
288 * &lt;action android:name="android.intent.action.EDIT" /&gt;
289 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
290 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700291 * &lt;/intent-filter&gt;
292 *
293 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.INSERT" /&gt;
295 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
296 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700297 * &lt;/intent-filter&gt;
298 *
299 * &lt;/activity&gt;
300 *
301 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
302 * android:theme="@android:style/Theme.Dialog"&gt;
303 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
307 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
308 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700309 * &lt;/intent-filter&gt;
310 * &lt;/activity&gt;
311 *
312 * &lt;/application&gt;
313 * &lt;/manifest&gt;</pre>
314 *
315 * <p>The first activity,
316 * <code>com.android.notepad.NotesList</code>, serves as our main
317 * entry into the app. It can do three things as described by its three intent
318 * templates:
319 * <ol>
320 * <li><pre>
321 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700322 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
323 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700324 * &lt;/intent-filter&gt;</pre>
325 * <p>This provides a top-level entry into the NotePad application: the standard
326 * MAIN action is a main entry point (not requiring any other information in
327 * the Intent), and the LAUNCHER category says that this entry point should be
328 * listed in the application launcher.</p>
329 * <li><pre>
330 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700331 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
332 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
333 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
334 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
335 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700336 * &lt;/intent-filter&gt;</pre>
337 * <p>This declares the things that the activity can do on a directory of
338 * notes. The type being supported is given with the &lt;type&gt; tag, where
339 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
340 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
341 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
342 * The activity allows the user to view or edit the directory of data (via
343 * the VIEW and EDIT actions), or to pick a particular note and return it
344 * to the caller (via the PICK action). Note also the DEFAULT category
345 * supplied here: this is <em>required</em> for the
346 * {@link Context#startActivity Context.startActivity} method to resolve your
347 * activity when its component name is not explicitly specified.</p>
348 * <li><pre>
349 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700350 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
351 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
352 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * &lt;/intent-filter&gt;</pre>
354 * <p>This filter describes the ability return to the caller a note selected by
355 * the user without needing to know where it came from. The data type
356 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
357 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
358 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
359 * The GET_CONTENT action is similar to the PICK action, where the activity
360 * will return to its caller a piece of data selected by the user. Here,
361 * however, the caller specifies the type of data they desire instead of
362 * the type of data the user will be picking from.</p>
363 * </ol>
364 *
365 * <p>Given these capabilities, the following intents will resolve to the
366 * NotesList activity:</p>
367 *
368 * <ul>
369 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
370 * activities that can be used as top-level entry points into an
371 * application.</p>
372 * <li> <p><b>{ action=android.app.action.MAIN,
373 * category=android.app.category.LAUNCHER }</b> is the actual intent
374 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700375 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700376 * data=content://com.google.provider.NotePad/notes }</b>
377 * displays a list of all the notes under
378 * "content://com.google.provider.NotePad/notes", which
379 * the user can browse through and see the details on.</p>
380 * <li> <p><b>{ action=android.app.action.PICK
381 * data=content://com.google.provider.NotePad/notes }</b>
382 * provides a list of the notes under
383 * "content://com.google.provider.NotePad/notes", from which
384 * the user can pick a note whose data URL is returned back to the caller.</p>
385 * <li> <p><b>{ action=android.app.action.GET_CONTENT
386 * type=vnd.android.cursor.item/vnd.google.note }</b>
387 * is similar to the pick action, but allows the caller to specify the
388 * kind of data they want back so that the system can find the appropriate
389 * activity to pick something of that data type.</p>
390 * </ul>
391 *
392 * <p>The second activity,
393 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
394 * note entry and allows them to edit it. It can do two things as described
395 * by its two intent templates:
396 * <ol>
397 * <li><pre>
398 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700399 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
400 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
401 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
402 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700403 * &lt;/intent-filter&gt;</pre>
404 * <p>The first, primary, purpose of this activity is to let the user interact
405 * with a single note, as decribed by the MIME type
406 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
407 * either VIEW a note or allow the user to EDIT it. Again we support the
408 * DEFAULT category to allow the activity to be launched without explicitly
409 * specifying its component.</p>
410 * <li><pre>
411 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700412 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
413 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
414 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700415 * &lt;/intent-filter&gt;</pre>
416 * <p>The secondary use of this activity is to insert a new note entry into
417 * an existing directory of notes. This is used when the user creates a new
418 * note: the INSERT action is executed on the directory of notes, causing
419 * this activity to run and have the user create the new note data which
420 * it then adds to the content provider.</p>
421 * </ol>
422 *
423 * <p>Given these capabilities, the following intents will resolve to the
424 * NoteEditor activity:</p>
425 *
426 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700427 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700428 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
429 * shows the user the content of note <var>{ID}</var>.</p>
430 * <li> <p><b>{ action=android.app.action.EDIT
431 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
432 * allows the user to edit the content of note <var>{ID}</var>.</p>
433 * <li> <p><b>{ action=android.app.action.INSERT
434 * data=content://com.google.provider.NotePad/notes }</b>
435 * creates a new, empty note in the notes list at
436 * "content://com.google.provider.NotePad/notes"
437 * and allows the user to edit it. If they keep their changes, the URI
438 * of the newly created note is returned to the caller.</p>
439 * </ul>
440 *
441 * <p>The last activity,
442 * <code>com.android.notepad.TitleEditor</code>, allows the user to
443 * edit the title of a note. This could be implemented as a class that the
444 * application directly invokes (by explicitly setting its component in
445 * the Intent), but here we show a way you can publish alternative
446 * operations on existing data:</p>
447 *
448 * <pre>
449 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700450 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
451 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
452 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
453 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
454 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700455 * &lt;/intent-filter&gt;</pre>
456 *
457 * <p>In the single intent template here, we
458 * have created our own private action called
459 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
460 * edit the title of a note. It must be invoked on a specific note
461 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
462 * view and edit actions, but here displays and edits the title contained
463 * in the note data.
464 *
465 * <p>In addition to supporting the default category as usual, our title editor
466 * also supports two other standard categories: ALTERNATIVE and
467 * SELECTED_ALTERNATIVE. Implementing
468 * these categories allows others to find the special action it provides
469 * without directly knowing about it, through the
470 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
471 * more often to build dynamic menu items with
472 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
473 * template here was also supply an explicit name for the template
474 * (via <code>android:label="@string/resolve_title"</code>) to better control
475 * what the user sees when presented with this activity as an alternative
476 * action to the data they are viewing.
477 *
478 * <p>Given these capabilities, the following intent will resolve to the
479 * TitleEditor activity:</p>
480 *
481 * <ul>
482 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
483 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
484 * displays and allows the user to edit the title associated
485 * with note <var>{ID}</var>.</p>
486 * </ul>
487 *
488 * <h3>Standard Activity Actions</h3>
489 *
490 * <p>These are the current standard actions that Intent defines for launching
491 * activities (usually through {@link Context#startActivity}. The most
492 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
493 * {@link #ACTION_EDIT}.
494 *
495 * <ul>
496 * <li> {@link #ACTION_MAIN}
497 * <li> {@link #ACTION_VIEW}
498 * <li> {@link #ACTION_ATTACH_DATA}
499 * <li> {@link #ACTION_EDIT}
500 * <li> {@link #ACTION_PICK}
501 * <li> {@link #ACTION_CHOOSER}
502 * <li> {@link #ACTION_GET_CONTENT}
503 * <li> {@link #ACTION_DIAL}
504 * <li> {@link #ACTION_CALL}
505 * <li> {@link #ACTION_SEND}
506 * <li> {@link #ACTION_SENDTO}
507 * <li> {@link #ACTION_ANSWER}
508 * <li> {@link #ACTION_INSERT}
509 * <li> {@link #ACTION_DELETE}
510 * <li> {@link #ACTION_RUN}
511 * <li> {@link #ACTION_SYNC}
512 * <li> {@link #ACTION_PICK_ACTIVITY}
513 * <li> {@link #ACTION_SEARCH}
514 * <li> {@link #ACTION_WEB_SEARCH}
515 * <li> {@link #ACTION_FACTORY_TEST}
516 * </ul>
517 *
518 * <h3>Standard Broadcast Actions</h3>
519 *
520 * <p>These are the current standard actions that Intent defines for receiving
521 * broadcasts (usually through {@link Context#registerReceiver} or a
522 * &lt;receiver&gt; tag in a manifest).
523 *
524 * <ul>
525 * <li> {@link #ACTION_TIME_TICK}
526 * <li> {@link #ACTION_TIME_CHANGED}
527 * <li> {@link #ACTION_TIMEZONE_CHANGED}
528 * <li> {@link #ACTION_BOOT_COMPLETED}
529 * <li> {@link #ACTION_PACKAGE_ADDED}
530 * <li> {@link #ACTION_PACKAGE_CHANGED}
531 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800532 * <li> {@link #ACTION_PACKAGE_RESTARTED}
533 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700534 * <li> {@link #ACTION_UID_REMOVED}
535 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700536 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700537 * <li> {@link #ACTION_POWER_DISCONNECTED}
538 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700539 * </ul>
540 *
541 * <h3>Standard Categories</h3>
542 *
543 * <p>These are the current standard categories that can be used to further
544 * clarify an Intent via {@link #addCategory}.
545 *
546 * <ul>
547 * <li> {@link #CATEGORY_DEFAULT}
548 * <li> {@link #CATEGORY_BROWSABLE}
549 * <li> {@link #CATEGORY_TAB}
550 * <li> {@link #CATEGORY_ALTERNATIVE}
551 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
552 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800553 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700554 * <li> {@link #CATEGORY_HOME}
555 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700556 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400557 * <li> {@link #CATEGORY_CAR_DOCK}
558 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500559 * <li> {@link #CATEGORY_LE_DESK_DOCK}
560 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200561 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700562 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * </ul>
564 *
565 * <h3>Standard Extra Data</h3>
566 *
567 * <p>These are the current standard fields that can be used as extra data via
568 * {@link #putExtra}.
569 *
570 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800571 * <li> {@link #EXTRA_ALARM_COUNT}
572 * <li> {@link #EXTRA_BCC}
573 * <li> {@link #EXTRA_CC}
574 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
575 * <li> {@link #EXTRA_DATA_REMOVED}
576 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500577 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
578 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800579 * <li> {@link #EXTRA_DOCK_STATE_CAR}
580 * <li> {@link #EXTRA_DOCK_STATE_DESK}
581 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
582 * <li> {@link #EXTRA_DONT_KILL_APP}
583 * <li> {@link #EXTRA_EMAIL}
584 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700585 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800586 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700587 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800588 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700589 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800590 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
591 * <li> {@link #EXTRA_REPLACING}
592 * <li> {@link #EXTRA_SHORTCUT_ICON}
593 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
594 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700595 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_SHORTCUT_NAME}
597 * <li> {@link #EXTRA_SUBJECT}
598 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700599 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_TITLE}
601 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * </ul>
603 *
604 * <h3>Flags</h3>
605 *
606 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800607 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
608 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800610public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700611 private static final String ATTR_ACTION = "action";
612 private static final String TAG_CATEGORIES = "categories";
613 private static final String ATTR_CATEGORY = "category";
614 private static final String TAG_EXTRA = "extra";
615 private static final String ATTR_TYPE = "type";
616 private static final String ATTR_COMPONENT = "component";
617 private static final String ATTR_DATA = "data";
618 private static final String ATTR_FLAGS = "flags";
619
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 // ---------------------------------------------------------------------
621 // ---------------------------------------------------------------------
622 // Standard intent activity actions (see action variable).
623
624 /**
625 * Activity Action: Start as a main entry point, does not expect to
626 * receive data.
627 * <p>Input: nothing
628 * <p>Output: nothing
629 */
630 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
631 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800632
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700633 /**
634 * Activity Action: Display the data to the user. This is the most common
635 * action performed on data -- it is the generic action you can use on
636 * a piece of data to get the most reasonable thing to occur. For example,
637 * when used on a contacts entry it will view the entry; when used on a
638 * mailto: URI it will bring up a compose window filled with the information
639 * supplied by the URI; when used with a tel: URI it will invoke the
640 * dialer.
641 * <p>Input: {@link #getData} is URI from which to retrieve data.
642 * <p>Output: nothing.
643 */
644 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
645 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800646
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700647 /**
648 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
649 * performed on a piece of data.
650 */
651 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700653 /**
654 * Used to indicate that some piece of data should be attached to some other
655 * place. For example, image data could be attached to a contact. It is up
656 * to the recipient to decide where the data should be attached; the intent
657 * does not specify the ultimate destination.
658 * <p>Input: {@link #getData} is URI of data to be attached.
659 * <p>Output: nothing.
660 */
661 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
662 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800663
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700664 /**
665 * Activity Action: Provide explicit editable access to the given data.
666 * <p>Input: {@link #getData} is URI of data to be edited.
667 * <p>Output: nothing.
668 */
669 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
670 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800671
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700672 /**
673 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
674 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
675 * The extras can contain type specific data to pass through to the editing/creating
676 * activity.
677 * <p>Output: The URI of the item that was picked. This must be a content:
678 * URI so that any receiver can access it.
679 */
680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
681 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800682
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700683 /**
684 * Activity Action: Pick an item from the data, returning what was selected.
685 * <p>Input: {@link #getData} is URI containing a directory of data
686 * (vnd.android.cursor.dir/*) from which to pick an item.
687 * <p>Output: The URI of the item that was picked.
688 */
689 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
690 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800691
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700692 /**
693 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800694 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700695 * <p>Output: An Intent representing the shortcut. The intent must contain three
696 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
697 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800698 * (value: ShortcutIconResource).</p>
699 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700700 * @see #EXTRA_SHORTCUT_INTENT
701 * @see #EXTRA_SHORTCUT_NAME
702 * @see #EXTRA_SHORTCUT_ICON
703 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
704 * @see android.content.Intent.ShortcutIconResource
705 */
706 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
707 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
708
709 /**
710 * The name of the extra used to define the Intent of a shortcut.
711 *
712 * @see #ACTION_CREATE_SHORTCUT
713 */
714 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
715 /**
716 * The name of the extra used to define the name of a shortcut.
717 *
718 * @see #ACTION_CREATE_SHORTCUT
719 */
720 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
721 /**
722 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
723 *
724 * @see #ACTION_CREATE_SHORTCUT
725 */
726 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
727 /**
728 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
729 *
730 * @see #ACTION_CREATE_SHORTCUT
731 * @see android.content.Intent.ShortcutIconResource
732 */
733 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
734 "android.intent.extra.shortcut.ICON_RESOURCE";
735
736 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800737 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700738 *
739 * @see Intent#ACTION_CREATE_SHORTCUT
740 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
742 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700743 */
744 public static class ShortcutIconResource implements Parcelable {
745 /**
746 * The package name of the application containing the icon.
747 */
748 public String packageName;
749
750 /**
751 * The resource name of the icon, including package, name and type.
752 */
753 public String resourceName;
754
755 /**
756 * Creates a new ShortcutIconResource for the specified context and resource
757 * identifier.
758 *
759 * @param context The context of the application.
760 * @param resourceId The resource idenfitier for the icon.
761 * @return A new ShortcutIconResource with the specified's context package name
762 * and icon resource idenfitier.
763 */
764 public static ShortcutIconResource fromContext(Context context, int resourceId) {
765 ShortcutIconResource icon = new ShortcutIconResource();
766 icon.packageName = context.getPackageName();
767 icon.resourceName = context.getResources().getResourceName(resourceId);
768 return icon;
769 }
770
771 /**
772 * Used to read a ShortcutIconResource from a Parcel.
773 */
774 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
775 new Parcelable.Creator<ShortcutIconResource>() {
776
777 public ShortcutIconResource createFromParcel(Parcel source) {
778 ShortcutIconResource icon = new ShortcutIconResource();
779 icon.packageName = source.readString();
780 icon.resourceName = source.readString();
781 return icon;
782 }
783
784 public ShortcutIconResource[] newArray(int size) {
785 return new ShortcutIconResource[size];
786 }
787 };
788
789 /**
790 * No special parcel contents.
791 */
792 public int describeContents() {
793 return 0;
794 }
795
796 public void writeToParcel(Parcel dest, int flags) {
797 dest.writeString(packageName);
798 dest.writeString(resourceName);
799 }
800
801 @Override
802 public String toString() {
803 return resourceName;
804 }
805 }
806
807 /**
808 * Activity Action: Display an activity chooser, allowing the user to pick
809 * what they want to before proceeding. This can be used as an alternative
810 * to the standard activity picker that is displayed by the system when
811 * you try to start an activity with multiple possible matches, with these
812 * differences in behavior:
813 * <ul>
814 * <li>You can specify the title that will appear in the activity chooser.
815 * <li>The user does not have the option to make one of the matching
816 * activities a preferred activity, and all possible activities will
817 * always be shown even if one of them is currently marked as the
818 * preferred activity.
819 * </ul>
820 * <p>
821 * This action should be used when the user will naturally expect to
822 * select an activity in order to proceed. An example if when not to use
823 * it is when the user clicks on a "mailto:" link. They would naturally
824 * expect to go directly to their mail app, so startActivity() should be
825 * called directly: it will
826 * either launch the current preferred app, or put up a dialog allowing the
827 * user to pick an app to use and optionally marking that as preferred.
828 * <p>
829 * In contrast, if the user is selecting a menu item to send a picture
830 * they are viewing to someone else, there are many different things they
831 * may want to do at this point: send it through e-mail, upload it to a
832 * web service, etc. In this case the CHOOSER action should be used, to
833 * always present to the user a list of the things they can do, with a
834 * nice title given by the caller such as "Send this photo with:".
835 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700836 * If you need to grant URI permissions through a chooser, you must specify
837 * the permissions to be granted on the ACTION_CHOOSER Intent
838 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
839 * {@link #setClipData} to specify the URIs to be granted as well as
840 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
841 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
842 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 * As a convenience, an Intent of this form can be created with the
844 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700845 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700846 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700847 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
848 * and can optionally have a {@link #EXTRA_TITLE} field containing the
849 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700850 * <p>
851 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700852 */
853 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
854 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
855
856 /**
857 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
858 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700859 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
860 * target intent, also optionally supplying a title. If the target
861 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
862 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
863 * set in the returned chooser intent, with its ClipData set appropriately:
864 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500865 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700866 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700867 * @param target The Intent that the user will be selecting an activity
868 * to perform.
869 * @param title Optional title that will be displayed in the chooser.
870 * @return Return a new Intent object that you can hand to
871 * {@link Context#startActivity(Intent) Context.startActivity()} and
872 * related methods.
873 */
874 public static Intent createChooser(Intent target, CharSequence title) {
875 Intent intent = new Intent(ACTION_CHOOSER);
876 intent.putExtra(EXTRA_INTENT, target);
877 if (title != null) {
878 intent.putExtra(EXTRA_TITLE, title);
879 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700880
881 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700882 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
883 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
884 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700885 if (permFlags != 0) {
886 ClipData targetClipData = target.getClipData();
887 if (targetClipData == null && target.getData() != null) {
888 ClipData.Item item = new ClipData.Item(target.getData());
889 String[] mimeTypes;
890 if (target.getType() != null) {
891 mimeTypes = new String[] { target.getType() };
892 } else {
893 mimeTypes = new String[] { };
894 }
895 targetClipData = new ClipData(null, mimeTypes, item);
896 }
897 if (targetClipData != null) {
898 intent.setClipData(targetClipData);
899 intent.addFlags(permFlags);
900 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700901 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700902
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700903 return intent;
904 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700905
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700906 /**
907 * Activity Action: Allow the user to select a particular kind of data and
908 * return it. This is different than {@link #ACTION_PICK} in that here we
909 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800910 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700911 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900912 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700913 * etc.
914 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900915 * 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 -0700916 * of data, such as a person contact, you set the MIME type to the kind of
917 * data you want and launch it with {@link Context#startActivity(Intent)}.
918 * The system will then launch the best application to select that kind
919 * of data for you.
920 * <p>
921 * You may also be interested in any of a set of types of content the user
922 * can pick. For example, an e-mail application that wants to allow the
923 * user to add an attachment to an e-mail message can use this action to
924 * bring up a list of all of the types of content the user can attach.
925 * <p>
926 * In this case, you should wrap the GET_CONTENT intent with a chooser
927 * (through {@link #createChooser}), which will give the proper interface
928 * for the user to pick how to send your data and allow you to specify
929 * a prompt indicating what they are doing. You will usually specify a
930 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
931 * broad range of content types the user can select from.
932 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900933 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700934 * only pick from data that can be represented as a stream. This is
935 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
936 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800937 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900938 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800939 * is locally available on the device. For example, if this extra is set
940 * to true then an image picker should not show any pictures that are available
941 * from a remote server but not already on the local device (thus requiring
942 * they be downloaded when opened).
943 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800944 * If the caller can handle multiple returned items (the user performing
945 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
946 * to indicate this.
947 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700948 * Input: {@link #getType} is the desired MIME type to retrieve. Note
949 * that no URI is supplied in the intent, as there are no constraints on
950 * where the returned data originally comes from. You may also include the
951 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800952 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800953 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
954 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700955 * <p>
956 * Output: The URI of the item that was picked. This must be a content:
957 * URI so that any receiver can access it.
958 */
959 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
960 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
961 /**
962 * Activity Action: Dial a number as specified by the data. This shows a
963 * UI with the number being dialed, allowing the user to explicitly
964 * initiate the call.
965 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
966 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
967 * number.
968 * <p>Output: nothing.
969 */
970 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
971 public static final String ACTION_DIAL = "android.intent.action.DIAL";
972 /**
973 * Activity Action: Perform a call to someone specified by the data.
974 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
975 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
976 * number.
977 * <p>Output: nothing.
978 *
979 * <p>Note: there will be restrictions on which applications can initiate a
980 * call; most applications should use the {@link #ACTION_DIAL}.
981 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
982 * numbers. Applications can <strong>dial</strong> emergency numbers using
983 * {@link #ACTION_DIAL}, however.
984 */
985 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
986 public static final String ACTION_CALL = "android.intent.action.CALL";
987 /**
988 * Activity Action: Perform a call to an emergency number specified by the
989 * data.
990 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
991 * tel: URI of an explicit phone number.
992 * <p>Output: nothing.
993 * @hide
994 */
995 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
996 /**
997 * Activity action: Perform a call to any number (emergency or not)
998 * specified by the data.
999 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1000 * tel: URI of an explicit phone number.
1001 * <p>Output: nothing.
1002 * @hide
1003 */
1004 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1005 /**
1006 * Activity Action: Send a message to someone specified by the data.
1007 * <p>Input: {@link #getData} is URI describing the target.
1008 * <p>Output: nothing.
1009 */
1010 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1011 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1012 /**
1013 * Activity Action: Deliver some data to someone else. Who the data is
1014 * being delivered to is not specified; it is up to the receiver of this
1015 * action to ask the user where the data should be sent.
1016 * <p>
1017 * When launching a SEND intent, you should usually wrap it in a chooser
1018 * (through {@link #createChooser}), which will give the proper interface
1019 * for the user to pick how to send your data and allow you to specify
1020 * a prompt indicating what they are doing.
1021 * <p>
1022 * Input: {@link #getType} is the MIME type of the data being sent.
1023 * get*Extra can have either a {@link #EXTRA_TEXT}
1024 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1025 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1026 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1027 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001028 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1029 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1030 * your text with HTML formatting.
1031 * <p>
1032 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1033 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1034 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1035 * content: URIs and other advanced features of {@link ClipData}. If
1036 * using this approach, you still must supply the same data through the
1037 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1038 * for compatibility with old applications. If you don't set a ClipData,
1039 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001040 * <p>
1041 * Optional standard extras, which may be interpreted by some recipients as
1042 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1043 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1044 * <p>
1045 * Output: nothing.
1046 */
1047 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1048 public static final String ACTION_SEND = "android.intent.action.SEND";
1049 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001050 * Activity Action: Deliver multiple data to someone else.
1051 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001052 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001053 * <p>
1054 * Input: {@link #getType} is the MIME type of the data being sent.
1055 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001056 * #EXTRA_STREAM} field, containing the data to be sent. If using
1057 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1058 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001059 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001060 * Multiple types are supported, and receivers should handle mixed types
1061 * whenever possible. The right way for the receiver to check them is to
1062 * use the content resolver on each URI. The intent sender should try to
1063 * put the most concrete mime type in the intent type, but it can fall
1064 * back to {@literal <type>/*} or {@literal *}/* as needed.
1065 * <p>
1066 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1067 * be image/jpg, but if you are sending image/jpg and image/png, then the
1068 * intent's type should be image/*.
1069 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001070 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1071 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1072 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1073 * content: URIs and other advanced features of {@link ClipData}. If
1074 * using this approach, you still must supply the same data through the
1075 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1076 * for compatibility with old applications. If you don't set a ClipData,
1077 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1078 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001079 * Optional standard extras, which may be interpreted by some recipients as
1080 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1081 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1082 * <p>
1083 * Output: nothing.
1084 */
1085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1086 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1087 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001088 * Activity Action: Handle an incoming phone call.
1089 * <p>Input: nothing.
1090 * <p>Output: nothing.
1091 */
1092 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1093 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1094 /**
1095 * Activity Action: Insert an empty item into the given container.
1096 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1097 * in which to place the data.
1098 * <p>Output: URI of the new data that was created.
1099 */
1100 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1101 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1102 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001103 * Activity Action: Create a new item in the given container, initializing it
1104 * from the current contents of the clipboard.
1105 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1106 * in which to place the data.
1107 * <p>Output: URI of the new data that was created.
1108 */
1109 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1110 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1111 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001112 * Activity Action: Delete the given data from its container.
1113 * <p>Input: {@link #getData} is URI of data to be deleted.
1114 * <p>Output: nothing.
1115 */
1116 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1118 /**
1119 * Activity Action: Run the data, whatever that means.
1120 * <p>Input: ? (Note: this is currently specific to the test harness.)
1121 * <p>Output: nothing.
1122 */
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1124 public static final String ACTION_RUN = "android.intent.action.RUN";
1125 /**
1126 * Activity Action: Perform a data synchronization.
1127 * <p>Input: ?
1128 * <p>Output: ?
1129 */
1130 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1131 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1132 /**
1133 * Activity Action: Pick an activity given an intent, returning the class
1134 * selected.
1135 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1136 * used with {@link PackageManager#queryIntentActivities} to determine the
1137 * set of activities from which to pick.
1138 * <p>Output: Class name of the activity that was selected.
1139 */
1140 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1141 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1142 /**
1143 * Activity Action: Perform a search.
1144 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1145 * is the text to search for. If empty, simply
1146 * enter your search results Activity with the search UI activated.
1147 * <p>Output: nothing.
1148 */
1149 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1150 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1151 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001152 * Activity Action: Start the platform-defined tutorial
1153 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1154 * is the text to search for. If empty, simply
1155 * enter your search results Activity with the search UI activated.
1156 * <p>Output: nothing.
1157 */
1158 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1159 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1160 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001161 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001162 * <p>
1163 * Input: {@link android.app.SearchManager#QUERY
1164 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1165 * a url starts with http or https, the site will be opened. If it is plain
1166 * text, Google search will be applied.
1167 * <p>
1168 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001169 */
1170 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1171 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001172
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001173 /**
Jim Miller07994402012-05-02 14:22:27 -07001174 * Activity Action: Perform assist action.
1175 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001176 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1177 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001178 * requested the assist.
Jim Miller07994402012-05-02 14:22:27 -07001179 * Output: nothing.
1180 */
1181 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1182 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001183
1184 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001185 * Activity Action: Perform voice assist action.
1186 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001187 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1188 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001189 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001190 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001191 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001192 */
1193 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1194 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1195
1196 /**
Adam Skory7140a252013-09-11 12:04:58 +01001197 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1198 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001199 */
1200 public static final String EXTRA_ASSIST_PACKAGE
1201 = "android.intent.extra.ASSIST_PACKAGE";
1202
1203 /**
Adam Skory7140a252013-09-11 12:04:58 +01001204 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1205 * information supplied by the current foreground app at the time of the assist request.
1206 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001207 */
1208 public static final String EXTRA_ASSIST_CONTEXT
1209 = "android.intent.extra.ASSIST_CONTEXT";
1210
Jim Miller07994402012-05-02 14:22:27 -07001211 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001212 * Activity Action: List all available applications
1213 * <p>Input: Nothing.
1214 * <p>Output: nothing.
1215 */
1216 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1217 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1218 /**
1219 * Activity Action: Show settings for choosing wallpaper
1220 * <p>Input: Nothing.
1221 * <p>Output: Nothing.
1222 */
1223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1224 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1225
1226 /**
1227 * Activity Action: Show activity for reporting a bug.
1228 * <p>Input: Nothing.
1229 * <p>Output: Nothing.
1230 */
1231 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1232 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1233
1234 /**
1235 * Activity Action: Main entry point for factory tests. Only used when
1236 * the device is booting in factory test node. The implementing package
1237 * must be installed in the system image.
1238 * <p>Input: nothing
1239 * <p>Output: nothing
1240 */
1241 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1242
1243 /**
1244 * Activity Action: The user pressed the "call" button to go to the dialer
1245 * or other appropriate UI for placing a call.
1246 * <p>Input: Nothing.
1247 * <p>Output: Nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1251
1252 /**
1253 * Activity Action: Start Voice Command.
1254 * <p>Input: Nothing.
1255 * <p>Output: Nothing.
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001259
1260 /**
1261 * Activity Action: Start action associated with long pressing on the
1262 * search key.
1263 * <p>Input: Nothing.
1264 * <p>Output: Nothing.
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001268
Jacek Surazski86b6c532009-05-13 14:38:28 +02001269 /**
1270 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1271 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001272 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001273 * <p>Input: No data is specified. The bug report is passed in using
1274 * an {@link #EXTRA_BUG_REPORT} field.
1275 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001276 *
1277 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001278 */
1279 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1280 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001281
1282 /**
1283 * Activity Action: Show power usage information to the user.
1284 * <p>Input: Nothing.
1285 * <p>Output: Nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001289
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001290 /**
1291 * Activity Action: Setup wizard to launch after a platform update. This
1292 * activity should have a string meta-data field associated with it,
1293 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1294 * the platform for setup. The activity will be launched only if
1295 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1296 * same value.
1297 * <p>Input: Nothing.
1298 * <p>Output: Nothing.
1299 * @hide
1300 */
1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1302 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001303
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001304 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001305 * Activity Action: Show settings for managing network data usage of a
1306 * specific application. Applications should define an activity that offers
1307 * options to control data usage.
1308 */
1309 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1310 public static final String ACTION_MANAGE_NETWORK_USAGE =
1311 "android.intent.action.MANAGE_NETWORK_USAGE";
1312
1313 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001314 * Activity Action: Launch application installer.
1315 * <p>
1316 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001317 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1318 * you can also use "package:<package-name>" to install an application for the
1319 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001320 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1321 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1322 * <p>
1323 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1324 * succeeded.
1325 *
1326 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1327 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1328 * @see #EXTRA_RETURN_RESULT
1329 */
1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1332
1333 /**
1334 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1335 * package. Specifies the installer package name; this package will receive the
1336 * {@link #ACTION_APP_ERROR} intent.
1337 */
1338 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1339 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1340
1341 /**
1342 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1343 * package. Specifies that the application being installed should not be
1344 * treated as coming from an unknown source, but as coming from the app
1345 * invoking the Intent. For this to work you must start the installer with
1346 * startActivityForResult().
1347 */
1348 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1349 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1350
1351 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001352 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1353 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001354 * data field originated from.
1355 */
rich cannings706e8ba2012-08-20 13:20:14 -07001356 public static final String EXTRA_ORIGINATING_URI
1357 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001358
1359 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001360 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1361 * {@link #ACTION_VIEW} to indicate the HTTP referrer URI associated with the Intent
1362 * data field or {@link #EXTRA_ORIGINATING_URI}.
rich cannings368ed012012-06-07 15:37:57 -07001363 */
1364 public static final String EXTRA_REFERRER
1365 = "android.intent.extra.REFERRER";
1366
1367 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001368 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1369 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1370 * @hide
1371 */
1372 public static final String EXTRA_ORIGINATING_UID
1373 = "android.intent.extra.ORIGINATING_UID";
1374
1375 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001376 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1377 * package. Tells the installer UI to skip the confirmation with the user
1378 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001379 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1380 * will no longer show an interstitial message about updating existing
1381 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001382 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001383 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001384 public static final String EXTRA_ALLOW_REPLACE
1385 = "android.intent.extra.ALLOW_REPLACE";
1386
1387 /**
1388 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1389 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1390 * return to the application the result code of the install/uninstall. The returned result
1391 * code will be {@link android.app.Activity#RESULT_OK} on success or
1392 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1393 */
1394 public static final String EXTRA_RETURN_RESULT
1395 = "android.intent.extra.RETURN_RESULT";
1396
1397 /**
1398 * Package manager install result code. @hide because result codes are not
1399 * yet ready to be exposed.
1400 */
1401 public static final String EXTRA_INSTALL_RESULT
1402 = "android.intent.extra.INSTALL_RESULT";
1403
1404 /**
1405 * Activity Action: Launch application uninstaller.
1406 * <p>
1407 * Input: The data must be a package: URI whose scheme specific part is
1408 * the package name of the current installed package to be uninstalled.
1409 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1410 * <p>
1411 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1412 * succeeded.
1413 */
1414 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1415 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1416
1417 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001418 * Specify whether the package should be uninstalled for all users.
1419 * @hide because these should not be part of normal application flow.
1420 */
1421 public static final String EXTRA_UNINSTALL_ALL_USERS
1422 = "android.intent.extra.UNINSTALL_ALL_USERS";
1423
1424 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001425 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1426 * describing the last run version of the platform that was setup.
1427 * @hide
1428 */
1429 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1430
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001431 // ---------------------------------------------------------------------
1432 // ---------------------------------------------------------------------
1433 // Standard intent broadcast actions (see action variable).
1434
1435 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001436 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1437 * <p>
1438 * For historical reasons, the name of this broadcast action refers to the power
1439 * state of the screen but it is actually sent in response to changes in the
1440 * overall interactive state of the device.
1441 * </p><p>
1442 * This broadcast is sent when the device becomes non-interactive which may have
1443 * nothing to do with the screen turning off. To determine the
1444 * actual state of the screen, use {@link android.view.Display#getState}.
1445 * </p><p>
1446 * See {@link android.os.PowerManager#isInteractive} for details.
1447 * </p>
Tom Taylord4a47292009-12-21 13:59:18 -08001448 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001449 * <p class="note">This is a protected intent that can only be sent
1450 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001451 */
1452 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1453 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001454
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001455 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001456 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1457 * <p>
1458 * For historical reasons, the name of this broadcast action refers to the power
1459 * state of the screen but it is actually sent in response to changes in the
1460 * overall interactive state of the device.
1461 * </p><p>
1462 * This broadcast is sent when the device becomes interactive which may have
1463 * nothing to do with the screen turning on. To determine the
1464 * actual state of the screen, use {@link android.view.Display#getState}.
1465 * </p><p>
1466 * See {@link android.os.PowerManager#isInteractive} for details.
1467 * </p>
Tom Taylord4a47292009-12-21 13:59:18 -08001468 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001469 * <p class="note">This is a protected intent that can only be sent
1470 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001471 */
1472 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1473 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001474
1475 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001476 * Broadcast Action: Sent after the system stops dreaming.
1477 *
1478 * <p class="note">This is a protected intent that can only be sent by the system.
1479 * It is only sent to registered receivers.</p>
1480 */
1481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1482 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1483
1484 /**
1485 * Broadcast Action: Sent after the system starts dreaming.
1486 *
1487 * <p class="note">This is a protected intent that can only be sent by the system.
1488 * It is only sent to registered receivers.</p>
1489 */
1490 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1491 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1492
1493 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001494 * 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 -07001495 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001496 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001497 * <p class="note">This is a protected intent that can only be sent
1498 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001499 */
1500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001501 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001502
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001503 /**
1504 * Broadcast Action: The current time has changed. Sent every
1505 * minute. You can <em>not</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001506 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001507 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1508 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001509 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001510 * <p class="note">This is a protected intent that can only be sent
1511 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001512 */
1513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1514 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1515 /**
1516 * Broadcast Action: The time was set.
1517 */
1518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1519 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1520 /**
1521 * Broadcast Action: The date has changed.
1522 */
1523 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1524 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1525 /**
1526 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1527 * <ul>
1528 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1529 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001530 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001531 * <p class="note">This is a protected intent that can only be sent
1532 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001533 */
1534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1535 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1536 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001537 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1538 * DNS entries should be tossed.
1539 * @hide
1540 */
1541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1542 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1543 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001544 * Alarm Changed Action: This is broadcast when the AlarmClock
1545 * application's alarm is set or unset. It is used by the
1546 * AlarmClock application and the StatusBar service.
1547 * @hide
1548 */
1549 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1550 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1551 /**
1552 * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
1553 * been failing for a long time. It is used by the SyncManager and the StatusBar service.
1554 * @hide
1555 */
1556 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1557 public static final String ACTION_SYNC_STATE_CHANGED
1558 = "android.intent.action.SYNC_STATE_CHANGED";
1559 /**
1560 * Broadcast Action: This is broadcast once, after the system has finished
1561 * booting. It can be used to perform application-specific initialization,
1562 * such as installing alarms. You must hold the
1563 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1564 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001565 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001566 * <p class="note">This is a protected intent that can only be sent
1567 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001568 */
1569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1570 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1571 /**
1572 * Broadcast Action: This is broadcast when a user action should request a
1573 * temporary system dialog to dismiss. Some examples of temporary system
1574 * dialogs are the notification window-shade and the recent tasks dialog.
1575 */
1576 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1577 /**
1578 * Broadcast Action: Trigger the download and eventual installation
1579 * of a package.
1580 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001581 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001582 * <p class="note">This is a protected intent that can only be sent
1583 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001584 *
1585 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001586 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001587 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1589 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1590 /**
1591 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001592 * device. The data contains the name of the package. Note that the
1593 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001594 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001595 * <ul>
1596 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1597 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1598 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1599 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001600 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001601 * <p class="note">This is a protected intent that can only be sent
1602 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001603 */
1604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1605 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1606 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001607 * Broadcast Action: A new version of an application package has been
1608 * installed, replacing an existing version that was previously installed.
1609 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001610 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001611 * <ul>
1612 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1613 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001614 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001615 * <p class="note">This is a protected intent that can only be sent
1616 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001617 */
1618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1619 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1620 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001621 * Broadcast Action: A new version of your application has been installed
1622 * over an existing one. This is only sent to the application that was
1623 * replaced. It does not contain any additional data; to receive it, just
1624 * use an intent filter for this action.
1625 *
1626 * <p class="note">This is a protected intent that can only be sent
1627 * by the system.
1628 */
1629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1630 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1631 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001632 * Broadcast Action: An existing application package has been removed from
1633 * the device. The data contains the name of the package. The package
1634 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001635 * <ul>
1636 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1637 * to the package.
1638 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1639 * application -- data and code -- is being removed.
1640 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1641 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1642 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001643 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001644 * <p class="note">This is a protected intent that can only be sent
1645 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001646 */
1647 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1648 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1649 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001650 * Broadcast Action: An existing application package has been completely
1651 * removed from the device. The data contains the name of the package.
1652 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1653 * {@link #EXTRA_DATA_REMOVED} is true and
1654 * {@link #EXTRA_REPLACING} is false of that broadcast.
1655 *
1656 * <ul>
1657 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1658 * to the package.
1659 * </ul>
1660 *
1661 * <p class="note">This is a protected intent that can only be sent
1662 * by the system.
1663 */
1664 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1665 public static final String ACTION_PACKAGE_FULLY_REMOVED
1666 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1667 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001668 * Broadcast Action: An existing application package has been changed (e.g.
1669 * a component has been enabled or disabled). The data contains the name of
1670 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001671 * <ul>
1672 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001673 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001674 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001675 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1676 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001677 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001678 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001679 * <p class="note">This is a protected intent that can only be sent
1680 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001681 */
1682 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1683 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1684 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001685 * @hide
1686 * Broadcast Action: Ask system services if there is any reason to
1687 * restart the given package. The data contains the name of the
1688 * package.
1689 * <ul>
1690 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1691 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
1692 * </ul>
1693 *
1694 * <p class="note">This is a protected intent that can only be sent
1695 * by the system.
1696 */
1697 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1698 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
1699 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001700 * Broadcast Action: The user has restarted a package, and all of its
1701 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001702 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001703 * be removed. Note that the restarted package does <em>not</em>
1704 * receive this broadcast.
1705 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001706 * <ul>
1707 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1708 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001709 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001710 * <p class="note">This is a protected intent that can only be sent
1711 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001712 */
1713 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1714 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
1715 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001716 * Broadcast Action: The user has cleared the data of a package. This should
1717 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001718 * its persistent data is erased and this broadcast sent.
1719 * Note that the cleared package does <em>not</em>
1720 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001721 * <ul>
1722 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
1723 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001724 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001725 * <p class="note">This is a protected intent that can only be sent
1726 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001727 */
1728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1729 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
1730 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001731 * Broadcast Action: A user ID has been removed from the system. The user
1732 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08001733 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001734 * <p class="note">This is a protected intent that can only be sent
1735 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001736 */
1737 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1738 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001739
1740 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001741 * Broadcast Action: Sent to the installer package of an application
1742 * when that application is first launched (that is the first time it
1743 * is moved out of the stopped state). The data contains the name of the package.
1744 *
1745 * <p class="note">This is a protected intent that can only be sent
1746 * by the system.
1747 */
1748 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1749 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
1750
1751 /**
Kenny Root5ab21572011-07-27 11:11:19 -07001752 * Broadcast Action: Sent to the system package verifier when a package
1753 * needs to be verified. The data contains the package URI.
1754 * <p class="note">
1755 * This is a protected intent that can only be sent by the system.
1756 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07001757 */
1758 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1759 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
1760
1761 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07001762 * Broadcast Action: Sent to the system package verifier when a package is
1763 * verified. The data contains the package URI.
1764 * <p class="note">
1765 * This is a protected intent that can only be sent by the system.
1766 */
1767 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1768 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
1769
1770 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001771 * Broadcast Action: Resources for a set of packages (which were
1772 * previously unavailable) are currently
1773 * available since the media on which they exist is available.
1774 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1775 * list of packages whose availability changed.
1776 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1777 * list of uids of packages whose availability changed.
1778 * Note that the
1779 * packages in this list do <em>not</em> receive this broadcast.
1780 * The specified set of packages are now available on the system.
1781 * <p>Includes the following extras:
1782 * <ul>
1783 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1784 * whose resources(were previously unavailable) are currently available.
1785 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
1786 * packages whose resources(were previously unavailable)
1787 * are currently available.
1788 * </ul>
1789 *
1790 * <p class="note">This is a protected intent that can only be sent
1791 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001792 */
1793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001794 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
1795 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001796
1797 /**
1798 * Broadcast Action: Resources for a set of packages are currently
1799 * unavailable since the media on which they exist is unavailable.
1800 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
1801 * list of packages whose availability changed.
1802 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
1803 * list of uids of packages whose availability changed.
1804 * The specified set of packages can no longer be
1805 * launched and are practically unavailable on the system.
1806 * <p>Inclues the following extras:
1807 * <ul>
1808 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
1809 * whose resources are no longer available.
1810 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
1811 * whose resources are no longer available.
1812 * </ul>
1813 *
1814 * <p class="note">This is a protected intent that can only be sent
1815 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001816 */
1817 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08001818 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05001819 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08001820
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001821 /**
1822 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07001823 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001824 * This should <em>only</em> be used to determine when the wallpaper
1825 * has changed to show the new wallpaper to the user. You should certainly
1826 * never, in response to this, change the wallpaper or other attributes of
1827 * it such as the suggested size. That would be crazy, right? You'd cause
1828 * all kinds of loops, especially if other apps are doing similar things,
1829 * right? Of course. So please don't do this.
1830 *
1831 * @deprecated Modern applications should use
1832 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
1833 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
1834 * shown behind their UI, rather than watching for this broadcast and
1835 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001836 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07001837 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001838 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
1839 /**
1840 * Broadcast Action: The current device {@link android.content.res.Configuration}
1841 * (orientation, locale, etc) has changed. When such a change happens, the
1842 * UIs (view hierarchy) will need to be rebuilt based on this new
1843 * information; for the most part, applications don't need to worry about
1844 * this, because the system will take care of stopping and restarting the
1845 * application to make sure it sees the new changes. Some system code that
1846 * can not be restarted will need to watch for this action and handle it
1847 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08001848 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001849 * <p class="note">
1850 * You can <em>not</em> receive this through components declared
1851 * in manifests, only by explicitly registering for it with
1852 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1853 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001854 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001855 * <p class="note">This is a protected intent that can only be sent
1856 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001857 *
1858 * @see android.content.res.Configuration
1859 */
1860 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1861 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
1862 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001863 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08001864 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08001865 * <p class="note">This is a protected intent that can only be sent
1866 * by the system.
1867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
1870 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001871 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
1872 * charging state, level, and other information about the battery.
1873 * See {@link android.os.BatteryManager} for documentation on the
1874 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07001875 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001876 * <p class="note">
1877 * You can <em>not</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07001878 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001879 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07001880 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
1881 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
1882 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
1883 * broadcasts that are sent and can be received through manifest
1884 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08001885 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001886 * <p class="note">This is a protected intent that can only be sent
1887 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001888 */
1889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1890 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
1891 /**
1892 * Broadcast Action: Indicates low battery condition on the device.
1893 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08001894 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001895 * <p class="note">This is a protected intent that can only be sent
1896 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1899 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
1900 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001901 * Broadcast Action: Indicates the battery is now okay after being low.
1902 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
1903 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08001904 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001905 * <p class="note">This is a protected intent that can only be sent
1906 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07001907 */
1908 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1909 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
1910 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001911 * Broadcast Action: External power has been connected to the device.
1912 * This is intended for applications that wish to register specifically to this notification.
1913 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1914 * stay active to receive this notification. This action can be used to implement actions
1915 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001916 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001917 * <p class="note">This is a protected intent that can only be sent
1918 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001919 */
1920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001921 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001922 /**
1923 * Broadcast Action: External power has been removed from the device.
1924 * This is intended for applications that wish to register specifically to this notification.
1925 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
1926 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07001927 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08001928 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001929 * <p class="note">This is a protected intent that can only be sent
1930 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001931 */
1932 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07001933 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001934 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07001935 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07001936 * Broadcast Action: Device is shutting down.
1937 * This is broadcast when the device is being shut down (completely turned
1938 * off, not sleeping). Once the broadcast is complete, the final shutdown
1939 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07001940 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08001941 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001942 * <p class="note">This is a protected intent that can only be sent
1943 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07001944 * <p>May include the following extras:
1945 * <ul>
1946 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
1947 * shutdown is only for userspace processes. If not set, assumed to be false.
1948 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07001949 */
1950 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07001951 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07001952 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001953 * Activity Action: Start this activity to request system shutdown.
1954 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
1955 * to request confirmation from the user before shutting down.
1956 *
1957 * <p class="note">This is a protected intent that can only be sent
1958 * by the system.
1959 *
1960 * {@hide}
1961 */
1962 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
1963 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07001964 * Broadcast Action: A sticky broadcast that indicates low memory
1965 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08001966 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001967 * <p class="note">This is a protected intent that can only be sent
1968 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001969 */
1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1971 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
1972 /**
1973 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08001974 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001975 * <p class="note">This is a protected intent that can only be sent
1976 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001977 */
1978 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1979 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
1980 /**
Jake Hambybb371632010-08-23 18:16:48 -07001981 * Broadcast Action: A sticky broadcast that indicates a memory full
1982 * condition on the device. This is intended for activities that want
1983 * to be able to fill the data partition completely, leaving only
1984 * enough free space to prevent system-wide SQLite failures.
1985 *
1986 * <p class="note">This is a protected intent that can only be sent
1987 * by the system.
1988 *
1989 * {@hide}
1990 */
1991 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1992 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
1993 /**
1994 * Broadcast Action: Indicates memory full condition on the device
1995 * no longer exists.
1996 *
1997 * <p class="note">This is a protected intent that can only be sent
1998 * by the system.
1999 *
2000 * {@hide}
2001 */
2002 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2003 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2004 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002005 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2006 * and package management should be started.
2007 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2008 * notification.
2009 */
2010 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2011 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2012 /**
2013 * Broadcast Action: The device has entered USB Mass Storage mode.
2014 * This is used mainly for the USB Settings panel.
2015 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2016 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002017 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002018 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002019 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002020 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2021
2022 /**
2023 * Broadcast Action: The device has exited USB Mass Storage mode.
2024 * This is used mainly for the USB Settings panel.
2025 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2026 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002027 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002028 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002029 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002030 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2031
2032 /**
2033 * Broadcast Action: External media has been removed.
2034 * The path to the mount point for the removed media is contained in the Intent.mData field.
2035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2038
2039 /**
2040 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002041 * 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 -07002042 */
2043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2044 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2045
2046 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002047 * Broadcast Action: External media is present, and being disk-checked
2048 * 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 -08002049 */
2050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2051 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2052
2053 /**
2054 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2055 * 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 -08002056 */
2057 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2058 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2059
2060 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002062 * 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 -07002063 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2064 * media was mounted read only.
2065 */
2066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2067 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2068
2069 /**
2070 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002071 * 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 -07002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2074 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2075
2076 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002077 * Broadcast Action: External media is no longer being shared via USB mass storage.
2078 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2079 *
2080 * @hide
2081 */
2082 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2083
2084 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002085 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2086 * The path to the mount point for the removed media is contained in the Intent.mData field.
2087 */
2088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2089 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2090
2091 /**
2092 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002093 * 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 -07002094 */
2095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2096 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2097
2098 /**
2099 * Broadcast Action: User has expressed the desire to remove the external storage media.
2100 * Applications should close all files they have open within the mount point when they receive this intent.
2101 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2102 */
2103 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2104 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2105
2106 /**
2107 * Broadcast Action: The media scanner has started scanning a directory.
2108 * The path to the directory being scanned is contained in the Intent.mData field.
2109 */
2110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2111 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2112
2113 /**
2114 * Broadcast Action: The media scanner has finished scanning a directory.
2115 * The path to the scanned directory is contained in the Intent.mData field.
2116 */
2117 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2118 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2119
2120 /**
2121 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2122 * The path to the file is contained in the Intent.mData field.
2123 */
2124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2125 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2126
2127 /**
2128 * Broadcast Action: The "Media Button" was pressed. Includes a single
2129 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2130 * caused the broadcast.
2131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2134
2135 /**
2136 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2137 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2138 * caused the broadcast.
2139 */
2140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2141 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2142
2143 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2144 // location; they are not general-purpose actions.
2145
2146 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002147 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002148 */
2149 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2150 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2151 "android.intent.action.GTALK_CONNECTED";
2152
2153 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002154 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002155 */
2156 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2157 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2158 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002159
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002160 /**
2161 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002162 */
2163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2164 public static final String ACTION_INPUT_METHOD_CHANGED =
2165 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002166
2167 /**
2168 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2169 * more radios have been turned off or on. The intent will have the following extra value:</p>
2170 * <ul>
2171 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2172 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2173 * turned off</li>
2174 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002175 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002176 * <p class="note">This is a protected intent that can only be sent
2177 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002178 */
2179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2180 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2181
2182 /**
2183 * Broadcast Action: Some content providers have parts of their namespace
2184 * where they publish new events or items that the user may be especially
2185 * interested in. For these things, they may broadcast this action when the
2186 * set of interesting items change.
2187 *
2188 * For example, GmailProvider sends this notification when the set of unread
2189 * mail in the inbox changes.
2190 *
2191 * <p>The data of the intent identifies which part of which provider
2192 * changed. When queried through the content resolver, the data URI will
2193 * return the data set in question.
2194 *
2195 * <p>The intent will have the following extra values:
2196 * <ul>
2197 * <li><em>count</em> - The number of items in the data set. This is the
2198 * same as the number of items in the cursor returned by querying the
2199 * data URI. </li>
2200 * </ul>
2201 *
2202 * This intent will be sent at boot (if the count is non-zero) and when the
2203 * data set changes. It is possible for the data set to change without the
2204 * count changing (for example, if a new unread message arrives in the same
2205 * sync operation in which a message is archived). The phone should still
2206 * ring/vibrate/etc as normal in this case.
2207 */
2208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_PROVIDER_CHANGED =
2210 "android.intent.action.PROVIDER_CHANGED";
2211
2212 /**
2213 * Broadcast Action: Wired Headset plugged in or unplugged.
2214 *
Matt Casey79867f52014-03-26 15:20:25 -07002215 * You <em>cannot</em> receive this through components declared
2216 * in manifests, only by explicitly registering for it with
2217 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2218 * Context.registerReceiver()}.
2219 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002220 * <p>The intent will have the following extra values:
2221 * <ul>
2222 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2223 * <li><em>name</em> - Headset type, human readable string </li>
Eric Laurent923d7d72009-11-12 12:09:06 -08002224 * <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002225 * </ul>
2226 * </ul>
2227 */
2228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2229 public static final String ACTION_HEADSET_PLUG =
2230 "android.intent.action.HEADSET_PLUG";
2231
2232 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002233 * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
2234 *
2235 * <p>The intent will have the following extra values:
2236 * <ul>
2237 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2238 * <li><em>name</em> - Headset type, human readable string </li>
2239 * </ul>
2240 * </ul>
2241 * @hide
2242 */
2243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002244 public static final String ACTION_ANALOG_AUDIO_DOCK_PLUG =
2245 "android.intent.action.ANALOG_AUDIO_DOCK_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002246
2247 /**
Marco Nelisseneb6b9e62011-04-21 15:43:34 -07002248 * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002249 *
2250 * <p>The intent will have the following extra values:
2251 * <ul>
2252 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2253 * <li><em>name</em> - Headset type, human readable string </li>
2254 * </ul>
2255 * </ul>
2256 * @hide
2257 */
2258 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Eric Laurent59f48272012-04-05 19:42:21 -07002259 public static final String ACTION_DIGITAL_AUDIO_DOCK_PLUG =
2260 "android.intent.action.DIGITAL_AUDIO_DOCK_PLUG";
Praveen Bharathi26e37342010-11-02 19:23:30 -07002261
2262 /**
2263 * Broadcast Action: A HMDI cable was plugged or unplugged
2264 *
2265 * <p>The intent will have the following extra values:
2266 * <ul>
2267 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2268 * <li><em>name</em> - HDMI cable, human readable string </li>
2269 * </ul>
2270 * </ul>
2271 * @hide
2272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_HDMI_AUDIO_PLUG =
2275 "android.intent.action.HDMI_AUDIO_PLUG";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002276
2277 /**
Mike Lockwood9d5a4be2012-04-06 09:41:32 -07002278 * Broadcast Action: A USB audio accessory was plugged in or unplugged.
2279 *
2280 * <p>The intent will have the following extra values:
2281 * <ul>
2282 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2283 * <li><em>card</em> - ALSA card number (integer) </li>
2284 * <li><em>device</em> - ALSA device number (integer) </li>
2285 * </ul>
2286 * </ul>
2287 * @hide
2288 */
2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2290 public static final String ACTION_USB_AUDIO_ACCESSORY_PLUG =
2291 "android.intent.action.USB_AUDIO_ACCESSORY_PLUG";
2292
2293 /**
Eric Laurent59f48272012-04-05 19:42:21 -07002294 * Broadcast Action: A USB audio device was plugged in or unplugged.
2295 *
2296 * <p>The intent will have the following extra values:
2297 * <ul>
2298 * <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
2299 * <li><em>card</em> - ALSA card number (integer) </li>
2300 * <li><em>device</em> - ALSA device number (integer) </li>
2301 * </ul>
2302 * </ul>
2303 * @hide
2304 */
2305 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2306 public static final String ACTION_USB_AUDIO_DEVICE_PLUG =
2307 "android.intent.action.USB_AUDIO_DEVICE_PLUG";
2308
2309 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002310 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2311 * <ul>
2312 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2313 * </ul>
2314 *
2315 * <p class="note">This is a protected intent that can only be sent
2316 * by the system.
2317 *
2318 * @hide
2319 */
2320 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2321 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2322 = "android.intent.action.ADVANCED_SETTINGS";
2323
2324 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002325 * Broadcast Action: Sent after application restrictions are changed.
2326 *
2327 * <p class="note">This is a protected intent that can only be sent
2328 * by the system.</p>
2329 */
2330 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2331 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2332 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2333
2334 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335 * Broadcast Action: An outgoing call is about to be placed.
2336 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002337 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002338 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002339 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002340 * the phone number originally intended to be dialed.</li>
2341 * </ul>
2342 * <p>Once the broadcast is finished, the resultData is used as the actual
2343 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002344 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002345 * outgoing call in turn: for example, a parental control application
2346 * might verify that the user is authorized to place the call at that
2347 * time, then a number-rewriting application might add an area code if
2348 * one was not specified.</p>
2349 * <p>For consistency, any receiver whose purpose is to prohibit phone
2350 * calls should have a priority of 0, to ensure it will see the final
2351 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002352 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002353 * should have a positive priority.
2354 * Negative priorities are reserved for the system for this broadcast;
2355 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002356 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2357 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002358 * <p>Emergency calls cannot be intercepted using this mechanism, and
2359 * other calls cannot be modified to call emergency numbers using this
2360 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002361 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2362 * call to use their own service instead. Those apps should first prevent
2363 * the call from being placed by setting resultData to <code>null</code>
2364 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002365 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002366 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2367 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002368 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002369 * <p class="note">This is a protected intent that can only be sent
2370 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002371 */
2372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373 public static final String ACTION_NEW_OUTGOING_CALL =
2374 "android.intent.action.NEW_OUTGOING_CALL";
2375
2376 /**
2377 * Broadcast Action: Have the device reboot. This is only for use by
2378 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002379 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002380 * <p class="note">This is a protected intent that can only be sent
2381 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002382 */
2383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2384 public static final String ACTION_REBOOT =
2385 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002386
Wei Huang97ecc9c2009-05-11 17:44:20 -07002387 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002388 * Broadcast Action: A sticky broadcast for changes in the physical
2389 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002390 *
2391 * <p>The intent will have the following extra values:
2392 * <ul>
2393 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002394 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002395 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002396 * <p>This is intended for monitoring the current physical dock state.
2397 * See {@link android.app.UiModeManager} for the normal API dealing with
2398 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002399 */
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401 public static final String ACTION_DOCK_EVENT =
2402 "android.intent.action.DOCK_EVENT";
2403
2404 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002405 * Broadcast Action: A broadcast when idle maintenance can be started.
2406 * This means that the user is not interacting with the device and is
2407 * not expected to do so soon. Typical use of the idle maintenance is
2408 * to perform somehow expensive tasks that can be postponed at a moment
2409 * when they will not degrade user experience.
2410 * <p>
2411 * <p class="note">In order to keep the device responsive in case of an
2412 * unexpected user interaction, implementations of a maintenance task
2413 * should be interruptible. In such a scenario a broadcast with action
2414 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2415 * should not do the maintenance work in
2416 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2417 * maintenance service by {@link Context#startService(Intent)}. Also
2418 * you should hold a wake lock while your maintenance service is running
2419 * to prevent the device going to sleep.
2420 * </p>
2421 * <p>
2422 * <p class="note">This is a protected intent that can only be sent by
2423 * the system.
2424 * </p>
2425 *
2426 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002427 *
2428 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002429 */
2430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2431 public static final String ACTION_IDLE_MAINTENANCE_START =
2432 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2433
2434 /**
2435 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2436 * This means that the user was not interacting with the device as a result
2437 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2438 * was sent and now the user started interacting with the device. Typical
2439 * use of the idle maintenance is to perform somehow expensive tasks that
2440 * can be postponed at a moment when they will not degrade user experience.
2441 * <p>
2442 * <p class="note">In order to keep the device responsive in case of an
2443 * unexpected user interaction, implementations of a maintenance task
2444 * should be interruptible. Hence, on receiving a broadcast with this
2445 * action, the maintenance task should be interrupted as soon as possible.
2446 * In other words, you should not do the maintenance work in
2447 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2448 * maintenance service that was started on receiving of
2449 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2450 * lock you acquired when your maintenance service started.
2451 * </p>
2452 * <p class="note">This is a protected intent that can only be sent
2453 * by the system.
2454 *
2455 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002456 *
2457 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002458 */
2459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2460 public static final String ACTION_IDLE_MAINTENANCE_END =
2461 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2462
2463 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002464 * Broadcast Action: a remote intent is to be broadcasted.
2465 *
2466 * A remote intent is used for remote RPC between devices. The remote intent
2467 * is serialized and sent from one device to another device. The receiving
2468 * device parses the remote intent and broadcasts it. Note that anyone can
2469 * broadcast a remote intent. However, if the intent receiver of the remote intent
2470 * does not trust intent broadcasts from arbitrary intent senders, it should require
2471 * the sender to hold certain permissions so only trusted sender's broadcast will be
2472 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002473 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002474 */
2475 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002476 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002477
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002478 /**
2479 * Broadcast Action: hook for permforming cleanup after a system update.
2480 *
2481 * The broadcast is sent when the system is booting, before the
2482 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2483 * image. A receiver for this should do its work and then disable itself
2484 * so that it does not get run again at the next boot.
2485 * @hide
2486 */
2487 public static final String ACTION_PRE_BOOT_COMPLETED =
2488 "android.intent.action.PRE_BOOT_COMPLETED";
2489
Amith Yamasani13593602012-03-22 16:16:17 -07002490 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002491 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002492 * on restricted users. The broadcast intent contains an extra
2493 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2494 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2495 * String[] depending on the restriction type.<p/>
2496 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002497 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2498 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2499 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002500 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2501 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002502 * @see RestrictionEntry
2503 */
2504 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2505 "android.intent.action.GET_RESTRICTION_ENTRIES";
2506
2507 /**
Amith Yamasanid304af62013-09-05 09:30:23 -07002508 * @hide
Amith Yamasani655d0e22013-06-12 14:19:10 -07002509 * Activity to challenge the user for a PIN that was configured when setting up
Amith Yamasanid304af62013-09-05 09:30:23 -07002510 * restrictions. Restrictions include blocking of apps and preventing certain user operations,
2511 * controlled by {@link android.os.UserManager#setUserRestrictions(Bundle).
2512 * Launch the activity using
Amith Yamasani655d0e22013-06-12 14:19:10 -07002513 * {@link android.app.Activity#startActivityForResult(Intent, int)} and check if the
2514 * result is {@link android.app.Activity#RESULT_OK} for a successful response to the
2515 * challenge.<p/>
2516 * Before launching this activity, make sure that there is a PIN in effect, by calling
Amith Yamasanid304af62013-09-05 09:30:23 -07002517 * {@link android.os.UserManager#hasRestrictionsChallenge()}.
Amith Yamasani655d0e22013-06-12 14:19:10 -07002518 */
Amith Yamasanid304af62013-09-05 09:30:23 -07002519 public static final String ACTION_RESTRICTIONS_CHALLENGE =
2520 "android.intent.action.RESTRICTIONS_CHALLENGE";
Amith Yamasani655d0e22013-06-12 14:19:10 -07002521
2522 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002523 * Sent the first time a user is starting, to allow system apps to
2524 * perform one time initialization. (This will not be seen by third
2525 * party applications because a newly initialized user does not have any
2526 * third party applications installed for it.) This is sent early in
2527 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002528 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2529 * broadcast, since it is part of a visible user interaction; be as quick
2530 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002531 */
2532 public static final String ACTION_USER_INITIALIZE =
2533 "android.intent.action.USER_INITIALIZE";
2534
2535 /**
2536 * Sent when a user switch is happening, causing the process's user to be
2537 * brought to the foreground. This is only sent to receivers registered
2538 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2539 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002540 * foreground. This is sent as a foreground
2541 * broadcast, since it is part of a visible user interaction; be as quick
2542 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002543 */
2544 public static final String ACTION_USER_FOREGROUND =
2545 "android.intent.action.USER_FOREGROUND";
2546
2547 /**
2548 * Sent when a user switch is happening, causing the process's user to be
2549 * sent to the background. This is only sent to receivers registered
2550 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2551 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002552 * background. This is sent as a foreground
2553 * broadcast, since it is part of a visible user interaction; be as quick
2554 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002555 */
2556 public static final String ACTION_USER_BACKGROUND =
2557 "android.intent.action.USER_BACKGROUND";
2558
2559 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002560 * Broadcast sent to the system when a user is added. Carries an extra
2561 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2562 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002563 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002564 * @hide
2565 */
2566 public static final String ACTION_USER_ADDED =
2567 "android.intent.action.USER_ADDED";
2568
2569 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002570 * Broadcast sent by the system when a user is started. Carries an extra
2571 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002572 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002573 * that has been started. This is sent as a foreground
2574 * broadcast, since it is part of a visible user interaction; be as quick
2575 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002576 * @hide
2577 */
2578 public static final String ACTION_USER_STARTED =
2579 "android.intent.action.USER_STARTED";
2580
2581 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002582 * Broadcast sent when a user is in the process of starting. Carries an extra
2583 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2584 * sent to registered receivers, not manifest receivers. It is sent to all
2585 * users (including the one that is being started). You must hold
2586 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2587 * this broadcast. This is sent as a background broadcast, since
2588 * its result is not part of the primary UX flow; to safely keep track of
2589 * started/stopped state of a user you can use this in conjunction with
2590 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2591 * other user state broadcasts since those are foreground broadcasts so can
2592 * execute in a different order.
2593 * @hide
2594 */
2595 public static final String ACTION_USER_STARTING =
2596 "android.intent.action.USER_STARTING";
2597
2598 /**
2599 * Broadcast sent when a user is going to be stopped. Carries an extra
2600 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2601 * sent to registered receivers, not manifest receivers. It is sent to all
2602 * users (including the one that is being stopped). You must hold
2603 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2604 * this broadcast. The user will not stop until all receivers have
2605 * handled the broadcast. This is sent as a background broadcast, since
2606 * its result is not part of the primary UX flow; to safely keep track of
2607 * started/stopped state of a user you can use this in conjunction with
2608 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2609 * other user state broadcasts since those are foreground broadcasts so can
2610 * execute in a different order.
2611 * @hide
2612 */
2613 public static final String ACTION_USER_STOPPING =
2614 "android.intent.action.USER_STOPPING";
2615
2616 /**
2617 * Broadcast sent to the system when a user is stopped. Carries an extra
2618 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2619 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2620 * specific package. This is only sent to registered receivers, not manifest
2621 * receivers. It is sent to all running users <em>except</em> the one that
2622 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002623 * @hide
2624 */
2625 public static final String ACTION_USER_STOPPED =
2626 "android.intent.action.USER_STOPPED";
2627
2628 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002629 * 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 -07002630 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002631 * one that has been removed. The user will not be completely removed until all receivers have
2632 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002633 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002634 * @hide
2635 */
2636 public static final String ACTION_USER_REMOVED =
2637 "android.intent.action.USER_REMOVED";
2638
2639 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002640 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002641 * the userHandle of the user to become the current one. This is only sent to
2642 * registered receivers, not manifest receivers. It is sent to all running users.
2643 * You must hold
2644 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002645 * @hide
2646 */
2647 public static final String ACTION_USER_SWITCHED =
2648 "android.intent.action.USER_SWITCHED";
2649
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002650 /**
2651 * Broadcast sent to the system when a user's information changes. Carries an extra
2652 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002653 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002654 * @hide
2655 */
2656 public static final String ACTION_USER_INFO_CHANGED =
2657 "android.intent.action.USER_INFO_CHANGED";
2658
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002659 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002660 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2661 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002662 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2663 * that need to display merged content across both primary and managed profiles need to
2664 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002665 * not manifest receivers.
2666 */
2667 public static final String ACTION_MANAGED_PROFILE_ADDED =
2668 "android.intent.action.MANAGED_PROFILE_ADDED";
2669
2670 /**
2671 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002672 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2673 * Only applications (for example Launchers) that need to display merged content across both
2674 * primary and managed profiles need to worry about this broadcast. This is only sent to
2675 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002676 */
2677 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2678 "android.intent.action.MANAGED_PROFILE_REMOVED";
2679
2680 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002681 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2682 */
2683 public static final String ACTION_QUICK_CLOCK =
2684 "android.intent.action.QUICK_CLOCK";
2685
Michael Wright0087a142013-02-05 16:29:39 -08002686 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002687 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002688 * @hide
2689 */
2690 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2691 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2692
Justin Kohd378ad72013-04-01 12:18:26 -07002693 /**
2694 * Broadcast Action: A global button was pressed. Includes a single
2695 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2696 * caused the broadcast.
2697 * @hide
2698 */
2699 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2700
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002701 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002702 * Activity Action: Allow the user to select and return one or more existing
2703 * documents. When invoked, the system will display the various
2704 * {@link DocumentsProvider} instances installed on the device, letting the
2705 * user interactively navigate through them. These documents include local
2706 * media, such as photos and video, and documents provided by installed
2707 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002708 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002709 * Each document is represented as a {@code content://} URI backed by a
2710 * {@link DocumentsProvider}, which can be opened as a stream with
2711 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2712 * {@link android.provider.DocumentsContract.Document} metadata.
2713 * <p>
2714 * All selected documents are returned to the calling application with
2715 * persistable read and write permission grants. If you want to maintain
2716 * access to the documents across device reboots, you need to explicitly
2717 * take the persistable permissions using
2718 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2719 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002720 * Callers must indicate the acceptable document MIME types through
2721 * {@link #setType(String)}. For example, to select photos, use
2722 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2723 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2724 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002725 * <p>
2726 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002727 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2728 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002729 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002730 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2731 * returned URIs can be opened with
2732 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002733 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002734 * Output: The URI of the item that was picked, returned in
2735 * {@link #getData()}. This must be a {@code content://} URI so that any
2736 * receiver can access it. If multiple documents were selected, they are
2737 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002738 *
2739 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002740 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002741 * @see #ACTION_CREATE_DOCUMENT
2742 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002743 */
2744 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2745 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2746
2747 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002748 * Activity Action: Allow the user to create a new document. When invoked,
2749 * the system will display the various {@link DocumentsProvider} instances
2750 * installed on the device, letting the user navigate through them. The
2751 * returned document may be a newly created document with no content, or it
2752 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002753 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002754 * Each document is represented as a {@code content://} URI backed by a
2755 * {@link DocumentsProvider}, which can be opened as a stream with
2756 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2757 * {@link android.provider.DocumentsContract.Document} metadata.
2758 * <p>
2759 * Callers must indicate the concrete MIME type of the document being
2760 * created by setting {@link #setType(String)}. This MIME type cannot be
2761 * changed after the document is created.
2762 * <p>
2763 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
2764 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002765 * <p>
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002766 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
2767 * returned URIs can be opened with
2768 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002769 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002770 * Output: The URI of the item that was created. This must be a
2771 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002772 *
2773 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002774 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002775 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002776 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002777 */
2778 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2779 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
2780
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002781 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002782 * Activity Action: Allow the user to pick a directory subtree. When
2783 * invoked, the system will display the various {@link DocumentsProvider}
2784 * instances installed on the device, letting the user navigate through
2785 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002786 * <p>
2787 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002788 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
2789 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
2790 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002791 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002792 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002793 *
2794 * @see DocumentsContract
2795 */
2796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002797 public static final String
2798 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002799
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002800 // ---------------------------------------------------------------------
2801 // ---------------------------------------------------------------------
2802 // Standard intent categories (see addCategory()).
2803
2804 /**
2805 * Set if the activity should be an option for the default action
2806 * (center press) to perform on a piece of data. Setting this will
2807 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04002808 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002809 * Intent when initiating an action -- it is for use in intent filters
2810 * specified in packages.
2811 */
2812 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2813 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
2814 /**
2815 * Activities that can be safely invoked from a browser must support this
2816 * category. For example, if the user is viewing a web page or an e-mail
2817 * and clicks on a link in the text, the Intent generated execute that
2818 * link will require the BROWSABLE category, so that only activities
2819 * supporting this category will be considered as possible actions. By
2820 * supporting this category, you are promising that there is nothing
2821 * damaging (without user intervention) that can happen by invoking any
2822 * matching Intent.
2823 */
2824 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2825 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
2826 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07002827 * Categories for activities that can participate in voice interaction.
2828 * An activity that supports this category must be prepared to run with
2829 * no UI shown at all (though in some case it may have a UI shown), and
2830 * rely on {@link android.app.VoiceInteractor} to interact with the user.
2831 */
2832 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2833 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
2834 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002835 * Set if the activity should be considered as an alternative action to
2836 * the data the user is currently viewing. See also
2837 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
2838 * applies to the selection in a list of items.
2839 *
2840 * <p>Supporting this category means that you would like your activity to be
2841 * displayed in the set of alternative things the user can do, usually as
2842 * part of the current activity's options menu. You will usually want to
2843 * include a specific label in the &lt;intent-filter&gt; of this action
2844 * describing to the user what it does.
2845 *
2846 * <p>The action of IntentFilter with this category is important in that it
2847 * describes the specific action the target will perform. This generally
2848 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
2849 * a specific name such as "com.android.camera.action.CROP. Only one
2850 * alternative of any particular action will be shown to the user, so using
2851 * a specific action like this makes sure that your alternative will be
2852 * displayed while also allowing other applications to provide their own
2853 * overrides of that particular action.
2854 */
2855 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2856 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
2857 /**
2858 * Set if the activity should be considered as an alternative selection
2859 * action to the data the user has currently selected. This is like
2860 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
2861 * of items from which the user can select, giving them alternatives to the
2862 * default action that will be performed on it.
2863 */
2864 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2865 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
2866 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002867 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002868 */
2869 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2870 public static final String CATEGORY_TAB = "android.intent.category.TAB";
2871 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002872 * Should be displayed in the top-level launcher.
2873 */
2874 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2875 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
2876 /**
Jose Lima38b75b62014-03-11 10:41:39 -07002877 * Indicates an activity optimized for Leanback mode, and that should
2878 * be displayed in the Leanback launcher.
2879 */
2880 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2881 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
2882 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002883 * Provides information about the package it is in; typically used if
2884 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
2885 * a front-door to the user without having to be shown in the all apps list.
2886 */
2887 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2888 public static final String CATEGORY_INFO = "android.intent.category.INFO";
2889 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002890 * This is the home activity, that is the first activity that is displayed
2891 * when the device boots.
2892 */
2893 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2894 public static final String CATEGORY_HOME = "android.intent.category.HOME";
2895 /**
2896 * This activity is a preference panel.
2897 */
2898 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2899 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
2900 /**
2901 * This activity is a development preference panel.
2902 */
2903 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2904 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
2905 /**
2906 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002907 */
2908 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2909 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
2910 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07002911 * This activity allows the user to browse and download new applications.
2912 */
2913 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2914 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
2915 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002916 * This activity may be exercised by the monkey or other automated test tools.
2917 */
2918 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2919 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
2920 /**
2921 * To be used as a test (not part of the normal user experience).
2922 */
2923 public static final String CATEGORY_TEST = "android.intent.category.TEST";
2924 /**
2925 * To be used as a unit test (run through the Test Harness).
2926 */
2927 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
2928 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002929 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002930 * experience).
2931 */
2932 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002933
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002934 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002935 * Used to indicate that an intent only wants URIs that can be opened with
2936 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
2937 * must support at least the columns defined in {@link OpenableColumns} when
2938 * queried.
2939 *
2940 * @see #ACTION_GET_CONTENT
2941 * @see #ACTION_OPEN_DOCUMENT
2942 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002943 */
2944 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2945 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
2946
2947 /**
2948 * To be used as code under test for framework instrumentation tests.
2949 */
2950 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
2951 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04002952 /**
2953 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002954 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2955 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002956 */
2957 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2958 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
2959 /**
2960 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08002961 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2962 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04002963 */
2964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2965 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05002966 /**
2967 * An activity to run when device is inserted into a analog (low end) dock.
2968 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2969 * information, see {@link android.app.UiModeManager}.
2970 */
2971 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2972 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
2973
2974 /**
2975 * An activity to run when device is inserted into a digital (high end) dock.
2976 * Used with {@link #ACTION_MAIN} to launch an activity. For more
2977 * information, see {@link android.app.UiModeManager}.
2978 */
2979 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2980 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05002981
Bernd Holzheyaea4b672010-03-31 09:46:13 +02002982 /**
2983 * Used to indicate that the activity can be used in a car environment.
2984 */
2985 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
2986 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
2987
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002988 // ---------------------------------------------------------------------
2989 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08002990 // Application launch intent categories (see addCategory()).
2991
2992 /**
2993 * Used with {@link #ACTION_MAIN} to launch the browser application.
2994 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002995 * <p>NOTE: This should not be used as the primary key of an Intent,
2996 * since it will not result in the app launching with the correct
2997 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08002998 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08002999 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003000 */
3001 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3002 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3003
3004 /**
3005 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3006 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003007 * <p>NOTE: This should not be used as the primary key of an Intent,
3008 * since it will not result in the app launching with the correct
3009 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003010 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003011 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003012 */
3013 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3014 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3015
3016 /**
3017 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3018 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003019 * <p>NOTE: This should not be used as the primary key of an Intent,
3020 * since it will not result in the app launching with the correct
3021 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003022 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003023 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003024 */
3025 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3026 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3027
3028 /**
3029 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3030 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003031 * <p>NOTE: This should not be used as the primary key of an Intent,
3032 * since it will not result in the app launching with the correct
3033 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003034 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003035 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003036 */
3037 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3038 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3039
3040 /**
3041 * Used with {@link #ACTION_MAIN} to launch the email application.
3042 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003043 * <p>NOTE: This should not be used as the primary key of an Intent,
3044 * since it will not result in the app launching with the correct
3045 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003046 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003047 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003048 */
3049 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3050 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3051
3052 /**
3053 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3054 * The activity should be able to view and manipulate image and video files
3055 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003056 * <p>NOTE: This should not be used as the primary key of an Intent,
3057 * since it will not result in the app launching with the correct
3058 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003059 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003060 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003061 */
3062 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3063 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3064
3065 /**
3066 * Used with {@link #ACTION_MAIN} to launch the maps application.
3067 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003068 * <p>NOTE: This should not be used as the primary key of an Intent,
3069 * since it will not result in the app launching with the correct
3070 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003071 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003072 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003073 */
3074 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3075 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3076
3077 /**
3078 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3079 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003080 * <p>NOTE: This should not be used as the primary key of an Intent,
3081 * since it will not result in the app launching with the correct
3082 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003083 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003084 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003085 */
3086 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3087 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3088
3089 /**
3090 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003091 * The activity should be able to play, browse, or manipulate music files
3092 * stored on the device.
3093 * <p>NOTE: This should not be used as the primary key of an Intent,
3094 * since it will not result in the app launching with the correct
3095 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003096 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003097 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003098 */
3099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3100 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3101
3102 // ---------------------------------------------------------------------
3103 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003104 // Standard extra data keys.
3105
3106 /**
3107 * The initial data to place in a newly created record. Use with
3108 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3109 * fields as would be given to the underlying ContentProvider.insert()
3110 * call.
3111 */
3112 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3113
3114 /**
3115 * A constant CharSequence that is associated with the Intent, used with
3116 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3117 * this may be a styled CharSequence, so you must use
3118 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3119 * retrieve it.
3120 */
3121 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3122
3123 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003124 * A constant String that is associated with the Intent, used with
3125 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3126 * as HTML formatted text. Note that you <em>must</em> also supply
3127 * {@link #EXTRA_TEXT}.
3128 */
3129 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3130
3131 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003132 * A content: URI holding a stream of data associated with the Intent,
3133 * used with {@link #ACTION_SEND} to supply the data being sent.
3134 */
3135 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3136
3137 /**
3138 * A String[] holding e-mail addresses that should be delivered to.
3139 */
3140 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3141
3142 /**
3143 * A String[] holding e-mail addresses that should be carbon copied.
3144 */
3145 public static final String EXTRA_CC = "android.intent.extra.CC";
3146
3147 /**
3148 * A String[] holding e-mail addresses that should be blind carbon copied.
3149 */
3150 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3151
3152 /**
3153 * A constant string holding the desired subject line of a message.
3154 */
3155 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3156
3157 /**
3158 * An Intent describing the choices you would like shown with
3159 * {@link #ACTION_PICK_ACTIVITY}.
3160 */
3161 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3162
3163 /**
3164 * A CharSequence dialog title to provide to the user when used with a
3165 * {@link #ACTION_CHOOSER}.
3166 */
3167 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3168
3169 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003170 * A Parcelable[] of {@link Intent} or
3171 * {@link android.content.pm.LabeledIntent} objects as set with
3172 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3173 * a the front of the list of choices, when shown to the user with a
3174 * {@link #ACTION_CHOOSER}.
3175 */
3176 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3177
3178 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003179 * A Bundle forming a mapping of potential target package names to different extras Bundles
3180 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3181 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3182 * be currently installed on the device.
3183 *
3184 * <p>An application may choose to provide alternate extras for the case where a user
3185 * selects an activity from a predetermined set of target packages. If the activity
3186 * the user selects from the chooser belongs to a package with its package name as
3187 * a key in this bundle, the corresponding extras for that package will be merged with
3188 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3189 * extra has the same key as an extra already present in the intent it will overwrite
3190 * the extra from the intent.</p>
3191 *
3192 * <p><em>Examples:</em>
3193 * <ul>
3194 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3195 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3196 * parameters for that target.</li>
3197 * <li>An application may offer additional metadata for known targets of a given intent
3198 * to pass along information only relevant to that target such as account or content
3199 * identifiers already known to that application.</li>
3200 * </ul></p>
3201 */
3202 public static final String EXTRA_REPLACEMENT_EXTRAS =
3203 "android.intent.extra.REPLACEMENT_EXTRAS";
3204
3205 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003206 * A {@link android.view.KeyEvent} object containing the event that
3207 * triggered the creation of the Intent it is in.
3208 */
3209 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3210
3211 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003212 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3213 * before shutting down.
3214 *
3215 * {@hide}
3216 */
3217 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3218
3219 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003220 * 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 -07003221 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3222 * of restarting the application.
3223 */
3224 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3225
3226 /**
3227 * A String holding the phone number originally entered in
3228 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3229 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3230 */
3231 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003232
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003233 /**
3234 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3235 * intents to supply the uid the package had been assigned. Also an optional
3236 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3237 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3238 * purpose.
3239 */
3240 public static final String EXTRA_UID = "android.intent.extra.UID";
3241
3242 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003243 * @hide String array of package names.
3244 */
3245 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3246
3247 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003248 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3249 * intents to indicate whether this represents a full uninstall (removing
3250 * both the code and its data) or a partial uninstall (leaving its data,
3251 * implying that this is an update).
3252 */
3253 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003254
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003255 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003256 * @hide
3257 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3258 * intents to indicate that at this point the package has been removed for
3259 * all users on the device.
3260 */
3261 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3262 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3263
3264 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003265 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3266 * intents to indicate that this is a replacement of the package, so this
3267 * broadcast will immediately be followed by an add broadcast for a
3268 * different version of the same package.
3269 */
3270 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003271
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003272 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003273 * Used as an int extra field in {@link android.app.AlarmManager} intents
3274 * to tell the application being invoked how many pending alarms are being
3275 * delievered with the intent. For one-shot alarms this will always be 1.
3276 * For recurring alarms, this might be greater than 1 if the device was
3277 * asleep or powered off at the time an earlier alarm would have been
3278 * delivered.
3279 */
3280 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003281
Jacek Surazski86b6c532009-05-13 14:38:28 +02003282 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003283 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3284 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003285 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3286 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003287 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3288 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3289 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003290 */
3291 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3292
3293 /**
3294 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3295 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003296 */
3297 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3298
3299 /**
3300 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3301 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003302 */
3303 public static final int EXTRA_DOCK_STATE_DESK = 1;
3304
3305 /**
3306 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3307 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003308 */
3309 public static final int EXTRA_DOCK_STATE_CAR = 2;
3310
3311 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003312 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3313 * to represent that the phone is in a analog (low end) dock.
3314 */
3315 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3316
3317 /**
3318 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3319 * to represent that the phone is in a digital (high end) dock.
3320 */
3321 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3322
3323 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003324 * Boolean that can be supplied as meta-data with a dock activity, to
3325 * indicate that the dock should take over the home key when it is active.
3326 */
3327 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003328
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003329 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003330 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3331 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003332 */
3333 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3334
3335 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003336 * Used in the extra field in the remote intent. It's astring token passed with the
3337 * remote intent.
3338 */
3339 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3340 "android.intent.extra.remote_intent_token";
3341
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003342 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003343 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003344 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003345 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003346 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003347 "android.intent.extra.changed_component_name";
3348
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003349 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003350 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003351 * and contains a string array of all of the components that have changed. If
3352 * the state of the overall package has changed, then it will contain an entry
3353 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003354 */
3355 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3356 "android.intent.extra.changed_component_name_list";
3357
3358 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003359 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003360 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3361 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003362 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003363 */
3364 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3365 "android.intent.extra.changed_package_list";
3366
3367 /**
3368 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003369 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3370 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003371 * and contains an integer array of uids of all of the components
3372 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003373 */
3374 public static final String EXTRA_CHANGED_UID_LIST =
3375 "android.intent.extra.changed_uid_list";
3376
3377 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003378 * @hide
3379 * Magic extra system code can use when binding, to give a label for
3380 * who it is that has bound to a service. This is an integer giving
3381 * a framework string resource that can be displayed to the user.
3382 */
3383 public static final String EXTRA_CLIENT_LABEL =
3384 "android.intent.extra.client_label";
3385
3386 /**
3387 * @hide
3388 * Magic extra system code can use when binding, to give a PendingIntent object
3389 * that can be launched for the user to disable the system's use of this
3390 * service.
3391 */
3392 public static final String EXTRA_CLIENT_INTENT =
3393 "android.intent.extra.client_intent";
3394
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003395 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003396 * Extra used to indicate that an intent should only return data that is on
3397 * the local device. This is a boolean extra; the default is false. If true,
3398 * an implementation should only allow the user to select data that is
3399 * already on the device, not requiring it be downloaded from a remote
3400 * service when opened.
3401 *
3402 * @see #ACTION_GET_CONTENT
3403 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003404 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003405 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003406 */
3407 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003408 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003409
Amith Yamasani13593602012-03-22 16:16:17 -07003410 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003411 * Extra used to indicate that an intent can allow the user to select and
3412 * return multiple items. This is a boolean extra; the default is false. If
3413 * true, an implementation is allowed to present the user with a UI where
3414 * they can pick multiple items that are all returned to the caller. When
3415 * this happens, they should be returned as the {@link #getClipData()} part
3416 * of the result Intent.
3417 *
3418 * @see #ACTION_GET_CONTENT
3419 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003420 */
3421 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003422 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003423
3424 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003425 * The integer userHandle carried with broadcast intents related to addition, removal and
3426 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3427 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3428 *
Amith Yamasani13593602012-03-22 16:16:17 -07003429 * @hide
3430 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003431 public static final String EXTRA_USER_HANDLE =
3432 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003433
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003434 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003435 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3436 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3437 */
3438 public static final String EXTRA_USER =
3439 "android.intent.extra.user";
3440
3441 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003442 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003443 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3444 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003445 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003446 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3447
3448 /**
3449 * Extra sent in the intent to the BroadcastReceiver that handles
3450 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3451 * the restrictions as key/value pairs.
3452 */
3453 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3454 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003455
Amith Yamasani86118ba2013-03-28 14:33:16 -07003456 /**
3457 * Extra used in the response from a BroadcastReceiver that handles
3458 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3459 */
3460 public static final String EXTRA_RESTRICTIONS_INTENT =
3461 "android.intent.extra.restrictions_intent";
3462
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003463 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003464 * Extra used to communicate a set of acceptable MIME types. The type of the
3465 * extra is {@code String[]}. Values may be a combination of concrete MIME
3466 * types (such as "image/png") and/or partial MIME types (such as
3467 * "audio/*").
3468 *
3469 * @see #ACTION_GET_CONTENT
3470 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003471 */
3472 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3473
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003474 /**
3475 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3476 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003477 * When this is true, hardware devices can use this information to determine that
3478 * they shouldn't do a complete shutdown of their device since this is not a
3479 * complete shutdown down to the kernel, but only user space restarting.
3480 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003481 */
3482 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3483 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3484
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003485 /**
3486 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3487 * user has set their time format preferences to the 24 hour format.
3488 *
3489 * @hide for internal use only.
3490 */
3491 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3492 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3493
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003494 // ---------------------------------------------------------------------
3495 // ---------------------------------------------------------------------
3496 // Intent flags (see mFlags variable).
3497
Tor Norbyed9273d62013-05-30 15:59:53 -07003498 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003499 @IntDef(flag = true, value = {
3500 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3501 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003502 @Retention(RetentionPolicy.SOURCE)
3503 public @interface GrantUriMode {}
3504
Jeff Sharkey846318a2014-04-04 12:12:41 -07003505 /** @hide */
3506 @IntDef(flag = true, value = {
3507 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3508 @Retention(RetentionPolicy.SOURCE)
3509 public @interface AccessUriMode {}
3510
3511 /**
3512 * Test if given mode flags specify an access mode, which must be at least
3513 * read and/or write.
3514 *
3515 * @hide
3516 */
3517 public static boolean isAccessUriMode(int modeFlags) {
3518 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3519 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3520 }
3521
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003522 /**
3523 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003524 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003525 * specified in its ClipData. When applying to an Intent's ClipData,
3526 * all URIs as well as recursive traversals through data or other ClipData
3527 * in Intent items will be granted; only the grant flags of the top-level
3528 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003529 */
3530 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3531 /**
3532 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003533 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003534 * specified in its ClipData. When applying to an Intent's ClipData,
3535 * all URIs as well as recursive traversals through data or other ClipData
3536 * in Intent items will be granted; only the grant flags of the top-level
3537 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003538 */
3539 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
3540 /**
3541 * Can be set by the caller to indicate that this Intent is coming from
3542 * a background operation, not from direct user interaction.
3543 */
3544 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
3545 /**
3546 * A flag you can enable for debugging: when set, log messages will be
3547 * printed during the resolution of this intent to show you what has
3548 * been found to create the final resolved list.
3549 */
3550 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08003551 /**
3552 * If set, this intent will not match any components in packages that
3553 * are currently stopped. If this is not set, then the default behavior
3554 * is to include such applications in the result.
3555 */
3556 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
3557 /**
3558 * If set, this intent will always match any components in packages that
3559 * are currently stopped. This is the default behavior when
3560 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
3561 * flags are set, this one wins (it allows overriding of exclude for
3562 * places where the framework may automatically set the exclude flag).
3563 */
3564 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003565
3566 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003567 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003568 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003569 * persisted across device reboots until explicitly revoked with
3570 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
3571 * grant for possible persisting; the receiving application must call
3572 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
3573 * actually persist.
3574 *
3575 * @see ContentResolver#takePersistableUriPermission(Uri, int)
3576 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
3577 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003578 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003579 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07003580 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07003581
3582 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07003583 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
3584 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
3585 * applies to any URI that is a prefix match against the original granted
3586 * URI. (Without this flag, the URI must match exactly for access to be
3587 * granted.) Another URI is considered a prefix match only when scheme,
3588 * authority, and all path segments defined by the prefix are an exact
3589 * match.
3590 */
3591 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
3592
3593 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003594 * If set, the new activity is not kept in the history stack. As soon as
3595 * the user navigates away from it, the activity is finished. This may also
3596 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
3597 * noHistory} attribute.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003598 */
3599 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
3600 /**
3601 * If set, the activity will not be launched if it is already running
3602 * at the top of the history stack.
3603 */
3604 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
3605 /**
3606 * If set, this activity will become the start of a new task on this
3607 * history stack. A task (from the activity that started it to the
3608 * next task activity) defines an atomic group of activities that the
3609 * user can move to. Tasks can be moved to the foreground and background;
3610 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07003611 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08003612 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3613 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003614 *
3615 * <p>This flag is generally used by activities that want
3616 * to present a "launcher" style behavior: they give the user a list of
3617 * separate things that can be done, which otherwise run completely
3618 * independently of the activity launching them.
3619 *
3620 * <p>When using this flag, if a task is already running for the activity
3621 * you are now starting, then a new activity will not be started; instead,
3622 * the current task will simply be brought to the front of the screen with
3623 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
3624 * to disable this behavior.
3625 *
3626 * <p>This flag can not be used when the caller is requesting a result from
3627 * the activity being launched.
3628 */
3629 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
3630 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07003631 * This flag is used to create a new task and launch an activity into it.
3632 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
3633 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
3634 * search through existing tasks for ones matching this Intent. Only if no such
3635 * task is found would a new task be created. When paired with
3636 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
3637 * the search for a matching task and unconditionally start a new task.
3638 *
3639 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
3640 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003641 * top-level application launcher.</strong> Used in conjunction with
3642 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
3643 * behavior of bringing an existing task to the foreground. When set,
3644 * a new task is <em>always</em> started to host the Activity for the
3645 * Intent, regardless of whether there is already an existing task running
3646 * the same thing.
3647 *
3648 * <p><strong>Because the default system does not include graphical task management,
3649 * you should not use this flag unless you provide some way for a user to
3650 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07003651 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07003652 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
3653 * creating new document tasks.
3654 *
3655 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
3656 * {@link #FLAG_ACTIVITY_NEW_TASK} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003657 *
Scott Main7aee61f2011-02-08 11:25:01 -08003658 * <p>See
3659 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3660 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003661 *
3662 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
3663 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003664 */
3665 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
3666 /**
3667 * If set, and the activity being launched is already running in the
3668 * current task, then instead of launching a new instance of that activity,
3669 * all of the other activities on top of it will be closed and this Intent
3670 * will be delivered to the (now on top) old activity as a new Intent.
3671 *
3672 * <p>For example, consider a task consisting of the activities: A, B, C, D.
3673 * If D calls startActivity() with an Intent that resolves to the component
3674 * of activity B, then C and D will be finished and B receive the given
3675 * Intent, resulting in the stack now being: A, B.
3676 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003677 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003678 * either receive the new intent you are starting here in its
3679 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003680 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07003681 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
3682 * the same intent, then it will be finished and re-created; for all other
3683 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
3684 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003685 *
3686 * <p>This launch mode can also be used to good effect in conjunction with
3687 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
3688 * of a task, it will bring any currently running instance of that task
3689 * to the foreground, and then clear it to its root state. This is
3690 * especially useful, for example, when launching an activity from the
3691 * notification manager.
3692 *
Scott Main7aee61f2011-02-08 11:25:01 -08003693 * <p>See
3694 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
3695 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003696 */
3697 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
3698 /**
3699 * If set and this intent is being used to launch a new activity from an
3700 * existing one, then the reply target of the existing activity will be
3701 * transfered to the new activity. This way the new activity can call
3702 * {@link android.app.Activity#setResult} and have that result sent back to
3703 * the reply target of the original activity.
3704 */
3705 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
3706 /**
3707 * If set and this intent is being used to launch a new activity from an
3708 * existing one, the current activity will not be counted as the top
3709 * activity for deciding whether the new intent should be delivered to
3710 * the top instead of starting a new one. The previous activity will
3711 * be used as the top, with the assumption being that the current activity
3712 * will finish itself immediately.
3713 */
3714 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
3715 /**
3716 * If set, the new activity is not kept in the list of recently launched
3717 * activities.
3718 */
3719 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
3720 /**
3721 * This flag is not normally set by application code, but set for you by
3722 * the system as described in the
3723 * {@link android.R.styleable#AndroidManifestActivity_launchMode
3724 * launchMode} documentation for the singleTask mode.
3725 */
3726 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
3727 /**
3728 * If set, and this activity is either being started in a new task or
3729 * bringing to the top an existing task, then it will be launched as
3730 * the front door of the task. This will result in the application of
3731 * any affinities needed to have that task in the proper state (either
3732 * moving activities to or from it), or simply resetting that task to
3733 * its initial state if needed.
3734 */
3735 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
3736 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003737 * This flag is not normally set by application code, but set for you by
3738 * the system if this activity is being launched from history
3739 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003740 */
3741 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003742 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003743 * @deprecated As of API 21 this performs identically to
3744 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003745 */
3746 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003747 /**
Craig Mautner026596b2014-05-21 15:35:44 -07003748 * This flag is used to open a document into a new task rooted at the activity launched
3749 * by this Intent. Through the use of this flag, or its equivalent attribute,
3750 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
3751 * containing different douments will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003752 *
Craig Mautner026596b2014-05-21 15:35:44 -07003753 * <p>The use of the activity attribute form of this,
3754 * {@link android.R.attr#documentLaunchMode}, is
3755 * preferred over the Intent flag described here. The attribute form allows the
3756 * Activity to specify multiple document behavior for all launchers of the Activity
3757 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003758 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07003759 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
3760 * it is kept after the activity is finished is different than the use of
3761 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
3762 * this flag is being used to create a new recents entry, then by default that entry
3763 * will be removed once the activity is finished. You can modify this behavior with
3764 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
3765 *
Craig Mautner026596b2014-05-21 15:35:44 -07003766 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
3767 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
3768 * equivalent of the Activity manifest specifying {@link
3769 * android.R.attr#documentLaunchMode}="intoExisting". When used with
3770 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
3771 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07003772 *
Craig Mautner026596b2014-05-21 15:35:44 -07003773 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07003774 *
Craig Mautner026596b2014-05-21 15:35:44 -07003775 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07003776 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
3777 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07003778 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07003779 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003780 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003781 * callback from occurring on the current frontmost activity before it is
3782 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07003783 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003784 * <p>Typically, an activity can rely on that callback to indicate that an
3785 * explicit user action has caused their activity to be moved out of the
3786 * foreground. The callback marks an appropriate point in the activity's
3787 * lifecycle for it to dismiss any notifications that it intends to display
3788 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07003789 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003790 * <p>If an activity is ever started via any non-user-driven events such as
3791 * phone-call receipt or an alarm handler, this flag should be passed to {@link
3792 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07003793 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003794 */
3795 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003796 /**
3797 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3798 * this flag will cause the launched activity to be brought to the front of its
3799 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07003800 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003801 * <p>For example, consider a task consisting of four activities: A, B, C, D.
3802 * If D calls startActivity() with an Intent that resolves to the component
3803 * of activity B, then B will be brought to the front of the history stack,
3804 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07003805 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003806 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07003807 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003808 */
3809 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003810 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003811 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3812 * this flag will prevent the system from applying an activity transition
3813 * animation to go to the next activity state. This doesn't mean an
3814 * animation will never run -- if another activity change happens that doesn't
3815 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003816 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07003817 * when you are going to do a series of activity operations but the
3818 * animation seen by the user shouldn't be driven by the first activity
3819 * change but rather a later one.
3820 */
3821 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
3822 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08003823 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3824 * this flag will cause any existing task that would be associated with the
3825 * activity to be cleared before the activity is started. That is, the activity
3826 * becomes the new root of an otherwise empty task, and any old activities
3827 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3828 */
3829 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
3830 /**
3831 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
3832 * this flag will cause a newly launching task to be placed on top of the current
3833 * home activity task (if there is one). That is, pressing back from the task
3834 * will always return the user to home even if that was not the last activity they
3835 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
3836 */
3837 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
3838 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07003839 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
3840 * have its entry in recent tasks removed when the user closes it (with back
3841 * or however else it may finish()). If you would like to instead allow the
3842 * document to be kept in recents so that it can be re-launched, you can use
3843 * this flag. When set and the task's activity is finished, the recents entry
3844 * will remain in the interface for the user to re-launch it, like a recents
3845 * entry for a top-level application.
Craig Mautner2dac0562014-05-06 09:06:44 -07003846 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07003847 * <p>The receiving activity can override this request with
3848 * {@link android.R.styleable#AndroidManifestActivity_autoRemoveFromRecents}
3849 * or by explcitly calling {@link android.app.Activity#finishAndRemoveTask()
3850 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07003851 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07003852 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07003853
3854 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003855 * If set, when sending a broadcast only registered receivers will be
3856 * called -- no BroadcastReceiver components will be launched.
3857 */
3858 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003859 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003860 * If set, when sending a broadcast the new broadcast will replace
3861 * any existing pending broadcast that matches it. Matching is defined
3862 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
3863 * true for the intents of the two broadcasts. When a match is found,
3864 * the new broadcast (and receivers associated with it) will replace the
3865 * existing one in the pending broadcast list, remaining at the same
3866 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08003867 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08003868 * <p>This flag is most typically used with sticky broadcasts, which
3869 * only care about delivering the most recent values of the broadcast
3870 * to their receivers.
3871 */
3872 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
3873 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08003874 * If set, when sending a broadcast the recipient is allowed to run at
3875 * foreground priority, with a shorter timeout interval. During normal
3876 * broadcasts the receivers are not automatically hoisted out of the
3877 * background priority class.
3878 */
3879 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
3880 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07003881 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
3882 * They can still propagate results through to later receivers, but they can not prevent
3883 * later receivers from seeing the broadcast.
3884 */
3885 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
3886 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003887 * If set, when sending a broadcast <i>before boot has completed</i> only
3888 * registered receivers will be called -- no BroadcastReceiver components
3889 * will be launched. Sticky intent state will be recorded properly even
3890 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
3891 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07003892 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003893 * <p>This flag is only for use by system sevices as a convenience to
3894 * avoid having to implement a more complex mechanism around detection
3895 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07003896 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003897 * @hide
3898 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003899 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003900 /**
3901 * Set when this broadcast is for a boot upgrade, a special mode that
3902 * allows the broadcast to be sent before the system is ready and launches
3903 * the app process with no providers running in it.
3904 * @hide
3905 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07003906 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003907
Dianne Hackbornfa82f222009-09-17 15:14:12 -07003908 /**
3909 * @hide Flags that can't be changed with PendingIntent.
3910 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003911 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
3912 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3913 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08003914
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003915 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003916 // ---------------------------------------------------------------------
3917 // toUri() and parseUri() options.
3918
3919 /**
3920 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
3921 * always has the "intent:" scheme. This syntax can be used when you want
3922 * to later disambiguate between URIs that are intended to describe an
3923 * Intent vs. all others that should be treated as raw URIs. When used
3924 * with {@link #parseUri}, any other scheme will result in a generic
3925 * VIEW action for that raw URI.
3926 */
3927 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08003928
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003929 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003930
3931 private String mAction;
3932 private Uri mData;
3933 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003934 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003935 private ComponentName mComponent;
3936 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003937 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003938 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003939 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003940 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003941 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01003942 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003943
3944 // ---------------------------------------------------------------------
3945
3946 /**
3947 * Create an empty intent.
3948 */
3949 public Intent() {
3950 }
3951
3952 /**
3953 * Copy constructor.
3954 */
3955 public Intent(Intent o) {
3956 this.mAction = o.mAction;
3957 this.mData = o.mData;
3958 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003959 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003960 this.mComponent = o.mComponent;
3961 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01003962 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003963 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003964 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003965 }
3966 if (o.mExtras != null) {
3967 this.mExtras = new Bundle(o.mExtras);
3968 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08003969 if (o.mSourceBounds != null) {
3970 this.mSourceBounds = new Rect(o.mSourceBounds);
3971 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003972 if (o.mSelector != null) {
3973 this.mSelector = new Intent(o.mSelector);
3974 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003975 if (o.mClipData != null) {
3976 this.mClipData = new ClipData(o.mClipData);
3977 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003978 }
3979
3980 @Override
3981 public Object clone() {
3982 return new Intent(this);
3983 }
3984
3985 private Intent(Intent o, boolean all) {
3986 this.mAction = o.mAction;
3987 this.mData = o.mData;
3988 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07003989 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003990 this.mComponent = o.mComponent;
3991 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07003992 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003993 }
3994 }
3995
3996 /**
3997 * Make a clone of only the parts of the Intent that are relevant for
3998 * filter matching: the action, data, type, component, and categories.
3999 */
4000 public Intent cloneFilter() {
4001 return new Intent(this, false);
4002 }
4003
4004 /**
4005 * Create an intent with a given action. All other fields (data, type,
4006 * class) are null. Note that the action <em>must</em> be in a
4007 * namespace because Intents are used globally in the system -- for
4008 * example the system VIEW action is android.intent.action.VIEW; an
4009 * application's custom action would be something like
4010 * com.google.app.myapp.CUSTOM_ACTION.
4011 *
4012 * @param action The Intent action, such as ACTION_VIEW.
4013 */
4014 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004015 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004016 }
4017
4018 /**
4019 * Create an intent with a given action and for a given data url. Note
4020 * that the action <em>must</em> be in a namespace because Intents are
4021 * used globally in the system -- for example the system VIEW action is
4022 * android.intent.action.VIEW; an application's custom action would be
4023 * something like com.google.app.myapp.CUSTOM_ACTION.
4024 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004025 * <p><em>Note: scheme and host name matching in the Android framework is
4026 * case-sensitive, unlike the formal RFC. As a result,
4027 * you should always ensure that you write your Uri with these elements
4028 * using lower case letters, and normalize any Uris you receive from
4029 * outside of Android to ensure the scheme and host is lower case.</em></p>
4030 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004031 * @param action The Intent action, such as ACTION_VIEW.
4032 * @param uri The Intent data URI.
4033 */
4034 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004035 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004036 mData = uri;
4037 }
4038
4039 /**
4040 * Create an intent for a specific component. All other fields (action, data,
4041 * type, class) are null, though they can be modified later with explicit
4042 * calls. This provides a convenient way to create an intent that is
4043 * intended to execute a hard-coded class name, rather than relying on the
4044 * system to find an appropriate class for you; see {@link #setComponent}
4045 * for more information on the repercussions of this.
4046 *
4047 * @param packageContext A Context of the application package implementing
4048 * this class.
4049 * @param cls The component class that is to be used for the intent.
4050 *
4051 * @see #setClass
4052 * @see #setComponent
4053 * @see #Intent(String, android.net.Uri , Context, Class)
4054 */
4055 public Intent(Context packageContext, Class<?> cls) {
4056 mComponent = new ComponentName(packageContext, cls);
4057 }
4058
4059 /**
4060 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004061 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004062 * construct the Intent and then calling {@link #setClass} to set its
4063 * class.
4064 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004065 * <p><em>Note: scheme and host name matching in the Android framework is
4066 * case-sensitive, unlike the formal RFC. As a result,
4067 * you should always ensure that you write your Uri with these elements
4068 * using lower case letters, and normalize any Uris you receive from
4069 * outside of Android to ensure the scheme and host is lower case.</em></p>
4070 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004071 * @param action The Intent action, such as ACTION_VIEW.
4072 * @param uri The Intent data URI.
4073 * @param packageContext A Context of the application package implementing
4074 * this class.
4075 * @param cls The component class that is to be used for the intent.
4076 *
4077 * @see #Intent(String, android.net.Uri)
4078 * @see #Intent(Context, Class)
4079 * @see #setClass
4080 * @see #setComponent
4081 */
4082 public Intent(String action, Uri uri,
4083 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004084 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004085 mData = uri;
4086 mComponent = new ComponentName(packageContext, cls);
4087 }
4088
4089 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004090 * Create an intent to launch the main (root) activity of a task. This
4091 * is the Intent that is started when the application's is launched from
4092 * Home. For anything else that wants to launch an application in the
4093 * same way, it is important that they use an Intent structured the same
4094 * way, and can use this function to ensure this is the case.
4095 *
4096 * <p>The returned Intent has the given Activity component as its explicit
4097 * component, {@link #ACTION_MAIN} as its action, and includes the
4098 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4099 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4100 * to do that through {@link #addFlags(int)} on the returned Intent.
4101 *
4102 * @param mainActivity The main activity component that this Intent will
4103 * launch.
4104 * @return Returns a newly created Intent that can be used to launch the
4105 * activity as a main application entry.
4106 *
4107 * @see #setClass
4108 * @see #setComponent
4109 */
4110 public static Intent makeMainActivity(ComponentName mainActivity) {
4111 Intent intent = new Intent(ACTION_MAIN);
4112 intent.setComponent(mainActivity);
4113 intent.addCategory(CATEGORY_LAUNCHER);
4114 return intent;
4115 }
4116
4117 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004118 * Make an Intent for the main activity of an application, without
4119 * specifying a specific activity to run but giving a selector to find
4120 * the activity. This results in a final Intent that is structured
4121 * the same as when the application is launched from
4122 * Home. For anything else that wants to launch an application in the
4123 * same way, it is important that they use an Intent structured the same
4124 * way, and can use this function to ensure this is the case.
4125 *
4126 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4127 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4128 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4129 * to do that through {@link #addFlags(int)} on the returned Intent.
4130 *
4131 * @param selectorAction The action name of the Intent's selector.
4132 * @param selectorCategory The name of a category to add to the Intent's
4133 * selector.
4134 * @return Returns a newly created Intent that can be used to launch the
4135 * activity as a main application entry.
4136 *
4137 * @see #setSelector(Intent)
4138 */
4139 public static Intent makeMainSelectorActivity(String selectorAction,
4140 String selectorCategory) {
4141 Intent intent = new Intent(ACTION_MAIN);
4142 intent.addCategory(CATEGORY_LAUNCHER);
4143 Intent selector = new Intent();
4144 selector.setAction(selectorAction);
4145 selector.addCategory(selectorCategory);
4146 intent.setSelector(selector);
4147 return intent;
4148 }
4149
4150 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004151 * Make an Intent that can be used to re-launch an application's task
4152 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4153 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4154 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4155 *
4156 * @param mainActivity The activity component that is the root of the
4157 * task; this is the activity that has been published in the application's
4158 * manifest as the main launcher icon.
4159 *
4160 * @return Returns a newly created Intent that can be used to relaunch the
4161 * activity's task in its root state.
4162 */
4163 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4164 Intent intent = makeMainActivity(mainActivity);
4165 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4166 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4167 return intent;
4168 }
4169
4170 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004171 * Call {@link #parseUri} with 0 flags.
4172 * @deprecated Use {@link #parseUri} instead.
4173 */
4174 @Deprecated
4175 public static Intent getIntent(String uri) throws URISyntaxException {
4176 return parseUri(uri, 0);
4177 }
Tom Taylord4a47292009-12-21 13:59:18 -08004178
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004179 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004180 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004181 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004182 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004183 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004184 *
4185 * <p>The URI given here must not be relative -- that is, it must include
4186 * the scheme and full path.
4187 *
4188 * @param uri The URI to turn into an Intent.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004189 * @param flags Additional processing flags. Either 0 or
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004190 * {@link #URI_INTENT_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004191 *
4192 * @return Intent The newly created Intent object.
4193 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004194 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4195 * it bad (as parsed by the Uri class) or the Intent data within the
4196 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004197 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004198 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004199 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004200 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004201 int i = 0;
4202 try {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004203 // Validate intent scheme for if requested.
4204 if ((flags&URI_INTENT_SCHEME) != 0) {
4205 if (!uri.startsWith("intent:")) {
4206 Intent intent = new Intent(ACTION_VIEW);
4207 try {
4208 intent.setData(Uri.parse(uri));
4209 } catch (IllegalArgumentException e) {
4210 throw new URISyntaxException(uri, e.getMessage());
4211 }
4212 return intent;
4213 }
4214 }
Tom Taylord4a47292009-12-21 13:59:18 -08004215
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 // simple case
4217 i = uri.lastIndexOf("#");
4218 if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
4219
4220 // old format Intent URI
4221 if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
The Android Open Source Project10592532009-03-18 17:39:46 -07004222
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004223 // new format
4224 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004225 Intent baseIntent = intent;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004226
4227 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004228 String data = i >= 0 ? uri.substring(0, i) : null;
4229 String scheme = null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004230 i += "#Intent;".length();
The Android Open Source Project10592532009-03-18 17:39:46 -07004231
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004232 // loop over contents of Intent, all name=value;
4233 while (!uri.startsWith("end", i)) {
4234 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004235 if (eq < 0) eq = i-1;
4236 int semi = uri.indexOf(';', i);
4237 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004238
4239 // action
4240 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004241 intent.setAction(value);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004242 }
4243
4244 // categories
4245 else if (uri.startsWith("category=", i)) {
4246 intent.addCategory(value);
4247 }
4248
4249 // type
4250 else if (uri.startsWith("type=", i)) {
4251 intent.mType = value;
4252 }
4253
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004254 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004255 else if (uri.startsWith("launchFlags=", i)) {
4256 intent.mFlags = Integer.decode(value).intValue();
4257 }
4258
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004259 // package
4260 else if (uri.startsWith("package=", i)) {
4261 intent.mPackage = value;
4262 }
4263
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004264 // component
4265 else if (uri.startsWith("component=", i)) {
4266 intent.mComponent = ComponentName.unflattenFromString(value);
4267 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004268
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004269 // scheme
4270 else if (uri.startsWith("scheme=", i)) {
4271 scheme = value;
4272 }
4273
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004274 // source bounds
4275 else if (uri.startsWith("sourceBounds=", i)) {
4276 intent.mSourceBounds = Rect.unflattenFromString(value);
4277 }
4278
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004279 // selector
4280 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4281 intent = new Intent();
4282 }
4283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004284 // extra
4285 else {
4286 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004287 // create Bundle if it doesn't already exist
4288 if (intent.mExtras == null) intent.mExtras = new Bundle();
4289 Bundle b = intent.mExtras;
4290 // add EXTRA
4291 if (uri.startsWith("S.", i)) b.putString(key, value);
4292 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4293 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4294 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4295 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4296 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4297 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4298 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4299 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4300 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4301 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004302
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004303 // move to the next item
4304 i = semi + 1;
4305 }
4306
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004307 if (intent != baseIntent) {
4308 // The Intent had a selector; fix it up.
4309 baseIntent.setSelector(intent);
4310 intent = baseIntent;
4311 }
4312
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004313 if (data != null) {
4314 if (data.startsWith("intent:")) {
4315 data = data.substring(7);
4316 if (scheme != null) {
4317 data = scheme + ':' + data;
4318 }
4319 }
Tom Taylord4a47292009-12-21 13:59:18 -08004320
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004321 if (data.length() > 0) {
4322 try {
4323 intent.mData = Uri.parse(data);
4324 } catch (IllegalArgumentException e) {
4325 throw new URISyntaxException(uri, e.getMessage());
4326 }
4327 }
4328 }
Tom Taylord4a47292009-12-21 13:59:18 -08004329
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004330 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004331
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004332 } catch (IndexOutOfBoundsException e) {
4333 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4334 }
4335 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004336
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004337 public static Intent getIntentOld(String uri) throws URISyntaxException {
4338 Intent intent;
4339
4340 int i = uri.lastIndexOf('#');
4341 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004342 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004343 final int intentFragmentStart = i;
4344 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004345
4346 i++;
4347
4348 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004349 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004350 i += 7;
4351 int j = uri.indexOf(')', i);
4352 action = uri.substring(i, j);
4353 i = j + 1;
4354 }
4355
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004356 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004357
4358 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004359 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004360 i += 11;
4361 int j = uri.indexOf(')', i);
4362 while (i < j) {
4363 int sep = uri.indexOf('!', i);
4364 if (sep < 0) sep = j;
4365 if (i < sep) {
4366 intent.addCategory(uri.substring(i, sep));
4367 }
4368 i = sep + 1;
4369 }
4370 i = j + 1;
4371 }
4372
4373 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004374 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004375 i += 5;
4376 int j = uri.indexOf(')', i);
4377 intent.mType = uri.substring(i, j);
4378 i = j + 1;
4379 }
4380
4381 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004382 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004383 i += 12;
4384 int j = uri.indexOf(')', i);
4385 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
4386 i = j + 1;
4387 }
4388
4389 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004390 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004391 i += 10;
4392 int j = uri.indexOf(')', i);
4393 int sep = uri.indexOf('!', i);
4394 if (sep >= 0 && sep < j) {
4395 String pkg = uri.substring(i, sep);
4396 String cls = uri.substring(sep + 1, j);
4397 intent.mComponent = new ComponentName(pkg, cls);
4398 }
4399 i = j + 1;
4400 }
4401
4402 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004403 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004404 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07004405
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004406 final int closeParen = uri.indexOf(')', i);
4407 if (closeParen == -1) throw new URISyntaxException(uri,
4408 "EXTRA missing trailing ')'", i);
4409
4410 while (i < closeParen) {
4411 // fetch the key value
4412 int j = uri.indexOf('=', i);
4413 if (j <= i + 1 || i >= closeParen) {
4414 throw new URISyntaxException(uri, "EXTRA missing '='", i);
4415 }
4416 char type = uri.charAt(i);
4417 i++;
4418 String key = uri.substring(i, j);
4419 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07004420
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004421 // get type-value
4422 j = uri.indexOf('!', i);
4423 if (j == -1 || j >= closeParen) j = closeParen;
4424 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4425 String value = uri.substring(i, j);
4426 i = j;
4427
4428 // create Bundle if it doesn't already exist
4429 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07004430
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004431 // add item to bundle
4432 try {
4433 switch (type) {
4434 case 'S':
4435 intent.mExtras.putString(key, Uri.decode(value));
4436 break;
4437 case 'B':
4438 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
4439 break;
4440 case 'b':
4441 intent.mExtras.putByte(key, Byte.parseByte(value));
4442 break;
4443 case 'c':
4444 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
4445 break;
4446 case 'd':
4447 intent.mExtras.putDouble(key, Double.parseDouble(value));
4448 break;
4449 case 'f':
4450 intent.mExtras.putFloat(key, Float.parseFloat(value));
4451 break;
4452 case 'i':
4453 intent.mExtras.putInt(key, Integer.parseInt(value));
4454 break;
4455 case 'l':
4456 intent.mExtras.putLong(key, Long.parseLong(value));
4457 break;
4458 case 's':
4459 intent.mExtras.putShort(key, Short.parseShort(value));
4460 break;
4461 default:
4462 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
4463 }
4464 } catch (NumberFormatException e) {
4465 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
4466 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004467
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004468 char ch = uri.charAt(i);
4469 if (ch == ')') break;
4470 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
4471 i++;
4472 }
4473 }
4474
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004475 if (isIntentFragment) {
4476 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
4477 } else {
4478 intent.mData = Uri.parse(uri);
4479 }
Tom Taylord4a47292009-12-21 13:59:18 -08004480
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004481 if (intent.mAction == null) {
4482 // By default, if no action is specified, then use VIEW.
4483 intent.mAction = ACTION_VIEW;
4484 }
4485
4486 } else {
4487 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
4488 }
4489
4490 return intent;
4491 }
4492
4493 /**
4494 * Retrieve the general action to be performed, such as
4495 * {@link #ACTION_VIEW}. The action describes the general way the rest of
4496 * the information in the intent should be interpreted -- most importantly,
4497 * what to do with the data returned by {@link #getData}.
4498 *
4499 * @return The action of this intent or null if none is specified.
4500 *
4501 * @see #setAction
4502 */
4503 public String getAction() {
4504 return mAction;
4505 }
4506
4507 /**
4508 * Retrieve data this intent is operating on. This URI specifies the name
4509 * of the data; often it uses the content: scheme, specifying data in a
4510 * content provider. Other schemes may be handled by specific activities,
4511 * such as http: by the web browser.
4512 *
4513 * @return The URI of the data this intent is targeting or null.
4514 *
4515 * @see #getScheme
4516 * @see #setData
4517 */
4518 public Uri getData() {
4519 return mData;
4520 }
4521
4522 /**
4523 * The same as {@link #getData()}, but returns the URI as an encoded
4524 * String.
4525 */
4526 public String getDataString() {
4527 return mData != null ? mData.toString() : null;
4528 }
4529
4530 /**
4531 * Return the scheme portion of the intent's data. If the data is null or
4532 * does not include a scheme, null is returned. Otherwise, the scheme
4533 * prefix without the final ':' is returned, i.e. "http".
4534 *
4535 * <p>This is the same as calling getData().getScheme() (and checking for
4536 * null data).
4537 *
4538 * @return The scheme of this intent.
4539 *
4540 * @see #getData
4541 */
4542 public String getScheme() {
4543 return mData != null ? mData.getScheme() : null;
4544 }
4545
4546 /**
4547 * Retrieve any explicit MIME type included in the intent. This is usually
4548 * null, as the type is determined by the intent data.
4549 *
4550 * @return If a type was manually set, it is returned; else null is
4551 * returned.
4552 *
4553 * @see #resolveType(ContentResolver)
4554 * @see #setType
4555 */
4556 public String getType() {
4557 return mType;
4558 }
4559
4560 /**
4561 * Return the MIME data type of this intent. If the type field is
4562 * explicitly set, that is simply returned. Otherwise, if the data is set,
4563 * the type of that data is returned. If neither fields are set, a null is
4564 * returned.
4565 *
4566 * @return The MIME type of this intent.
4567 *
4568 * @see #getType
4569 * @see #resolveType(ContentResolver)
4570 */
4571 public String resolveType(Context context) {
4572 return resolveType(context.getContentResolver());
4573 }
4574
4575 /**
4576 * Return the MIME data type of this intent. If the type field is
4577 * explicitly set, that is simply returned. Otherwise, if the data is set,
4578 * the type of that data is returned. If neither fields are set, a null is
4579 * returned.
4580 *
4581 * @param resolver A ContentResolver that can be used to determine the MIME
4582 * type of the intent's data.
4583 *
4584 * @return The MIME type of this intent.
4585 *
4586 * @see #getType
4587 * @see #resolveType(Context)
4588 */
4589 public String resolveType(ContentResolver resolver) {
4590 if (mType != null) {
4591 return mType;
4592 }
4593 if (mData != null) {
4594 if ("content".equals(mData.getScheme())) {
4595 return resolver.getType(mData);
4596 }
4597 }
4598 return null;
4599 }
4600
4601 /**
4602 * Return the MIME data type of this intent, only if it will be needed for
4603 * intent resolution. This is not generally useful for application code;
4604 * it is used by the frameworks for communicating with back-end system
4605 * services.
4606 *
4607 * @param resolver A ContentResolver that can be used to determine the MIME
4608 * type of the intent's data.
4609 *
4610 * @return The MIME type of this intent, or null if it is unknown or not
4611 * needed.
4612 */
4613 public String resolveTypeIfNeeded(ContentResolver resolver) {
4614 if (mComponent != null) {
4615 return mType;
4616 }
4617 return resolveType(resolver);
4618 }
4619
4620 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004621 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004622 *
4623 * @param category The category to check.
4624 *
4625 * @return boolean True if the intent contains the category, else false.
4626 *
4627 * @see #getCategories
4628 * @see #addCategory
4629 */
4630 public boolean hasCategory(String category) {
4631 return mCategories != null && mCategories.contains(category);
4632 }
4633
4634 /**
4635 * Return the set of all categories in the intent. If there are no categories,
4636 * returns NULL.
4637 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004638 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004639 *
4640 * @see #hasCategory
4641 * @see #addCategory
4642 */
4643 public Set<String> getCategories() {
4644 return mCategories;
4645 }
4646
4647 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004648 * Return the specific selector associated with this Intent. If there is
4649 * none, returns null. See {@link #setSelector} for more information.
4650 *
4651 * @see #setSelector
4652 */
4653 public Intent getSelector() {
4654 return mSelector;
4655 }
4656
4657 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004658 * Return the {@link ClipData} associated with this Intent. If there is
4659 * none, returns null. See {@link #setClipData} for more information.
4660 *
John Spurlock125d1332013-11-25 11:58:37 -05004661 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004662 */
4663 public ClipData getClipData() {
4664 return mClipData;
4665 }
4666
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004667 /** @hide */
4668 public int getContentUserHint() {
4669 return mContentUserHint;
4670 }
4671
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004672 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004673 * Sets the ClassLoader that will be used when unmarshalling
4674 * any Parcelable values from the extras of this Intent.
4675 *
4676 * @param loader a ClassLoader, or null to use the default loader
4677 * at the time of unmarshalling.
4678 */
4679 public void setExtrasClassLoader(ClassLoader loader) {
4680 if (mExtras != null) {
4681 mExtras.setClassLoader(loader);
4682 }
4683 }
4684
4685 /**
4686 * Returns true if an extra value is associated with the given name.
4687 * @param name the extra's name
4688 * @return true if the given extra is present.
4689 */
4690 public boolean hasExtra(String name) {
4691 return mExtras != null && mExtras.containsKey(name);
4692 }
4693
4694 /**
4695 * Returns true if the Intent's extras contain a parcelled file descriptor.
4696 * @return true if the Intent contains a parcelled file descriptor.
4697 */
4698 public boolean hasFileDescriptors() {
4699 return mExtras != null && mExtras.hasFileDescriptors();
4700 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004701
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04004702 /** @hide */
4703 public void setAllowFds(boolean allowFds) {
4704 if (mExtras != null) {
4705 mExtras.setAllowFds(allowFds);
4706 }
4707 }
4708
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004709 /**
4710 * Retrieve extended data from the intent.
4711 *
4712 * @param name The name of the desired item.
4713 *
4714 * @return the value of an item that previously added with putExtra()
4715 * or null if none was found.
4716 *
4717 * @deprecated
4718 * @hide
4719 */
4720 @Deprecated
4721 public Object getExtra(String name) {
4722 return getExtra(name, null);
4723 }
4724
4725 /**
4726 * Retrieve extended data from the intent.
4727 *
4728 * @param name The name of the desired item.
4729 * @param defaultValue the value to be returned if no value of the desired
4730 * type is stored with the given name.
4731 *
4732 * @return the value of an item that previously added with putExtra()
4733 * or the default value if none was found.
4734 *
4735 * @see #putExtra(String, boolean)
4736 */
4737 public boolean getBooleanExtra(String name, boolean defaultValue) {
4738 return mExtras == null ? defaultValue :
4739 mExtras.getBoolean(name, defaultValue);
4740 }
4741
4742 /**
4743 * Retrieve extended data from the intent.
4744 *
4745 * @param name The name of the desired item.
4746 * @param defaultValue the value to be returned if no value of the desired
4747 * type is stored with the given name.
4748 *
4749 * @return the value of an item that previously added with putExtra()
4750 * or the default value if none was found.
4751 *
4752 * @see #putExtra(String, byte)
4753 */
4754 public byte getByteExtra(String name, byte defaultValue) {
4755 return mExtras == null ? defaultValue :
4756 mExtras.getByte(name, defaultValue);
4757 }
4758
4759 /**
4760 * Retrieve extended data from the intent.
4761 *
4762 * @param name The name of the desired item.
4763 * @param defaultValue the value to be returned if no value of the desired
4764 * type is stored with the given name.
4765 *
4766 * @return the value of an item that previously added with putExtra()
4767 * or the default value if none was found.
4768 *
4769 * @see #putExtra(String, short)
4770 */
4771 public short getShortExtra(String name, short defaultValue) {
4772 return mExtras == null ? defaultValue :
4773 mExtras.getShort(name, defaultValue);
4774 }
4775
4776 /**
4777 * Retrieve extended data from the intent.
4778 *
4779 * @param name The name of the desired item.
4780 * @param defaultValue the value to be returned if no value of the desired
4781 * type is stored with the given name.
4782 *
4783 * @return the value of an item that previously added with putExtra()
4784 * or the default value if none was found.
4785 *
4786 * @see #putExtra(String, char)
4787 */
4788 public char getCharExtra(String name, char defaultValue) {
4789 return mExtras == null ? defaultValue :
4790 mExtras.getChar(name, defaultValue);
4791 }
4792
4793 /**
4794 * Retrieve extended data from the intent.
4795 *
4796 * @param name The name of the desired item.
4797 * @param defaultValue the value to be returned if no value of the desired
4798 * type is stored with the given name.
4799 *
4800 * @return the value of an item that previously added with putExtra()
4801 * or the default value if none was found.
4802 *
4803 * @see #putExtra(String, int)
4804 */
4805 public int getIntExtra(String name, int defaultValue) {
4806 return mExtras == null ? defaultValue :
4807 mExtras.getInt(name, defaultValue);
4808 }
4809
4810 /**
4811 * Retrieve extended data from the intent.
4812 *
4813 * @param name The name of the desired item.
4814 * @param defaultValue the value to be returned if no value of the desired
4815 * type is stored with the given name.
4816 *
4817 * @return the value of an item that previously added with putExtra()
4818 * or the default value if none was found.
4819 *
4820 * @see #putExtra(String, long)
4821 */
4822 public long getLongExtra(String name, long defaultValue) {
4823 return mExtras == null ? defaultValue :
4824 mExtras.getLong(name, defaultValue);
4825 }
4826
4827 /**
4828 * Retrieve extended data from the intent.
4829 *
4830 * @param name The name of the desired item.
4831 * @param defaultValue the value to be returned if no value of the desired
4832 * type is stored with the given name.
4833 *
4834 * @return the value of an item that previously added with putExtra(),
4835 * or the default value if no such item is present
4836 *
4837 * @see #putExtra(String, float)
4838 */
4839 public float getFloatExtra(String name, float defaultValue) {
4840 return mExtras == null ? defaultValue :
4841 mExtras.getFloat(name, defaultValue);
4842 }
4843
4844 /**
4845 * Retrieve extended data from the intent.
4846 *
4847 * @param name The name of the desired item.
4848 * @param defaultValue the value to be returned if no value of the desired
4849 * type is stored with the given name.
4850 *
4851 * @return the value of an item that previously added with putExtra()
4852 * or the default value if none was found.
4853 *
4854 * @see #putExtra(String, double)
4855 */
4856 public double getDoubleExtra(String name, double defaultValue) {
4857 return mExtras == null ? defaultValue :
4858 mExtras.getDouble(name, defaultValue);
4859 }
4860
4861 /**
4862 * Retrieve extended data from the intent.
4863 *
4864 * @param name The name of the desired item.
4865 *
4866 * @return the value of an item that previously added with putExtra()
4867 * or null if no String value was found.
4868 *
4869 * @see #putExtra(String, String)
4870 */
4871 public String getStringExtra(String name) {
4872 return mExtras == null ? null : mExtras.getString(name);
4873 }
4874
4875 /**
4876 * Retrieve extended data from the intent.
4877 *
4878 * @param name The name of the desired item.
4879 *
4880 * @return the value of an item that previously added with putExtra()
4881 * or null if no CharSequence value was found.
4882 *
4883 * @see #putExtra(String, CharSequence)
4884 */
4885 public CharSequence getCharSequenceExtra(String name) {
4886 return mExtras == null ? null : mExtras.getCharSequence(name);
4887 }
4888
4889 /**
4890 * Retrieve extended data from the intent.
4891 *
4892 * @param name The name of the desired item.
4893 *
4894 * @return the value of an item that previously added with putExtra()
4895 * or null if no Parcelable value was found.
4896 *
4897 * @see #putExtra(String, Parcelable)
4898 */
4899 public <T extends Parcelable> T getParcelableExtra(String name) {
4900 return mExtras == null ? null : mExtras.<T>getParcelable(name);
4901 }
4902
4903 /**
4904 * Retrieve extended data from the intent.
4905 *
4906 * @param name The name of the desired item.
4907 *
4908 * @return the value of an item that previously added with putExtra()
4909 * or null if no Parcelable[] value was found.
4910 *
4911 * @see #putExtra(String, Parcelable[])
4912 */
4913 public Parcelable[] getParcelableArrayExtra(String name) {
4914 return mExtras == null ? null : mExtras.getParcelableArray(name);
4915 }
4916
4917 /**
4918 * Retrieve extended data from the intent.
4919 *
4920 * @param name The name of the desired item.
4921 *
4922 * @return the value of an item that previously added with putExtra()
4923 * or null if no ArrayList<Parcelable> value was found.
4924 *
4925 * @see #putParcelableArrayListExtra(String, ArrayList)
4926 */
4927 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
4928 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
4929 }
4930
4931 /**
4932 * Retrieve extended data from the intent.
4933 *
4934 * @param name The name of the desired item.
4935 *
4936 * @return the value of an item that previously added with putExtra()
4937 * or null if no Serializable value was found.
4938 *
4939 * @see #putExtra(String, Serializable)
4940 */
4941 public Serializable getSerializableExtra(String name) {
4942 return mExtras == null ? null : mExtras.getSerializable(name);
4943 }
4944
4945 /**
4946 * Retrieve extended data from the intent.
4947 *
4948 * @param name The name of the desired item.
4949 *
4950 * @return the value of an item that previously added with putExtra()
4951 * or null if no ArrayList<Integer> value was found.
4952 *
4953 * @see #putIntegerArrayListExtra(String, ArrayList)
4954 */
4955 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
4956 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
4957 }
4958
4959 /**
4960 * Retrieve extended data from the intent.
4961 *
4962 * @param name The name of the desired item.
4963 *
4964 * @return the value of an item that previously added with putExtra()
4965 * or null if no ArrayList<String> value was found.
4966 *
4967 * @see #putStringArrayListExtra(String, ArrayList)
4968 */
4969 public ArrayList<String> getStringArrayListExtra(String name) {
4970 return mExtras == null ? null : mExtras.getStringArrayList(name);
4971 }
4972
4973 /**
4974 * Retrieve extended data from the intent.
4975 *
4976 * @param name The name of the desired item.
4977 *
4978 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00004979 * or null if no ArrayList<CharSequence> value was found.
4980 *
4981 * @see #putCharSequenceArrayListExtra(String, ArrayList)
4982 */
4983 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
4984 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
4985 }
4986
4987 /**
4988 * Retrieve extended data from the intent.
4989 *
4990 * @param name The name of the desired item.
4991 *
4992 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004993 * or null if no boolean array value was found.
4994 *
4995 * @see #putExtra(String, boolean[])
4996 */
4997 public boolean[] getBooleanArrayExtra(String name) {
4998 return mExtras == null ? null : mExtras.getBooleanArray(name);
4999 }
5000
5001 /**
5002 * Retrieve extended data from the intent.
5003 *
5004 * @param name The name of the desired item.
5005 *
5006 * @return the value of an item that previously added with putExtra()
5007 * or null if no byte array value was found.
5008 *
5009 * @see #putExtra(String, byte[])
5010 */
5011 public byte[] getByteArrayExtra(String name) {
5012 return mExtras == null ? null : mExtras.getByteArray(name);
5013 }
5014
5015 /**
5016 * Retrieve extended data from the intent.
5017 *
5018 * @param name The name of the desired item.
5019 *
5020 * @return the value of an item that previously added with putExtra()
5021 * or null if no short array value was found.
5022 *
5023 * @see #putExtra(String, short[])
5024 */
5025 public short[] getShortArrayExtra(String name) {
5026 return mExtras == null ? null : mExtras.getShortArray(name);
5027 }
5028
5029 /**
5030 * Retrieve extended data from the intent.
5031 *
5032 * @param name The name of the desired item.
5033 *
5034 * @return the value of an item that previously added with putExtra()
5035 * or null if no char array value was found.
5036 *
5037 * @see #putExtra(String, char[])
5038 */
5039 public char[] getCharArrayExtra(String name) {
5040 return mExtras == null ? null : mExtras.getCharArray(name);
5041 }
5042
5043 /**
5044 * Retrieve extended data from the intent.
5045 *
5046 * @param name The name of the desired item.
5047 *
5048 * @return the value of an item that previously added with putExtra()
5049 * or null if no int array value was found.
5050 *
5051 * @see #putExtra(String, int[])
5052 */
5053 public int[] getIntArrayExtra(String name) {
5054 return mExtras == null ? null : mExtras.getIntArray(name);
5055 }
5056
5057 /**
5058 * Retrieve extended data from the intent.
5059 *
5060 * @param name The name of the desired item.
5061 *
5062 * @return the value of an item that previously added with putExtra()
5063 * or null if no long array value was found.
5064 *
5065 * @see #putExtra(String, long[])
5066 */
5067 public long[] getLongArrayExtra(String name) {
5068 return mExtras == null ? null : mExtras.getLongArray(name);
5069 }
5070
5071 /**
5072 * Retrieve extended data from the intent.
5073 *
5074 * @param name The name of the desired item.
5075 *
5076 * @return the value of an item that previously added with putExtra()
5077 * or null if no float array value was found.
5078 *
5079 * @see #putExtra(String, float[])
5080 */
5081 public float[] getFloatArrayExtra(String name) {
5082 return mExtras == null ? null : mExtras.getFloatArray(name);
5083 }
5084
5085 /**
5086 * Retrieve extended data from the intent.
5087 *
5088 * @param name The name of the desired item.
5089 *
5090 * @return the value of an item that previously added with putExtra()
5091 * or null if no double array value was found.
5092 *
5093 * @see #putExtra(String, double[])
5094 */
5095 public double[] getDoubleArrayExtra(String name) {
5096 return mExtras == null ? null : mExtras.getDoubleArray(name);
5097 }
5098
5099 /**
5100 * Retrieve extended data from the intent.
5101 *
5102 * @param name The name of the desired item.
5103 *
5104 * @return the value of an item that previously added with putExtra()
5105 * or null if no String array value was found.
5106 *
5107 * @see #putExtra(String, String[])
5108 */
5109 public String[] getStringArrayExtra(String name) {
5110 return mExtras == null ? null : mExtras.getStringArray(name);
5111 }
5112
5113 /**
5114 * Retrieve extended data from the intent.
5115 *
5116 * @param name The name of the desired item.
5117 *
5118 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00005119 * or null if no CharSequence array value was found.
5120 *
5121 * @see #putExtra(String, CharSequence[])
5122 */
5123 public CharSequence[] getCharSequenceArrayExtra(String name) {
5124 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
5125 }
5126
5127 /**
5128 * Retrieve extended data from the intent.
5129 *
5130 * @param name The name of the desired item.
5131 *
5132 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005133 * or null if no Bundle value was found.
5134 *
5135 * @see #putExtra(String, Bundle)
5136 */
5137 public Bundle getBundleExtra(String name) {
5138 return mExtras == null ? null : mExtras.getBundle(name);
5139 }
5140
5141 /**
5142 * Retrieve extended data from the intent.
5143 *
5144 * @param name The name of the desired item.
5145 *
5146 * @return the value of an item that previously added with putExtra()
5147 * or null if no IBinder value was found.
5148 *
5149 * @see #putExtra(String, IBinder)
5150 *
5151 * @deprecated
5152 * @hide
5153 */
5154 @Deprecated
5155 public IBinder getIBinderExtra(String name) {
5156 return mExtras == null ? null : mExtras.getIBinder(name);
5157 }
5158
5159 /**
5160 * Retrieve extended data from the intent.
5161 *
5162 * @param name The name of the desired item.
5163 * @param defaultValue The default value to return in case no item is
5164 * associated with the key 'name'
5165 *
5166 * @return the value of an item that previously added with putExtra()
5167 * or defaultValue if none was found.
5168 *
5169 * @see #putExtra
5170 *
5171 * @deprecated
5172 * @hide
5173 */
5174 @Deprecated
5175 public Object getExtra(String name, Object defaultValue) {
5176 Object result = defaultValue;
5177 if (mExtras != null) {
5178 Object result2 = mExtras.get(name);
5179 if (result2 != null) {
5180 result = result2;
5181 }
5182 }
5183
5184 return result;
5185 }
5186
5187 /**
5188 * Retrieves a map of extended data from the intent.
5189 *
5190 * @return the map of all extras previously added with putExtra(),
5191 * or null if none have been added.
5192 */
5193 public Bundle getExtras() {
5194 return (mExtras != null)
5195 ? new Bundle(mExtras)
5196 : null;
5197 }
5198
5199 /**
5200 * Retrieve any special flags associated with this intent. You will
5201 * normally just set them with {@link #setFlags} and let the system
5202 * take the appropriate action with them.
5203 *
5204 * @return int The currently set flags.
5205 *
5206 * @see #setFlags
5207 */
5208 public int getFlags() {
5209 return mFlags;
5210 }
5211
Dianne Hackborne7f97212011-02-24 14:40:20 -08005212 /** @hide */
5213 public boolean isExcludingStopped() {
5214 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
5215 == FLAG_EXCLUDE_STOPPED_PACKAGES;
5216 }
5217
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005218 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005219 * Retrieve the application package name this Intent is limited to. When
5220 * resolving an Intent, if non-null this limits the resolution to only
5221 * components in the given application package.
5222 *
5223 * @return The name of the application package for the Intent.
5224 *
5225 * @see #resolveActivity
5226 * @see #setPackage
5227 */
5228 public String getPackage() {
5229 return mPackage;
5230 }
5231
5232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005233 * Retrieve the concrete component associated with the intent. When receiving
5234 * an intent, this is the component that was found to best handle it (that is,
5235 * yourself) and will always be non-null; in all other cases it will be
5236 * null unless explicitly set.
5237 *
5238 * @return The name of the application component to handle the intent.
5239 *
5240 * @see #resolveActivity
5241 * @see #setComponent
5242 */
5243 public ComponentName getComponent() {
5244 return mComponent;
5245 }
5246
5247 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005248 * Get the bounds of the sender of this intent, in screen coordinates. This can be
5249 * used as a hint to the receiver for animations and the like. Null means that there
5250 * is no source bounds.
5251 */
5252 public Rect getSourceBounds() {
5253 return mSourceBounds;
5254 }
5255
5256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005257 * Return the Activity component that should be used to handle this intent.
5258 * The appropriate component is determined based on the information in the
5259 * intent, evaluated as follows:
5260 *
5261 * <p>If {@link #getComponent} returns an explicit class, that is returned
5262 * without any further consideration.
5263 *
5264 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
5265 * category to be considered.
5266 *
5267 * <p>If {@link #getAction} is non-NULL, the activity must handle this
5268 * action.
5269 *
5270 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
5271 * this type.
5272 *
5273 * <p>If {@link #addCategory} has added any categories, the activity must
5274 * handle ALL of the categories specified.
5275 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005276 * <p>If {@link #getPackage} is non-NULL, only activity components in
5277 * that application package will be considered.
5278 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005279 * <p>If there are no activities that satisfy all of these conditions, a
5280 * null string is returned.
5281 *
5282 * <p>If multiple activities are found to satisfy the intent, the one with
5283 * the highest priority will be used. If there are multiple activities
5284 * with the same priority, the system will either pick the best activity
5285 * based on user preference, or resolve to a system class that will allow
5286 * the user to pick an activity and forward from there.
5287 *
5288 * <p>This method is implemented simply by calling
5289 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
5290 * true.</p>
5291 * <p> This API is called for you as part of starting an activity from an
5292 * intent. You do not normally need to call it yourself.</p>
5293 *
5294 * @param pm The package manager with which to resolve the Intent.
5295 *
5296 * @return Name of the component implementing an activity that can
5297 * display the intent.
5298 *
5299 * @see #setComponent
5300 * @see #getComponent
5301 * @see #resolveActivityInfo
5302 */
5303 public ComponentName resolveActivity(PackageManager pm) {
5304 if (mComponent != null) {
5305 return mComponent;
5306 }
5307
5308 ResolveInfo info = pm.resolveActivity(
5309 this, PackageManager.MATCH_DEFAULT_ONLY);
5310 if (info != null) {
5311 return new ComponentName(
5312 info.activityInfo.applicationInfo.packageName,
5313 info.activityInfo.name);
5314 }
5315
5316 return null;
5317 }
5318
5319 /**
5320 * Resolve the Intent into an {@link ActivityInfo}
5321 * describing the activity that should execute the intent. Resolution
5322 * follows the same rules as described for {@link #resolveActivity}, but
5323 * you get back the completely information about the resolved activity
5324 * instead of just its class name.
5325 *
5326 * @param pm The package manager with which to resolve the Intent.
5327 * @param flags Addition information to retrieve as per
5328 * {@link PackageManager#getActivityInfo(ComponentName, int)
5329 * PackageManager.getActivityInfo()}.
5330 *
5331 * @return PackageManager.ActivityInfo
5332 *
5333 * @see #resolveActivity
5334 */
5335 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
5336 ActivityInfo ai = null;
5337 if (mComponent != null) {
5338 try {
5339 ai = pm.getActivityInfo(mComponent, flags);
5340 } catch (PackageManager.NameNotFoundException e) {
5341 // ignore
5342 }
5343 } else {
5344 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005345 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005346 if (info != null) {
5347 ai = info.activityInfo;
5348 }
5349 }
5350
5351 return ai;
5352 }
5353
5354 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07005355 * Special function for use by the system to resolve service
5356 * intents to system apps. Throws an exception if there are
5357 * multiple potential matches to the Intent. Returns null if
5358 * there are no matches.
5359 * @hide
5360 */
5361 public ComponentName resolveSystemService(PackageManager pm, int flags) {
5362 if (mComponent != null) {
5363 return mComponent;
5364 }
5365
5366 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
5367 if (results == null) {
5368 return null;
5369 }
5370 ComponentName comp = null;
5371 for (int i=0; i<results.size(); i++) {
5372 ResolveInfo ri = results.get(i);
5373 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
5374 continue;
5375 }
5376 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
5377 ri.serviceInfo.name);
5378 if (comp != null) {
5379 throw new IllegalStateException("Multiple system services handle " + this
5380 + ": " + comp + ", " + foundComp);
5381 }
5382 comp = foundComp;
5383 }
5384 return comp;
5385 }
5386
5387 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005388 * Set the general action to be performed.
5389 *
5390 * @param action An action name, such as ACTION_VIEW. Application-specific
5391 * actions should be prefixed with the vendor's package name.
5392 *
5393 * @return Returns the same Intent object, for chaining multiple calls
5394 * into a single statement.
5395 *
5396 * @see #getAction
5397 */
5398 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005399 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005400 return this;
5401 }
5402
5403 /**
5404 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08005405 * clears any type that was previously set by {@link #setType} or
5406 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005407 *
Nick Pellyccae4122012-01-09 14:12:58 -08005408 * <p><em>Note: scheme matching in the Android framework is
5409 * case-sensitive, unlike the formal RFC. As a result,
5410 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005411 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005412 * {@link #setDataAndNormalize}
5413 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005414 *
Nick Pellyccae4122012-01-09 14:12:58 -08005415 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005416 *
5417 * @return Returns the same Intent object, for chaining multiple calls
5418 * into a single statement.
5419 *
5420 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08005421 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07005422 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005423 */
5424 public Intent setData(Uri data) {
5425 mData = data;
5426 mType = null;
5427 return this;
5428 }
5429
5430 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005431 * Normalize and set the data this intent is operating on.
5432 *
5433 * <p>This method automatically clears any type that was
5434 * previously set (for example, by {@link #setType}).
5435 *
5436 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005437 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08005438 * so really this is just a convenience method for
5439 * <pre>
5440 * setData(data.normalize())
5441 * </pre>
5442 *
5443 * @param data The Uri of the data this intent is now targeting.
5444 *
5445 * @return Returns the same Intent object, for chaining multiple calls
5446 * into a single statement.
5447 *
5448 * @see #getData
5449 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005450 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005451 */
5452 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005453 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08005454 }
5455
5456 /**
5457 * Set an explicit MIME data type.
5458 *
5459 * <p>This is used to create intents that only specify a type and not data,
5460 * for example to indicate the type of data to return.
5461 *
5462 * <p>This method automatically clears any data that was
5463 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07005464 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005465 * <p><em>Note: MIME type matching in the Android framework is
5466 * case-sensitive, unlike formal RFC MIME types. As a result,
5467 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08005468 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
5469 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005470 *
5471 * @param type The MIME type of the data being handled by this intent.
5472 *
5473 * @return Returns the same Intent object, for chaining multiple calls
5474 * into a single statement.
5475 *
5476 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08005477 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005478 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08005479 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005480 */
5481 public Intent setType(String type) {
5482 mData = null;
5483 mType = type;
5484 return this;
5485 }
5486
5487 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005488 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005489 *
Nick Pellyccae4122012-01-09 14:12:58 -08005490 * <p>This is used to create intents that only specify a type and not data,
5491 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005492 *
Nick Pellyccae4122012-01-09 14:12:58 -08005493 * <p>This method automatically clears any data that was
5494 * previously set (for example by {@link #setData}).
5495 *
5496 * <p>The MIME type is normalized using
5497 * {@link #normalizeMimeType} before it is set,
5498 * so really this is just a convenience method for
5499 * <pre>
5500 * setType(Intent.normalizeMimeType(type))
5501 * </pre>
5502 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005503 * @param type The MIME type of the data being handled by this intent.
5504 *
5505 * @return Returns the same Intent object, for chaining multiple calls
5506 * into a single statement.
5507 *
Nick Pellyccae4122012-01-09 14:12:58 -08005508 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08005510 * @see #normalizeMimeType
5511 */
5512 public Intent setTypeAndNormalize(String type) {
5513 return setType(normalizeMimeType(type));
5514 }
5515
5516 /**
5517 * (Usually optional) Set the data for the intent along with an explicit
5518 * MIME data type. This method should very rarely be used -- it allows you
5519 * to override the MIME type that would ordinarily be inferred from the
5520 * data with your own type given here.
5521 *
5522 * <p><em>Note: MIME type and Uri scheme matching in the
5523 * Android framework is case-sensitive, unlike the formal RFC definitions.
5524 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005525 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08005526 * {@link #setDataAndTypeAndNormalize}
5527 * to ensure that they are converted to lower case.</em>
5528 *
5529 * @param data The Uri of the data this intent is now targeting.
5530 * @param type The MIME type of the data being handled by this intent.
5531 *
5532 * @return Returns the same Intent object, for chaining multiple calls
5533 * into a single statement.
5534 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005535 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08005536 * @see #setData
5537 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005538 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005539 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005540 */
5541 public Intent setDataAndType(Uri data, String type) {
5542 mData = data;
5543 mType = type;
5544 return this;
5545 }
5546
5547 /**
Nick Pellyccae4122012-01-09 14:12:58 -08005548 * (Usually optional) Normalize and set both the data Uri and an explicit
5549 * MIME data type. This method should very rarely be used -- it allows you
5550 * to override the MIME type that would ordinarily be inferred from the
5551 * data with your own type given here.
5552 *
5553 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005554 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08005555 * before they are set, so really this is just a convenience method for
5556 * <pre>
5557 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
5558 * </pre>
5559 *
5560 * @param data The Uri of the data this intent is now targeting.
5561 * @param type The MIME type of the data being handled by this intent.
5562 *
5563 * @return Returns the same Intent object, for chaining multiple calls
5564 * into a single statement.
5565 *
5566 * @see #setType
5567 * @see #setData
5568 * @see #setDataAndType
5569 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005570 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08005571 */
5572 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04005573 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08005574 }
5575
5576 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005577 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005578 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005579 * activities that provide <em>all</em> of the requested categories will be
5580 * used.
5581 *
5582 * @param category The desired category. This can be either one of the
5583 * predefined Intent categories, or a custom category in your own
5584 * namespace.
5585 *
5586 * @return Returns the same Intent object, for chaining multiple calls
5587 * into a single statement.
5588 *
5589 * @see #hasCategory
5590 * @see #removeCategory
5591 */
5592 public Intent addCategory(String category) {
5593 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005594 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005595 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08005596 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005597 return this;
5598 }
5599
5600 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005601 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005602 *
5603 * @param category The category to remove.
5604 *
5605 * @see #addCategory
5606 */
5607 public void removeCategory(String category) {
5608 if (mCategories != null) {
5609 mCategories.remove(category);
5610 if (mCategories.size() == 0) {
5611 mCategories = null;
5612 }
5613 }
5614 }
5615
5616 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005617 * Set a selector for this Intent. This is a modification to the kinds of
5618 * things the Intent will match. If the selector is set, it will be used
5619 * when trying to find entities that can handle the Intent, instead of the
5620 * main contents of the Intent. This allows you build an Intent containing
5621 * a generic protocol while targeting it more specifically.
5622 *
5623 * <p>An example of where this may be used is with things like
5624 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
5625 * Intent that will launch the Browser application. However, the correct
5626 * main entry point of an application is actually {@link #ACTION_MAIN}
5627 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
5628 * used to specify the actual Activity to launch. If you launch the browser
5629 * with something different, undesired behavior may happen if the user has
5630 * previously or later launches it the normal way, since they do not match.
5631 * Instead, you can build an Intent with the MAIN action (but no ComponentName
5632 * yet specified) and set a selector with {@link #ACTION_MAIN} and
5633 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
5634 *
5635 * <p>Setting a selector does not impact the behavior of
5636 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
5637 * desired behavior of a selector -- it does not impact the base meaning
5638 * of the Intent, just what kinds of things will be matched against it
5639 * when determining who can handle it.</p>
5640 *
5641 * <p>You can not use both a selector and {@link #setPackage(String)} on
5642 * the same base Intent.</p>
5643 *
5644 * @param selector The desired selector Intent; set to null to not use
5645 * a special selector.
5646 */
5647 public void setSelector(Intent selector) {
5648 if (selector == this) {
5649 throw new IllegalArgumentException(
5650 "Intent being set as a selector of itself");
5651 }
5652 if (selector != null && mPackage != null) {
5653 throw new IllegalArgumentException(
5654 "Can't set selector when package name is already set");
5655 }
5656 mSelector = selector;
5657 }
5658
5659 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005660 * Set a {@link ClipData} associated with this Intent. This replaces any
5661 * previously set ClipData.
5662 *
5663 * <p>The ClipData in an intent is not used for Intent matching or other
5664 * such operations. Semantically it is like extras, used to transmit
5665 * additional data with the Intent. The main feature of using this over
5666 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
5667 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
5668 * items included in the clip data. This is useful, in particular, if
5669 * you want to transmit an Intent containing multiple <code>content:</code>
5670 * URIs for which the recipient may not have global permission to access the
5671 * content provider.
5672 *
5673 * <p>If the ClipData contains items that are themselves Intents, any
5674 * grant flags in those Intents will be ignored. Only the top-level flags
5675 * of the main Intent are respected, and will be applied to all Uri or
5676 * Intent items in the clip (or sub-items of the clip).
5677 *
5678 * <p>The MIME type, label, and icon in the ClipData object are not
5679 * directly used by Intent. Applications should generally rely on the
5680 * MIME type of the Intent itself, not what it may find in the ClipData.
5681 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05005682 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005683 *
5684 * @param clip The new clip to set. May be null to clear the current clip.
5685 */
5686 public void setClipData(ClipData clip) {
5687 mClipData = clip;
5688 }
5689
5690 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005691 * This is NOT a secure mechanism to identify the user who sent the intent.
5692 * When the intent is sent to a different user, it is used to fix uris by adding the userId
5693 * who sent the intent.
5694 * @hide
5695 */
5696 public void setContentUserHint(int contentUserHint) {
5697 mContentUserHint = contentUserHint;
5698 }
5699
5700 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005701 * 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 boolean 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 #getBooleanExtra(String, boolean)
5714 */
5715 public Intent putExtra(String name, boolean value) {
5716 if (mExtras == null) {
5717 mExtras = new Bundle();
5718 }
5719 mExtras.putBoolean(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 byte 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 #getByteExtra(String, byte)
5737 */
5738 public Intent putExtra(String name, byte value) {
5739 if (mExtras == null) {
5740 mExtras = new Bundle();
5741 }
5742 mExtras.putByte(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 char 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 #getCharExtra(String, char)
5760 */
5761 public Intent putExtra(String name, char value) {
5762 if (mExtras == null) {
5763 mExtras = new Bundle();
5764 }
5765 mExtras.putChar(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 short 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 #getShortExtra(String, short)
5783 */
5784 public Intent putExtra(String name, short value) {
5785 if (mExtras == null) {
5786 mExtras = new Bundle();
5787 }
5788 mExtras.putShort(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.
5798 * @param value The integer 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 #getIntExtra(String, int)
5806 */
5807 public Intent putExtra(String name, int value) {
5808 if (mExtras == null) {
5809 mExtras = new Bundle();
5810 }
5811 mExtras.putInt(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.
5821 * @param value The long 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 #getLongExtra(String, long)
5829 */
5830 public Intent putExtra(String name, long value) {
5831 if (mExtras == null) {
5832 mExtras = new Bundle();
5833 }
5834 mExtras.putLong(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 float 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 #getFloatExtra(String, float)
5852 */
5853 public Intent putExtra(String name, float value) {
5854 if (mExtras == null) {
5855 mExtras = new Bundle();
5856 }
5857 mExtras.putFloat(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 double 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 #getDoubleExtra(String, double)
5875 */
5876 public Intent putExtra(String name, double value) {
5877 if (mExtras == null) {
5878 mExtras = new Bundle();
5879 }
5880 mExtras.putDouble(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 String 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 #getStringExtra(String)
5898 */
5899 public Intent putExtra(String name, String value) {
5900 if (mExtras == null) {
5901 mExtras = new Bundle();
5902 }
5903 mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
5921 */
5922 public Intent putExtra(String name, CharSequence value) {
5923 if (mExtras == null) {
5924 mExtras = new Bundle();
5925 }
5926 mExtras.putCharSequence(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 Parcelable 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 #getParcelableExtra(String)
5944 */
5945 public Intent putExtra(String name, Parcelable value) {
5946 if (mExtras == null) {
5947 mExtras = new Bundle();
5948 }
5949 mExtras.putParcelable(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 Parcelable[] 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 #getParcelableArrayExtra(String)
5967 */
5968 public Intent putExtra(String name, Parcelable[] value) {
5969 if (mExtras == null) {
5970 mExtras = new Bundle();
5971 }
5972 mExtras.putParcelableArray(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 ArrayList<Parcelable> 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 #getParcelableArrayListExtra(String)
5990 */
5991 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
5992 if (mExtras == null) {
5993 mExtras = new Bundle();
5994 }
5995 mExtras.putParcelableArrayList(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 ArrayList<Integer> 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 #getIntegerArrayListExtra(String)
6013 */
6014 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
6015 if (mExtras == null) {
6016 mExtras = new Bundle();
6017 }
6018 mExtras.putIntegerArrayList(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 ArrayList<String> 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 #getStringArrayListExtra(String)
6036 */
6037 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
6038 if (mExtras == null) {
6039 mExtras = new Bundle();
6040 }
6041 mExtras.putStringArrayList(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 ArrayList<CharSequence> 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 #getCharSequenceArrayListExtra(String)
6059 */
6060 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
6061 if (mExtras == null) {
6062 mExtras = new Bundle();
6063 }
6064 mExtras.putCharSequenceArrayList(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 Serializable 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 #getSerializableExtra(String)
6082 */
6083 public Intent putExtra(String name, Serializable value) {
6084 if (mExtras == null) {
6085 mExtras = new Bundle();
6086 }
6087 mExtras.putSerializable(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 boolean array 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 #getBooleanArrayExtra(String)
6105 */
6106 public Intent putExtra(String name, boolean[] value) {
6107 if (mExtras == null) {
6108 mExtras = new Bundle();
6109 }
6110 mExtras.putBooleanArray(name, value);
6111 return this;
6112 }
6113
6114 /**
6115 * Add extended data to the intent. The name must include a package
6116 * prefix, for example the app com.android.contacts would use names
6117 * like "com.android.contacts.ShowAll".
6118 *
6119 * @param name The name of the extra data, with package prefix.
6120 * @param value The byte array data value.
6121 *
6122 * @return Returns the same Intent object, for chaining multiple calls
6123 * into a single statement.
6124 *
6125 * @see #putExtras
6126 * @see #removeExtra
6127 * @see #getByteArrayExtra(String)
6128 */
6129 public Intent putExtra(String name, byte[] value) {
6130 if (mExtras == null) {
6131 mExtras = new Bundle();
6132 }
6133 mExtras.putByteArray(name, value);
6134 return this;
6135 }
6136
6137 /**
6138 * Add extended data to the intent. The name must include a package
6139 * prefix, for example the app com.android.contacts would use names
6140 * like "com.android.contacts.ShowAll".
6141 *
6142 * @param name The name of the extra data, with package prefix.
6143 * @param value The short array data value.
6144 *
6145 * @return Returns the same Intent object, for chaining multiple calls
6146 * into a single statement.
6147 *
6148 * @see #putExtras
6149 * @see #removeExtra
6150 * @see #getShortArrayExtra(String)
6151 */
6152 public Intent putExtra(String name, short[] value) {
6153 if (mExtras == null) {
6154 mExtras = new Bundle();
6155 }
6156 mExtras.putShortArray(name, value);
6157 return this;
6158 }
6159
6160 /**
6161 * Add extended data to the intent. The name must include a package
6162 * prefix, for example the app com.android.contacts would use names
6163 * like "com.android.contacts.ShowAll".
6164 *
6165 * @param name The name of the extra data, with package prefix.
6166 * @param value The char array data value.
6167 *
6168 * @return Returns the same Intent object, for chaining multiple calls
6169 * into a single statement.
6170 *
6171 * @see #putExtras
6172 * @see #removeExtra
6173 * @see #getCharArrayExtra(String)
6174 */
6175 public Intent putExtra(String name, char[] value) {
6176 if (mExtras == null) {
6177 mExtras = new Bundle();
6178 }
6179 mExtras.putCharArray(name, value);
6180 return this;
6181 }
6182
6183 /**
6184 * Add extended data to the intent. The name must include a package
6185 * prefix, for example the app com.android.contacts would use names
6186 * like "com.android.contacts.ShowAll".
6187 *
6188 * @param name The name of the extra data, with package prefix.
6189 * @param value The int array data value.
6190 *
6191 * @return Returns the same Intent object, for chaining multiple calls
6192 * into a single statement.
6193 *
6194 * @see #putExtras
6195 * @see #removeExtra
6196 * @see #getIntArrayExtra(String)
6197 */
6198 public Intent putExtra(String name, int[] value) {
6199 if (mExtras == null) {
6200 mExtras = new Bundle();
6201 }
6202 mExtras.putIntArray(name, value);
6203 return this;
6204 }
6205
6206 /**
6207 * Add extended data to the intent. The name must include a package
6208 * prefix, for example the app com.android.contacts would use names
6209 * like "com.android.contacts.ShowAll".
6210 *
6211 * @param name The name of the extra data, with package prefix.
6212 * @param value The byte array data value.
6213 *
6214 * @return Returns the same Intent object, for chaining multiple calls
6215 * into a single statement.
6216 *
6217 * @see #putExtras
6218 * @see #removeExtra
6219 * @see #getLongArrayExtra(String)
6220 */
6221 public Intent putExtra(String name, long[] value) {
6222 if (mExtras == null) {
6223 mExtras = new Bundle();
6224 }
6225 mExtras.putLongArray(name, value);
6226 return this;
6227 }
6228
6229 /**
6230 * Add extended data to the intent. The name must include a package
6231 * prefix, for example the app com.android.contacts would use names
6232 * like "com.android.contacts.ShowAll".
6233 *
6234 * @param name The name of the extra data, with package prefix.
6235 * @param value The float array data value.
6236 *
6237 * @return Returns the same Intent object, for chaining multiple calls
6238 * into a single statement.
6239 *
6240 * @see #putExtras
6241 * @see #removeExtra
6242 * @see #getFloatArrayExtra(String)
6243 */
6244 public Intent putExtra(String name, float[] value) {
6245 if (mExtras == null) {
6246 mExtras = new Bundle();
6247 }
6248 mExtras.putFloatArray(name, value);
6249 return this;
6250 }
6251
6252 /**
6253 * Add extended data to the intent. The name must include a package
6254 * prefix, for example the app com.android.contacts would use names
6255 * like "com.android.contacts.ShowAll".
6256 *
6257 * @param name The name of the extra data, with package prefix.
6258 * @param value The double array data value.
6259 *
6260 * @return Returns the same Intent object, for chaining multiple calls
6261 * into a single statement.
6262 *
6263 * @see #putExtras
6264 * @see #removeExtra
6265 * @see #getDoubleArrayExtra(String)
6266 */
6267 public Intent putExtra(String name, double[] value) {
6268 if (mExtras == null) {
6269 mExtras = new Bundle();
6270 }
6271 mExtras.putDoubleArray(name, value);
6272 return this;
6273 }
6274
6275 /**
6276 * Add extended data to the intent. The name must include a package
6277 * prefix, for example the app com.android.contacts would use names
6278 * like "com.android.contacts.ShowAll".
6279 *
6280 * @param name The name of the extra data, with package prefix.
6281 * @param value The String array data value.
6282 *
6283 * @return Returns the same Intent object, for chaining multiple calls
6284 * into a single statement.
6285 *
6286 * @see #putExtras
6287 * @see #removeExtra
6288 * @see #getStringArrayExtra(String)
6289 */
6290 public Intent putExtra(String name, String[] value) {
6291 if (mExtras == null) {
6292 mExtras = new Bundle();
6293 }
6294 mExtras.putStringArray(name, value);
6295 return this;
6296 }
6297
6298 /**
6299 * Add extended data to the intent. The name must include a package
6300 * prefix, for example the app com.android.contacts would use names
6301 * like "com.android.contacts.ShowAll".
6302 *
6303 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006304 * @param value The CharSequence array data value.
6305 *
6306 * @return Returns the same Intent object, for chaining multiple calls
6307 * into a single statement.
6308 *
6309 * @see #putExtras
6310 * @see #removeExtra
6311 * @see #getCharSequenceArrayExtra(String)
6312 */
6313 public Intent putExtra(String name, CharSequence[] value) {
6314 if (mExtras == null) {
6315 mExtras = new Bundle();
6316 }
6317 mExtras.putCharSequenceArray(name, value);
6318 return this;
6319 }
6320
6321 /**
6322 * Add extended data to the intent. The name must include a package
6323 * prefix, for example the app com.android.contacts would use names
6324 * like "com.android.contacts.ShowAll".
6325 *
6326 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006327 * @param value The Bundle data value.
6328 *
6329 * @return Returns the same Intent object, for chaining multiple calls
6330 * into a single statement.
6331 *
6332 * @see #putExtras
6333 * @see #removeExtra
6334 * @see #getBundleExtra(String)
6335 */
6336 public Intent putExtra(String name, Bundle value) {
6337 if (mExtras == null) {
6338 mExtras = new Bundle();
6339 }
6340 mExtras.putBundle(name, value);
6341 return this;
6342 }
6343
6344 /**
6345 * Add extended data to the intent. The name must include a package
6346 * prefix, for example the app com.android.contacts would use names
6347 * like "com.android.contacts.ShowAll".
6348 *
6349 * @param name The name of the extra data, with package prefix.
6350 * @param value The IBinder data value.
6351 *
6352 * @return Returns the same Intent object, for chaining multiple calls
6353 * into a single statement.
6354 *
6355 * @see #putExtras
6356 * @see #removeExtra
6357 * @see #getIBinderExtra(String)
6358 *
6359 * @deprecated
6360 * @hide
6361 */
6362 @Deprecated
6363 public Intent putExtra(String name, IBinder value) {
6364 if (mExtras == null) {
6365 mExtras = new Bundle();
6366 }
6367 mExtras.putIBinder(name, value);
6368 return this;
6369 }
6370
6371 /**
6372 * Copy all extras in 'src' in to this intent.
6373 *
6374 * @param src Contains the extras to copy.
6375 *
6376 * @see #putExtra
6377 */
6378 public Intent putExtras(Intent src) {
6379 if (src.mExtras != null) {
6380 if (mExtras == null) {
6381 mExtras = new Bundle(src.mExtras);
6382 } else {
6383 mExtras.putAll(src.mExtras);
6384 }
6385 }
6386 return this;
6387 }
6388
6389 /**
6390 * Add a set of extended data to the intent. The keys must include a package
6391 * prefix, for example the app com.android.contacts would use names
6392 * like "com.android.contacts.ShowAll".
6393 *
6394 * @param extras The Bundle of extras to add to this intent.
6395 *
6396 * @see #putExtra
6397 * @see #removeExtra
6398 */
6399 public Intent putExtras(Bundle extras) {
6400 if (mExtras == null) {
6401 mExtras = new Bundle();
6402 }
6403 mExtras.putAll(extras);
6404 return this;
6405 }
6406
6407 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006408 * Completely replace the extras in the Intent with the extras in the
6409 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07006410 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006411 * @param src The exact extras contained in this Intent are copied
6412 * into the target intent, replacing any that were previously there.
6413 */
6414 public Intent replaceExtras(Intent src) {
6415 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
6416 return this;
6417 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006418
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006419 /**
6420 * Completely replace the extras in the Intent with the given Bundle of
6421 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07006422 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006423 * @param extras The new set of extras in the Intent, or null to erase
6424 * all extras.
6425 */
6426 public Intent replaceExtras(Bundle extras) {
6427 mExtras = extras != null ? new Bundle(extras) : null;
6428 return this;
6429 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006430
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006431 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006432 * Remove extended data from the intent.
6433 *
6434 * @see #putExtra
6435 */
6436 public void removeExtra(String name) {
6437 if (mExtras != null) {
6438 mExtras.remove(name);
6439 if (mExtras.size() == 0) {
6440 mExtras = null;
6441 }
6442 }
6443 }
6444
6445 /**
6446 * Set special flags controlling how this intent is handled. Most values
6447 * here depend on the type of component being executed by the Intent,
6448 * specifically the FLAG_ACTIVITY_* flags are all for use with
6449 * {@link Context#startActivity Context.startActivity()} and the
6450 * FLAG_RECEIVER_* flags are all for use with
6451 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
6452 *
Scott Main7aee61f2011-02-08 11:25:01 -08006453 * <p>See the
6454 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6455 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006456 * the behavior of your application.
6457 *
6458 * @param flags The desired flags.
6459 *
6460 * @return Returns the same Intent object, for chaining multiple calls
6461 * into a single statement.
6462 *
6463 * @see #getFlags
6464 * @see #addFlags
6465 *
6466 * @see #FLAG_GRANT_READ_URI_PERMISSION
6467 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07006468 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6469 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006470 * @see #FLAG_DEBUG_LOG_RESOLUTION
6471 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006472 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006473 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006474 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006475 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006476 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
6477 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006478 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006479 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07006480 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006481 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006482 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006483 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006484 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006485 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
6486 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006487 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006488 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006489 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006490 * @see #FLAG_RECEIVER_REGISTERED_ONLY
6491 */
6492 public Intent setFlags(int flags) {
6493 mFlags = flags;
6494 return this;
6495 }
6496
6497 /**
6498 * Add additional flags to the intent (or with existing flags
6499 * value).
6500 *
6501 * @param flags The new flags to set.
6502 *
6503 * @return Returns the same Intent object, for chaining multiple calls
6504 * into a single statement.
6505 *
6506 * @see #setFlags
6507 */
6508 public Intent addFlags(int flags) {
6509 mFlags |= flags;
6510 return this;
6511 }
6512
6513 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006514 * (Usually optional) Set an explicit application package name that limits
6515 * the components this Intent will resolve to. If left to the default
6516 * value of null, all components in all applications will considered.
6517 * If non-null, the Intent can only match the components in the given
6518 * application package.
6519 *
6520 * @param packageName The name of the application package to handle the
6521 * intent, or null to allow any application package.
6522 *
6523 * @return Returns the same Intent object, for chaining multiple calls
6524 * into a single statement.
6525 *
6526 * @see #getPackage
6527 * @see #resolveActivity
6528 */
6529 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006530 if (packageName != null && mSelector != null) {
6531 throw new IllegalArgumentException(
6532 "Can't set package name when selector is already set");
6533 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006534 mPackage = packageName;
6535 return this;
6536 }
6537
6538 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006539 * (Usually optional) Explicitly set the component to handle the intent.
6540 * If left with the default value of null, the system will determine the
6541 * appropriate class to use based on the other fields (action, data,
6542 * type, categories) in the Intent. If this class is defined, the
6543 * specified class will always be used regardless of the other fields. You
6544 * should only set this value when you know you absolutely want a specific
6545 * class to be used; otherwise it is better to let the system find the
6546 * appropriate class so that you will respect the installed applications
6547 * and user preferences.
6548 *
6549 * @param component The name of the application component to handle the
6550 * intent, or null to let the system find one for you.
6551 *
6552 * @return Returns the same Intent object, for chaining multiple calls
6553 * into a single statement.
6554 *
6555 * @see #setClass
6556 * @see #setClassName(Context, String)
6557 * @see #setClassName(String, String)
6558 * @see #getComponent
6559 * @see #resolveActivity
6560 */
6561 public Intent setComponent(ComponentName component) {
6562 mComponent = component;
6563 return this;
6564 }
6565
6566 /**
6567 * Convenience for calling {@link #setComponent} with an
6568 * explicit class name.
6569 *
6570 * @param packageContext A Context of the application package implementing
6571 * this class.
6572 * @param className The name of a class inside of the application package
6573 * that will be used as the component for this Intent.
6574 *
6575 * @return Returns the same Intent object, for chaining multiple calls
6576 * into a single statement.
6577 *
6578 * @see #setComponent
6579 * @see #setClass
6580 */
6581 public Intent setClassName(Context packageContext, String className) {
6582 mComponent = new ComponentName(packageContext, className);
6583 return this;
6584 }
6585
6586 /**
6587 * Convenience for calling {@link #setComponent} with an
6588 * explicit application package name and class name.
6589 *
6590 * @param packageName The name of the package implementing the desired
6591 * component.
6592 * @param className The name of a class inside of the application package
6593 * that will be used as the component for this Intent.
6594 *
6595 * @return Returns the same Intent object, for chaining multiple calls
6596 * into a single statement.
6597 *
6598 * @see #setComponent
6599 * @see #setClass
6600 */
6601 public Intent setClassName(String packageName, String className) {
6602 mComponent = new ComponentName(packageName, className);
6603 return this;
6604 }
6605
6606 /**
6607 * Convenience for calling {@link #setComponent(ComponentName)} with the
6608 * name returned by a {@link Class} object.
6609 *
6610 * @param packageContext A Context of the application package implementing
6611 * this class.
6612 * @param cls The class name to set, equivalent to
6613 * <code>setClassName(context, cls.getName())</code>.
6614 *
6615 * @return Returns the same Intent object, for chaining multiple calls
6616 * into a single statement.
6617 *
6618 * @see #setComponent
6619 */
6620 public Intent setClass(Context packageContext, Class<?> cls) {
6621 mComponent = new ComponentName(packageContext, cls);
6622 return this;
6623 }
6624
6625 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006626 * Set the bounds of the sender of this intent, in screen coordinates. This can be
6627 * used as a hint to the receiver for animations and the like. Null means that there
6628 * is no source bounds.
6629 */
6630 public void setSourceBounds(Rect r) {
6631 if (r != null) {
6632 mSourceBounds = new Rect(r);
6633 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07006634 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006635 }
6636 }
6637
Tor Norbyed9273d62013-05-30 15:59:53 -07006638 /** @hide */
6639 @IntDef(flag = true,
6640 value = {
6641 FILL_IN_ACTION,
6642 FILL_IN_DATA,
6643 FILL_IN_CATEGORIES,
6644 FILL_IN_COMPONENT,
6645 FILL_IN_PACKAGE,
6646 FILL_IN_SOURCE_BOUNDS,
6647 FILL_IN_SELECTOR,
6648 FILL_IN_CLIP_DATA
6649 })
6650 @Retention(RetentionPolicy.SOURCE)
6651 public @interface FillInFlags {}
6652
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006653 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006654 * Use with {@link #fillIn} to allow the current action value to be
6655 * overwritten, even if it is already set.
6656 */
6657 public static final int FILL_IN_ACTION = 1<<0;
6658
6659 /**
6660 * Use with {@link #fillIn} to allow the current data or type value
6661 * overwritten, even if it is already set.
6662 */
6663 public static final int FILL_IN_DATA = 1<<1;
6664
6665 /**
6666 * Use with {@link #fillIn} to allow the current categories to be
6667 * overwritten, even if they are already set.
6668 */
6669 public static final int FILL_IN_CATEGORIES = 1<<2;
6670
6671 /**
6672 * Use with {@link #fillIn} to allow the current component value to be
6673 * overwritten, even if it is already set.
6674 */
6675 public static final int FILL_IN_COMPONENT = 1<<3;
6676
6677 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006678 * Use with {@link #fillIn} to allow the current package value to be
6679 * overwritten, even if it is already set.
6680 */
6681 public static final int FILL_IN_PACKAGE = 1<<4;
6682
6683 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006684 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006685 * overwritten, even if it is already set.
6686 */
6687 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
6688
6689 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006690 * Use with {@link #fillIn} to allow the current selector to be
6691 * overwritten, even if it is already set.
6692 */
6693 public static final int FILL_IN_SELECTOR = 1<<6;
6694
6695 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006696 * Use with {@link #fillIn} to allow the current ClipData to be
6697 * overwritten, even if it is already set.
6698 */
6699 public static final int FILL_IN_CLIP_DATA = 1<<7;
6700
6701 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006702 * Copy the contents of <var>other</var> in to this object, but only
6703 * where fields are not defined by this object. For purposes of a field
6704 * being defined, the following pieces of data in the Intent are
6705 * considered to be separate fields:
6706 *
6707 * <ul>
6708 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08006709 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006710 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
6711 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006712 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006713 * <li> component, as set by {@link #setComponent(ComponentName)} or
6714 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006715 * <li> source bounds, as set by {@link #setSourceBounds}.
6716 * <li> selector, as set by {@link #setSelector(Intent)}.
6717 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006718 * <li> each top-level name in the associated extras.
6719 * </ul>
6720 *
6721 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006722 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006723 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6724 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
6725 * the restriction where the corresponding field will not be replaced if
6726 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006727 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006728 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
6729 * is explicitly specified. The selector will only be copied if
6730 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07006731 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006732 * <p>For example, consider Intent A with {data="foo", categories="bar"}
6733 * and Intent B with {action="gotit", data-type="some/thing",
6734 * categories="one","two"}.
6735 *
6736 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
6737 * containing: {action="gotit", data-type="some/thing",
6738 * categories="bar"}.
6739 *
6740 * @param other Another Intent whose values are to be used to fill in
6741 * the current one.
6742 * @param flags Options to control which fields can be filled in.
6743 *
6744 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006745 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07006746 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
6747 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
6748 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006749 */
Tor Norbyed9273d62013-05-30 15:59:53 -07006750 @FillInFlags
6751 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006752 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006753 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006754 if (other.mAction != null
6755 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006756 mAction = other.mAction;
6757 changes |= FILL_IN_ACTION;
6758 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006759 if ((other.mData != null || other.mType != null)
6760 && ((mData == null && mType == null)
6761 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006762 mData = other.mData;
6763 mType = other.mType;
6764 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006765 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006766 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006767 if (other.mCategories != null
6768 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006769 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006770 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006771 }
6772 changes |= FILL_IN_CATEGORIES;
6773 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006774 if (other.mPackage != null
6775 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006776 // Only do this if mSelector is not set.
6777 if (mSelector == null) {
6778 mPackage = other.mPackage;
6779 changes |= FILL_IN_PACKAGE;
6780 }
6781 }
6782 // Selector is special: it can only be set if explicitly allowed,
6783 // for the same reason as the component name.
6784 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
6785 if (mPackage == null) {
6786 mSelector = new Intent(other.mSelector);
6787 mPackage = null;
6788 changes |= FILL_IN_SELECTOR;
6789 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006790 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006791 if (other.mClipData != null
6792 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
6793 mClipData = other.mClipData;
6794 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006795 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006796 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006797 // Component is special: it can -only- be set if explicitly allowed,
6798 // since otherwise the sender could force the intent somewhere the
6799 // originator didn't intend.
6800 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006801 mComponent = other.mComponent;
6802 changes |= FILL_IN_COMPONENT;
6803 }
6804 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006805 if (other.mSourceBounds != null
6806 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
6807 mSourceBounds = new Rect(other.mSourceBounds);
6808 changes |= FILL_IN_SOURCE_BOUNDS;
6809 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006810 if (mExtras == null) {
6811 if (other.mExtras != null) {
6812 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006813 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006814 }
6815 } else if (other.mExtras != null) {
6816 try {
6817 Bundle newb = new Bundle(other.mExtras);
6818 newb.putAll(mExtras);
6819 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006820 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006821 } catch (RuntimeException e) {
6822 // Modifying the extras can cause us to unparcel the contents
6823 // of the bundle, and if we do this in the system process that
6824 // may fail. We really should handle this (i.e., the Bundle
6825 // impl shouldn't be on top of a plain map), but for now just
6826 // ignore it and keep the original contents. :(
6827 Log.w("Intent", "Failure filling in extras", e);
6828 }
6829 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006830 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
6831 && other.mContentUserHint != UserHandle.USER_CURRENT) {
6832 mContentUserHint = other.mContentUserHint;
6833 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006834 return changes;
6835 }
6836
6837 /**
6838 * Wrapper class holding an Intent and implementing comparisons on it for
6839 * the purpose of filtering. The class implements its
6840 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
6841 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
6842 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
6843 * on the wrapped Intent.
6844 */
6845 public static final class FilterComparison {
6846 private final Intent mIntent;
6847 private final int mHashCode;
6848
6849 public FilterComparison(Intent intent) {
6850 mIntent = intent;
6851 mHashCode = intent.filterHashCode();
6852 }
6853
6854 /**
6855 * Return the Intent that this FilterComparison represents.
6856 * @return Returns the Intent held by the FilterComparison. Do
6857 * not modify!
6858 */
6859 public Intent getIntent() {
6860 return mIntent;
6861 }
6862
6863 @Override
6864 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006865 if (obj instanceof FilterComparison) {
6866 Intent other = ((FilterComparison)obj).mIntent;
6867 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006868 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006869 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006870 }
6871
6872 @Override
6873 public int hashCode() {
6874 return mHashCode;
6875 }
6876 }
6877
6878 /**
6879 * Determine if two intents are the same for the purposes of intent
6880 * resolution (filtering). That is, if their action, data, type,
6881 * class, and categories are the same. This does <em>not</em> compare
6882 * any extra data included in the intents.
6883 *
6884 * @param other The other Intent to compare against.
6885 *
6886 * @return Returns true if action, data, type, class, and categories
6887 * are the same.
6888 */
6889 public boolean filterEquals(Intent other) {
6890 if (other == null) {
6891 return false;
6892 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07006893 if (!Objects.equals(this.mAction, other.mAction)) return false;
6894 if (!Objects.equals(this.mData, other.mData)) return false;
6895 if (!Objects.equals(this.mType, other.mType)) return false;
6896 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
6897 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
6898 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006899
6900 return true;
6901 }
6902
6903 /**
6904 * Generate hash code that matches semantics of filterEquals().
6905 *
6906 * @return Returns the hash value of the action, data, type, class, and
6907 * categories.
6908 *
6909 * @see #filterEquals
6910 */
6911 public int filterHashCode() {
6912 int code = 0;
6913 if (mAction != null) {
6914 code += mAction.hashCode();
6915 }
6916 if (mData != null) {
6917 code += mData.hashCode();
6918 }
6919 if (mType != null) {
6920 code += mType.hashCode();
6921 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006922 if (mPackage != null) {
6923 code += mPackage.hashCode();
6924 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006925 if (mComponent != null) {
6926 code += mComponent.hashCode();
6927 }
6928 if (mCategories != null) {
6929 code += mCategories.hashCode();
6930 }
6931 return code;
6932 }
6933
6934 @Override
6935 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006936 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006937
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006938 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006939 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006940 b.append(" }");
6941
6942 return b.toString();
6943 }
6944
6945 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006946 public String toInsecureString() {
6947 StringBuilder b = new StringBuilder(128);
6948
6949 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006950 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006951 b.append(" }");
6952
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006953 return b.toString();
6954 }
Romain Guy4969af72009-06-17 10:53:19 -07006955
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006956 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006957 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006958 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006959
6960 b.append("Intent { ");
6961 toShortString(b, false, true, true, true);
6962 b.append(" }");
6963
Dianne Hackborn90c52de2011-09-23 12:57:44 -07006964 return b.toString();
6965 }
6966
6967 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006968 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
6969 StringBuilder b = new StringBuilder(128);
6970 toShortString(b, secure, comp, extras, clip);
6971 return b.toString();
6972 }
6973
6974 /** @hide */
6975 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
6976 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006977 boolean first = true;
6978 if (mAction != null) {
6979 b.append("act=").append(mAction);
6980 first = false;
6981 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006982 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006983 if (!first) {
6984 b.append(' ');
6985 }
6986 first = false;
6987 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006988 for (int i=0; i<mCategories.size(); i++) {
6989 if (i > 0) b.append(',');
6990 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006991 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006992 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006993 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07006994 if (mData != null) {
6995 if (!first) {
6996 b.append(' ');
6997 }
6998 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07006999 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07007000 if (secure) {
7001 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07007002 } else {
7003 b.append(mData);
7004 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007005 }
7006 if (mType != null) {
7007 if (!first) {
7008 b.append(' ');
7009 }
7010 first = false;
7011 b.append("typ=").append(mType);
7012 }
7013 if (mFlags != 0) {
7014 if (!first) {
7015 b.append(' ');
7016 }
7017 first = false;
7018 b.append("flg=0x").append(Integer.toHexString(mFlags));
7019 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007020 if (mPackage != null) {
7021 if (!first) {
7022 b.append(' ');
7023 }
7024 first = false;
7025 b.append("pkg=").append(mPackage);
7026 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007027 if (comp && mComponent != null) {
7028 if (!first) {
7029 b.append(' ');
7030 }
7031 first = false;
7032 b.append("cmp=").append(mComponent.flattenToShortString());
7033 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007034 if (mSourceBounds != null) {
7035 if (!first) {
7036 b.append(' ');
7037 }
7038 first = false;
7039 b.append("bnds=").append(mSourceBounds.toShortString());
7040 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007041 if (mClipData != null) {
7042 if (!first) {
7043 b.append(' ');
7044 }
7045 first = false;
7046 if (clip) {
7047 b.append("clip={");
7048 mClipData.toShortString(b);
7049 b.append('}');
7050 } else {
7051 b.append("(has clip)");
7052 }
7053 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007054 if (extras && mExtras != null) {
7055 if (!first) {
7056 b.append(' ');
7057 }
7058 first = false;
7059 b.append("(has extras)");
7060 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007061 if (mContentUserHint != UserHandle.USER_CURRENT) {
7062 if (!first) {
7063 b.append(' ');
7064 }
7065 first = false;
7066 b.append("u=").append(mContentUserHint);
7067 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007068 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007069 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007070 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007071 b.append("}");
7072 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007073 }
7074
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007075 /**
7076 * Call {@link #toUri} with 0 flags.
7077 * @deprecated Use {@link #toUri} instead.
7078 */
7079 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007080 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007081 return toUri(0);
7082 }
7083
7084 /**
7085 * Convert this Intent into a String holding a URI representation of it.
7086 * The returned URI string has been properly URI encoded, so it can be
7087 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
7088 * Intent's data as the base URI, with an additional fragment describing
7089 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08007090 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007091 * <p>You can convert the returned string back to an Intent with
7092 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08007093 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007094 * @param flags Additional operating flags. Either 0 or
7095 * {@link #URI_INTENT_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08007096 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007097 * @return Returns a URI encoding URI string describing the entire contents
7098 * of the Intent.
7099 */
7100 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07007101 StringBuilder uri = new StringBuilder(128);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007102 String scheme = null;
7103 if (mData != null) {
7104 String data = mData.toString();
7105 if ((flags&URI_INTENT_SCHEME) != 0) {
7106 final int N = data.length();
7107 for (int i=0; i<N; i++) {
7108 char c = data.charAt(i);
7109 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
7110 || c == '.' || c == '-') {
7111 continue;
7112 }
7113 if (c == ':' && i > 0) {
7114 // Valid scheme.
7115 scheme = data.substring(0, i);
7116 uri.append("intent:");
7117 data = data.substring(i+1);
7118 break;
7119 }
Tom Taylord4a47292009-12-21 13:59:18 -08007120
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007121 // No scheme.
7122 break;
7123 }
7124 }
7125 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08007126
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007127 } else if ((flags&URI_INTENT_SCHEME) != 0) {
7128 uri.append("intent:");
7129 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007130
7131 uri.append("#Intent;");
7132
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007133 toUriInner(uri, scheme, flags);
7134 if (mSelector != null) {
7135 uri.append("SEL;");
7136 // Note that for now we are not going to try to handle the
7137 // data part; not clear how to represent this as a URI, and
7138 // not much utility in it.
7139 mSelector.toUriInner(uri, null, flags);
7140 }
7141
7142 uri.append("end");
7143
7144 return uri.toString();
7145 }
7146
7147 private void toUriInner(StringBuilder uri, String scheme, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007148 if (scheme != null) {
7149 uri.append("scheme=").append(scheme).append(';');
7150 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007151 if (mAction != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007152 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007153 }
7154 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007155 for (int i=0; i<mCategories.size(); i++) {
7156 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007157 }
7158 }
7159 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007160 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007161 }
7162 if (mFlags != 0) {
7163 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
7164 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007165 if (mPackage != null) {
7166 uri.append("package=").append(Uri.encode(mPackage)).append(';');
7167 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007168 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007169 uri.append("component=").append(Uri.encode(
7170 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007171 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007172 if (mSourceBounds != null) {
7173 uri.append("sourceBounds=")
7174 .append(Uri.encode(mSourceBounds.flattenToString()))
7175 .append(';');
7176 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007177 if (mExtras != null) {
7178 for (String key : mExtras.keySet()) {
7179 final Object value = mExtras.get(key);
7180 char entryType =
7181 value instanceof String ? 'S' :
7182 value instanceof Boolean ? 'B' :
7183 value instanceof Byte ? 'b' :
7184 value instanceof Character ? 'c' :
7185 value instanceof Double ? 'd' :
7186 value instanceof Float ? 'f' :
7187 value instanceof Integer ? 'i' :
7188 value instanceof Long ? 'l' :
7189 value instanceof Short ? 's' :
7190 '\0';
7191
7192 if (entryType != '\0') {
7193 uri.append(entryType);
7194 uri.append('.');
7195 uri.append(Uri.encode(key));
7196 uri.append('=');
7197 uri.append(Uri.encode(value.toString()));
7198 uri.append(';');
7199 }
7200 }
7201 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007202 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007204 public int describeContents() {
7205 return (mExtras != null) ? mExtras.describeContents() : 0;
7206 }
7207
7208 public void writeToParcel(Parcel out, int flags) {
7209 out.writeString(mAction);
7210 Uri.writeToParcel(out, mData);
7211 out.writeString(mType);
7212 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007213 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007214 ComponentName.writeToParcel(mComponent, out);
7215
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007216 if (mSourceBounds != null) {
7217 out.writeInt(1);
7218 mSourceBounds.writeToParcel(out, flags);
7219 } else {
7220 out.writeInt(0);
7221 }
7222
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007223 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007224 final int N = mCategories.size();
7225 out.writeInt(N);
7226 for (int i=0; i<N; i++) {
7227 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007228 }
7229 } else {
7230 out.writeInt(0);
7231 }
7232
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007233 if (mSelector != null) {
7234 out.writeInt(1);
7235 mSelector.writeToParcel(out, flags);
7236 } else {
7237 out.writeInt(0);
7238 }
7239
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007240 if (mClipData != null) {
7241 out.writeInt(1);
7242 mClipData.writeToParcel(out, flags);
7243 } else {
7244 out.writeInt(0);
7245 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007246 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007247 out.writeBundle(mExtras);
7248 }
7249
7250 public static final Parcelable.Creator<Intent> CREATOR
7251 = new Parcelable.Creator<Intent>() {
7252 public Intent createFromParcel(Parcel in) {
7253 return new Intent(in);
7254 }
7255 public Intent[] newArray(int size) {
7256 return new Intent[size];
7257 }
7258 };
7259
Dianne Hackborneb034652009-09-07 00:49:58 -07007260 /** @hide */
7261 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007262 readFromParcel(in);
7263 }
7264
7265 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007266 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007267 mData = Uri.CREATOR.createFromParcel(in);
7268 mType = in.readString();
7269 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007270 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007271 mComponent = ComponentName.readFromParcel(in);
7272
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007273 if (in.readInt() != 0) {
7274 mSourceBounds = Rect.CREATOR.createFromParcel(in);
7275 }
7276
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007277 int N = in.readInt();
7278 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007279 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007280 int i;
7281 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007282 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007283 }
7284 } else {
7285 mCategories = null;
7286 }
7287
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007288 if (in.readInt() != 0) {
7289 mSelector = new Intent(in);
7290 }
7291
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007292 if (in.readInt() != 0) {
7293 mClipData = new ClipData(in);
7294 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007295 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007296 mExtras = in.readBundle();
7297 }
7298
7299 /**
7300 * Parses the "intent" element (and its children) from XML and instantiates
7301 * an Intent object. The given XML parser should be located at the tag
7302 * where parsing should start (often named "intent"), from which the
7303 * basic action, data, type, and package and class name will be
7304 * retrieved. The function will then parse in to any child elements,
7305 * looking for <category android:name="xxx"> tags to add categories and
7306 * <extra android:name="xxx" android:value="yyy"> to attach extra data
7307 * to the intent.
7308 *
7309 * @param resources The Resources to use when inflating resources.
7310 * @param parser The XML parser pointing at an "intent" tag.
7311 * @param attrs The AttributeSet interface for retrieving extended
7312 * attribute data at the current <var>parser</var> location.
7313 * @return An Intent object matching the XML data.
7314 * @throws XmlPullParserException If there was an XML parsing error.
7315 * @throws IOException If there was an I/O error.
7316 */
7317 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
7318 throws XmlPullParserException, IOException {
7319 Intent intent = new Intent();
7320
7321 TypedArray sa = resources.obtainAttributes(attrs,
7322 com.android.internal.R.styleable.Intent);
7323
7324 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
7325
7326 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
7327 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
7328 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
7329
7330 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
7331 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
7332 if (packageName != null && className != null) {
7333 intent.setComponent(new ComponentName(packageName, className));
7334 }
7335
7336 sa.recycle();
7337
7338 int outerDepth = parser.getDepth();
7339 int type;
7340 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
7341 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
7342 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
7343 continue;
7344 }
7345
7346 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07007347 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007348 sa = resources.obtainAttributes(attrs,
7349 com.android.internal.R.styleable.IntentCategory);
7350 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
7351 sa.recycle();
7352
7353 if (cat != null) {
7354 intent.addCategory(cat);
7355 }
7356 XmlUtils.skipCurrentTag(parser);
7357
Craig Mautner21d24a22014-04-23 11:45:37 -07007358 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007359 if (intent.mExtras == null) {
7360 intent.mExtras = new Bundle();
7361 }
Craig Mautner21d24a22014-04-23 11:45:37 -07007362 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007363 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007364
7365 } else {
7366 XmlUtils.skipCurrentTag(parser);
7367 }
7368 }
7369
7370 return intent;
7371 }
Nick Pellyccae4122012-01-09 14:12:58 -08007372
Craig Mautner21d24a22014-04-23 11:45:37 -07007373 /** @hide */
7374 public void saveToXml(XmlSerializer out) throws IOException {
7375 if (mAction != null) {
7376 out.attribute(null, ATTR_ACTION, mAction);
7377 }
7378 if (mData != null) {
7379 out.attribute(null, ATTR_DATA, mData.toString());
7380 }
7381 if (mType != null) {
7382 out.attribute(null, ATTR_TYPE, mType);
7383 }
7384 if (mComponent != null) {
7385 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
7386 }
7387 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
7388
7389 if (mCategories != null) {
7390 out.startTag(null, TAG_CATEGORIES);
7391 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
7392 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
7393 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07007394 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07007395 }
7396 }
7397
7398 /** @hide */
7399 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
7400 XmlPullParserException {
7401 Intent intent = new Intent();
7402 final int outerDepth = in.getDepth();
7403
7404 int attrCount = in.getAttributeCount();
7405 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7406 final String attrName = in.getAttributeName(attrNdx);
7407 final String attrValue = in.getAttributeValue(attrNdx);
7408 if (ATTR_ACTION.equals(attrName)) {
7409 intent.setAction(attrValue);
7410 } else if (ATTR_DATA.equals(attrName)) {
7411 intent.setData(Uri.parse(attrValue));
7412 } else if (ATTR_TYPE.equals(attrName)) {
7413 intent.setType(attrValue);
7414 } else if (ATTR_COMPONENT.equals(attrName)) {
7415 intent.setComponent(ComponentName.unflattenFromString(attrValue));
7416 } else if (ATTR_FLAGS.equals(attrName)) {
7417 intent.setFlags(Integer.valueOf(attrValue, 16));
7418 } else {
7419 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
7420 }
7421 }
7422
7423 int event;
7424 String name;
7425 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
7426 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
7427 if (event == XmlPullParser.START_TAG) {
7428 name = in.getName();
7429 if (TAG_CATEGORIES.equals(name)) {
7430 attrCount = in.getAttributeCount();
7431 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
7432 intent.addCategory(in.getAttributeValue(attrNdx));
7433 }
7434 } else {
7435 Log.w("Intent", "restoreFromXml: unknown name=" + name);
7436 XmlUtils.skipCurrentTag(in);
7437 }
7438 }
7439 }
7440
7441 return intent;
7442 }
7443
Nick Pellyccae4122012-01-09 14:12:58 -08007444 /**
7445 * Normalize a MIME data type.
7446 *
7447 * <p>A normalized MIME type has white-space trimmed,
7448 * content-type parameters removed, and is lower-case.
7449 * This aligns the type with Android best practices for
7450 * intent filtering.
7451 *
7452 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
7453 * "text/x-vCard" becomes "text/x-vcard".
7454 *
7455 * <p>All MIME types received from outside Android (such as user input,
7456 * or external sources like Bluetooth, NFC, or the Internet) should
7457 * be normalized before they are used to create an Intent.
7458 *
7459 * @param type MIME data type to normalize
7460 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05007461 * @see #setType
7462 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08007463 */
7464 public static String normalizeMimeType(String type) {
7465 if (type == null) {
7466 return null;
7467 }
7468
Elliott Hughescb64d432013-08-02 10:00:44 -07007469 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08007470
7471 final int semicolonIndex = type.indexOf(';');
7472 if (semicolonIndex != -1) {
7473 type = type.substring(0, semicolonIndex);
7474 }
7475 return type;
7476 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007477
7478 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07007479 * Prepare this {@link Intent} to leave an app process.
7480 *
7481 * @hide
7482 */
7483 public void prepareToLeaveProcess() {
7484 setAllowFds(false);
7485
7486 if (mSelector != null) {
7487 mSelector.prepareToLeaveProcess();
7488 }
7489 if (mClipData != null) {
7490 mClipData.prepareToLeaveProcess();
7491 }
7492
7493 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
7494 // There are several ACTION_MEDIA_* broadcasts that send file://
7495 // Uris, so only check common actions.
7496 if (ACTION_VIEW.equals(mAction) ||
7497 ACTION_EDIT.equals(mAction) ||
7498 ACTION_ATTACH_DATA.equals(mAction)) {
7499 mData.checkFileUriExposed("Intent.getData()");
7500 }
7501 }
7502 }
7503
7504 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007505 * @hide
7506 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007507 public void prepareToEnterProcess() {
7508 if (mContentUserHint != UserHandle.USER_CURRENT) {
7509 fixUris(mContentUserHint);
7510 mContentUserHint = UserHandle.USER_CURRENT;
7511 }
7512 }
7513
7514 /**
7515 * @hide
7516 */
7517 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007518 Uri data = getData();
7519 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007520 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007521 }
7522 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007523 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007524 }
7525 String action = getAction();
7526 if (ACTION_SEND.equals(action)) {
7527 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7528 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007529 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007530 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007531 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007532 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7533 if (streams != null) {
7534 ArrayList<Uri> newStreams = new ArrayList<Uri>();
7535 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007536 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007537 }
7538 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
7539 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007540 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7541 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7542 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7543 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7544 if (output != null) {
7545 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
7546 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007547 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007548 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01007549
7550 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007551 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007552 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
7553 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007554 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007555 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007556 * @hide
7557 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007558 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007559 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007560 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007561
7562 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007563 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007564
7565 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007566 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkey1c297002012-05-18 13:55:47 -07007567 try {
7568 // Inspect target intent to see if we need to migrate
7569 final Intent target = getParcelableExtra(EXTRA_INTENT);
7570 if (target != null && target.migrateExtraStreamToClipData()) {
7571 // Since we migrated in child, we need to promote ClipData
7572 // and flags to ourselves to grant.
7573 setClipData(target.getClipData());
Jeff Sharkey846318a2014-04-04 12:12:41 -07007574 addFlags(target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
7575 | FLAG_GRANT_WRITE_URI_PERMISSION
7576 | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7577 | FLAG_GRANT_PREFIX_URI_PERMISSION));
Jeff Sharkey1c297002012-05-18 13:55:47 -07007578 return true;
7579 } else {
7580 return false;
7581 }
7582 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007583 }
7584
7585 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007586 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007587 final Uri stream = getParcelableExtra(EXTRA_STREAM);
7588 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
7589 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
7590 if (stream != null || text != null || htmlText != null) {
7591 final ClipData clipData = new ClipData(
7592 null, new String[] { getType() },
7593 new ClipData.Item(text, htmlText, null, stream));
7594 setClipData(clipData);
7595 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007596 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007597 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007598 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007599 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007600
7601 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007602 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007603 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
7604 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
7605 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
7606 int num = -1;
7607 if (streams != null) {
7608 num = streams.size();
7609 }
7610 if (texts != null) {
7611 if (num >= 0 && num != texts.size()) {
7612 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007613 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007614 }
7615 num = texts.size();
7616 }
7617 if (htmlTexts != null) {
7618 if (num >= 0 && num != htmlTexts.size()) {
7619 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007620 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007621 }
7622 num = htmlTexts.size();
7623 }
7624 if (num > 0) {
7625 final ClipData clipData = new ClipData(
7626 null, new String[] { getType() },
7627 makeClipItem(streams, texts, htmlTexts, 0));
7628
7629 for (int i = 1; i < num; i++) {
7630 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
7631 }
7632
7633 setClipData(clipData);
7634 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007635 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07007636 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007637 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07007638 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007639 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
7640 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
7641 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
7642 final Uri output;
7643 try {
7644 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
7645 } catch (ClassCastException e) {
7646 return false;
7647 }
7648 if (output != null) {
7649 setClipData(ClipData.newRawUri("", output));
7650 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
7651 return true;
7652 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007653 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07007654
7655 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07007656 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07007657
7658 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
7659 ArrayList<String> htmlTexts, int which) {
7660 Uri uri = streams != null ? streams.get(which) : null;
7661 CharSequence text = texts != null ? texts.get(which) : null;
7662 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
7663 return new ClipData.Item(text, htmlText, null, uri);
7664 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07007665
7666 /** @hide */
7667 public boolean isDocument() {
7668 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
7669 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007670}