blob: e25f1d7804ceb018c20abfdc51bd21f6ddf4b756 [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;
Adam Powell2ed547e2015-04-29 18:45:04 -070020import android.os.ResultReceiver;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080021import android.os.ShellCommand;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010022import android.provider.MediaStore;
Dianne Hackbornadd005c2013-07-17 18:43:12 -070023import android.util.ArraySet;
Jeff Sharkey846318a2014-04-04 12:12:41 -070024
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070025import org.xmlpull.v1.XmlPullParser;
26import org.xmlpull.v1.XmlPullParserException;
27
Tor Norbye7b9c9122013-05-30 16:48:33 -070028import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070029import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.annotation.SdkConstant;
Jose Lima73915cf2014-07-29 17:16:31 -070031import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.annotation.SdkConstant.SdkConstantType;
33import android.content.pm.ActivityInfo;
Jose Lima73915cf2014-07-29 17:16:31 -070034
Nicolas Prevotd85fc722014-04-16 19:52:08 +010035import static android.content.ContentProvider.maybeAddUserId;
Jose Lima73915cf2014-07-29 17:16:31 -070036
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.content.pm.PackageManager;
38import android.content.pm.ResolveInfo;
39import android.content.res.Resources;
40import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080041import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070042import android.net.Uri;
43import android.os.Bundle;
44import android.os.IBinder;
45import android.os.Parcel;
46import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000047import android.os.Process;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070048import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010049import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070050import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070051import android.provider.DocumentsProvider;
52import android.provider.OpenableColumns;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070053import android.util.AttributeSet;
54import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080055
56import com.android.internal.util.XmlUtils;
Jose Lima73915cf2014-07-29 17:16:31 -070057
Craig Mautner21d24a22014-04-23 11:45:37 -070058import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059
60import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080061import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070062import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070063import java.lang.annotation.Retention;
64import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import java.net.URISyntaxException;
66import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080067import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070068import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080069import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070070import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.util.Set;
72
73/**
74 * An intent is an abstract description of an operation to be performed. It
75 * can be used with {@link Context#startActivity(Intent) startActivity} to
76 * launch an {@link android.app.Activity},
77 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
78 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
79 * and {@link android.content.Context#startService} or
80 * {@link android.content.Context#bindService} to communicate with a
81 * background {@link android.app.Service}.
82 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070083 * <p>An Intent provides a facility for performing late runtime binding between the code in
84 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070085 * can be thought of as the glue between activities. It is basically a passive data structure
86 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070087 *
88 * <div class="special reference">
89 * <h3>Developer Guides</h3>
90 * <p>For information about how to create and resolve intents, read the
91 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
92 * developer guide.</p>
93 * </div>
94 *
95 * <a name="IntentStructure"></a>
96 * <h3>Intent Structure</h3>
97 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070098 *
99 * <ul>
100 * <li> <p><b>action</b> -- The general action to be performed, such as
101 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
102 * etc.</p>
103 * </li>
104 * <li> <p><b>data</b> -- The data to operate on, such as a person record
105 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
106 * </li>
107 * </ul>
108 *
109 *
110 * <p>Some examples of action/data pairs are:</p>
111 *
112 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700113 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 * information about the person whose identifier is "1".</p>
115 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700116 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700117 * the phone dialer with the person filled in.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in. Note how the
121 * VIEW action does what what is considered the most reasonable thing for
122 * a particular URI.</p>
123 * </li>
124 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
125 * the phone dialer with the given number filled in.</p>
126 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700127 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * information about the person whose identifier is "1".</p>
129 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700130 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * a list of people, which the user can browse through. This example is a
132 * typical top-level entry into the Contacts application, showing you the
133 * list of people. Selecting a particular person to view would result in a
134 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
135 * being used to start an activity to display that person.</p>
136 * </li>
137 * </ul>
138 *
139 * <p>In addition to these primary attributes, there are a number of secondary
140 * attributes that you can also include with an intent:</p>
141 *
142 * <ul>
143 * <li> <p><b>category</b> -- Gives additional information about the action
144 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
145 * appear in the Launcher as a top-level application, while
146 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
147 * of alternative actions the user can perform on a piece of data.</p>
148 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
149 * intent data. Normally the type is inferred from the data itself.
150 * By setting this attribute, you disable that evaluation and force
151 * an explicit type.</p>
152 * <li> <p><b>component</b> -- Specifies an explicit name of a component
153 * class to use for the intent. Normally this is determined by looking
154 * at the other information in the intent (the action, data/type, and
155 * categories) and matching that with a component that can handle it.
156 * If this attribute is set then none of the evaluation is performed,
157 * and this component is used exactly as is. By specifying this attribute,
158 * all of the other Intent attributes become optional.</p>
159 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
160 * This can be used to provide extended information to the component.
161 * For example, if we have a action to send an e-mail message, we could
162 * also include extra pieces of data here to supply a subject, body,
163 * etc.</p>
164 * </ul>
165 *
166 * <p>Here are some examples of other operations you can specify as intents
167 * using these additional parameters:</p>
168 *
169 * <ul>
170 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
171 * Launch the home screen.</p>
172 * </li>
173 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
174 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
175 * vnd.android.cursor.item/phone}</i></b>
176 * -- Display the list of people's phone numbers, allowing the user to
177 * browse through them and pick one and return it to the parent activity.</p>
178 * </li>
179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
180 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
181 * -- Display all pickers for data that can be opened with
182 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
183 * allowing the user to pick one of them and then some data inside of it
184 * and returning the resulting URI to the caller. This can be used,
185 * for example, in an e-mail application to allow the user to pick some
186 * data to include as an attachment.</p>
187 * </li>
188 * </ul>
189 *
190 * <p>There are a variety of standard Intent action and category constants
191 * defined in the Intent class, but applications can also define their own.
192 * These strings use java style scoping, to ensure they are unique -- for
193 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700194 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700195 *
196 * <p>Put together, the set of actions, data types, categories, and extra data
197 * defines a language for the system allowing for the expression of phrases
198 * such as "call john smith's cell". As applications are added to the system,
199 * they can extend this language by adding new actions, types, and categories, or
200 * they can modify the behavior of existing phrases by supplying their own
201 * activities that handle them.</p>
202 *
203 * <a name="IntentResolution"></a>
204 * <h3>Intent Resolution</h3>
205 *
206 * <p>There are two primary forms of intents you will use.
207 *
208 * <ul>
209 * <li> <p><b>Explicit Intents</b> have specified a component (via
210 * {@link #setComponent} or {@link #setClass}), which provides the exact
211 * class to be run. Often these will not include any other information,
212 * simply being a way for an application to launch various internal
213 * activities it has as the user interacts with the application.
214 *
215 * <li> <p><b>Implicit Intents</b> have not specified a component;
216 * instead, they must include enough information for the system to
217 * determine which of the available components is best to run for that
218 * intent.
219 * </ul>
220 *
221 * <p>When using implicit intents, given such an arbitrary intent we need to
222 * know what to do with it. This is handled by the process of <em>Intent
223 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
224 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
225 * more activities/receivers) that can handle it.</p>
226 *
227 * <p>The intent resolution mechanism basically revolves around matching an
228 * Intent against all of the &lt;intent-filter&gt; descriptions in the
229 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
230 * objects explicitly registered with {@link Context#registerReceiver}.) More
231 * details on this can be found in the documentation on the {@link
232 * IntentFilter} class.</p>
233 *
234 * <p>There are three pieces of information in the Intent that are used for
235 * resolution: the action, type, and category. Using this information, a query
236 * is done on the {@link PackageManager} for a component that can handle the
237 * intent. The appropriate component is determined based on the intent
238 * information supplied in the <code>AndroidManifest.xml</code> file as
239 * follows:</p>
240 *
241 * <ul>
242 * <li> <p>The <b>action</b>, if given, must be listed by the component as
243 * one it handles.</p>
244 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
245 * already supplied in the Intent. Like the action, if a type is
246 * included in the intent (either explicitly or implicitly in its
247 * data), then this must be listed by the component as one it handles.</p>
248 * <li> For data that is not a <code>content:</code> URI and where no explicit
249 * type is included in the Intent, instead the <b>scheme</b> of the
250 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
251 * considered. Again like the action, if we are matching a scheme it
252 * must be listed by the component as one it can handle.
253 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
254 * by the activity as categories it handles. That is, if you include
255 * the categories {@link #CATEGORY_LAUNCHER} and
256 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
257 * with an intent that lists <em>both</em> of those categories.
258 * Activities will very often need to support the
259 * {@link #CATEGORY_DEFAULT} so that they can be found by
260 * {@link Context#startActivity Context.startActivity()}.</p>
261 * </ul>
262 *
263 * <p>For example, consider the Note Pad sample application that
264 * allows user to browse through a list of notes data and view details about
265 * individual items. Text in italics indicate places were you would replace a
266 * name with one specific to your own package.</p>
267 *
268 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
269 * package="<i>com.android.notepad</i>"&gt;
270 * &lt;application android:icon="@drawable/app_notes"
271 * android:label="@string/app_name"&gt;
272 *
273 * &lt;provider class=".NotePadProvider"
274 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
275 *
276 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
277 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700278 * &lt;action android:name="android.intent.action.MAIN" /&gt;
279 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700280 * &lt;/intent-filter&gt;
281 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700282 * &lt;action android:name="android.intent.action.VIEW" /&gt;
283 * &lt;action android:name="android.intent.action.EDIT" /&gt;
284 * &lt;action android:name="android.intent.action.PICK" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
290 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
291 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700292 * &lt;/intent-filter&gt;
293 * &lt;/activity&gt;
294 *
295 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
296 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.VIEW" /&gt;
298 * &lt;action android:name="android.intent.action.EDIT" /&gt;
299 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
300 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;
302 *
303 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.INSERT" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700307 * &lt;/intent-filter&gt;
308 *
309 * &lt;/activity&gt;
310 *
311 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
312 * android:theme="@android:style/Theme.Dialog"&gt;
313 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700314 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
317 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
318 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700319 * &lt;/intent-filter&gt;
320 * &lt;/activity&gt;
321 *
322 * &lt;/application&gt;
323 * &lt;/manifest&gt;</pre>
324 *
325 * <p>The first activity,
326 * <code>com.android.notepad.NotesList</code>, serves as our main
327 * entry into the app. It can do three things as described by its three intent
328 * templates:
329 * <ol>
330 * <li><pre>
331 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700332 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
333 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700334 * &lt;/intent-filter&gt;</pre>
335 * <p>This provides a top-level entry into the NotePad application: the standard
336 * MAIN action is a main entry point (not requiring any other information in
337 * the Intent), and the LAUNCHER category says that this entry point should be
338 * listed in the application launcher.</p>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
342 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
343 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
344 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
345 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700346 * &lt;/intent-filter&gt;</pre>
347 * <p>This declares the things that the activity can do on a directory of
348 * notes. The type being supported is given with the &lt;type&gt; tag, where
349 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
350 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
351 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
352 * The activity allows the user to view or edit the directory of data (via
353 * the VIEW and EDIT actions), or to pick a particular note and return it
354 * to the caller (via the PICK action). Note also the DEFAULT category
355 * supplied here: this is <em>required</em> for the
356 * {@link Context#startActivity Context.startActivity} method to resolve your
357 * activity when its component name is not explicitly specified.</p>
358 * <li><pre>
359 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700360 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
361 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
362 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700363 * &lt;/intent-filter&gt;</pre>
364 * <p>This filter describes the ability return to the caller a note selected by
365 * the user without needing to know where it came from. The data type
366 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
367 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
368 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
369 * The GET_CONTENT action is similar to the PICK action, where the activity
370 * will return to its caller a piece of data selected by the user. Here,
371 * however, the caller specifies the type of data they desire instead of
372 * the type of data the user will be picking from.</p>
373 * </ol>
374 *
375 * <p>Given these capabilities, the following intents will resolve to the
376 * NotesList activity:</p>
377 *
378 * <ul>
379 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
380 * activities that can be used as top-level entry points into an
381 * application.</p>
382 * <li> <p><b>{ action=android.app.action.MAIN,
383 * category=android.app.category.LAUNCHER }</b> is the actual intent
384 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700385 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700386 * data=content://com.google.provider.NotePad/notes }</b>
387 * displays a list of all the notes under
388 * "content://com.google.provider.NotePad/notes", which
389 * the user can browse through and see the details on.</p>
390 * <li> <p><b>{ action=android.app.action.PICK
391 * data=content://com.google.provider.NotePad/notes }</b>
392 * provides a list of the notes under
393 * "content://com.google.provider.NotePad/notes", from which
394 * the user can pick a note whose data URL is returned back to the caller.</p>
395 * <li> <p><b>{ action=android.app.action.GET_CONTENT
396 * type=vnd.android.cursor.item/vnd.google.note }</b>
397 * is similar to the pick action, but allows the caller to specify the
398 * kind of data they want back so that the system can find the appropriate
399 * activity to pick something of that data type.</p>
400 * </ul>
401 *
402 * <p>The second activity,
403 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
404 * note entry and allows them to edit it. It can do two things as described
405 * by its two intent templates:
406 * <ol>
407 * <li><pre>
408 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700409 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
410 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
411 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
412 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700413 * &lt;/intent-filter&gt;</pre>
414 * <p>The first, primary, purpose of this activity is to let the user interact
415 * with a single note, as decribed by the MIME type
416 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
417 * either VIEW a note or allow the user to EDIT it. Again we support the
418 * DEFAULT category to allow the activity to be launched without explicitly
419 * specifying its component.</p>
420 * <li><pre>
421 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700422 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
423 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
424 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700425 * &lt;/intent-filter&gt;</pre>
426 * <p>The secondary use of this activity is to insert a new note entry into
427 * an existing directory of notes. This is used when the user creates a new
428 * note: the INSERT action is executed on the directory of notes, causing
429 * this activity to run and have the user create the new note data which
430 * it then adds to the content provider.</p>
431 * </ol>
432 *
433 * <p>Given these capabilities, the following intents will resolve to the
434 * NoteEditor activity:</p>
435 *
436 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700437 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700438 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
439 * shows the user the content of note <var>{ID}</var>.</p>
440 * <li> <p><b>{ action=android.app.action.EDIT
441 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
442 * allows the user to edit the content of note <var>{ID}</var>.</p>
443 * <li> <p><b>{ action=android.app.action.INSERT
444 * data=content://com.google.provider.NotePad/notes }</b>
445 * creates a new, empty note in the notes list at
446 * "content://com.google.provider.NotePad/notes"
447 * and allows the user to edit it. If they keep their changes, the URI
448 * of the newly created note is returned to the caller.</p>
449 * </ul>
450 *
451 * <p>The last activity,
452 * <code>com.android.notepad.TitleEditor</code>, allows the user to
453 * edit the title of a note. This could be implemented as a class that the
454 * application directly invokes (by explicitly setting its component in
455 * the Intent), but here we show a way you can publish alternative
456 * operations on existing data:</p>
457 *
458 * <pre>
459 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700460 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
461 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
462 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
463 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
464 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700465 * &lt;/intent-filter&gt;</pre>
466 *
467 * <p>In the single intent template here, we
468 * have created our own private action called
469 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
470 * edit the title of a note. It must be invoked on a specific note
471 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
472 * view and edit actions, but here displays and edits the title contained
473 * in the note data.
474 *
475 * <p>In addition to supporting the default category as usual, our title editor
476 * also supports two other standard categories: ALTERNATIVE and
477 * SELECTED_ALTERNATIVE. Implementing
478 * these categories allows others to find the special action it provides
479 * without directly knowing about it, through the
480 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
481 * more often to build dynamic menu items with
482 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
483 * template here was also supply an explicit name for the template
484 * (via <code>android:label="@string/resolve_title"</code>) to better control
485 * what the user sees when presented with this activity as an alternative
486 * action to the data they are viewing.
487 *
488 * <p>Given these capabilities, the following intent will resolve to the
489 * TitleEditor activity:</p>
490 *
491 * <ul>
492 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
493 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
494 * displays and allows the user to edit the title associated
495 * with note <var>{ID}</var>.</p>
496 * </ul>
497 *
498 * <h3>Standard Activity Actions</h3>
499 *
500 * <p>These are the current standard actions that Intent defines for launching
501 * activities (usually through {@link Context#startActivity}. The most
502 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
503 * {@link #ACTION_EDIT}.
504 *
505 * <ul>
506 * <li> {@link #ACTION_MAIN}
507 * <li> {@link #ACTION_VIEW}
508 * <li> {@link #ACTION_ATTACH_DATA}
509 * <li> {@link #ACTION_EDIT}
510 * <li> {@link #ACTION_PICK}
511 * <li> {@link #ACTION_CHOOSER}
512 * <li> {@link #ACTION_GET_CONTENT}
513 * <li> {@link #ACTION_DIAL}
514 * <li> {@link #ACTION_CALL}
515 * <li> {@link #ACTION_SEND}
516 * <li> {@link #ACTION_SENDTO}
517 * <li> {@link #ACTION_ANSWER}
518 * <li> {@link #ACTION_INSERT}
519 * <li> {@link #ACTION_DELETE}
520 * <li> {@link #ACTION_RUN}
521 * <li> {@link #ACTION_SYNC}
522 * <li> {@link #ACTION_PICK_ACTIVITY}
523 * <li> {@link #ACTION_SEARCH}
524 * <li> {@link #ACTION_WEB_SEARCH}
525 * <li> {@link #ACTION_FACTORY_TEST}
526 * </ul>
527 *
528 * <h3>Standard Broadcast Actions</h3>
529 *
530 * <p>These are the current standard actions that Intent defines for receiving
531 * broadcasts (usually through {@link Context#registerReceiver} or a
532 * &lt;receiver&gt; tag in a manifest).
533 *
534 * <ul>
535 * <li> {@link #ACTION_TIME_TICK}
536 * <li> {@link #ACTION_TIME_CHANGED}
537 * <li> {@link #ACTION_TIMEZONE_CHANGED}
538 * <li> {@link #ACTION_BOOT_COMPLETED}
539 * <li> {@link #ACTION_PACKAGE_ADDED}
540 * <li> {@link #ACTION_PACKAGE_CHANGED}
541 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 * <li> {@link #ACTION_PACKAGE_RESTARTED}
543 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700544 * <li> {@link #ACTION_UID_REMOVED}
545 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700546 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700547 * <li> {@link #ACTION_POWER_DISCONNECTED}
548 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700549 * </ul>
550 *
551 * <h3>Standard Categories</h3>
552 *
553 * <p>These are the current standard categories that can be used to further
554 * clarify an Intent via {@link #addCategory}.
555 *
556 * <ul>
557 * <li> {@link #CATEGORY_DEFAULT}
558 * <li> {@link #CATEGORY_BROWSABLE}
559 * <li> {@link #CATEGORY_TAB}
560 * <li> {@link #CATEGORY_ALTERNATIVE}
561 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
562 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800563 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700564 * <li> {@link #CATEGORY_HOME}
565 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400567 * <li> {@link #CATEGORY_CAR_DOCK}
568 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500569 * <li> {@link #CATEGORY_LE_DESK_DOCK}
570 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200571 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700572 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * </ul>
574 *
575 * <h3>Standard Extra Data</h3>
576 *
577 * <p>These are the current standard fields that can be used as extra data via
578 * {@link #putExtra}.
579 *
580 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800581 * <li> {@link #EXTRA_ALARM_COUNT}
582 * <li> {@link #EXTRA_BCC}
583 * <li> {@link #EXTRA_CC}
584 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
585 * <li> {@link #EXTRA_DATA_REMOVED}
586 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500587 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800589 * <li> {@link #EXTRA_DOCK_STATE_CAR}
590 * <li> {@link #EXTRA_DOCK_STATE_DESK}
591 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
592 * <li> {@link #EXTRA_DONT_KILL_APP}
593 * <li> {@link #EXTRA_EMAIL}
594 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700595 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800596 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700597 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700599 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
601 * <li> {@link #EXTRA_REPLACING}
602 * <li> {@link #EXTRA_SHORTCUT_ICON}
603 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
604 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_SHORTCUT_NAME}
607 * <li> {@link #EXTRA_SUBJECT}
608 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_TITLE}
611 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700612 * </ul>
613 *
614 * <h3>Flags</h3>
615 *
616 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800617 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
618 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800620public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700621 private static final String ATTR_ACTION = "action";
622 private static final String TAG_CATEGORIES = "categories";
623 private static final String ATTR_CATEGORY = "category";
624 private static final String TAG_EXTRA = "extra";
625 private static final String ATTR_TYPE = "type";
626 private static final String ATTR_COMPONENT = "component";
627 private static final String ATTR_DATA = "data";
628 private static final String ATTR_FLAGS = "flags";
629
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 // ---------------------------------------------------------------------
631 // ---------------------------------------------------------------------
632 // Standard intent activity actions (see action variable).
633
634 /**
635 * Activity Action: Start as a main entry point, does not expect to
636 * receive data.
637 * <p>Input: nothing
638 * <p>Output: nothing
639 */
640 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
641 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 /**
644 * Activity Action: Display the data to the user. This is the most common
645 * action performed on data -- it is the generic action you can use on
646 * a piece of data to get the most reasonable thing to occur. For example,
647 * when used on a contacts entry it will view the entry; when used on a
648 * mailto: URI it will bring up a compose window filled with the information
649 * supplied by the URI; when used with a tel: URI it will invoke the
650 * dialer.
651 * <p>Input: {@link #getData} is URI from which to retrieve data.
652 * <p>Output: nothing.
653 */
654 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
655 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800656
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700657 /**
658 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
659 * performed on a piece of data.
660 */
661 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800662
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700663 /**
Steve McKayc78bcb82015-07-31 14:35:22 -0700664 * Activity Action: Quick view the data.
665 * <p>Input: {@link #getData} is URI from which to retrieve data.
666 * <p>Output: nothing.
667 * @hide
668 */
669 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
670 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
671
672 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700673 * Used to indicate that some piece of data should be attached to some other
674 * place. For example, image data could be attached to a contact. It is up
675 * to the recipient to decide where the data should be attached; the intent
676 * does not specify the ultimate destination.
677 * <p>Input: {@link #getData} is URI of data to be attached.
678 * <p>Output: nothing.
679 */
680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
681 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
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: Provide explicit editable access to the given data.
685 * <p>Input: {@link #getData} is URI of data to be edited.
686 * <p>Output: nothing.
687 */
688 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
689 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800690
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700691 /**
692 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
693 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
694 * The extras can contain type specific data to pass through to the editing/creating
695 * activity.
696 * <p>Output: The URI of the item that was picked. This must be a content:
697 * URI so that any receiver can access it.
698 */
699 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
700 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800701
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 /**
703 * Activity Action: Pick an item from the data, returning what was selected.
704 * <p>Input: {@link #getData} is URI containing a directory of data
705 * (vnd.android.cursor.dir/*) from which to pick an item.
706 * <p>Output: The URI of the item that was picked.
707 */
708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
709 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800710
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700711 /**
712 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 * <p>Output: An Intent representing the shortcut. The intent must contain three
715 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
716 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717 * (value: ShortcutIconResource).</p>
718 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700719 * @see #EXTRA_SHORTCUT_INTENT
720 * @see #EXTRA_SHORTCUT_NAME
721 * @see #EXTRA_SHORTCUT_ICON
722 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
723 * @see android.content.Intent.ShortcutIconResource
724 */
725 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
726 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
727
728 /**
729 * The name of the extra used to define the Intent of a shortcut.
730 *
731 * @see #ACTION_CREATE_SHORTCUT
732 */
733 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
734 /**
735 * The name of the extra used to define the name of a shortcut.
736 *
737 * @see #ACTION_CREATE_SHORTCUT
738 */
739 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
740 /**
741 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
742 *
743 * @see #ACTION_CREATE_SHORTCUT
744 */
745 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
746 /**
747 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
748 *
749 * @see #ACTION_CREATE_SHORTCUT
750 * @see android.content.Intent.ShortcutIconResource
751 */
752 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
753 "android.intent.extra.shortcut.ICON_RESOURCE";
754
755 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800756 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700757 *
758 * @see Intent#ACTION_CREATE_SHORTCUT
759 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800760 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
761 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700762 */
763 public static class ShortcutIconResource implements Parcelable {
764 /**
765 * The package name of the application containing the icon.
766 */
767 public String packageName;
768
769 /**
770 * The resource name of the icon, including package, name and type.
771 */
772 public String resourceName;
773
774 /**
775 * Creates a new ShortcutIconResource for the specified context and resource
776 * identifier.
777 *
778 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700779 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700780 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700781 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700783 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 ShortcutIconResource icon = new ShortcutIconResource();
785 icon.packageName = context.getPackageName();
786 icon.resourceName = context.getResources().getResourceName(resourceId);
787 return icon;
788 }
789
790 /**
791 * Used to read a ShortcutIconResource from a Parcel.
792 */
793 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
794 new Parcelable.Creator<ShortcutIconResource>() {
795
796 public ShortcutIconResource createFromParcel(Parcel source) {
797 ShortcutIconResource icon = new ShortcutIconResource();
798 icon.packageName = source.readString();
799 icon.resourceName = source.readString();
800 return icon;
801 }
802
803 public ShortcutIconResource[] newArray(int size) {
804 return new ShortcutIconResource[size];
805 }
806 };
807
808 /**
809 * No special parcel contents.
810 */
811 public int describeContents() {
812 return 0;
813 }
814
815 public void writeToParcel(Parcel dest, int flags) {
816 dest.writeString(packageName);
817 dest.writeString(resourceName);
818 }
819
820 @Override
821 public String toString() {
822 return resourceName;
823 }
824 }
825
826 /**
827 * Activity Action: Display an activity chooser, allowing the user to pick
828 * what they want to before proceeding. This can be used as an alternative
829 * to the standard activity picker that is displayed by the system when
830 * you try to start an activity with multiple possible matches, with these
831 * differences in behavior:
832 * <ul>
833 * <li>You can specify the title that will appear in the activity chooser.
834 * <li>The user does not have the option to make one of the matching
835 * activities a preferred activity, and all possible activities will
836 * always be shown even if one of them is currently marked as the
837 * preferred activity.
838 * </ul>
839 * <p>
840 * This action should be used when the user will naturally expect to
841 * select an activity in order to proceed. An example if when not to use
842 * it is when the user clicks on a "mailto:" link. They would naturally
843 * expect to go directly to their mail app, so startActivity() should be
844 * called directly: it will
845 * either launch the current preferred app, or put up a dialog allowing the
846 * user to pick an app to use and optionally marking that as preferred.
847 * <p>
848 * In contrast, if the user is selecting a menu item to send a picture
849 * they are viewing to someone else, there are many different things they
850 * may want to do at this point: send it through e-mail, upload it to a
851 * web service, etc. In this case the CHOOSER action should be used, to
852 * always present to the user a list of the things they can do, with a
853 * nice title given by the caller such as "Send this photo with:".
854 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700855 * If you need to grant URI permissions through a chooser, you must specify
856 * the permissions to be granted on the ACTION_CHOOSER Intent
857 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
858 * {@link #setClipData} to specify the URIs to be granted as well as
859 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
860 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
861 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700862 * As a convenience, an Intent of this form can be created with the
863 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700864 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700865 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700866 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
867 * and can optionally have a {@link #EXTRA_TITLE} field containing the
868 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700869 * <p>
870 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700871 */
872 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
873 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
874
875 /**
876 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
877 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700878 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
879 * target intent, also optionally supplying a title. If the target
880 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
881 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
882 * set in the returned chooser intent, with its ClipData set appropriately:
883 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500884 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700885 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700886 * @param target The Intent that the user will be selecting an activity
887 * to perform.
888 * @param title Optional title that will be displayed in the chooser.
889 * @return Return a new Intent object that you can hand to
890 * {@link Context#startActivity(Intent) Context.startActivity()} and
891 * related methods.
892 */
893 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700894 return createChooser(target, title, null);
895 }
896
897 /**
898 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
899 *
900 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
901 * target intent, also optionally supplying a title. If the target
902 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
903 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
904 * set in the returned chooser intent, with its ClipData set appropriately:
905 * either a direct reflection of {@link #getClipData()} if that is non-null,
906 * or a new ClipData built from {@link #getData()}.</p>
907 *
908 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
909 * when the user makes a choice. This can be useful if the calling application wants
910 * to remember the last chosen target and surface it as a more prominent or one-touch
911 * affordance elsewhere in the UI for next time.</p>
912 *
913 * @param target The Intent that the user will be selecting an activity
914 * to perform.
915 * @param title Optional title that will be displayed in the chooser.
916 * @param sender Optional IntentSender to be called when a choice is made.
917 * @return Return a new Intent object that you can hand to
918 * {@link Context#startActivity(Intent) Context.startActivity()} and
919 * related methods.
920 */
921 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700922 Intent intent = new Intent(ACTION_CHOOSER);
923 intent.putExtra(EXTRA_INTENT, target);
924 if (title != null) {
925 intent.putExtra(EXTRA_TITLE, title);
926 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927
Adam Powell0b3c1122014-10-09 12:50:14 -0700928 if (sender != null) {
929 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
930 }
931
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700932 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700933 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
934 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
935 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700936 if (permFlags != 0) {
937 ClipData targetClipData = target.getClipData();
938 if (targetClipData == null && target.getData() != null) {
939 ClipData.Item item = new ClipData.Item(target.getData());
940 String[] mimeTypes;
941 if (target.getType() != null) {
942 mimeTypes = new String[] { target.getType() };
943 } else {
944 mimeTypes = new String[] { };
945 }
946 targetClipData = new ClipData(null, mimeTypes, item);
947 }
948 if (targetClipData != null) {
949 intent.setClipData(targetClipData);
950 intent.addFlags(permFlags);
951 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700952 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700953
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700954 return intent;
955 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700956
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700957 /**
958 * Activity Action: Allow the user to select a particular kind of data and
959 * return it. This is different than {@link #ACTION_PICK} in that here we
960 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800961 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700962 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900963 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700964 * etc.
965 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900966 * 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 -0700967 * of data, such as a person contact, you set the MIME type to the kind of
968 * data you want and launch it with {@link Context#startActivity(Intent)}.
969 * The system will then launch the best application to select that kind
970 * of data for you.
971 * <p>
972 * You may also be interested in any of a set of types of content the user
973 * can pick. For example, an e-mail application that wants to allow the
974 * user to add an attachment to an e-mail message can use this action to
975 * bring up a list of all of the types of content the user can attach.
976 * <p>
977 * In this case, you should wrap the GET_CONTENT intent with a chooser
978 * (through {@link #createChooser}), which will give the proper interface
979 * for the user to pick how to send your data and allow you to specify
980 * a prompt indicating what they are doing. You will usually specify a
981 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
982 * broad range of content types the user can select from.
983 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900984 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700985 * only pick from data that can be represented as a stream. This is
986 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
987 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800988 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900989 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800990 * is locally available on the device. For example, if this extra is set
991 * to true then an image picker should not show any pictures that are available
992 * from a remote server but not already on the local device (thus requiring
993 * they be downloaded when opened).
994 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800995 * If the caller can handle multiple returned items (the user performing
996 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
997 * to indicate this.
998 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700999 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1000 * that no URI is supplied in the intent, as there are no constraints on
1001 * where the returned data originally comes from. You may also include the
1002 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001003 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001004 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1005 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001006 * <p>
1007 * Output: The URI of the item that was picked. This must be a content:
1008 * URI so that any receiver can access it.
1009 */
1010 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1011 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1012 /**
1013 * Activity Action: Dial a number as specified by the data. This shows a
1014 * UI with the number being dialed, allowing the user to explicitly
1015 * initiate the call.
1016 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1017 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1018 * number.
1019 * <p>Output: nothing.
1020 */
1021 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1022 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1023 /**
1024 * Activity Action: Perform a call to someone specified by the data.
1025 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1026 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1027 * number.
1028 * <p>Output: nothing.
1029 *
1030 * <p>Note: there will be restrictions on which applications can initiate a
1031 * call; most applications should use the {@link #ACTION_DIAL}.
1032 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1033 * numbers. Applications can <strong>dial</strong> emergency numbers using
1034 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001035 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001036 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001037 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001038 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001039 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001040 */
1041 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1042 public static final String ACTION_CALL = "android.intent.action.CALL";
1043 /**
1044 * Activity Action: Perform a call to an emergency number specified by the
1045 * data.
1046 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1047 * tel: URI of an explicit phone number.
1048 * <p>Output: nothing.
1049 * @hide
1050 */
1051 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1052 /**
1053 * Activity action: Perform a call to any number (emergency or not)
1054 * specified by the data.
1055 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1056 * tel: URI of an explicit phone number.
1057 * <p>Output: nothing.
1058 * @hide
1059 */
1060 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1061 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001062 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1063 * sending this intent is a no-op.
1064 * <p>Input: No data should be specified. get*Extra may have an optional
1065 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1066 * send the activation result.
1067 * <p>Output: nothing.
1068 * @hide
1069 */
1070 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1071 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1072 "android.intent.action.SIM_ACTIVATION_REQUEST";
1073 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001074 * Activity Action: Send a message to someone specified by the data.
1075 * <p>Input: {@link #getData} is URI describing the target.
1076 * <p>Output: nothing.
1077 */
1078 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1079 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1080 /**
1081 * Activity Action: Deliver some data to someone else. Who the data is
1082 * being delivered to is not specified; it is up to the receiver of this
1083 * action to ask the user where the data should be sent.
1084 * <p>
1085 * When launching a SEND intent, you should usually wrap it in a chooser
1086 * (through {@link #createChooser}), which will give the proper interface
1087 * for the user to pick how to send your data and allow you to specify
1088 * a prompt indicating what they are doing.
1089 * <p>
1090 * Input: {@link #getType} is the MIME type of the data being sent.
1091 * get*Extra can have either a {@link #EXTRA_TEXT}
1092 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1093 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1094 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1095 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001096 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1097 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1098 * your text with HTML formatting.
1099 * <p>
1100 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1101 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1102 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1103 * content: URIs and other advanced features of {@link ClipData}. If
1104 * using this approach, you still must supply the same data through the
1105 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1106 * for compatibility with old applications. If you don't set a ClipData,
1107 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001108 * <p>
1109 * Optional standard extras, which may be interpreted by some recipients as
1110 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1111 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1112 * <p>
1113 * Output: nothing.
1114 */
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1116 public static final String ACTION_SEND = "android.intent.action.SEND";
1117 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001118 * Activity Action: Deliver multiple data to someone else.
1119 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001120 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001121 * <p>
1122 * Input: {@link #getType} is the MIME type of the data being sent.
1123 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001124 * #EXTRA_STREAM} field, containing the data to be sent. If using
1125 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1126 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001127 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001128 * Multiple types are supported, and receivers should handle mixed types
1129 * whenever possible. The right way for the receiver to check them is to
1130 * use the content resolver on each URI. The intent sender should try to
1131 * put the most concrete mime type in the intent type, but it can fall
1132 * back to {@literal <type>/*} or {@literal *}/* as needed.
1133 * <p>
1134 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1135 * be image/jpg, but if you are sending image/jpg and image/png, then the
1136 * intent's type should be image/*.
1137 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001138 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1139 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1140 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1141 * content: URIs and other advanced features of {@link ClipData}. If
1142 * using this approach, you still must supply the same data through the
1143 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1144 * for compatibility with old applications. If you don't set a ClipData,
1145 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1146 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001147 * Optional standard extras, which may be interpreted by some recipients as
1148 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1149 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1150 * <p>
1151 * Output: nothing.
1152 */
1153 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1154 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1155 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001156 * Activity Action: Handle an incoming phone call.
1157 * <p>Input: nothing.
1158 * <p>Output: nothing.
1159 */
1160 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1161 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1162 /**
1163 * Activity Action: Insert an empty item into the given container.
1164 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1165 * in which to place the data.
1166 * <p>Output: URI of the new data that was created.
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1170 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001171 * Activity Action: Create a new item in the given container, initializing it
1172 * from the current contents of the clipboard.
1173 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1174 * in which to place the data.
1175 * <p>Output: URI of the new data that was created.
1176 */
1177 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1178 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1179 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001180 * Activity Action: Delete the given data from its container.
1181 * <p>Input: {@link #getData} is URI of data to be deleted.
1182 * <p>Output: nothing.
1183 */
1184 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1185 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1186 /**
1187 * Activity Action: Run the data, whatever that means.
1188 * <p>Input: ? (Note: this is currently specific to the test harness.)
1189 * <p>Output: nothing.
1190 */
1191 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1192 public static final String ACTION_RUN = "android.intent.action.RUN";
1193 /**
1194 * Activity Action: Perform a data synchronization.
1195 * <p>Input: ?
1196 * <p>Output: ?
1197 */
1198 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1199 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1200 /**
1201 * Activity Action: Pick an activity given an intent, returning the class
1202 * selected.
1203 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1204 * used with {@link PackageManager#queryIntentActivities} to determine the
1205 * set of activities from which to pick.
1206 * <p>Output: Class name of the activity that was selected.
1207 */
1208 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1209 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1210 /**
1211 * Activity Action: Perform a search.
1212 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1213 * is the text to search for. If empty, simply
1214 * enter your search results Activity with the search UI activated.
1215 * <p>Output: nothing.
1216 */
1217 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1218 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1219 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001220 * Activity Action: Start the platform-defined tutorial
1221 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1222 * is the text to search for. If empty, simply
1223 * enter your search results Activity with the search UI activated.
1224 * <p>Output: nothing.
1225 */
1226 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1227 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1228 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001229 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001230 * <p>
1231 * Input: {@link android.app.SearchManager#QUERY
1232 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1233 * a url starts with http or https, the site will be opened. If it is plain
1234 * text, Google search will be applied.
1235 * <p>
1236 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001237 */
1238 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1239 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001240
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001241 /**
Jim Miller07994402012-05-02 14:22:27 -07001242 * Activity Action: Perform assist action.
1243 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001244 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1245 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001246 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1247 * information.
Jim Miller07994402012-05-02 14:22:27 -07001248 * Output: nothing.
1249 */
1250 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1251 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001252
1253 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001254 * Activity Action: Perform voice assist action.
1255 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001256 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1257 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001258 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001259 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001260 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001261 */
1262 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1263 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1264
1265 /**
Adam Skory7140a252013-09-11 12:04:58 +01001266 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1267 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001268 */
1269 public static final String EXTRA_ASSIST_PACKAGE
1270 = "android.intent.extra.ASSIST_PACKAGE";
1271
1272 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001273 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1274 * application package at the time the assist was invoked.
1275 */
1276 public static final String EXTRA_ASSIST_UID
1277 = "android.intent.extra.ASSIST_UID";
1278
1279 /**
Adam Skory7140a252013-09-11 12:04:58 +01001280 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1281 * information supplied by the current foreground app at the time of the assist request.
1282 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001283 */
1284 public static final String EXTRA_ASSIST_CONTEXT
1285 = "android.intent.extra.ASSIST_CONTEXT";
1286
Jim Miller07994402012-05-02 14:22:27 -07001287 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001288 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1289 * keyboard as the primary input device for assistance.
1290 */
1291 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1292 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1293
1294 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001295 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1296 * that was used to invoke the assist.
1297 */
1298 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1299 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1300
1301 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001302 * Activity Action: List all available applications
1303 * <p>Input: Nothing.
1304 * <p>Output: nothing.
1305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1308 /**
1309 * Activity Action: Show settings for choosing wallpaper
1310 * <p>Input: Nothing.
1311 * <p>Output: Nothing.
1312 */
1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1315
1316 /**
1317 * Activity Action: Show activity for reporting a bug.
1318 * <p>Input: Nothing.
1319 * <p>Output: Nothing.
1320 */
1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1323
1324 /**
1325 * Activity Action: Main entry point for factory tests. Only used when
1326 * the device is booting in factory test node. The implementing package
1327 * must be installed in the system image.
1328 * <p>Input: nothing
1329 * <p>Output: nothing
1330 */
1331 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1332
1333 /**
1334 * Activity Action: The user pressed the "call" button to go to the dialer
1335 * or other appropriate UI for placing a call.
1336 * <p>Input: Nothing.
1337 * <p>Output: Nothing.
1338 */
1339 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1340 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1341
1342 /**
1343 * Activity Action: Start Voice Command.
1344 * <p>Input: Nothing.
1345 * <p>Output: Nothing.
1346 */
1347 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1348 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001349
1350 /**
1351 * Activity Action: Start action associated with long pressing on the
1352 * search key.
1353 * <p>Input: Nothing.
1354 * <p>Output: Nothing.
1355 */
1356 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1357 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001358
Jacek Surazski86b6c532009-05-13 14:38:28 +02001359 /**
1360 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1361 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001362 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001363 * <p>Input: No data is specified. The bug report is passed in using
1364 * an {@link #EXTRA_BUG_REPORT} field.
1365 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001366 *
1367 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001368 */
1369 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1370 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001371
1372 /**
1373 * Activity Action: Show power usage information to the user.
1374 * <p>Input: Nothing.
1375 * <p>Output: Nothing.
1376 */
1377 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001379
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001380 /**
1381 * Activity Action: Setup wizard to launch after a platform update. This
1382 * activity should have a string meta-data field associated with it,
1383 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1384 * the platform for setup. The activity will be launched only if
1385 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1386 * same value.
1387 * <p>Input: Nothing.
1388 * <p>Output: Nothing.
1389 * @hide
1390 */
1391 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1392 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001393
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001394 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001395 * Activity Action: Show settings for managing network data usage of a
1396 * specific application. Applications should define an activity that offers
1397 * options to control data usage.
1398 */
1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1400 public static final String ACTION_MANAGE_NETWORK_USAGE =
1401 "android.intent.action.MANAGE_NETWORK_USAGE";
1402
1403 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001404 * Activity Action: Launch application installer.
1405 * <p>
1406 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001407 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1408 * you can also use "package:<package-name>" to install an application for the
1409 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001410 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1411 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1412 * <p>
1413 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1414 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001415 * <p>
1416 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1417 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1418 * in order to launch the application installer.
1419 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001420 *
1421 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1422 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1423 * @see #EXTRA_RETURN_RESULT
1424 */
1425 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1426 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1427
1428 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001429 * Activity Action: Launch ephemeral installer.
1430 * <p>
1431 * Input: The data must be a http: URI that the ephemeral application is registered
1432 * to handle.
1433 * <p class="note">
1434 * This is a protected intent that can only be sent by the system.
1435 * </p>
1436 *
1437 * @hide
1438 */
1439 @SystemApi
1440 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1441 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1442 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1443
1444 /**
1445 * Service Action: Resolve ephemeral application.
1446 * <p>
1447 * The system will have a persistent connection to this service.
1448 * This is a protected intent that can only be sent by the system.
1449 * </p>
1450 *
1451 * @hide
1452 */
1453 @SystemApi
1454 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1455 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1456 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1457
1458 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001459 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1460 * package. Specifies the installer package name; this package will receive the
1461 * {@link #ACTION_APP_ERROR} intent.
1462 */
1463 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1464 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1465
1466 /**
1467 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1468 * package. Specifies that the application being installed should not be
1469 * treated as coming from an unknown source, but as coming from the app
1470 * invoking the Intent. For this to work you must start the installer with
1471 * startActivityForResult().
1472 */
1473 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1474 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1475
1476 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001477 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1478 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001479 * data field originated from.
1480 */
rich cannings706e8ba2012-08-20 13:20:14 -07001481 public static final String EXTRA_ORIGINATING_URI
1482 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001483
1484 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001485 * This extra can be used with any Intent used to launch an activity, supplying information
1486 * about who is launching that activity. This field contains a {@link android.net.Uri}
1487 * object, typically an http: or https: URI of the web site that the referral came from;
1488 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1489 * a native application that it came from.
1490 *
1491 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1492 * instead of directly retrieving the extra. It is also valid for applications to
1493 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1494 * a string, not a Uri; the field here, if supplied, will always take precedence,
1495 * however.</p>
1496 *
1497 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001498 */
1499 public static final String EXTRA_REFERRER
1500 = "android.intent.extra.REFERRER";
1501
1502 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001503 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1504 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1505 * not be created, in particular when Intent extras are supplied through the
1506 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1507 * schemes.
1508 *
1509 * @see #EXTRA_REFERRER
1510 */
1511 public static final String EXTRA_REFERRER_NAME
1512 = "android.intent.extra.REFERRER_NAME";
1513
1514 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001515 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1516 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1517 * @hide
1518 */
1519 public static final String EXTRA_ORIGINATING_UID
1520 = "android.intent.extra.ORIGINATING_UID";
1521
1522 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001523 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1524 * package. Tells the installer UI to skip the confirmation with the user
1525 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001526 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1527 * will no longer show an interstitial message about updating existing
1528 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001529 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001530 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 public static final String EXTRA_ALLOW_REPLACE
1532 = "android.intent.extra.ALLOW_REPLACE";
1533
1534 /**
1535 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1536 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1537 * return to the application the result code of the install/uninstall. The returned result
1538 * code will be {@link android.app.Activity#RESULT_OK} on success or
1539 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1540 */
1541 public static final String EXTRA_RETURN_RESULT
1542 = "android.intent.extra.RETURN_RESULT";
1543
1544 /**
1545 * Package manager install result code. @hide because result codes are not
1546 * yet ready to be exposed.
1547 */
1548 public static final String EXTRA_INSTALL_RESULT
1549 = "android.intent.extra.INSTALL_RESULT";
1550
1551 /**
1552 * Activity Action: Launch application uninstaller.
1553 * <p>
1554 * Input: The data must be a package: URI whose scheme specific part is
1555 * the package name of the current installed package to be uninstalled.
1556 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1557 * <p>
1558 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1559 * succeeded.
1560 */
1561 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1562 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1563
1564 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001565 * Specify whether the package should be uninstalled for all users.
1566 * @hide because these should not be part of normal application flow.
1567 */
1568 public static final String EXTRA_UNINSTALL_ALL_USERS
1569 = "android.intent.extra.UNINSTALL_ALL_USERS";
1570
1571 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001572 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1573 * describing the last run version of the platform that was setup.
1574 * @hide
1575 */
1576 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1577
Svet Ganov3695b8a2015-03-24 16:30:25 -07001578 /**
1579 * Activity action: Launch UI to manage the permissions of an app.
1580 * <p>
1581 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1582 * will be managed by the launched UI.
1583 * </p>
1584 * <p>
1585 * Output: Nothing.
1586 * </p>
1587 *
1588 * @see #EXTRA_PACKAGE_NAME
1589 *
1590 * @hide
1591 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001592 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1593 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1594 "android.intent.action.MANAGE_APP_PERMISSIONS";
1595
1596 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001597 * Activity action: Launch UI to manage permissions.
1598 * <p>
1599 * Input: Nothing.
1600 * </p>
1601 * <p>
1602 * Output: Nothing.
1603 * </p>
1604 *
1605 * @hide
1606 */
Svet Ganov321f0152015-05-16 22:51:50 -07001607 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1608 public static final String ACTION_MANAGE_PERMISSIONS =
1609 "android.intent.action.MANAGE_PERMISSIONS";
1610
1611 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001612 * Intent extra: An app package name.
1613 * <p>
1614 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001615 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001616 *
1617 * @hide
1618 */
1619 @SystemApi
1620 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1621
1622 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001623 * Broadcast action that requests current permission granted information. It will respond
1624 * to the request by sending a broadcast with action defined by
1625 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001626 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1627 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1628 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001629 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001630 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1631 * number of permissions requested and the number of granted additional permissions
1632 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001633 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001634 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1635 * of localized permission group names that are granted in
1636 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001637 *
1638 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1639 * permissions and the total number of apps requesting runtime permissions will be the first
1640 * and second elements respectively of an int[] in the response as
1641 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1642 *
1643 * @hide
1644 */
1645 public static final String ACTION_GET_PERMISSIONS_COUNT
1646 = "android.intent.action.GET_PERMISSIONS_COUNT";
1647
1648 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001649 * Broadcast action that requests list of all apps that have runtime permissions. It will
1650 * respond to the request by sending a broadcast with action defined by
1651 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1652 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1653 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1654 * a null upon failure.
1655 *
1656 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1657 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1658 * will contain the list of app labels corresponding ot the apps in the first list.
1659 *
1660 * @hide
1661 */
1662 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1663 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1664
1665 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001666 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1667 * @hide
1668 */
1669 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1670 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1671
1672 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001673 * List of CharSequence of localized permission group labels.
1674 * @hide
1675 */
1676 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1677 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1678
1679 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001680 * String list of apps that have one or more runtime permissions.
1681 * @hide
1682 */
1683 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1684 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1685
1686 /**
1687 * String list of app labels for apps that have one or more runtime permissions.
1688 * @hide
1689 */
1690 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1691 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1692
1693 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001694 * Boolean list describing if the app is a system app for apps that have one or more runtime
1695 * permissions.
1696 * @hide
1697 */
1698 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1699 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1700
1701 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001702 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001703 * @hide
1704 */
1705 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1706 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1707
1708 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001709 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1710 * @hide
1711 */
1712 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1713 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1714
1715 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001716 * Activity action: Launch UI to manage which apps have a given permission.
1717 * <p>
1718 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1719 * to which will be managed by the launched UI.
1720 * </p>
1721 * <p>
1722 * Output: Nothing.
1723 * </p>
1724 *
1725 * @see #EXTRA_PERMISSION_NAME
1726 *
1727 * @hide
1728 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001729 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1730 public static final String ACTION_MANAGE_PERMISSION_APPS =
1731 "android.intent.action.MANAGE_PERMISSION_APPS";
1732
1733 /**
1734 * Intent extra: The name of a permission.
1735 * <p>
1736 * Type: String
1737 * </p>
1738 *
1739 * @hide
1740 */
1741 @SystemApi
1742 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1743
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001744 // ---------------------------------------------------------------------
1745 // ---------------------------------------------------------------------
1746 // Standard intent broadcast actions (see action variable).
1747
1748 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001749 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1750 * <p>
1751 * For historical reasons, the name of this broadcast action refers to the power
1752 * state of the screen but it is actually sent in response to changes in the
1753 * overall interactive state of the device.
1754 * </p><p>
1755 * This broadcast is sent when the device becomes non-interactive which may have
1756 * nothing to do with the screen turning off. To determine the
1757 * actual state of the screen, use {@link android.view.Display#getState}.
1758 * </p><p>
1759 * See {@link android.os.PowerManager#isInteractive} for details.
1760 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001761 * You <em>cannot</em> receive this through components declared in
1762 * manifests, only by explicitly registering for it with
1763 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1764 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001765 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001766 * <p class="note">This is a protected intent that can only be sent
1767 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001768 */
1769 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1770 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001771
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001772 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001773 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1774 * <p>
1775 * For historical reasons, the name of this broadcast action refers to the power
1776 * state of the screen but it is actually sent in response to changes in the
1777 * overall interactive state of the device.
1778 * </p><p>
1779 * This broadcast is sent when the device becomes interactive which may have
1780 * nothing to do with the screen turning on. To determine the
1781 * actual state of the screen, use {@link android.view.Display#getState}.
1782 * </p><p>
1783 * See {@link android.os.PowerManager#isInteractive} for details.
1784 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001785 * You <em>cannot</em> receive this through components declared in
1786 * manifests, only by explicitly registering for it with
1787 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1788 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001789 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001790 * <p class="note">This is a protected intent that can only be sent
1791 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001792 */
1793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1794 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001795
1796 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001797 * Broadcast Action: Sent after the system stops dreaming.
1798 *
1799 * <p class="note">This is a protected intent that can only be sent by the system.
1800 * It is only sent to registered receivers.</p>
1801 */
1802 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1803 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1804
1805 /**
1806 * Broadcast Action: Sent after the system starts dreaming.
1807 *
1808 * <p class="note">This is a protected intent that can only be sent by the system.
1809 * It is only sent to registered receivers.</p>
1810 */
1811 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1812 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1813
1814 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001815 * 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 -07001816 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001817 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001818 * <p class="note">This is a protected intent that can only be sent
1819 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001820 */
1821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001822 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001823
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001824 /**
1825 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001826 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001827 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001828 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1829 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001830 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001831 * <p class="note">This is a protected intent that can only be sent
1832 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001833 */
1834 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1835 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1836 /**
1837 * Broadcast Action: The time was set.
1838 */
1839 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1840 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1841 /**
1842 * Broadcast Action: The date has changed.
1843 */
1844 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1845 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1846 /**
1847 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1848 * <ul>
1849 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1850 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001851 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001852 * <p class="note">This is a protected intent that can only be sent
1853 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001854 */
1855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1856 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1857 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001858 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1859 * DNS entries should be tossed.
1860 * @hide
1861 */
1862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1863 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1864 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001865 * Alarm Changed Action: This is broadcast when the AlarmClock
1866 * application's alarm is set or unset. It is used by the
1867 * AlarmClock application and the StatusBar service.
1868 * @hide
1869 */
1870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1871 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
1872 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001873 * Broadcast Action: This is broadcast once, after the system has finished
1874 * booting. It can be used to perform application-specific initialization,
1875 * such as installing alarms. You must hold the
1876 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1877 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001878 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001879 * <p class="note">This is a protected intent that can only be sent
1880 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001881 */
1882 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1883 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
1884 /**
1885 * Broadcast Action: This is broadcast when a user action should request a
1886 * temporary system dialog to dismiss. Some examples of temporary system
1887 * dialogs are the notification window-shade and the recent tasks dialog.
1888 */
1889 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1890 /**
1891 * Broadcast Action: Trigger the download and eventual installation
1892 * of a package.
1893 * <p>Input: {@link #getData} is the URI of the package file to download.
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.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001897 *
1898 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001899 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001900 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001901 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1902 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1903 /**
1904 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001905 * device. The data contains the name of the package. Note that the
1906 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001907 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001908 * <ul>
1909 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1910 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1911 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1912 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001913 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001914 * <p class="note">This is a protected intent that can only be sent
1915 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001916 */
1917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1918 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1919 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001920 * Broadcast Action: A new version of an application package has been
1921 * installed, replacing an existing version that was previously installed.
1922 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001923 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001924 * <ul>
1925 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1926 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001927 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001928 * <p class="note">This is a protected intent that can only be sent
1929 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001930 */
1931 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1932 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
1933 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08001934 * Broadcast Action: A new version of your application has been installed
1935 * over an existing one. This is only sent to the application that was
1936 * replaced. It does not contain any additional data; to receive it, just
1937 * use an intent filter for this action.
1938 *
1939 * <p class="note">This is a protected intent that can only be sent
1940 * by the system.
1941 */
1942 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1943 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
1944 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001945 * Broadcast Action: An existing application package has been removed from
1946 * the device. The data contains the name of the package. The package
1947 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001948 * <ul>
1949 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1950 * to the package.
1951 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
1952 * application -- data and code -- is being removed.
1953 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
1954 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
1955 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001956 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001957 * <p class="note">This is a protected intent that can only be sent
1958 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
1962 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07001963 * Broadcast Action: An existing application package has been completely
1964 * removed from the device. The data contains the name of the package.
1965 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
1966 * {@link #EXTRA_DATA_REMOVED} is true and
1967 * {@link #EXTRA_REPLACING} is false of that broadcast.
1968 *
1969 * <ul>
1970 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
1971 * to the package.
1972 * </ul>
1973 *
1974 * <p class="note">This is a protected intent that can only be sent
1975 * by the system.
1976 */
1977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1978 public static final String ACTION_PACKAGE_FULLY_REMOVED
1979 = "android.intent.action.PACKAGE_FULLY_REMOVED";
1980 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001981 * Broadcast Action: An existing application package has been changed (e.g.
1982 * a component has been enabled or disabled). The data contains the name of
1983 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001984 * <ul>
1985 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001986 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08001987 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08001988 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
1989 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001990 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001991 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001992 * <p class="note">This is a protected intent that can only be sent
1993 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
1997 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08001998 * @hide
1999 * Broadcast Action: Ask system services if there is any reason to
2000 * restart the given package. The data contains the name of the
2001 * package.
2002 * <ul>
2003 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2004 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2005 * </ul>
2006 *
2007 * <p class="note">This is a protected intent that can only be sent
2008 * by the system.
2009 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002010 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002011 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2012 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2013 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002014 * Broadcast Action: The user has restarted a package, and all of its
2015 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002016 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002017 * be removed. Note that the restarted package does <em>not</em>
2018 * receive this broadcast.
2019 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002020 * <ul>
2021 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2022 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002023 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002024 * <p class="note">This is a protected intent that can only be sent
2025 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002026 */
2027 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2028 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2029 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002030 * Broadcast Action: The user has cleared the data of a package. This should
2031 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002032 * its persistent data is erased and this broadcast sent.
2033 * Note that the cleared package does <em>not</em>
2034 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002035 * <ul>
2036 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2037 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002038 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002039 * <p class="note">This is a protected intent that can only be sent
2040 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002041 */
2042 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2043 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2044 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002045 * Broadcast Action: A user ID has been removed from the system. The user
2046 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002047 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002048 * <p class="note">This is a protected intent that can only be sent
2049 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002050 */
2051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2052 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002053
2054 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002055 * Broadcast Action: Sent to the installer package of an application
2056 * when that application is first launched (that is the first time it
2057 * is moved out of the stopped state). The data contains the name of the package.
2058 *
2059 * <p class="note">This is a protected intent that can only be sent
2060 * by the system.
2061 */
2062 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2063 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2064
2065 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002066 * Broadcast Action: Sent to the system package verifier when a package
2067 * needs to be verified. The data contains the package URI.
2068 * <p class="note">
2069 * This is a protected intent that can only be sent by the system.
2070 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002071 */
2072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2073 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2074
2075 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002076 * Broadcast Action: Sent to the system package verifier when a package is
2077 * verified. The data contains the package URI.
2078 * <p class="note">
2079 * This is a protected intent that can only be sent by the system.
2080 */
2081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2082 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2083
2084 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002085 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2086 * needs to be verified. The data contains the filter data hosts to be verified against.
2087 * <p class="note">
2088 * This is a protected intent that can only be sent by the system.
2089 * </p>
2090 *
2091 * @hide
2092 */
2093 @SystemApi
2094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2095 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2096
2097 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002098 * Broadcast Action: Resources for a set of packages (which were
2099 * previously unavailable) are currently
2100 * available since the media on which they exist is available.
2101 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2102 * list of packages whose availability changed.
2103 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2104 * list of uids of packages whose availability changed.
2105 * Note that the
2106 * packages in this list do <em>not</em> receive this broadcast.
2107 * The specified set of packages are now available on the system.
2108 * <p>Includes the following extras:
2109 * <ul>
2110 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2111 * whose resources(were previously unavailable) are currently available.
2112 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2113 * packages whose resources(were previously unavailable)
2114 * are currently available.
2115 * </ul>
2116 *
2117 * <p class="note">This is a protected intent that can only be sent
2118 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002119 */
2120 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002121 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2122 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002123
2124 /**
2125 * Broadcast Action: Resources for a set of packages are currently
2126 * unavailable since the media on which they exist is unavailable.
2127 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2128 * list of packages whose availability changed.
2129 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2130 * list of uids of packages whose availability changed.
2131 * The specified set of packages can no longer be
2132 * launched and are practically unavailable on the system.
2133 * <p>Inclues the following extras:
2134 * <ul>
2135 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2136 * whose resources are no longer available.
2137 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2138 * whose resources are no longer available.
2139 * </ul>
2140 *
2141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002143 */
2144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002145 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002146 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002147
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002148 /**
2149 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002150 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002151 * This should <em>only</em> be used to determine when the wallpaper
2152 * has changed to show the new wallpaper to the user. You should certainly
2153 * never, in response to this, change the wallpaper or other attributes of
2154 * it such as the suggested size. That would be crazy, right? You'd cause
2155 * all kinds of loops, especially if other apps are doing similar things,
2156 * right? Of course. So please don't do this.
2157 *
2158 * @deprecated Modern applications should use
2159 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2160 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2161 * shown behind their UI, rather than watching for this broadcast and
2162 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002163 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002164 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002165 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2166 /**
2167 * Broadcast Action: The current device {@link android.content.res.Configuration}
2168 * (orientation, locale, etc) has changed. When such a change happens, the
2169 * UIs (view hierarchy) will need to be rebuilt based on this new
2170 * information; for the most part, applications don't need to worry about
2171 * this, because the system will take care of stopping and restarting the
2172 * application to make sure it sees the new changes. Some system code that
2173 * can not be restarted will need to watch for this action and handle it
2174 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002175 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002176 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002177 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002178 * in manifests, only by explicitly registering for it with
2179 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2180 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002181 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002182 * <p class="note">This is a protected intent that can only be sent
2183 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002184 *
2185 * @see android.content.res.Configuration
2186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2189 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002190 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002191 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002192 * <p class="note">This is a protected intent that can only be sent
2193 * by the system.
2194 */
2195 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2196 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2197 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002198 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2199 * charging state, level, and other information about the battery.
2200 * See {@link android.os.BatteryManager} for documentation on the
2201 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002202 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002203 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002204 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002205 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002206 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002207 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2208 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2209 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2210 * broadcasts that are sent and can be received through manifest
2211 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002212 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002213 * <p class="note">This is a protected intent that can only be sent
2214 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002215 */
2216 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2217 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2218 /**
2219 * Broadcast Action: Indicates low battery condition on the device.
2220 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002221 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002222 * <p class="note">This is a protected intent that can only be sent
2223 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2227 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002228 * Broadcast Action: Indicates the battery is now okay after being low.
2229 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2230 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002231 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002232 * <p class="note">This is a protected intent that can only be sent
2233 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002234 */
2235 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2236 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2237 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002238 * Broadcast Action: External power has been connected to the device.
2239 * This is intended for applications that wish to register specifically to this notification.
2240 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2241 * stay active to receive this notification. This action can be used to implement actions
2242 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002243 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002244 * <p class="note">This is a protected intent that can only be sent
2245 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002246 */
2247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002248 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002249 /**
2250 * Broadcast Action: External power has been removed from the device.
2251 * This is intended for applications that wish to register specifically to this notification.
2252 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2253 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002254 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002255 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002256 * <p class="note">This is a protected intent that can only be sent
2257 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002258 */
2259 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002260 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002261 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002262 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002263 * Broadcast Action: Device is shutting down.
2264 * This is broadcast when the device is being shut down (completely turned
2265 * off, not sleeping). Once the broadcast is complete, the final shutdown
2266 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002267 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002268 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002269 * <p class="note">This is a protected intent that can only be sent
2270 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002271 * <p>May include the following extras:
2272 * <ul>
2273 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2274 * shutdown is only for userspace processes. If not set, assumed to be false.
2275 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002276 */
2277 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002278 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002279 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002280 * Activity Action: Start this activity to request system shutdown.
2281 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002282 * to request confirmation from the user before shutting down. The optional boolean
2283 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2284 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002285 *
2286 * <p class="note">This is a protected intent that can only be sent
2287 * by the system.
2288 *
2289 * {@hide}
2290 */
2291 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2292 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002293 * Broadcast Action: A sticky broadcast that indicates low memory
2294 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002295 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002296 * <p class="note">This is a protected intent that can only be sent
2297 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002298 */
2299 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2300 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2301 /**
2302 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002303 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002304 * <p class="note">This is a protected intent that can only be sent
2305 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002306 */
2307 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2308 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2309 /**
Jake Hambybb371632010-08-23 18:16:48 -07002310 * Broadcast Action: A sticky broadcast that indicates a memory full
2311 * condition on the device. This is intended for activities that want
2312 * to be able to fill the data partition completely, leaving only
2313 * enough free space to prevent system-wide SQLite failures.
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_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2322 /**
2323 * Broadcast Action: Indicates memory full condition on the device
2324 * no longer exists.
2325 *
2326 * <p class="note">This is a protected intent that can only be sent
2327 * by the system.
2328 *
2329 * {@hide}
2330 */
2331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2332 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2333 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002334 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2335 * and package management should be started.
2336 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2337 * notification.
2338 */
2339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2340 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2341 /**
2342 * Broadcast Action: The device has entered USB Mass Storage mode.
2343 * This is used mainly for the USB Settings panel.
2344 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2345 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002346 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002347 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002348 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002349 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2350
2351 /**
2352 * Broadcast Action: The device has exited USB Mass Storage mode.
2353 * This is used mainly for the USB Settings panel.
2354 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2355 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002356 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002357 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002358 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002359 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2360
2361 /**
2362 * Broadcast Action: External media has been removed.
2363 * The path to the mount point for the removed media is contained in the Intent.mData field.
2364 */
2365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2366 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2367
2368 /**
2369 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002370 * 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 -07002371 */
2372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2374
2375 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002376 * Broadcast Action: External media is present, and being disk-checked
2377 * 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 -08002378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2380 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2381
2382 /**
2383 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2384 * 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 -08002385 */
2386 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2387 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2388
2389 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002390 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002391 * 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 -07002392 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2393 * media was mounted read only.
2394 */
2395 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2396 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2397
2398 /**
2399 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002400 * 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 -07002401 */
2402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2403 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2404
2405 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002406 * Broadcast Action: External media is no longer being shared via USB mass storage.
2407 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2408 *
2409 * @hide
2410 */
2411 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2412
2413 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002414 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2415 * The path to the mount point for the removed media is contained in the Intent.mData field.
2416 */
2417 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2418 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2419
2420 /**
2421 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002422 * 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 -07002423 */
2424 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2425 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2426
2427 /**
2428 * Broadcast Action: User has expressed the desire to remove the external storage media.
2429 * Applications should close all files they have open within the mount point when they receive this intent.
2430 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2431 */
2432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2433 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2434
2435 /**
2436 * Broadcast Action: The media scanner has started scanning a directory.
2437 * The path to the directory being scanned is contained in the Intent.mData field.
2438 */
2439 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2440 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2441
2442 /**
2443 * Broadcast Action: The media scanner has finished scanning a directory.
2444 * The path to the scanned directory is contained in the Intent.mData field.
2445 */
2446 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2447 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2448
2449 /**
2450 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2451 * The path to the file is contained in the Intent.mData field.
2452 */
2453 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2454 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2455
2456 /**
2457 * Broadcast Action: The "Media Button" was pressed. Includes a single
2458 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2459 * caused the broadcast.
2460 */
2461 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2462 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2463
2464 /**
2465 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2466 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2467 * caused the broadcast.
2468 */
2469 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2470 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2471
2472 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2473 // location; they are not general-purpose actions.
2474
2475 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002476 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002477 */
2478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2479 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2480 "android.intent.action.GTALK_CONNECTED";
2481
2482 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002483 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002484 */
2485 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2486 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2487 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002488
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002489 /**
2490 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002491 */
2492 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2493 public static final String ACTION_INPUT_METHOD_CHANGED =
2494 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002495
2496 /**
2497 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2498 * more radios have been turned off or on. The intent will have the following extra value:</p>
2499 * <ul>
2500 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2501 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2502 * turned off</li>
2503 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002504 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002505 * <p class="note">This is a protected intent that can only be sent
2506 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002507 */
2508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2509 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2510
2511 /**
2512 * Broadcast Action: Some content providers have parts of their namespace
2513 * where they publish new events or items that the user may be especially
2514 * interested in. For these things, they may broadcast this action when the
2515 * set of interesting items change.
2516 *
2517 * For example, GmailProvider sends this notification when the set of unread
2518 * mail in the inbox changes.
2519 *
2520 * <p>The data of the intent identifies which part of which provider
2521 * changed. When queried through the content resolver, the data URI will
2522 * return the data set in question.
2523 *
2524 * <p>The intent will have the following extra values:
2525 * <ul>
2526 * <li><em>count</em> - The number of items in the data set. This is the
2527 * same as the number of items in the cursor returned by querying the
2528 * data URI. </li>
2529 * </ul>
2530 *
2531 * This intent will be sent at boot (if the count is non-zero) and when the
2532 * data set changes. It is possible for the data set to change without the
2533 * count changing (for example, if a new unread message arrives in the same
2534 * sync operation in which a message is archived). The phone should still
2535 * ring/vibrate/etc as normal in this case.
2536 */
2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2538 public static final String ACTION_PROVIDER_CHANGED =
2539 "android.intent.action.PROVIDER_CHANGED";
2540
2541 /**
2542 * Broadcast Action: Wired Headset plugged in or unplugged.
2543 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002544 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2545 * and documentation.
2546 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002547 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002548 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002549 */
2550 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002551 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002552
2553 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002554 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2555 * <ul>
2556 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2557 * </ul>
2558 *
2559 * <p class="note">This is a protected intent that can only be sent
2560 * by the system.
2561 *
2562 * @hide
2563 */
2564 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2566 = "android.intent.action.ADVANCED_SETTINGS";
2567
2568 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002569 * Broadcast Action: Sent after application restrictions are changed.
2570 *
2571 * <p class="note">This is a protected intent that can only be sent
2572 * by the system.</p>
2573 */
2574 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2575 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2576 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2577
2578 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002579 * Broadcast Action: An outgoing call is about to be placed.
2580 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002581 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002582 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002583 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002584 * the phone number originally intended to be dialed.</li>
2585 * </ul>
2586 * <p>Once the broadcast is finished, the resultData is used as the actual
2587 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002588 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 * outgoing call in turn: for example, a parental control application
2590 * might verify that the user is authorized to place the call at that
2591 * time, then a number-rewriting application might add an area code if
2592 * one was not specified.</p>
2593 * <p>For consistency, any receiver whose purpose is to prohibit phone
2594 * calls should have a priority of 0, to ensure it will see the final
2595 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002596 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002597 * should have a positive priority.
2598 * Negative priorities are reserved for the system for this broadcast;
2599 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002600 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2601 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002602 * <p>Emergency calls cannot be intercepted using this mechanism, and
2603 * other calls cannot be modified to call emergency numbers using this
2604 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002605 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2606 * call to use their own service instead. Those apps should first prevent
2607 * the call from being placed by setting resultData to <code>null</code>
2608 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002609 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002610 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2611 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002612 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002613 * <p class="note">This is a protected intent that can only be sent
2614 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002615 */
2616 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2617 public static final String ACTION_NEW_OUTGOING_CALL =
2618 "android.intent.action.NEW_OUTGOING_CALL";
2619
2620 /**
2621 * Broadcast Action: Have the device reboot. This is only for use by
2622 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002623 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002624 * <p class="note">This is a protected intent that can only be sent
2625 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002626 */
2627 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2628 public static final String ACTION_REBOOT =
2629 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002630
Wei Huang97ecc9c2009-05-11 17:44:20 -07002631 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002632 * Broadcast Action: A sticky broadcast for changes in the physical
2633 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002634 *
2635 * <p>The intent will have the following extra values:
2636 * <ul>
2637 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002638 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002639 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002640 * <p>This is intended for monitoring the current physical dock state.
2641 * See {@link android.app.UiModeManager} for the normal API dealing with
2642 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002643 */
2644 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2645 public static final String ACTION_DOCK_EVENT =
2646 "android.intent.action.DOCK_EVENT";
2647
2648 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002649 * Broadcast Action: A broadcast when idle maintenance can be started.
2650 * This means that the user is not interacting with the device and is
2651 * not expected to do so soon. Typical use of the idle maintenance is
2652 * to perform somehow expensive tasks that can be postponed at a moment
2653 * when they will not degrade user experience.
2654 * <p>
2655 * <p class="note">In order to keep the device responsive in case of an
2656 * unexpected user interaction, implementations of a maintenance task
2657 * should be interruptible. In such a scenario a broadcast with action
2658 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2659 * should not do the maintenance work in
2660 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2661 * maintenance service by {@link Context#startService(Intent)}. Also
2662 * you should hold a wake lock while your maintenance service is running
2663 * to prevent the device going to sleep.
2664 * </p>
2665 * <p>
2666 * <p class="note">This is a protected intent that can only be sent by
2667 * the system.
2668 * </p>
2669 *
2670 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002671 *
2672 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002673 */
2674 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2675 public static final String ACTION_IDLE_MAINTENANCE_START =
2676 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2677
2678 /**
2679 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2680 * This means that the user was not interacting with the device as a result
2681 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2682 * was sent and now the user started interacting with the device. Typical
2683 * use of the idle maintenance is to perform somehow expensive tasks that
2684 * can be postponed at a moment when they will not degrade user experience.
2685 * <p>
2686 * <p class="note">In order to keep the device responsive in case of an
2687 * unexpected user interaction, implementations of a maintenance task
2688 * should be interruptible. Hence, on receiving a broadcast with this
2689 * action, the maintenance task should be interrupted as soon as possible.
2690 * In other words, you should not do the maintenance work in
2691 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2692 * maintenance service that was started on receiving of
2693 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2694 * lock you acquired when your maintenance service started.
2695 * </p>
2696 * <p class="note">This is a protected intent that can only be sent
2697 * by the system.
2698 *
2699 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002700 *
2701 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002702 */
2703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2704 public static final String ACTION_IDLE_MAINTENANCE_END =
2705 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2706
2707 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002708 * Broadcast Action: a remote intent is to be broadcasted.
2709 *
2710 * A remote intent is used for remote RPC between devices. The remote intent
2711 * is serialized and sent from one device to another device. The receiving
2712 * device parses the remote intent and broadcasts it. Note that anyone can
2713 * broadcast a remote intent. However, if the intent receiver of the remote intent
2714 * does not trust intent broadcasts from arbitrary intent senders, it should require
2715 * the sender to hold certain permissions so only trusted sender's broadcast will be
2716 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002717 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002718 */
2719 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002720 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002721
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002722 /**
2723 * Broadcast Action: hook for permforming cleanup after a system update.
2724 *
2725 * The broadcast is sent when the system is booting, before the
2726 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2727 * image. A receiver for this should do its work and then disable itself
2728 * so that it does not get run again at the next boot.
2729 * @hide
2730 */
2731 public static final String ACTION_PRE_BOOT_COMPLETED =
2732 "android.intent.action.PRE_BOOT_COMPLETED";
2733
Amith Yamasani13593602012-03-22 16:16:17 -07002734 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002735 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002736 * on restricted users. The broadcast intent contains an extra
2737 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2738 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2739 * String[] depending on the restriction type.<p/>
2740 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002741 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2742 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2743 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002744 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2745 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002746 * @see RestrictionEntry
2747 */
2748 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2749 "android.intent.action.GET_RESTRICTION_ENTRIES";
2750
2751 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002752 * Sent the first time a user is starting, to allow system apps to
2753 * perform one time initialization. (This will not be seen by third
2754 * party applications because a newly initialized user does not have any
2755 * third party applications installed for it.) This is sent early in
2756 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002757 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2758 * broadcast, since it is part of a visible user interaction; be as quick
2759 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002760 */
2761 public static final String ACTION_USER_INITIALIZE =
2762 "android.intent.action.USER_INITIALIZE";
2763
2764 /**
2765 * Sent when a user switch is happening, causing the process's user to be
2766 * brought to the foreground. This is only sent to receivers registered
2767 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2768 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002769 * foreground. This is sent as a foreground
2770 * broadcast, since it is part of a visible user interaction; be as quick
2771 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002772 */
2773 public static final String ACTION_USER_FOREGROUND =
2774 "android.intent.action.USER_FOREGROUND";
2775
2776 /**
2777 * Sent when a user switch is happening, causing the process's user to be
2778 * sent to the background. This is only sent to receivers registered
2779 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2780 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002781 * background. This is sent as a foreground
2782 * broadcast, since it is part of a visible user interaction; be as quick
2783 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002784 */
2785 public static final String ACTION_USER_BACKGROUND =
2786 "android.intent.action.USER_BACKGROUND";
2787
2788 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002789 * Broadcast sent to the system when a user is added. Carries an extra
2790 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2791 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002792 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002793 * @hide
2794 */
2795 public static final String ACTION_USER_ADDED =
2796 "android.intent.action.USER_ADDED";
2797
2798 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002799 * Broadcast sent by the system when a user is started. Carries an extra
2800 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002801 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002802 * that has been started. This is sent as a foreground
2803 * broadcast, since it is part of a visible user interaction; be as quick
2804 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002805 * @hide
2806 */
2807 public static final String ACTION_USER_STARTED =
2808 "android.intent.action.USER_STARTED";
2809
2810 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002811 * Broadcast sent when a user is in the process of starting. Carries an extra
2812 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2813 * sent to registered receivers, not manifest receivers. It is sent to all
2814 * users (including the one that is being started). You must hold
2815 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2816 * this broadcast. This is sent as a background broadcast, since
2817 * its result is not part of the primary UX flow; to safely keep track of
2818 * started/stopped state of a user you can use this in conjunction with
2819 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2820 * other user state broadcasts since those are foreground broadcasts so can
2821 * execute in a different order.
2822 * @hide
2823 */
2824 public static final String ACTION_USER_STARTING =
2825 "android.intent.action.USER_STARTING";
2826
2827 /**
2828 * Broadcast sent when a user is going to be stopped. Carries an extra
2829 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2830 * sent to registered receivers, not manifest receivers. It is sent to all
2831 * users (including the one that is being stopped). You must hold
2832 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2833 * this broadcast. The user will not stop until all receivers have
2834 * handled the broadcast. This is sent as a background broadcast, since
2835 * its result is not part of the primary UX flow; to safely keep track of
2836 * started/stopped state of a user you can use this in conjunction with
2837 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2838 * other user state broadcasts since those are foreground broadcasts so can
2839 * execute in a different order.
2840 * @hide
2841 */
2842 public static final String ACTION_USER_STOPPING =
2843 "android.intent.action.USER_STOPPING";
2844
2845 /**
2846 * Broadcast sent to the system when a user is stopped. Carries an extra
2847 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2848 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2849 * specific package. This is only sent to registered receivers, not manifest
2850 * receivers. It is sent to all running users <em>except</em> the one that
2851 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002852 * @hide
2853 */
2854 public static final String ACTION_USER_STOPPED =
2855 "android.intent.action.USER_STOPPED";
2856
2857 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002858 * 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 -07002859 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002860 * one that has been removed. The user will not be completely removed until all receivers have
2861 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002862 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002863 * @hide
2864 */
2865 public static final String ACTION_USER_REMOVED =
2866 "android.intent.action.USER_REMOVED";
2867
2868 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002869 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002870 * the userHandle of the user to become the current one. This is only sent to
2871 * registered receivers, not manifest receivers. It is sent to all running users.
2872 * You must hold
2873 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002874 * @hide
2875 */
2876 public static final String ACTION_USER_SWITCHED =
2877 "android.intent.action.USER_SWITCHED";
2878
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002879 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002880 * Broadcast Action: Sent when the credential-encrypted private storage has
2881 * become unlocked for the target user. This is only sent to registered
2882 * receivers, not manifest receivers.
2883 */
2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2885 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2886
2887 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002888 * Broadcast sent to the system when a user's information changes. Carries an extra
2889 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002890 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002891 * @hide
2892 */
2893 public static final String ACTION_USER_INFO_CHANGED =
2894 "android.intent.action.USER_INFO_CHANGED";
2895
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002896 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002897 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2898 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002899 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2900 * that need to display merged content across both primary and managed profiles need to
2901 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002902 * not manifest receivers.
2903 */
2904 public static final String ACTION_MANAGED_PROFILE_ADDED =
2905 "android.intent.action.MANAGED_PROFILE_ADDED";
2906
2907 /**
2908 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002909 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2910 * Only applications (for example Launchers) that need to display merged content across both
2911 * primary and managed profiles need to worry about this broadcast. This is only sent to
2912 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002913 */
2914 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2915 "android.intent.action.MANAGED_PROFILE_REMOVED";
2916
2917 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002918 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2919 */
2920 public static final String ACTION_QUICK_CLOCK =
2921 "android.intent.action.QUICK_CLOCK";
2922
Michael Wright0087a142013-02-05 16:29:39 -08002923 /**
Alan Viverette5a399492014-07-14 16:19:38 -07002924 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08002925 * @hide
2926 */
2927 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
2928 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
2929
Justin Kohd378ad72013-04-01 12:18:26 -07002930 /**
2931 * Broadcast Action: A global button was pressed. Includes a single
2932 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2933 * caused the broadcast.
2934 * @hide
2935 */
2936 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
2937
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002938 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002939 * Activity Action: Allow the user to select and return one or more existing
2940 * documents. When invoked, the system will display the various
2941 * {@link DocumentsProvider} instances installed on the device, letting the
2942 * user interactively navigate through them. These documents include local
2943 * media, such as photos and video, and documents provided by installed
2944 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002945 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002946 * Each document is represented as a {@code content://} URI backed by a
2947 * {@link DocumentsProvider}, which can be opened as a stream with
2948 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2949 * {@link android.provider.DocumentsContract.Document} metadata.
2950 * <p>
2951 * All selected documents are returned to the calling application with
2952 * persistable read and write permission grants. If you want to maintain
2953 * access to the documents across device reboots, you need to explicitly
2954 * take the persistable permissions using
2955 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
2956 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002957 * Callers must indicate the acceptable document MIME types through
2958 * {@link #setType(String)}. For example, to select photos, use
2959 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
2960 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
2961 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002962 * <p>
2963 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002964 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
2965 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002966 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09002967 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
2968 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002969 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002970 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07002971 * Output: The URI of the item that was picked, returned in
2972 * {@link #getData()}. This must be a {@code content://} URI so that any
2973 * receiver can access it. If multiple documents were selected, they are
2974 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07002975 *
2976 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07002977 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002978 * @see #ACTION_CREATE_DOCUMENT
2979 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002980 */
2981 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2982 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
2983
2984 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002985 * Activity Action: Allow the user to create a new document. When invoked,
2986 * the system will display the various {@link DocumentsProvider} instances
2987 * installed on the device, letting the user navigate through them. The
2988 * returned document may be a newly created document with no content, or it
2989 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07002990 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07002991 * Each document is represented as a {@code content://} URI backed by a
2992 * {@link DocumentsProvider}, which can be opened as a stream with
2993 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
2994 * {@link android.provider.DocumentsContract.Document} metadata.
2995 * <p>
2996 * Callers must indicate the concrete MIME type of the document being
2997 * created by setting {@link #setType(String)}. This MIME type cannot be
2998 * changed after the document is created.
2999 * <p>
3000 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3001 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003002 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003003 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3004 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003005 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003006 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003007 * Output: The URI of the item that was created. This must be a
3008 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003009 *
3010 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003011 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003012 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003013 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003014 */
3015 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3016 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3017
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003018 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003019 * Activity Action: Allow the user to pick a directory subtree. When
3020 * invoked, the system will display the various {@link DocumentsProvider}
3021 * instances installed on the device, letting the user navigate through
3022 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003023 * <p>
3024 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003025 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3026 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3027 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003028 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003029 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003030 *
3031 * @see DocumentsContract
3032 */
3033 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003034 public static final String
3035 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003036
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003037 /** {@hide} */
3038 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3039
Christopher Tate6597e342015-02-17 12:15:25 -08003040 /**
3041 * Broadcast action: report that a settings element is being restored from backup. The intent
3042 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3043 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3044 * is the value of that settings entry prior to the restore operation. All of these values are
3045 * represented as strings.
3046 *
3047 * <p>This broadcast is sent only for settings provider entries known to require special handling
3048 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3049 * the provider's backup agent implementation.
3050 *
3051 * @see #EXTRA_SETTING_NAME
3052 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3053 * @see #EXTRA_SETTING_NEW_VALUE
3054 * {@hide}
3055 */
3056 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3057
3058 /** {@hide} */
3059 public static final String EXTRA_SETTING_NAME = "setting_name";
3060 /** {@hide} */
3061 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3062 /** {@hide} */
3063 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3064
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003065 /**
3066 * Activity Action: Process a piece of text.
3067 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3068 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3069 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3070 */
3071 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3072 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3073 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003074 * The name of the extra used to define the text to be processed, as a
3075 * CharSequence. Note that this may be a styled CharSequence, so you must use
3076 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003077 */
3078 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3079 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003080 * The name of the boolean extra used to define if the processed text will be used as read-only.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003081 */
3082 public static final String EXTRA_PROCESS_TEXT_READONLY =
3083 "android.intent.extra.PROCESS_TEXT_READONLY";
3084
Bryce Leebc58f592015-09-25 16:43:01 -07003085 /**
3086 * Broadcast action: reports when a new thermal event has been reached. When the device
3087 * is reaching its maximum temperatue, the thermal level reported
3088 * {@hide}
3089 */
3090 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3091 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3092
3093 /** {@hide} */
3094 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3095
3096 /**
3097 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003098 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003099 * {@hide}
3100 */
3101 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3102
3103 /**
3104 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003105 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003106 * {@hide}
3107 */
3108 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3109
3110 /**
3111 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003112 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003113 * {@hide}
3114 */
3115 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3116
3117
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003118 // ---------------------------------------------------------------------
3119 // ---------------------------------------------------------------------
3120 // Standard intent categories (see addCategory()).
3121
3122 /**
3123 * Set if the activity should be an option for the default action
3124 * (center press) to perform on a piece of data. Setting this will
3125 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003126 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003127 * Intent when initiating an action -- it is for use in intent filters
3128 * specified in packages.
3129 */
3130 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3131 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3132 /**
3133 * Activities that can be safely invoked from a browser must support this
3134 * category. For example, if the user is viewing a web page or an e-mail
3135 * and clicks on a link in the text, the Intent generated execute that
3136 * link will require the BROWSABLE category, so that only activities
3137 * supporting this category will be considered as possible actions. By
3138 * supporting this category, you are promising that there is nothing
3139 * damaging (without user intervention) that can happen by invoking any
3140 * matching Intent.
3141 */
3142 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3143 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3144 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003145 * Categories for activities that can participate in voice interaction.
3146 * An activity that supports this category must be prepared to run with
3147 * no UI shown at all (though in some case it may have a UI shown), and
3148 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3149 */
3150 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3151 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3152 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003153 * Set if the activity should be considered as an alternative action to
3154 * the data the user is currently viewing. See also
3155 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3156 * applies to the selection in a list of items.
3157 *
3158 * <p>Supporting this category means that you would like your activity to be
3159 * displayed in the set of alternative things the user can do, usually as
3160 * part of the current activity's options menu. You will usually want to
3161 * include a specific label in the &lt;intent-filter&gt; of this action
3162 * describing to the user what it does.
3163 *
3164 * <p>The action of IntentFilter with this category is important in that it
3165 * describes the specific action the target will perform. This generally
3166 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3167 * a specific name such as "com.android.camera.action.CROP. Only one
3168 * alternative of any particular action will be shown to the user, so using
3169 * a specific action like this makes sure that your alternative will be
3170 * displayed while also allowing other applications to provide their own
3171 * overrides of that particular action.
3172 */
3173 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3174 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3175 /**
3176 * Set if the activity should be considered as an alternative selection
3177 * action to the data the user has currently selected. This is like
3178 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3179 * of items from which the user can select, giving them alternatives to the
3180 * default action that will be performed on it.
3181 */
3182 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3183 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3184 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003185 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003186 */
3187 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3188 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3189 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003190 * Should be displayed in the top-level launcher.
3191 */
3192 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3193 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3194 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003195 * Indicates an activity optimized for Leanback mode, and that should
3196 * be displayed in the Leanback launcher.
3197 */
3198 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3199 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3200 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003201 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3202 * @hide
3203 */
3204 @SystemApi
3205 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3206 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003207 * Provides information about the package it is in; typically used if
3208 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3209 * a front-door to the user without having to be shown in the all apps list.
3210 */
3211 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3212 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3213 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003214 * This is the home activity, that is the first activity that is displayed
3215 * when the device boots.
3216 */
3217 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3218 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3219 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003220 * This is the home activity that is displayed when the device is finished setting up and ready
3221 * for use.
3222 * @hide
3223 */
3224 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3225 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3226 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003227 * This is the setup wizard activity, that is the first activity that is displayed
3228 * when the user sets up the device for the first time.
3229 * @hide
3230 */
3231 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3232 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3233 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003234 * This activity is a preference panel.
3235 */
3236 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3237 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3238 /**
3239 * This activity is a development preference panel.
3240 */
3241 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3242 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3243 /**
3244 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003245 */
3246 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3247 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3248 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003249 * This activity allows the user to browse and download new applications.
3250 */
3251 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3252 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3253 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003254 * This activity may be exercised by the monkey or other automated test tools.
3255 */
3256 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3257 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3258 /**
3259 * To be used as a test (not part of the normal user experience).
3260 */
3261 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3262 /**
3263 * To be used as a unit test (run through the Test Harness).
3264 */
3265 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3266 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003267 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003268 * experience).
3269 */
3270 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003271
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003272 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003273 * Used to indicate that an intent only wants URIs that can be opened with
3274 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3275 * must support at least the columns defined in {@link OpenableColumns} when
3276 * queried.
3277 *
3278 * @see #ACTION_GET_CONTENT
3279 * @see #ACTION_OPEN_DOCUMENT
3280 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003281 */
3282 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3283 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3284
3285 /**
3286 * To be used as code under test for framework instrumentation tests.
3287 */
3288 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3289 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003290 /**
3291 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003292 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3293 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003294 */
3295 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3296 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3297 /**
3298 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003299 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3300 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003301 */
3302 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3303 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003304 /**
3305 * An activity to run when device is inserted into a analog (low end) dock.
3306 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3307 * information, see {@link android.app.UiModeManager}.
3308 */
3309 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3310 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3311
3312 /**
3313 * An activity to run when device is inserted into a digital (high end) dock.
3314 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3315 * information, see {@link android.app.UiModeManager}.
3316 */
3317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3318 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003319
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003320 /**
3321 * Used to indicate that the activity can be used in a car environment.
3322 */
3323 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3324 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3325
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003326 // ---------------------------------------------------------------------
3327 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003328 // Application launch intent categories (see addCategory()).
3329
3330 /**
3331 * Used with {@link #ACTION_MAIN} to launch the browser application.
3332 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003333 * <p>NOTE: This should not be used as the primary key of an Intent,
3334 * since it will not result in the app launching with the correct
3335 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003336 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003337 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003338 */
3339 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3340 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3341
3342 /**
3343 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3344 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003345 * <p>NOTE: This should not be used as the primary key of an Intent,
3346 * since it will not result in the app launching with the correct
3347 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003348 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003349 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003350 */
3351 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3352 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3353
3354 /**
3355 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3356 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003357 * <p>NOTE: This should not be used as the primary key of an Intent,
3358 * since it will not result in the app launching with the correct
3359 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003360 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003361 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003362 */
3363 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3364 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3365
3366 /**
3367 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3368 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003369 * <p>NOTE: This should not be used as the primary key of an Intent,
3370 * since it will not result in the app launching with the correct
3371 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003372 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003373 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003374 */
3375 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3376 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3377
3378 /**
3379 * Used with {@link #ACTION_MAIN} to launch the email application.
3380 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003381 * <p>NOTE: This should not be used as the primary key of an Intent,
3382 * since it will not result in the app launching with the correct
3383 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003384 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003385 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003386 */
3387 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3388 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3389
3390 /**
3391 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3392 * The activity should be able to view and manipulate image and video files
3393 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003394 * <p>NOTE: This should not be used as the primary key of an Intent,
3395 * since it will not result in the app launching with the correct
3396 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003397 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003398 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003399 */
3400 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3401 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3402
3403 /**
3404 * Used with {@link #ACTION_MAIN} to launch the maps application.
3405 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003406 * <p>NOTE: This should not be used as the primary key of an Intent,
3407 * since it will not result in the app launching with the correct
3408 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003409 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003410 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003411 */
3412 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3413 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3414
3415 /**
3416 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3417 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003418 * <p>NOTE: This should not be used as the primary key of an Intent,
3419 * since it will not result in the app launching with the correct
3420 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003421 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003422 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003423 */
3424 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3425 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3426
3427 /**
3428 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003429 * The activity should be able to play, browse, or manipulate music files
3430 * stored on the device.
3431 * <p>NOTE: This should not be used as the primary key of an Intent,
3432 * since it will not result in the app launching with the correct
3433 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003434 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003435 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003436 */
3437 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3438 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3439
3440 // ---------------------------------------------------------------------
3441 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003442 // Standard extra data keys.
3443
3444 /**
3445 * The initial data to place in a newly created record. Use with
3446 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3447 * fields as would be given to the underlying ContentProvider.insert()
3448 * call.
3449 */
3450 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3451
3452 /**
3453 * A constant CharSequence that is associated with the Intent, used with
3454 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3455 * this may be a styled CharSequence, so you must use
3456 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3457 * retrieve it.
3458 */
3459 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3460
3461 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003462 * A constant String that is associated with the Intent, used with
3463 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3464 * as HTML formatted text. Note that you <em>must</em> also supply
3465 * {@link #EXTRA_TEXT}.
3466 */
3467 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3468
3469 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003470 * A content: URI holding a stream of data associated with the Intent,
3471 * used with {@link #ACTION_SEND} to supply the data being sent.
3472 */
3473 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3474
3475 /**
3476 * A String[] holding e-mail addresses that should be delivered to.
3477 */
3478 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3479
3480 /**
3481 * A String[] holding e-mail addresses that should be carbon copied.
3482 */
3483 public static final String EXTRA_CC = "android.intent.extra.CC";
3484
3485 /**
3486 * A String[] holding e-mail addresses that should be blind carbon copied.
3487 */
3488 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3489
3490 /**
3491 * A constant string holding the desired subject line of a message.
3492 */
3493 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3494
3495 /**
3496 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003497 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003498 */
3499 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3500
3501 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003502 * An int representing the user id to be used.
3503 *
3504 * @hide
3505 */
3506 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3507
3508 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003509 * An Intent[] describing additional, alternate choices you would like shown with
3510 * {@link #ACTION_CHOOSER}.
3511 *
3512 * <p>An app may be capable of providing several different payload types to complete a
3513 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3514 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3515 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3516 * photo data or a hosted link where the photos can be viewed.</p>
3517 *
3518 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3519 * first/primary/preferred intent in the set. Additional intents specified in
3520 * this extra are ordered; by default intents that appear earlier in the array will be
3521 * preferred over intents that appear later in the array as matches for the same
3522 * target component. To alter this preference, a calling app may also supply
3523 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3524 */
3525 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3526
3527 /**
3528 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3529 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3530 *
3531 * <p>An app preparing an action for another app to complete may wish to allow the user to
3532 * disambiguate between several options for completing the action based on the chosen target
3533 * or otherwise refine the action before it is invoked.
3534 * </p>
3535 *
3536 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3537 * <ul>
3538 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3539 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3540 * chosen target beyond the first</li>
3541 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3542 * should fill in and send once the disambiguation is complete</li>
3543 * </ul>
3544 */
3545 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3546 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3547
3548 /**
3549 * A {@link ResultReceiver} used to return data back to the sender.
3550 *
3551 * <p>Used to complete an app-specific
3552 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3553 *
3554 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3555 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3556 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3557 * when the user selects a target component from the chooser. It is up to the recipient
3558 * to send a result to this ResultReceiver to signal that disambiguation is complete
3559 * and that the chooser should invoke the user's choice.</p>
3560 *
3561 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3562 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3563 * to match and fill in the final Intent or ChooserTarget before starting it.
3564 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3565 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3566 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3567 *
3568 * <p>The result code passed to the ResultReceiver should be
3569 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3570 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3571 * the chooser should finish without starting a target.</p>
3572 */
3573 public static final String EXTRA_RESULT_RECEIVER
3574 = "android.intent.extra.RESULT_RECEIVER";
3575
3576 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003577 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003578 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003579 */
3580 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3581
3582 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003583 * A Parcelable[] of {@link Intent} or
3584 * {@link android.content.pm.LabeledIntent} objects as set with
3585 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3586 * a the front of the list of choices, when shown to the user with a
3587 * {@link #ACTION_CHOOSER}.
3588 */
3589 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3590
3591 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003592 * A Bundle forming a mapping of potential target package names to different extras Bundles
3593 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3594 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3595 * be currently installed on the device.
3596 *
3597 * <p>An application may choose to provide alternate extras for the case where a user
3598 * selects an activity from a predetermined set of target packages. If the activity
3599 * the user selects from the chooser belongs to a package with its package name as
3600 * a key in this bundle, the corresponding extras for that package will be merged with
3601 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3602 * extra has the same key as an extra already present in the intent it will overwrite
3603 * the extra from the intent.</p>
3604 *
3605 * <p><em>Examples:</em>
3606 * <ul>
3607 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3608 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3609 * parameters for that target.</li>
3610 * <li>An application may offer additional metadata for known targets of a given intent
3611 * to pass along information only relevant to that target such as account or content
3612 * identifiers already known to that application.</li>
3613 * </ul></p>
3614 */
3615 public static final String EXTRA_REPLACEMENT_EXTRAS =
3616 "android.intent.extra.REPLACEMENT_EXTRAS";
3617
3618 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003619 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3620 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3621 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3622 * {@link ComponentName} of the chosen component.
3623 *
3624 * <p>In some situations this callback may never come, for example if the user abandons
3625 * the chooser, switches to another task or any number of other reasons. Apps should not
3626 * be written assuming that this callback will always occur.</p>
3627 */
3628 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3629 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3630
3631 /**
3632 * The {@link ComponentName} chosen by the user to complete an action.
3633 *
3634 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3635 */
3636 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3637
3638 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003639 * A {@link android.view.KeyEvent} object containing the event that
3640 * triggered the creation of the Intent it is in.
3641 */
3642 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3643
3644 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003645 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3646 * before shutting down.
3647 *
3648 * {@hide}
3649 */
3650 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3651
3652 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003653 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3654 * requested by the user.
3655 *
3656 * {@hide}
3657 */
3658 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3659 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3660
3661 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003662 * 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 -07003663 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3664 * of restarting the application.
3665 */
3666 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3667
3668 /**
3669 * A String holding the phone number originally entered in
3670 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3671 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3672 */
3673 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003674
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003675 /**
3676 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3677 * intents to supply the uid the package had been assigned. Also an optional
3678 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3679 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3680 * purpose.
3681 */
3682 public static final String EXTRA_UID = "android.intent.extra.UID";
3683
3684 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003685 * @hide String array of package names.
3686 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003687 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003688 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3689
3690 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003691 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3692 * intents to indicate whether this represents a full uninstall (removing
3693 * both the code and its data) or a partial uninstall (leaving its data,
3694 * implying that this is an update).
3695 */
3696 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003697
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003698 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003699 * @hide
3700 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3701 * intents to indicate that at this point the package has been removed for
3702 * all users on the device.
3703 */
3704 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3705 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3706
3707 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003708 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3709 * intents to indicate that this is a replacement of the package, so this
3710 * broadcast will immediately be followed by an add broadcast for a
3711 * different version of the same package.
3712 */
3713 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003714
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003715 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003716 * Used as an int extra field in {@link android.app.AlarmManager} intents
3717 * to tell the application being invoked how many pending alarms are being
3718 * delievered with the intent. For one-shot alarms this will always be 1.
3719 * For recurring alarms, this might be greater than 1 if the device was
3720 * asleep or powered off at the time an earlier alarm would have been
3721 * delivered.
3722 */
3723 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003724
Jacek Surazski86b6c532009-05-13 14:38:28 +02003725 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003726 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3727 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003728 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3729 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003730 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3731 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3732 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003733 */
3734 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3735
3736 /**
3737 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3738 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003739 */
3740 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3741
3742 /**
3743 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3744 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003745 */
3746 public static final int EXTRA_DOCK_STATE_DESK = 1;
3747
3748 /**
3749 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3750 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003751 */
3752 public static final int EXTRA_DOCK_STATE_CAR = 2;
3753
3754 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003755 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3756 * to represent that the phone is in a analog (low end) dock.
3757 */
3758 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3759
3760 /**
3761 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3762 * to represent that the phone is in a digital (high end) dock.
3763 */
3764 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3765
3766 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003767 * Boolean that can be supplied as meta-data with a dock activity, to
3768 * indicate that the dock should take over the home key when it is active.
3769 */
3770 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003771
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003772 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003773 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3774 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003775 */
3776 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3777
3778 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003779 * Used in the extra field in the remote intent. It's astring token passed with the
3780 * remote intent.
3781 */
3782 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3783 "android.intent.extra.remote_intent_token";
3784
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003785 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003786 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003787 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003788 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003789 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003790 "android.intent.extra.changed_component_name";
3791
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003792 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003793 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003794 * and contains a string array of all of the components that have changed. If
3795 * the state of the overall package has changed, then it will contain an entry
3796 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003797 */
3798 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3799 "android.intent.extra.changed_component_name_list";
3800
3801 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003802 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003803 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3804 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003805 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003806 */
3807 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3808 "android.intent.extra.changed_package_list";
3809
3810 /**
3811 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003812 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3813 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003814 * and contains an integer array of uids of all of the components
3815 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003816 */
3817 public static final String EXTRA_CHANGED_UID_LIST =
3818 "android.intent.extra.changed_uid_list";
3819
3820 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003821 * @hide
3822 * Magic extra system code can use when binding, to give a label for
3823 * who it is that has bound to a service. This is an integer giving
3824 * a framework string resource that can be displayed to the user.
3825 */
3826 public static final String EXTRA_CLIENT_LABEL =
3827 "android.intent.extra.client_label";
3828
3829 /**
3830 * @hide
3831 * Magic extra system code can use when binding, to give a PendingIntent object
3832 * that can be launched for the user to disable the system's use of this
3833 * service.
3834 */
3835 public static final String EXTRA_CLIENT_INTENT =
3836 "android.intent.extra.client_intent";
3837
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003838 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003839 * Extra used to indicate that an intent should only return data that is on
3840 * the local device. This is a boolean extra; the default is false. If true,
3841 * an implementation should only allow the user to select data that is
3842 * already on the device, not requiring it be downloaded from a remote
3843 * service when opened.
3844 *
3845 * @see #ACTION_GET_CONTENT
3846 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003847 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003848 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003849 */
3850 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003851 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003852
Amith Yamasani13593602012-03-22 16:16:17 -07003853 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003854 * Extra used to indicate that an intent can allow the user to select and
3855 * return multiple items. This is a boolean extra; the default is false. If
3856 * true, an implementation is allowed to present the user with a UI where
3857 * they can pick multiple items that are all returned to the caller. When
3858 * this happens, they should be returned as the {@link #getClipData()} part
3859 * of the result Intent.
3860 *
3861 * @see #ACTION_GET_CONTENT
3862 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003863 */
3864 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003865 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003866
3867 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003868 * The integer userHandle carried with broadcast intents related to addition, removal and
3869 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3870 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3871 *
Amith Yamasani13593602012-03-22 16:16:17 -07003872 * @hide
3873 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003874 public static final String EXTRA_USER_HANDLE =
3875 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003876
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003877 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003878 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3879 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3880 */
3881 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003882 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003883
3884 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003885 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003886 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3887 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003888 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003889 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3890
3891 /**
3892 * Extra sent in the intent to the BroadcastReceiver that handles
3893 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3894 * the restrictions as key/value pairs.
3895 */
3896 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3897 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003898
Amith Yamasani86118ba2013-03-28 14:33:16 -07003899 /**
3900 * Extra used in the response from a BroadcastReceiver that handles
3901 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3902 */
3903 public static final String EXTRA_RESTRICTIONS_INTENT =
3904 "android.intent.extra.restrictions_intent";
3905
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003906 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003907 * Extra used to communicate a set of acceptable MIME types. The type of the
3908 * extra is {@code String[]}. Values may be a combination of concrete MIME
3909 * types (such as "image/png") and/or partial MIME types (such as
3910 * "audio/*").
3911 *
3912 * @see #ACTION_GET_CONTENT
3913 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003914 */
3915 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3916
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003917 /**
3918 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3919 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003920 * When this is true, hardware devices can use this information to determine that
3921 * they shouldn't do a complete shutdown of their device since this is not a
3922 * complete shutdown down to the kernel, but only user space restarting.
3923 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003924 */
3925 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
3926 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
3927
Narayan Kamathccb2a0862013-12-19 14:49:36 +00003928 /**
3929 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
3930 * user has set their time format preferences to the 24 hour format.
3931 *
3932 * @hide for internal use only.
3933 */
3934 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
3935 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
3936
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003937 /** {@hide} */
3938 public static final String EXTRA_REASON = "android.intent.extra.REASON";
3939
Rubin Xue8490f12015-06-25 12:17:48 +01003940 /** {@hide} */
3941 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
3942
Santos Cordon15a13782015-03-31 18:32:31 -07003943 /**
3944 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
3945 * activation request.
3946 * TODO: Add information about the structure and response data used with the pending intent.
3947 * @hide
3948 */
3949 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
3950 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
3951
Steve McKay6eaf38632015-08-04 10:11:01 -07003952 /** {@hide} */
3953 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
3954
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003955 // ---------------------------------------------------------------------
3956 // ---------------------------------------------------------------------
3957 // Intent flags (see mFlags variable).
3958
Tor Norbyed9273d62013-05-30 15:59:53 -07003959 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07003960 @IntDef(flag = true, value = {
3961 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
3962 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07003963 @Retention(RetentionPolicy.SOURCE)
3964 public @interface GrantUriMode {}
3965
Jeff Sharkey846318a2014-04-04 12:12:41 -07003966 /** @hide */
3967 @IntDef(flag = true, value = {
3968 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
3969 @Retention(RetentionPolicy.SOURCE)
3970 public @interface AccessUriMode {}
3971
3972 /**
3973 * Test if given mode flags specify an access mode, which must be at least
3974 * read and/or write.
3975 *
3976 * @hide
3977 */
3978 public static boolean isAccessUriMode(int modeFlags) {
3979 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
3980 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
3981 }
3982
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003983 /**
3984 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003985 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003986 * specified in its ClipData. When applying to an Intent's ClipData,
3987 * all URIs as well as recursive traversals through data or other ClipData
3988 * in Intent items will be granted; only the grant flags of the top-level
3989 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003990 */
3991 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
3992 /**
3993 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003994 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08003995 * specified in its ClipData. When applying to an Intent's ClipData,
3996 * all URIs as well as recursive traversals through data or other ClipData
3997 * in Intent items will be granted; only the grant flags of the top-level
3998 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003999 */
4000 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4001 /**
4002 * Can be set by the caller to indicate that this Intent is coming from
4003 * a background operation, not from direct user interaction.
4004 */
4005 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4006 /**
4007 * A flag you can enable for debugging: when set, log messages will be
4008 * printed during the resolution of this intent to show you what has
4009 * been found to create the final resolved list.
4010 */
4011 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004012 /**
4013 * If set, this intent will not match any components in packages that
4014 * are currently stopped. If this is not set, then the default behavior
4015 * is to include such applications in the result.
4016 */
4017 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4018 /**
4019 * If set, this intent will always match any components in packages that
4020 * are currently stopped. This is the default behavior when
4021 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4022 * flags are set, this one wins (it allows overriding of exclude for
4023 * places where the framework may automatically set the exclude flag).
4024 */
4025 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004026
4027 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004028 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004029 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004030 * persisted across device reboots until explicitly revoked with
4031 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4032 * grant for possible persisting; the receiving application must call
4033 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4034 * actually persist.
4035 *
4036 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4037 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4038 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004039 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004040 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004041 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004042
4043 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004044 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4045 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4046 * applies to any URI that is a prefix match against the original granted
4047 * URI. (Without this flag, the URI must match exactly for access to be
4048 * granted.) Another URI is considered a prefix match only when scheme,
4049 * authority, and all path segments defined by the prefix are an exact
4050 * match.
4051 */
4052 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4053
4054 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004055 * If set, the new activity is not kept in the history stack. As soon as
4056 * the user navigates away from it, the activity is finished. This may also
4057 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4058 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004059 *
4060 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4061 * is never invoked when the current activity starts a new activity which
4062 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004063 */
4064 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4065 /**
4066 * If set, the activity will not be launched if it is already running
4067 * at the top of the history stack.
4068 */
4069 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4070 /**
4071 * If set, this activity will become the start of a new task on this
4072 * history stack. A task (from the activity that started it to the
4073 * next task activity) defines an atomic group of activities that the
4074 * user can move to. Tasks can be moved to the foreground and background;
4075 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004076 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004077 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4078 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004079 *
4080 * <p>This flag is generally used by activities that want
4081 * to present a "launcher" style behavior: they give the user a list of
4082 * separate things that can be done, which otherwise run completely
4083 * independently of the activity launching them.
4084 *
4085 * <p>When using this flag, if a task is already running for the activity
4086 * you are now starting, then a new activity will not be started; instead,
4087 * the current task will simply be brought to the front of the screen with
4088 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4089 * to disable this behavior.
4090 *
4091 * <p>This flag can not be used when the caller is requesting a result from
4092 * the activity being launched.
4093 */
4094 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4095 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004096 * This flag is used to create a new task and launch an activity into it.
4097 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4098 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4099 * search through existing tasks for ones matching this Intent. Only if no such
4100 * task is found would a new task be created. When paired with
4101 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4102 * the search for a matching task and unconditionally start a new task.
4103 *
4104 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4105 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004106 * top-level application launcher.</strong> Used in conjunction with
4107 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4108 * behavior of bringing an existing task to the foreground. When set,
4109 * a new task is <em>always</em> started to host the Activity for the
4110 * Intent, regardless of whether there is already an existing task running
4111 * the same thing.
4112 *
4113 * <p><strong>Because the default system does not include graphical task management,
4114 * you should not use this flag unless you provide some way for a user to
4115 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004116 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004117 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4118 * creating new document tasks.
4119 *
4120 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004121 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004122 *
Scott Main7aee61f2011-02-08 11:25:01 -08004123 * <p>See
4124 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4125 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004126 *
4127 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4128 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004129 */
4130 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4131 /**
4132 * If set, and the activity being launched is already running in the
4133 * current task, then instead of launching a new instance of that activity,
4134 * all of the other activities on top of it will be closed and this Intent
4135 * will be delivered to the (now on top) old activity as a new Intent.
4136 *
4137 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4138 * If D calls startActivity() with an Intent that resolves to the component
4139 * of activity B, then C and D will be finished and B receive the given
4140 * Intent, resulting in the stack now being: A, B.
4141 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004142 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004143 * either receive the new intent you are starting here in its
4144 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004145 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004146 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4147 * the same intent, then it will be finished and re-created; for all other
4148 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4149 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004150 *
4151 * <p>This launch mode can also be used to good effect in conjunction with
4152 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4153 * of a task, it will bring any currently running instance of that task
4154 * to the foreground, and then clear it to its root state. This is
4155 * especially useful, for example, when launching an activity from the
4156 * notification manager.
4157 *
Scott Main7aee61f2011-02-08 11:25:01 -08004158 * <p>See
4159 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4160 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004161 */
4162 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4163 /**
4164 * If set and this intent is being used to launch a new activity from an
4165 * existing one, then the reply target of the existing activity will be
4166 * transfered to the new activity. This way the new activity can call
4167 * {@link android.app.Activity#setResult} and have that result sent back to
4168 * the reply target of the original activity.
4169 */
4170 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4171 /**
4172 * If set and this intent is being used to launch a new activity from an
4173 * existing one, the current activity will not be counted as the top
4174 * activity for deciding whether the new intent should be delivered to
4175 * the top instead of starting a new one. The previous activity will
4176 * be used as the top, with the assumption being that the current activity
4177 * will finish itself immediately.
4178 */
4179 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4180 /**
4181 * If set, the new activity is not kept in the list of recently launched
4182 * activities.
4183 */
4184 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4185 /**
4186 * This flag is not normally set by application code, but set for you by
4187 * the system as described in the
4188 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4189 * launchMode} documentation for the singleTask mode.
4190 */
4191 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4192 /**
4193 * If set, and this activity is either being started in a new task or
4194 * bringing to the top an existing task, then it will be launched as
4195 * the front door of the task. This will result in the application of
4196 * any affinities needed to have that task in the proper state (either
4197 * moving activities to or from it), or simply resetting that task to
4198 * its initial state if needed.
4199 */
4200 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4201 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004202 * This flag is not normally set by application code, but set for you by
4203 * the system if this activity is being launched from history
4204 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004205 */
4206 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004207 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004208 * @deprecated As of API 21 this performs identically to
4209 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004210 */
4211 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004212 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004213 * This flag is used to open a document into a new task rooted at the activity launched
4214 * by this Intent. Through the use of this flag, or its equivalent attribute,
4215 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004216 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004217 *
Craig Mautner026596b2014-05-21 15:35:44 -07004218 * <p>The use of the activity attribute form of this,
4219 * {@link android.R.attr#documentLaunchMode}, is
4220 * preferred over the Intent flag described here. The attribute form allows the
4221 * Activity to specify multiple document behavior for all launchers of the Activity
4222 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004223 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004224 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4225 * it is kept after the activity is finished is different than the use of
4226 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4227 * this flag is being used to create a new recents entry, then by default that entry
4228 * will be removed once the activity is finished. You can modify this behavior with
4229 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4230 *
Craig Mautner026596b2014-05-21 15:35:44 -07004231 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4232 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4233 * equivalent of the Activity manifest specifying {@link
4234 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4235 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4236 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004237 *
Craig Mautner026596b2014-05-21 15:35:44 -07004238 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004239 *
Craig Mautner026596b2014-05-21 15:35:44 -07004240 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004241 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4242 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004243 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004244 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004245 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004246 * callback from occurring on the current frontmost activity before it is
4247 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004248 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004249 * <p>Typically, an activity can rely on that callback to indicate that an
4250 * explicit user action has caused their activity to be moved out of the
4251 * foreground. The callback marks an appropriate point in the activity's
4252 * lifecycle for it to dismiss any notifications that it intends to display
4253 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004254 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004255 * <p>If an activity is ever started via any non-user-driven events such as
4256 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4257 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004258 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004259 */
4260 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004261 /**
4262 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4263 * this flag will cause the launched activity to be brought to the front of its
4264 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004265 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004266 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4267 * If D calls startActivity() with an Intent that resolves to the component
4268 * of activity B, then B will be brought to the front of the history stack,
4269 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004270 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004271 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004272 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004273 */
4274 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004275 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004276 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4277 * this flag will prevent the system from applying an activity transition
4278 * animation to go to the next activity state. This doesn't mean an
4279 * animation will never run -- if another activity change happens that doesn't
4280 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004281 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004282 * when you are going to do a series of activity operations but the
4283 * animation seen by the user shouldn't be driven by the first activity
4284 * change but rather a later one.
4285 */
4286 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4287 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004288 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4289 * this flag will cause any existing task that would be associated with the
4290 * activity to be cleared before the activity is started. That is, the activity
4291 * becomes the new root of an otherwise empty task, and any old activities
4292 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4293 */
4294 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4295 /**
4296 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4297 * this flag will cause a newly launching task to be placed on top of the current
4298 * home activity task (if there is one). That is, pressing back from the task
4299 * will always return the user to home even if that was not the last activity they
4300 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4301 */
4302 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4303 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004304 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4305 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004306 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004307 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004308 * this flag. When set and the task's activity is finished, the recents
4309 * entry will remain in the interface for the user to re-launch it, like a
4310 * recents entry for a top-level application.
4311 * <p>
4312 * The receiving activity can override this request with
4313 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4314 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004315 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004316 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004317 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004318
4319 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004320 * If set, when sending a broadcast only registered receivers will be
4321 * called -- no BroadcastReceiver components will be launched.
4322 */
4323 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004324 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004325 * If set, when sending a broadcast the new broadcast will replace
4326 * any existing pending broadcast that matches it. Matching is defined
4327 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4328 * true for the intents of the two broadcasts. When a match is found,
4329 * the new broadcast (and receivers associated with it) will replace the
4330 * existing one in the pending broadcast list, remaining at the same
4331 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004332 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004333 * <p>This flag is most typically used with sticky broadcasts, which
4334 * only care about delivering the most recent values of the broadcast
4335 * to their receivers.
4336 */
4337 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4338 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004339 * If set, when sending a broadcast the recipient is allowed to run at
4340 * foreground priority, with a shorter timeout interval. During normal
4341 * broadcasts the receivers are not automatically hoisted out of the
4342 * background priority class.
4343 */
4344 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4345 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004346 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4347 * They can still propagate results through to later receivers, but they can not prevent
4348 * later receivers from seeing the broadcast.
4349 */
4350 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4351 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004352 * If set, when sending a broadcast <i>before boot has completed</i> only
4353 * registered receivers will be called -- no BroadcastReceiver components
4354 * will be launched. Sticky intent state will be recorded properly even
4355 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4356 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004357 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004358 * <p>This flag is only for use by system sevices as a convenience to
4359 * avoid having to implement a more complex mechanism around detection
4360 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004361 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004362 * @hide
4363 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004364 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004365 /**
4366 * Set when this broadcast is for a boot upgrade, a special mode that
4367 * allows the broadcast to be sent before the system is ready and launches
4368 * the app process with no providers running in it.
4369 * @hide
4370 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004371 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004372
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004373 /**
4374 * @hide Flags that can't be changed with PendingIntent.
4375 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004376 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4377 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4378 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004379
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004380 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004381 // ---------------------------------------------------------------------
4382 // toUri() and parseUri() options.
4383
4384 /**
4385 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4386 * always has the "intent:" scheme. This syntax can be used when you want
4387 * to later disambiguate between URIs that are intended to describe an
4388 * Intent vs. all others that should be treated as raw URIs. When used
4389 * with {@link #parseUri}, any other scheme will result in a generic
4390 * VIEW action for that raw URI.
4391 */
4392 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004393
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004394 /**
4395 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4396 * always has the "android-app:" scheme. This is a variation of
4397 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4398 * http/https URI being delivered to a specific package name. The format
4399 * is:
4400 *
4401 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004402 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004403 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004404 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4405 * you must also include a scheme; including a path also requires both a host and a scheme.
4406 * The final #Intent; fragment can be used without a scheme, host, or path.
4407 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004408 * used with intents that have a {@link #setSelector}, since the base intent
4409 * will always have an explicit package name.</p>
4410 *
4411 * <p>Some examples of how this scheme maps to Intent objects:</p>
4412 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4413 * <colgroup align="left" />
4414 * <colgroup align="left" />
4415 * <thead>
4416 * <tr><th>URI</th> <th>Intent</th></tr>
4417 * </thead>
4418 *
4419 * <tbody>
4420 * <tr><td><code>android-app://com.example.app</code></td>
4421 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4422 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4423 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4424 * </table></td>
4425 * </tr>
4426 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4427 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4428 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4429 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4430 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4431 * </table></td>
4432 * </tr>
4433 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4434 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4435 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4436 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4437 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4438 * </table></td>
4439 * </tr>
4440 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4441 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4442 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4443 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4444 * </table></td>
4445 * </tr>
4446 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4447 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4448 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4449 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4450 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4451 * </table></td>
4452 * </tr>
4453 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
4454 * <td><table border="" style="margin:0" >
4455 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4456 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4457 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4458 * </table></td>
4459 * </tr>
4460 * </tbody>
4461 * </table>
4462 */
4463 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4464
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004465 /**
4466 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4467 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4468 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4469 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4470 * generated Intent can not cause unexpected data access to happen.
4471 *
4472 * <p>If you do not trust the source of the URI being parsed, you should still do further
4473 * processing to protect yourself from it. In particular, when using it to start an
4474 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4475 * that can handle it.</p>
4476 */
4477 public static final int URI_ALLOW_UNSAFE = 1<<2;
4478
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004479 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004480
4481 private String mAction;
4482 private Uri mData;
4483 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004484 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004485 private ComponentName mComponent;
4486 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004487 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004488 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004489 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004490 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004491 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004492 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004493
4494 // ---------------------------------------------------------------------
4495
4496 /**
4497 * Create an empty intent.
4498 */
4499 public Intent() {
4500 }
4501
4502 /**
4503 * Copy constructor.
4504 */
4505 public Intent(Intent o) {
4506 this.mAction = o.mAction;
4507 this.mData = o.mData;
4508 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004509 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004510 this.mComponent = o.mComponent;
4511 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004512 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004513 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004514 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004515 }
4516 if (o.mExtras != null) {
4517 this.mExtras = new Bundle(o.mExtras);
4518 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004519 if (o.mSourceBounds != null) {
4520 this.mSourceBounds = new Rect(o.mSourceBounds);
4521 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004522 if (o.mSelector != null) {
4523 this.mSelector = new Intent(o.mSelector);
4524 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004525 if (o.mClipData != null) {
4526 this.mClipData = new ClipData(o.mClipData);
4527 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004528 }
4529
4530 @Override
4531 public Object clone() {
4532 return new Intent(this);
4533 }
4534
4535 private Intent(Intent o, boolean all) {
4536 this.mAction = o.mAction;
4537 this.mData = o.mData;
4538 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004539 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004540 this.mComponent = o.mComponent;
4541 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004542 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004543 }
4544 }
4545
4546 /**
4547 * Make a clone of only the parts of the Intent that are relevant for
4548 * filter matching: the action, data, type, component, and categories.
4549 */
4550 public Intent cloneFilter() {
4551 return new Intent(this, false);
4552 }
4553
4554 /**
4555 * Create an intent with a given action. All other fields (data, type,
4556 * class) are null. Note that the action <em>must</em> be in a
4557 * namespace because Intents are used globally in the system -- for
4558 * example the system VIEW action is android.intent.action.VIEW; an
4559 * application's custom action would be something like
4560 * com.google.app.myapp.CUSTOM_ACTION.
4561 *
4562 * @param action The Intent action, such as ACTION_VIEW.
4563 */
4564 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004565 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004566 }
4567
4568 /**
4569 * Create an intent with a given action and for a given data url. Note
4570 * that the action <em>must</em> be in a namespace because Intents are
4571 * used globally in the system -- for example the system VIEW action is
4572 * android.intent.action.VIEW; an application's custom action would be
4573 * something like com.google.app.myapp.CUSTOM_ACTION.
4574 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004575 * <p><em>Note: scheme and host name matching in the Android framework is
4576 * case-sensitive, unlike the formal RFC. As a result,
4577 * you should always ensure that you write your Uri with these elements
4578 * using lower case letters, and normalize any Uris you receive from
4579 * outside of Android to ensure the scheme and host is lower case.</em></p>
4580 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004581 * @param action The Intent action, such as ACTION_VIEW.
4582 * @param uri The Intent data URI.
4583 */
4584 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004585 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004586 mData = uri;
4587 }
4588
4589 /**
4590 * Create an intent for a specific component. All other fields (action, data,
4591 * type, class) are null, though they can be modified later with explicit
4592 * calls. This provides a convenient way to create an intent that is
4593 * intended to execute a hard-coded class name, rather than relying on the
4594 * system to find an appropriate class for you; see {@link #setComponent}
4595 * for more information on the repercussions of this.
4596 *
4597 * @param packageContext A Context of the application package implementing
4598 * this class.
4599 * @param cls The component class that is to be used for the intent.
4600 *
4601 * @see #setClass
4602 * @see #setComponent
4603 * @see #Intent(String, android.net.Uri , Context, Class)
4604 */
4605 public Intent(Context packageContext, Class<?> cls) {
4606 mComponent = new ComponentName(packageContext, cls);
4607 }
4608
4609 /**
4610 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004611 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004612 * construct the Intent and then calling {@link #setClass} to set its
4613 * class.
4614 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004615 * <p><em>Note: scheme and host name matching in the Android framework is
4616 * case-sensitive, unlike the formal RFC. As a result,
4617 * you should always ensure that you write your Uri with these elements
4618 * using lower case letters, and normalize any Uris you receive from
4619 * outside of Android to ensure the scheme and host is lower case.</em></p>
4620 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004621 * @param action The Intent action, such as ACTION_VIEW.
4622 * @param uri The Intent data URI.
4623 * @param packageContext A Context of the application package implementing
4624 * this class.
4625 * @param cls The component class that is to be used for the intent.
4626 *
4627 * @see #Intent(String, android.net.Uri)
4628 * @see #Intent(Context, Class)
4629 * @see #setClass
4630 * @see #setComponent
4631 */
4632 public Intent(String action, Uri uri,
4633 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004634 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004635 mData = uri;
4636 mComponent = new ComponentName(packageContext, cls);
4637 }
4638
4639 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004640 * Create an intent to launch the main (root) activity of a task. This
4641 * is the Intent that is started when the application's is launched from
4642 * Home. For anything else that wants to launch an application in the
4643 * same way, it is important that they use an Intent structured the same
4644 * way, and can use this function to ensure this is the case.
4645 *
4646 * <p>The returned Intent has the given Activity component as its explicit
4647 * component, {@link #ACTION_MAIN} as its action, and includes the
4648 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4649 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4650 * to do that through {@link #addFlags(int)} on the returned Intent.
4651 *
4652 * @param mainActivity The main activity component that this Intent will
4653 * launch.
4654 * @return Returns a newly created Intent that can be used to launch the
4655 * activity as a main application entry.
4656 *
4657 * @see #setClass
4658 * @see #setComponent
4659 */
4660 public static Intent makeMainActivity(ComponentName mainActivity) {
4661 Intent intent = new Intent(ACTION_MAIN);
4662 intent.setComponent(mainActivity);
4663 intent.addCategory(CATEGORY_LAUNCHER);
4664 return intent;
4665 }
4666
4667 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004668 * Make an Intent for the main activity of an application, without
4669 * specifying a specific activity to run but giving a selector to find
4670 * the activity. This results in a final Intent that is structured
4671 * the same as when the application is launched from
4672 * Home. For anything else that wants to launch an application in the
4673 * same way, it is important that they use an Intent structured the same
4674 * way, and can use this function to ensure this is the case.
4675 *
4676 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4677 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4678 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4679 * to do that through {@link #addFlags(int)} on the returned Intent.
4680 *
4681 * @param selectorAction The action name of the Intent's selector.
4682 * @param selectorCategory The name of a category to add to the Intent's
4683 * selector.
4684 * @return Returns a newly created Intent that can be used to launch the
4685 * activity as a main application entry.
4686 *
4687 * @see #setSelector(Intent)
4688 */
4689 public static Intent makeMainSelectorActivity(String selectorAction,
4690 String selectorCategory) {
4691 Intent intent = new Intent(ACTION_MAIN);
4692 intent.addCategory(CATEGORY_LAUNCHER);
4693 Intent selector = new Intent();
4694 selector.setAction(selectorAction);
4695 selector.addCategory(selectorCategory);
4696 intent.setSelector(selector);
4697 return intent;
4698 }
4699
4700 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004701 * Make an Intent that can be used to re-launch an application's task
4702 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4703 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4704 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4705 *
4706 * @param mainActivity The activity component that is the root of the
4707 * task; this is the activity that has been published in the application's
4708 * manifest as the main launcher icon.
4709 *
4710 * @return Returns a newly created Intent that can be used to relaunch the
4711 * activity's task in its root state.
4712 */
4713 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4714 Intent intent = makeMainActivity(mainActivity);
4715 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4716 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4717 return intent;
4718 }
4719
4720 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004721 * Call {@link #parseUri} with 0 flags.
4722 * @deprecated Use {@link #parseUri} instead.
4723 */
4724 @Deprecated
4725 public static Intent getIntent(String uri) throws URISyntaxException {
4726 return parseUri(uri, 0);
4727 }
Tom Taylord4a47292009-12-21 13:59:18 -08004728
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004729 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004730 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004731 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004732 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004733 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004734 *
4735 * <p>The URI given here must not be relative -- that is, it must include
4736 * the scheme and full path.
4737 *
4738 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004739 * @param flags Additional processing flags. Either 0,
4740 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004741 *
4742 * @return Intent The newly created Intent object.
4743 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004744 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4745 * it bad (as parsed by the Uri class) or the Intent data within the
4746 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004747 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004748 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004749 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004750 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004751 int i = 0;
4752 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004753 final boolean androidApp = uri.startsWith("android-app:");
4754
4755 // Validate intent scheme if requested.
4756 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4757 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004758 Intent intent = new Intent(ACTION_VIEW);
4759 try {
4760 intent.setData(Uri.parse(uri));
4761 } catch (IllegalArgumentException e) {
4762 throw new URISyntaxException(uri, e.getMessage());
4763 }
4764 return intent;
4765 }
4766 }
Tom Taylord4a47292009-12-21 13:59:18 -08004767
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004768 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004769 // simple case
4770 if (i == -1) {
4771 if (!androidApp) {
4772 return new Intent(ACTION_VIEW, Uri.parse(uri));
4773 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004774
4775 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004776 } else if (!uri.startsWith("#Intent;", i)) {
4777 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004778 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004779 } else {
4780 i = -1;
4781 }
4782 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004783
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004784 // new format
4785 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004786 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004787 boolean explicitAction = false;
4788 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004789
4790 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004791 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004792 String data;
4793 if (i >= 0) {
4794 data = uri.substring(0, i);
4795 i += 8; // length of "#Intent;"
4796 } else {
4797 data = uri;
4798 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004799
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004800 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004801 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004802 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004803 if (eq < 0) eq = i-1;
4804 int semi = uri.indexOf(';', i);
4805 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004806
4807 // action
4808 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004809 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004810 if (!inSelector) {
4811 explicitAction = true;
4812 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004813 }
4814
4815 // categories
4816 else if (uri.startsWith("category=", i)) {
4817 intent.addCategory(value);
4818 }
4819
4820 // type
4821 else if (uri.startsWith("type=", i)) {
4822 intent.mType = value;
4823 }
4824
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004825 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004826 else if (uri.startsWith("launchFlags=", i)) {
4827 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004828 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4829 intent.mFlags &= ~IMMUTABLE_FLAGS;
4830 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004831 }
4832
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004833 // package
4834 else if (uri.startsWith("package=", i)) {
4835 intent.mPackage = value;
4836 }
4837
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004838 // component
4839 else if (uri.startsWith("component=", i)) {
4840 intent.mComponent = ComponentName.unflattenFromString(value);
4841 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004842
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004843 // scheme
4844 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004845 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004846 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004847 } else {
4848 scheme = value;
4849 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004850 }
4851
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004852 // source bounds
4853 else if (uri.startsWith("sourceBounds=", i)) {
4854 intent.mSourceBounds = Rect.unflattenFromString(value);
4855 }
4856
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004857 // selector
4858 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4859 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004860 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004861 }
4862
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004863 // extra
4864 else {
4865 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004866 // create Bundle if it doesn't already exist
4867 if (intent.mExtras == null) intent.mExtras = new Bundle();
4868 Bundle b = intent.mExtras;
4869 // add EXTRA
4870 if (uri.startsWith("S.", i)) b.putString(key, value);
4871 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4872 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4873 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4874 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4875 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4876 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4877 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4878 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4879 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4880 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004881
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004882 // move to the next item
4883 i = semi + 1;
4884 }
4885
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004886 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004887 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004888 if (baseIntent.mPackage == null) {
4889 baseIntent.setSelector(intent);
4890 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004891 intent = baseIntent;
4892 }
4893
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004894 if (data != null) {
4895 if (data.startsWith("intent:")) {
4896 data = data.substring(7);
4897 if (scheme != null) {
4898 data = scheme + ':' + data;
4899 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004900 } else if (data.startsWith("android-app:")) {
4901 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4902 // Correctly formed android-app, first part is package name.
4903 int end = data.indexOf('/', 14);
4904 if (end < 0) {
4905 // All we have is a package name.
4906 intent.mPackage = data.substring(14);
4907 if (!explicitAction) {
4908 intent.setAction(ACTION_MAIN);
4909 }
4910 data = "";
4911 } else {
4912 // Target the Intent at the given package name always.
4913 String authority = null;
4914 intent.mPackage = data.substring(14, end);
4915 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004916 if ((end+1) < data.length()) {
4917 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4918 // Found a scheme, remember it.
4919 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004920 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004921 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4922 // Found a authority, remember it.
4923 authority = data.substring(end+1, newEnd);
4924 end = newEnd;
4925 }
4926 } else {
4927 // All we have is a scheme.
4928 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004929 }
4930 }
4931 if (scheme == null) {
4932 // If there was no scheme, then this just targets the package.
4933 if (!explicitAction) {
4934 intent.setAction(ACTION_MAIN);
4935 }
4936 data = "";
4937 } else if (authority == null) {
4938 data = scheme + ":";
4939 } else {
4940 data = scheme + "://" + authority + data.substring(end);
4941 }
4942 }
4943 } else {
4944 data = "";
4945 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004946 }
Tom Taylord4a47292009-12-21 13:59:18 -08004947
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004948 if (data.length() > 0) {
4949 try {
4950 intent.mData = Uri.parse(data);
4951 } catch (IllegalArgumentException e) {
4952 throw new URISyntaxException(uri, e.getMessage());
4953 }
4954 }
4955 }
Tom Taylord4a47292009-12-21 13:59:18 -08004956
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004957 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07004958
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004959 } catch (IndexOutOfBoundsException e) {
4960 throw new URISyntaxException(uri, "illegal Intent URI format", i);
4961 }
4962 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004963
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004964 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004965 return getIntentOld(uri, 0);
4966 }
4967
4968 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004969 Intent intent;
4970
4971 int i = uri.lastIndexOf('#');
4972 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004973 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004974 final int intentFragmentStart = i;
4975 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004976
4977 i++;
4978
4979 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004980 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004981 i += 7;
4982 int j = uri.indexOf(')', i);
4983 action = uri.substring(i, j);
4984 i = j + 1;
4985 }
4986
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004987 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004988
4989 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07004990 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004991 i += 11;
4992 int j = uri.indexOf(')', i);
4993 while (i < j) {
4994 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07004995 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004996 if (i < sep) {
4997 intent.addCategory(uri.substring(i, sep));
4998 }
4999 i = sep + 1;
5000 }
5001 i = j + 1;
5002 }
5003
5004 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005005 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005006 i += 5;
5007 int j = uri.indexOf(')', i);
5008 intent.mType = uri.substring(i, j);
5009 i = j + 1;
5010 }
5011
5012 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005013 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 i += 12;
5015 int j = uri.indexOf(')', i);
5016 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005017 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5018 intent.mFlags &= ~IMMUTABLE_FLAGS;
5019 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005020 i = j + 1;
5021 }
5022
5023 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005024 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005025 i += 10;
5026 int j = uri.indexOf(')', i);
5027 int sep = uri.indexOf('!', i);
5028 if (sep >= 0 && sep < j) {
5029 String pkg = uri.substring(i, sep);
5030 String cls = uri.substring(sep + 1, j);
5031 intent.mComponent = new ComponentName(pkg, cls);
5032 }
5033 i = j + 1;
5034 }
5035
5036 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005037 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005038 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005039
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 final int closeParen = uri.indexOf(')', i);
5041 if (closeParen == -1) throw new URISyntaxException(uri,
5042 "EXTRA missing trailing ')'", i);
5043
5044 while (i < closeParen) {
5045 // fetch the key value
5046 int j = uri.indexOf('=', i);
5047 if (j <= i + 1 || i >= closeParen) {
5048 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5049 }
5050 char type = uri.charAt(i);
5051 i++;
5052 String key = uri.substring(i, j);
5053 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005055 // get type-value
5056 j = uri.indexOf('!', i);
5057 if (j == -1 || j >= closeParen) j = closeParen;
5058 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5059 String value = uri.substring(i, j);
5060 i = j;
5061
5062 // create Bundle if it doesn't already exist
5063 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005064
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005065 // add item to bundle
5066 try {
5067 switch (type) {
5068 case 'S':
5069 intent.mExtras.putString(key, Uri.decode(value));
5070 break;
5071 case 'B':
5072 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5073 break;
5074 case 'b':
5075 intent.mExtras.putByte(key, Byte.parseByte(value));
5076 break;
5077 case 'c':
5078 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5079 break;
5080 case 'd':
5081 intent.mExtras.putDouble(key, Double.parseDouble(value));
5082 break;
5083 case 'f':
5084 intent.mExtras.putFloat(key, Float.parseFloat(value));
5085 break;
5086 case 'i':
5087 intent.mExtras.putInt(key, Integer.parseInt(value));
5088 break;
5089 case 'l':
5090 intent.mExtras.putLong(key, Long.parseLong(value));
5091 break;
5092 case 's':
5093 intent.mExtras.putShort(key, Short.parseShort(value));
5094 break;
5095 default:
5096 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5097 }
5098 } catch (NumberFormatException e) {
5099 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5100 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005101
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005102 char ch = uri.charAt(i);
5103 if (ch == ')') break;
5104 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5105 i++;
5106 }
5107 }
5108
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005109 if (isIntentFragment) {
5110 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5111 } else {
5112 intent.mData = Uri.parse(uri);
5113 }
Tom Taylord4a47292009-12-21 13:59:18 -08005114
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005115 if (intent.mAction == null) {
5116 // By default, if no action is specified, then use VIEW.
5117 intent.mAction = ACTION_VIEW;
5118 }
5119
5120 } else {
5121 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5122 }
5123
5124 return intent;
5125 }
5126
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005127 /** @hide */
5128 public interface CommandOptionHandler {
5129 boolean handleOption(String opt, ShellCommand cmd);
5130 }
5131
5132 /** @hide */
5133 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5134 throws URISyntaxException {
5135 Intent intent = new Intent();
5136 Intent baseIntent = intent;
5137 boolean hasIntentInfo = false;
5138
5139 Uri data = null;
5140 String type = null;
5141
5142 String opt;
5143 while ((opt=cmd.getNextOption()) != null) {
5144 switch (opt) {
5145 case "-a":
5146 intent.setAction(cmd.getNextArgRequired());
5147 if (intent == baseIntent) {
5148 hasIntentInfo = true;
5149 }
5150 break;
5151 case "-d":
5152 data = Uri.parse(cmd.getNextArgRequired());
5153 if (intent == baseIntent) {
5154 hasIntentInfo = true;
5155 }
5156 break;
5157 case "-t":
5158 type = cmd.getNextArgRequired();
5159 if (intent == baseIntent) {
5160 hasIntentInfo = true;
5161 }
5162 break;
5163 case "-c":
5164 intent.addCategory(cmd.getNextArgRequired());
5165 if (intent == baseIntent) {
5166 hasIntentInfo = true;
5167 }
5168 break;
5169 case "-e":
5170 case "--es": {
5171 String key = cmd.getNextArgRequired();
5172 String value = cmd.getNextArgRequired();
5173 intent.putExtra(key, value);
5174 }
5175 break;
5176 case "--esn": {
5177 String key = cmd.getNextArgRequired();
5178 intent.putExtra(key, (String) null);
5179 }
5180 break;
5181 case "--ei": {
5182 String key = cmd.getNextArgRequired();
5183 String value = cmd.getNextArgRequired();
5184 intent.putExtra(key, Integer.decode(value));
5185 }
5186 break;
5187 case "--eu": {
5188 String key = cmd.getNextArgRequired();
5189 String value = cmd.getNextArgRequired();
5190 intent.putExtra(key, Uri.parse(value));
5191 }
5192 break;
5193 case "--ecn": {
5194 String key = cmd.getNextArgRequired();
5195 String value = cmd.getNextArgRequired();
5196 ComponentName cn = ComponentName.unflattenFromString(value);
5197 if (cn == null)
5198 throw new IllegalArgumentException("Bad component name: " + value);
5199 intent.putExtra(key, cn);
5200 }
5201 break;
5202 case "--eia": {
5203 String key = cmd.getNextArgRequired();
5204 String value = cmd.getNextArgRequired();
5205 String[] strings = value.split(",");
5206 int[] list = new int[strings.length];
5207 for (int i = 0; i < strings.length; i++) {
5208 list[i] = Integer.decode(strings[i]);
5209 }
5210 intent.putExtra(key, list);
5211 }
5212 break;
5213 case "--eial": {
5214 String key = cmd.getNextArgRequired();
5215 String value = cmd.getNextArgRequired();
5216 String[] strings = value.split(",");
5217 ArrayList<Integer> list = new ArrayList<>(strings.length);
5218 for (int i = 0; i < strings.length; i++) {
5219 list.add(Integer.decode(strings[i]));
5220 }
5221 intent.putExtra(key, list);
5222 }
5223 break;
5224 case "--el": {
5225 String key = cmd.getNextArgRequired();
5226 String value = cmd.getNextArgRequired();
5227 intent.putExtra(key, Long.valueOf(value));
5228 }
5229 break;
5230 case "--ela": {
5231 String key = cmd.getNextArgRequired();
5232 String value = cmd.getNextArgRequired();
5233 String[] strings = value.split(",");
5234 long[] list = new long[strings.length];
5235 for (int i = 0; i < strings.length; i++) {
5236 list[i] = Long.valueOf(strings[i]);
5237 }
5238 intent.putExtra(key, list);
5239 hasIntentInfo = true;
5240 }
5241 break;
5242 case "--elal": {
5243 String key = cmd.getNextArgRequired();
5244 String value = cmd.getNextArgRequired();
5245 String[] strings = value.split(",");
5246 ArrayList<Long> list = new ArrayList<>(strings.length);
5247 for (int i = 0; i < strings.length; i++) {
5248 list.add(Long.valueOf(strings[i]));
5249 }
5250 intent.putExtra(key, list);
5251 hasIntentInfo = true;
5252 }
5253 break;
5254 case "--ef": {
5255 String key = cmd.getNextArgRequired();
5256 String value = cmd.getNextArgRequired();
5257 intent.putExtra(key, Float.valueOf(value));
5258 hasIntentInfo = true;
5259 }
5260 break;
5261 case "--efa": {
5262 String key = cmd.getNextArgRequired();
5263 String value = cmd.getNextArgRequired();
5264 String[] strings = value.split(",");
5265 float[] list = new float[strings.length];
5266 for (int i = 0; i < strings.length; i++) {
5267 list[i] = Float.valueOf(strings[i]);
5268 }
5269 intent.putExtra(key, list);
5270 hasIntentInfo = true;
5271 }
5272 break;
5273 case "--efal": {
5274 String key = cmd.getNextArgRequired();
5275 String value = cmd.getNextArgRequired();
5276 String[] strings = value.split(",");
5277 ArrayList<Float> list = new ArrayList<>(strings.length);
5278 for (int i = 0; i < strings.length; i++) {
5279 list.add(Float.valueOf(strings[i]));
5280 }
5281 intent.putExtra(key, list);
5282 hasIntentInfo = true;
5283 }
5284 break;
5285 case "--esa": {
5286 String key = cmd.getNextArgRequired();
5287 String value = cmd.getNextArgRequired();
5288 // Split on commas unless they are preceeded by an escape.
5289 // The escape character must be escaped for the string and
5290 // again for the regex, thus four escape characters become one.
5291 String[] strings = value.split("(?<!\\\\),");
5292 intent.putExtra(key, strings);
5293 hasIntentInfo = true;
5294 }
5295 break;
5296 case "--esal": {
5297 String key = cmd.getNextArgRequired();
5298 String value = cmd.getNextArgRequired();
5299 // Split on commas unless they are preceeded by an escape.
5300 // The escape character must be escaped for the string and
5301 // again for the regex, thus four escape characters become one.
5302 String[] strings = value.split("(?<!\\\\),");
5303 ArrayList<String> list = new ArrayList<>(strings.length);
5304 for (int i = 0; i < strings.length; i++) {
5305 list.add(strings[i]);
5306 }
5307 intent.putExtra(key, list);
5308 hasIntentInfo = true;
5309 }
5310 break;
5311 case "--ez": {
5312 String key = cmd.getNextArgRequired();
5313 String value = cmd.getNextArgRequired().toLowerCase();
5314 // Boolean.valueOf() results in false for anything that is not "true", which is
5315 // error-prone in shell commands
5316 boolean arg;
5317 if ("true".equals(value) || "t".equals(value)) {
5318 arg = true;
5319 } else if ("false".equals(value) || "f".equals(value)) {
5320 arg = false;
5321 } else {
5322 try {
5323 arg = Integer.decode(value) != 0;
5324 } catch (NumberFormatException ex) {
5325 throw new IllegalArgumentException("Invalid boolean value: " + value);
5326 }
5327 }
5328
5329 intent.putExtra(key, arg);
5330 }
5331 break;
5332 case "-n": {
5333 String str = cmd.getNextArgRequired();
5334 ComponentName cn = ComponentName.unflattenFromString(str);
5335 if (cn == null)
5336 throw new IllegalArgumentException("Bad component name: " + str);
5337 intent.setComponent(cn);
5338 if (intent == baseIntent) {
5339 hasIntentInfo = true;
5340 }
5341 }
5342 break;
5343 case "-p": {
5344 String str = cmd.getNextArgRequired();
5345 intent.setPackage(str);
5346 if (intent == baseIntent) {
5347 hasIntentInfo = true;
5348 }
5349 }
5350 break;
5351 case "-f":
5352 String str = cmd.getNextArgRequired();
5353 intent.setFlags(Integer.decode(str).intValue());
5354 break;
5355 case "--grant-read-uri-permission":
5356 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5357 break;
5358 case "--grant-write-uri-permission":
5359 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5360 break;
5361 case "--grant-persistable-uri-permission":
5362 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5363 break;
5364 case "--grant-prefix-uri-permission":
5365 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5366 break;
5367 case "--exclude-stopped-packages":
5368 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5369 break;
5370 case "--include-stopped-packages":
5371 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5372 break;
5373 case "--debug-log-resolution":
5374 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5375 break;
5376 case "--activity-brought-to-front":
5377 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5378 break;
5379 case "--activity-clear-top":
5380 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5381 break;
5382 case "--activity-clear-when-task-reset":
5383 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5384 break;
5385 case "--activity-exclude-from-recents":
5386 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5387 break;
5388 case "--activity-launched-from-history":
5389 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5390 break;
5391 case "--activity-multiple-task":
5392 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5393 break;
5394 case "--activity-no-animation":
5395 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5396 break;
5397 case "--activity-no-history":
5398 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5399 break;
5400 case "--activity-no-user-action":
5401 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5402 break;
5403 case "--activity-previous-is-top":
5404 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5405 break;
5406 case "--activity-reorder-to-front":
5407 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5408 break;
5409 case "--activity-reset-task-if-needed":
5410 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5411 break;
5412 case "--activity-single-top":
5413 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5414 break;
5415 case "--activity-clear-task":
5416 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5417 break;
5418 case "--activity-task-on-home":
5419 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5420 break;
5421 case "--receiver-registered-only":
5422 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5423 break;
5424 case "--receiver-replace-pending":
5425 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5426 break;
5427 case "--selector":
5428 intent.setDataAndType(data, type);
5429 intent = new Intent();
5430 break;
5431 default:
5432 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5433 // Okay, caller handled this option.
5434 } else {
5435 throw new IllegalArgumentException("Unknown option: " + opt);
5436 }
5437 break;
5438 }
5439 }
5440 intent.setDataAndType(data, type);
5441
5442 final boolean hasSelector = intent != baseIntent;
5443 if (hasSelector) {
5444 // A selector was specified; fix up.
5445 baseIntent.setSelector(intent);
5446 intent = baseIntent;
5447 }
5448
5449 String arg = cmd.getNextArg();
5450 baseIntent = null;
5451 if (arg == null) {
5452 if (hasSelector) {
5453 // If a selector has been specified, and no arguments
5454 // have been supplied for the main Intent, then we can
5455 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5456 // need to have a component name specified yet, the
5457 // selector will take care of that.
5458 baseIntent = new Intent(Intent.ACTION_MAIN);
5459 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5460 }
5461 } else if (arg.indexOf(':') >= 0) {
5462 // The argument is a URI. Fully parse it, and use that result
5463 // to fill in any data not specified so far.
5464 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5465 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5466 } else if (arg.indexOf('/') >= 0) {
5467 // The argument is a component name. Build an Intent to launch
5468 // it.
5469 baseIntent = new Intent(Intent.ACTION_MAIN);
5470 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5471 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5472 } else {
5473 // Assume the argument is a package name.
5474 baseIntent = new Intent(Intent.ACTION_MAIN);
5475 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5476 baseIntent.setPackage(arg);
5477 }
5478 if (baseIntent != null) {
5479 Bundle extras = intent.getExtras();
5480 intent.replaceExtras((Bundle)null);
5481 Bundle uriExtras = baseIntent.getExtras();
5482 baseIntent.replaceExtras((Bundle)null);
5483 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5484 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5485 for (String c : cats) {
5486 baseIntent.removeCategory(c);
5487 }
5488 }
5489 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5490 if (extras == null) {
5491 extras = uriExtras;
5492 } else if (uriExtras != null) {
5493 uriExtras.putAll(extras);
5494 extras = uriExtras;
5495 }
5496 intent.replaceExtras(extras);
5497 hasIntentInfo = true;
5498 }
5499
5500 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5501 return intent;
5502 }
5503
5504 /** @hide */
5505 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5506 final String[] lines = new String[] {
5507 "<INTENT> specifications include these flags and arguments:",
5508 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5509 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5510 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5511 " [--esn <EXTRA_KEY> ...]",
5512 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5513 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5514 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5515 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5516 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5517 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5518 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5519 " (mutiple extras passed as Integer[])",
5520 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5521 " (mutiple extras passed as List<Integer>)",
5522 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5523 " (mutiple extras passed as Long[])",
5524 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5525 " (mutiple extras passed as List<Long>)",
5526 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5527 " (mutiple extras passed as Float[])",
5528 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5529 " (mutiple extras passed as List<Float>)",
5530 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5531 " (mutiple extras passed as String[]; to embed a comma into a string,",
5532 " escape it using \"\\,\")",
5533 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5534 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5535 " escape it using \"\\,\")",
5536 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5537 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5538 " [--debug-log-resolution] [--exclude-stopped-packages]",
5539 " [--include-stopped-packages]",
5540 " [--activity-brought-to-front] [--activity-clear-top]",
5541 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5542 " [--activity-launched-from-history] [--activity-multiple-task]",
5543 " [--activity-no-animation] [--activity-no-history]",
5544 " [--activity-no-user-action] [--activity-previous-is-top]",
5545 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5546 " [--activity-single-top] [--activity-clear-task]",
5547 " [--activity-task-on-home]",
5548 " [--receiver-registered-only] [--receiver-replace-pending]",
5549 " [--selector]",
5550 " [<URI> | <PACKAGE> | <COMPONENT>]"
5551 };
5552 for (String line : lines) {
5553 pw.print(prefix);
5554 pw.println(line);
5555 }
5556 }
5557
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005558 /**
5559 * Retrieve the general action to be performed, such as
5560 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5561 * the information in the intent should be interpreted -- most importantly,
5562 * what to do with the data returned by {@link #getData}.
5563 *
5564 * @return The action of this intent or null if none is specified.
5565 *
5566 * @see #setAction
5567 */
5568 public String getAction() {
5569 return mAction;
5570 }
5571
5572 /**
5573 * Retrieve data this intent is operating on. This URI specifies the name
5574 * of the data; often it uses the content: scheme, specifying data in a
5575 * content provider. Other schemes may be handled by specific activities,
5576 * such as http: by the web browser.
5577 *
5578 * @return The URI of the data this intent is targeting or null.
5579 *
5580 * @see #getScheme
5581 * @see #setData
5582 */
5583 public Uri getData() {
5584 return mData;
5585 }
5586
5587 /**
5588 * The same as {@link #getData()}, but returns the URI as an encoded
5589 * String.
5590 */
5591 public String getDataString() {
5592 return mData != null ? mData.toString() : null;
5593 }
5594
5595 /**
5596 * Return the scheme portion of the intent's data. If the data is null or
5597 * does not include a scheme, null is returned. Otherwise, the scheme
5598 * prefix without the final ':' is returned, i.e. "http".
5599 *
5600 * <p>This is the same as calling getData().getScheme() (and checking for
5601 * null data).
5602 *
5603 * @return The scheme of this intent.
5604 *
5605 * @see #getData
5606 */
5607 public String getScheme() {
5608 return mData != null ? mData.getScheme() : null;
5609 }
5610
5611 /**
5612 * Retrieve any explicit MIME type included in the intent. This is usually
5613 * null, as the type is determined by the intent data.
5614 *
5615 * @return If a type was manually set, it is returned; else null is
5616 * returned.
5617 *
5618 * @see #resolveType(ContentResolver)
5619 * @see #setType
5620 */
5621 public String getType() {
5622 return mType;
5623 }
5624
5625 /**
5626 * Return the MIME data type of this intent. If the type field is
5627 * explicitly set, that is simply returned. Otherwise, if the data is set,
5628 * the type of that data is returned. If neither fields are set, a null is
5629 * returned.
5630 *
5631 * @return The MIME type of this intent.
5632 *
5633 * @see #getType
5634 * @see #resolveType(ContentResolver)
5635 */
5636 public String resolveType(Context context) {
5637 return resolveType(context.getContentResolver());
5638 }
5639
5640 /**
5641 * Return the MIME data type of this intent. If the type field is
5642 * explicitly set, that is simply returned. Otherwise, if the data is set,
5643 * the type of that data is returned. If neither fields are set, a null is
5644 * returned.
5645 *
5646 * @param resolver A ContentResolver that can be used to determine the MIME
5647 * type of the intent's data.
5648 *
5649 * @return The MIME type of this intent.
5650 *
5651 * @see #getType
5652 * @see #resolveType(Context)
5653 */
5654 public String resolveType(ContentResolver resolver) {
5655 if (mType != null) {
5656 return mType;
5657 }
5658 if (mData != null) {
5659 if ("content".equals(mData.getScheme())) {
5660 return resolver.getType(mData);
5661 }
5662 }
5663 return null;
5664 }
5665
5666 /**
5667 * Return the MIME data type of this intent, only if it will be needed for
5668 * intent resolution. This is not generally useful for application code;
5669 * it is used by the frameworks for communicating with back-end system
5670 * services.
5671 *
5672 * @param resolver A ContentResolver that can be used to determine the MIME
5673 * type of the intent's data.
5674 *
5675 * @return The MIME type of this intent, or null if it is unknown or not
5676 * needed.
5677 */
5678 public String resolveTypeIfNeeded(ContentResolver resolver) {
5679 if (mComponent != null) {
5680 return mType;
5681 }
5682 return resolveType(resolver);
5683 }
5684
5685 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005686 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005687 *
5688 * @param category The category to check.
5689 *
5690 * @return boolean True if the intent contains the category, else false.
5691 *
5692 * @see #getCategories
5693 * @see #addCategory
5694 */
5695 public boolean hasCategory(String category) {
5696 return mCategories != null && mCategories.contains(category);
5697 }
5698
5699 /**
5700 * Return the set of all categories in the intent. If there are no categories,
5701 * returns NULL.
5702 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005703 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 *
5705 * @see #hasCategory
5706 * @see #addCategory
5707 */
5708 public Set<String> getCategories() {
5709 return mCategories;
5710 }
5711
5712 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005713 * Return the specific selector associated with this Intent. If there is
5714 * none, returns null. See {@link #setSelector} for more information.
5715 *
5716 * @see #setSelector
5717 */
5718 public Intent getSelector() {
5719 return mSelector;
5720 }
5721
5722 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005723 * Return the {@link ClipData} associated with this Intent. If there is
5724 * none, returns null. See {@link #setClipData} for more information.
5725 *
John Spurlock125d1332013-11-25 11:58:37 -05005726 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005727 */
5728 public ClipData getClipData() {
5729 return mClipData;
5730 }
5731
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005732 /** @hide */
5733 public int getContentUserHint() {
5734 return mContentUserHint;
5735 }
5736
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005737 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005738 * Sets the ClassLoader that will be used when unmarshalling
5739 * any Parcelable values from the extras of this Intent.
5740 *
5741 * @param loader a ClassLoader, or null to use the default loader
5742 * at the time of unmarshalling.
5743 */
5744 public void setExtrasClassLoader(ClassLoader loader) {
5745 if (mExtras != null) {
5746 mExtras.setClassLoader(loader);
5747 }
5748 }
5749
5750 /**
5751 * Returns true if an extra value is associated with the given name.
5752 * @param name the extra's name
5753 * @return true if the given extra is present.
5754 */
5755 public boolean hasExtra(String name) {
5756 return mExtras != null && mExtras.containsKey(name);
5757 }
5758
5759 /**
5760 * Returns true if the Intent's extras contain a parcelled file descriptor.
5761 * @return true if the Intent contains a parcelled file descriptor.
5762 */
5763 public boolean hasFileDescriptors() {
5764 return mExtras != null && mExtras.hasFileDescriptors();
5765 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005766
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005767 /** @hide */
5768 public void setAllowFds(boolean allowFds) {
5769 if (mExtras != null) {
5770 mExtras.setAllowFds(allowFds);
5771 }
5772 }
5773
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005774 /**
5775 * Retrieve extended data from the intent.
5776 *
5777 * @param name The name of the desired item.
5778 *
5779 * @return the value of an item that previously added with putExtra()
5780 * or null if none was found.
5781 *
5782 * @deprecated
5783 * @hide
5784 */
5785 @Deprecated
5786 public Object getExtra(String name) {
5787 return getExtra(name, null);
5788 }
5789
5790 /**
5791 * Retrieve extended data from the intent.
5792 *
5793 * @param name The name of the desired item.
5794 * @param defaultValue the value to be returned if no value of the desired
5795 * type is stored with the given name.
5796 *
5797 * @return the value of an item that previously added with putExtra()
5798 * or the default value if none was found.
5799 *
5800 * @see #putExtra(String, boolean)
5801 */
5802 public boolean getBooleanExtra(String name, boolean defaultValue) {
5803 return mExtras == null ? defaultValue :
5804 mExtras.getBoolean(name, defaultValue);
5805 }
5806
5807 /**
5808 * Retrieve extended data from the intent.
5809 *
5810 * @param name The name of the desired item.
5811 * @param defaultValue the value to be returned if no value of the desired
5812 * type is stored with the given name.
5813 *
5814 * @return the value of an item that previously added with putExtra()
5815 * or the default value if none was found.
5816 *
5817 * @see #putExtra(String, byte)
5818 */
5819 public byte getByteExtra(String name, byte defaultValue) {
5820 return mExtras == null ? defaultValue :
5821 mExtras.getByte(name, defaultValue);
5822 }
5823
5824 /**
5825 * Retrieve extended data from the intent.
5826 *
5827 * @param name The name of the desired item.
5828 * @param defaultValue the value to be returned if no value of the desired
5829 * type is stored with the given name.
5830 *
5831 * @return the value of an item that previously added with putExtra()
5832 * or the default value if none was found.
5833 *
5834 * @see #putExtra(String, short)
5835 */
5836 public short getShortExtra(String name, short defaultValue) {
5837 return mExtras == null ? defaultValue :
5838 mExtras.getShort(name, defaultValue);
5839 }
5840
5841 /**
5842 * Retrieve extended data from the intent.
5843 *
5844 * @param name The name of the desired item.
5845 * @param defaultValue the value to be returned if no value of the desired
5846 * type is stored with the given name.
5847 *
5848 * @return the value of an item that previously added with putExtra()
5849 * or the default value if none was found.
5850 *
5851 * @see #putExtra(String, char)
5852 */
5853 public char getCharExtra(String name, char defaultValue) {
5854 return mExtras == null ? defaultValue :
5855 mExtras.getChar(name, defaultValue);
5856 }
5857
5858 /**
5859 * Retrieve extended data from the intent.
5860 *
5861 * @param name The name of the desired item.
5862 * @param defaultValue the value to be returned if no value of the desired
5863 * type is stored with the given name.
5864 *
5865 * @return the value of an item that previously added with putExtra()
5866 * or the default value if none was found.
5867 *
5868 * @see #putExtra(String, int)
5869 */
5870 public int getIntExtra(String name, int defaultValue) {
5871 return mExtras == null ? defaultValue :
5872 mExtras.getInt(name, defaultValue);
5873 }
5874
5875 /**
5876 * Retrieve extended data from the intent.
5877 *
5878 * @param name The name of the desired item.
5879 * @param defaultValue the value to be returned if no value of the desired
5880 * type is stored with the given name.
5881 *
5882 * @return the value of an item that previously added with putExtra()
5883 * or the default value if none was found.
5884 *
5885 * @see #putExtra(String, long)
5886 */
5887 public long getLongExtra(String name, long defaultValue) {
5888 return mExtras == null ? defaultValue :
5889 mExtras.getLong(name, defaultValue);
5890 }
5891
5892 /**
5893 * Retrieve extended data from the intent.
5894 *
5895 * @param name The name of the desired item.
5896 * @param defaultValue the value to be returned if no value of the desired
5897 * type is stored with the given name.
5898 *
5899 * @return the value of an item that previously added with putExtra(),
5900 * or the default value if no such item is present
5901 *
5902 * @see #putExtra(String, float)
5903 */
5904 public float getFloatExtra(String name, float defaultValue) {
5905 return mExtras == null ? defaultValue :
5906 mExtras.getFloat(name, defaultValue);
5907 }
5908
5909 /**
5910 * Retrieve extended data from the intent.
5911 *
5912 * @param name The name of the desired item.
5913 * @param defaultValue the value to be returned if no value of the desired
5914 * type is stored with the given name.
5915 *
5916 * @return the value of an item that previously added with putExtra()
5917 * or the default value if none was found.
5918 *
5919 * @see #putExtra(String, double)
5920 */
5921 public double getDoubleExtra(String name, double defaultValue) {
5922 return mExtras == null ? defaultValue :
5923 mExtras.getDouble(name, defaultValue);
5924 }
5925
5926 /**
5927 * Retrieve extended data from the intent.
5928 *
5929 * @param name The name of the desired item.
5930 *
5931 * @return the value of an item that previously added with putExtra()
5932 * or null if no String value was found.
5933 *
5934 * @see #putExtra(String, String)
5935 */
5936 public String getStringExtra(String name) {
5937 return mExtras == null ? null : mExtras.getString(name);
5938 }
5939
5940 /**
5941 * Retrieve extended data from the intent.
5942 *
5943 * @param name The name of the desired item.
5944 *
5945 * @return the value of an item that previously added with putExtra()
5946 * or null if no CharSequence value was found.
5947 *
5948 * @see #putExtra(String, CharSequence)
5949 */
5950 public CharSequence getCharSequenceExtra(String name) {
5951 return mExtras == null ? null : mExtras.getCharSequence(name);
5952 }
5953
5954 /**
5955 * Retrieve extended data from the intent.
5956 *
5957 * @param name The name of the desired item.
5958 *
5959 * @return the value of an item that previously added with putExtra()
5960 * or null if no Parcelable value was found.
5961 *
5962 * @see #putExtra(String, Parcelable)
5963 */
5964 public <T extends Parcelable> T getParcelableExtra(String name) {
5965 return mExtras == null ? null : mExtras.<T>getParcelable(name);
5966 }
5967
5968 /**
5969 * Retrieve extended data from the intent.
5970 *
5971 * @param name The name of the desired item.
5972 *
5973 * @return the value of an item that previously added with putExtra()
5974 * or null if no Parcelable[] value was found.
5975 *
5976 * @see #putExtra(String, Parcelable[])
5977 */
5978 public Parcelable[] getParcelableArrayExtra(String name) {
5979 return mExtras == null ? null : mExtras.getParcelableArray(name);
5980 }
5981
5982 /**
5983 * Retrieve extended data from the intent.
5984 *
5985 * @param name The name of the desired item.
5986 *
5987 * @return the value of an item that previously added with putExtra()
5988 * or null if no ArrayList<Parcelable> value was found.
5989 *
5990 * @see #putParcelableArrayListExtra(String, ArrayList)
5991 */
5992 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
5993 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
5994 }
5995
5996 /**
5997 * Retrieve extended data from the intent.
5998 *
5999 * @param name The name of the desired item.
6000 *
6001 * @return the value of an item that previously added with putExtra()
6002 * or null if no Serializable value was found.
6003 *
6004 * @see #putExtra(String, Serializable)
6005 */
6006 public Serializable getSerializableExtra(String name) {
6007 return mExtras == null ? null : mExtras.getSerializable(name);
6008 }
6009
6010 /**
6011 * Retrieve extended data from the intent.
6012 *
6013 * @param name The name of the desired item.
6014 *
6015 * @return the value of an item that previously added with putExtra()
6016 * or null if no ArrayList<Integer> value was found.
6017 *
6018 * @see #putIntegerArrayListExtra(String, ArrayList)
6019 */
6020 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6021 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6022 }
6023
6024 /**
6025 * Retrieve extended data from the intent.
6026 *
6027 * @param name The name of the desired item.
6028 *
6029 * @return the value of an item that previously added with putExtra()
6030 * or null if no ArrayList<String> value was found.
6031 *
6032 * @see #putStringArrayListExtra(String, ArrayList)
6033 */
6034 public ArrayList<String> getStringArrayListExtra(String name) {
6035 return mExtras == null ? null : mExtras.getStringArrayList(name);
6036 }
6037
6038 /**
6039 * Retrieve extended data from the intent.
6040 *
6041 * @param name The name of the desired item.
6042 *
6043 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006044 * or null if no ArrayList<CharSequence> value was found.
6045 *
6046 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6047 */
6048 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6049 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6050 }
6051
6052 /**
6053 * Retrieve extended data from the intent.
6054 *
6055 * @param name The name of the desired item.
6056 *
6057 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006058 * or null if no boolean array value was found.
6059 *
6060 * @see #putExtra(String, boolean[])
6061 */
6062 public boolean[] getBooleanArrayExtra(String name) {
6063 return mExtras == null ? null : mExtras.getBooleanArray(name);
6064 }
6065
6066 /**
6067 * Retrieve extended data from the intent.
6068 *
6069 * @param name The name of the desired item.
6070 *
6071 * @return the value of an item that previously added with putExtra()
6072 * or null if no byte array value was found.
6073 *
6074 * @see #putExtra(String, byte[])
6075 */
6076 public byte[] getByteArrayExtra(String name) {
6077 return mExtras == null ? null : mExtras.getByteArray(name);
6078 }
6079
6080 /**
6081 * Retrieve extended data from the intent.
6082 *
6083 * @param name The name of the desired item.
6084 *
6085 * @return the value of an item that previously added with putExtra()
6086 * or null if no short array value was found.
6087 *
6088 * @see #putExtra(String, short[])
6089 */
6090 public short[] getShortArrayExtra(String name) {
6091 return mExtras == null ? null : mExtras.getShortArray(name);
6092 }
6093
6094 /**
6095 * Retrieve extended data from the intent.
6096 *
6097 * @param name The name of the desired item.
6098 *
6099 * @return the value of an item that previously added with putExtra()
6100 * or null if no char array value was found.
6101 *
6102 * @see #putExtra(String, char[])
6103 */
6104 public char[] getCharArrayExtra(String name) {
6105 return mExtras == null ? null : mExtras.getCharArray(name);
6106 }
6107
6108 /**
6109 * Retrieve extended data from the intent.
6110 *
6111 * @param name The name of the desired item.
6112 *
6113 * @return the value of an item that previously added with putExtra()
6114 * or null if no int array value was found.
6115 *
6116 * @see #putExtra(String, int[])
6117 */
6118 public int[] getIntArrayExtra(String name) {
6119 return mExtras == null ? null : mExtras.getIntArray(name);
6120 }
6121
6122 /**
6123 * Retrieve extended data from the intent.
6124 *
6125 * @param name The name of the desired item.
6126 *
6127 * @return the value of an item that previously added with putExtra()
6128 * or null if no long array value was found.
6129 *
6130 * @see #putExtra(String, long[])
6131 */
6132 public long[] getLongArrayExtra(String name) {
6133 return mExtras == null ? null : mExtras.getLongArray(name);
6134 }
6135
6136 /**
6137 * Retrieve extended data from the intent.
6138 *
6139 * @param name The name of the desired item.
6140 *
6141 * @return the value of an item that previously added with putExtra()
6142 * or null if no float array value was found.
6143 *
6144 * @see #putExtra(String, float[])
6145 */
6146 public float[] getFloatArrayExtra(String name) {
6147 return mExtras == null ? null : mExtras.getFloatArray(name);
6148 }
6149
6150 /**
6151 * Retrieve extended data from the intent.
6152 *
6153 * @param name The name of the desired item.
6154 *
6155 * @return the value of an item that previously added with putExtra()
6156 * or null if no double array value was found.
6157 *
6158 * @see #putExtra(String, double[])
6159 */
6160 public double[] getDoubleArrayExtra(String name) {
6161 return mExtras == null ? null : mExtras.getDoubleArray(name);
6162 }
6163
6164 /**
6165 * Retrieve extended data from the intent.
6166 *
6167 * @param name The name of the desired item.
6168 *
6169 * @return the value of an item that previously added with putExtra()
6170 * or null if no String array value was found.
6171 *
6172 * @see #putExtra(String, String[])
6173 */
6174 public String[] getStringArrayExtra(String name) {
6175 return mExtras == null ? null : mExtras.getStringArray(name);
6176 }
6177
6178 /**
6179 * Retrieve extended data from the intent.
6180 *
6181 * @param name The name of the desired item.
6182 *
6183 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006184 * or null if no CharSequence array value was found.
6185 *
6186 * @see #putExtra(String, CharSequence[])
6187 */
6188 public CharSequence[] getCharSequenceArrayExtra(String name) {
6189 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6190 }
6191
6192 /**
6193 * Retrieve extended data from the intent.
6194 *
6195 * @param name The name of the desired item.
6196 *
6197 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006198 * or null if no Bundle value was found.
6199 *
6200 * @see #putExtra(String, Bundle)
6201 */
6202 public Bundle getBundleExtra(String name) {
6203 return mExtras == null ? null : mExtras.getBundle(name);
6204 }
6205
6206 /**
6207 * Retrieve extended data from the intent.
6208 *
6209 * @param name The name of the desired item.
6210 *
6211 * @return the value of an item that previously added with putExtra()
6212 * or null if no IBinder value was found.
6213 *
6214 * @see #putExtra(String, IBinder)
6215 *
6216 * @deprecated
6217 * @hide
6218 */
6219 @Deprecated
6220 public IBinder getIBinderExtra(String name) {
6221 return mExtras == null ? null : mExtras.getIBinder(name);
6222 }
6223
6224 /**
6225 * Retrieve extended data from the intent.
6226 *
6227 * @param name The name of the desired item.
6228 * @param defaultValue The default value to return in case no item is
6229 * associated with the key 'name'
6230 *
6231 * @return the value of an item that previously added with putExtra()
6232 * or defaultValue if none was found.
6233 *
6234 * @see #putExtra
6235 *
6236 * @deprecated
6237 * @hide
6238 */
6239 @Deprecated
6240 public Object getExtra(String name, Object defaultValue) {
6241 Object result = defaultValue;
6242 if (mExtras != null) {
6243 Object result2 = mExtras.get(name);
6244 if (result2 != null) {
6245 result = result2;
6246 }
6247 }
6248
6249 return result;
6250 }
6251
6252 /**
6253 * Retrieves a map of extended data from the intent.
6254 *
6255 * @return the map of all extras previously added with putExtra(),
6256 * or null if none have been added.
6257 */
6258 public Bundle getExtras() {
6259 return (mExtras != null)
6260 ? new Bundle(mExtras)
6261 : null;
6262 }
6263
6264 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006265 * Filter extras to only basic types.
6266 * @hide
6267 */
6268 public void removeUnsafeExtras() {
6269 if (mExtras != null) {
6270 mExtras.filterValues();
6271 }
6272 }
6273
6274 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006275 * Retrieve any special flags associated with this intent. You will
6276 * normally just set them with {@link #setFlags} and let the system
6277 * take the appropriate action with them.
6278 *
6279 * @return int The currently set flags.
6280 *
6281 * @see #setFlags
6282 */
6283 public int getFlags() {
6284 return mFlags;
6285 }
6286
Dianne Hackborne7f97212011-02-24 14:40:20 -08006287 /** @hide */
6288 public boolean isExcludingStopped() {
6289 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6290 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6291 }
6292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006293 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006294 * Retrieve the application package name this Intent is limited to. When
6295 * resolving an Intent, if non-null this limits the resolution to only
6296 * components in the given application package.
6297 *
6298 * @return The name of the application package for the Intent.
6299 *
6300 * @see #resolveActivity
6301 * @see #setPackage
6302 */
6303 public String getPackage() {
6304 return mPackage;
6305 }
6306
6307 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006308 * Retrieve the concrete component associated with the intent. When receiving
6309 * an intent, this is the component that was found to best handle it (that is,
6310 * yourself) and will always be non-null; in all other cases it will be
6311 * null unless explicitly set.
6312 *
6313 * @return The name of the application component to handle the intent.
6314 *
6315 * @see #resolveActivity
6316 * @see #setComponent
6317 */
6318 public ComponentName getComponent() {
6319 return mComponent;
6320 }
6321
6322 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006323 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6324 * used as a hint to the receiver for animations and the like. Null means that there
6325 * is no source bounds.
6326 */
6327 public Rect getSourceBounds() {
6328 return mSourceBounds;
6329 }
6330
6331 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006332 * Return the Activity component that should be used to handle this intent.
6333 * The appropriate component is determined based on the information in the
6334 * intent, evaluated as follows:
6335 *
6336 * <p>If {@link #getComponent} returns an explicit class, that is returned
6337 * without any further consideration.
6338 *
6339 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6340 * category to be considered.
6341 *
6342 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6343 * action.
6344 *
6345 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6346 * this type.
6347 *
6348 * <p>If {@link #addCategory} has added any categories, the activity must
6349 * handle ALL of the categories specified.
6350 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006351 * <p>If {@link #getPackage} is non-NULL, only activity components in
6352 * that application package will be considered.
6353 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006354 * <p>If there are no activities that satisfy all of these conditions, a
6355 * null string is returned.
6356 *
6357 * <p>If multiple activities are found to satisfy the intent, the one with
6358 * the highest priority will be used. If there are multiple activities
6359 * with the same priority, the system will either pick the best activity
6360 * based on user preference, or resolve to a system class that will allow
6361 * the user to pick an activity and forward from there.
6362 *
6363 * <p>This method is implemented simply by calling
6364 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6365 * true.</p>
6366 * <p> This API is called for you as part of starting an activity from an
6367 * intent. You do not normally need to call it yourself.</p>
6368 *
6369 * @param pm The package manager with which to resolve the Intent.
6370 *
6371 * @return Name of the component implementing an activity that can
6372 * display the intent.
6373 *
6374 * @see #setComponent
6375 * @see #getComponent
6376 * @see #resolveActivityInfo
6377 */
6378 public ComponentName resolveActivity(PackageManager pm) {
6379 if (mComponent != null) {
6380 return mComponent;
6381 }
6382
6383 ResolveInfo info = pm.resolveActivity(
6384 this, PackageManager.MATCH_DEFAULT_ONLY);
6385 if (info != null) {
6386 return new ComponentName(
6387 info.activityInfo.applicationInfo.packageName,
6388 info.activityInfo.name);
6389 }
6390
6391 return null;
6392 }
6393
6394 /**
6395 * Resolve the Intent into an {@link ActivityInfo}
6396 * describing the activity that should execute the intent. Resolution
6397 * follows the same rules as described for {@link #resolveActivity}, but
6398 * you get back the completely information about the resolved activity
6399 * instead of just its class name.
6400 *
6401 * @param pm The package manager with which to resolve the Intent.
6402 * @param flags Addition information to retrieve as per
6403 * {@link PackageManager#getActivityInfo(ComponentName, int)
6404 * PackageManager.getActivityInfo()}.
6405 *
6406 * @return PackageManager.ActivityInfo
6407 *
6408 * @see #resolveActivity
6409 */
6410 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6411 ActivityInfo ai = null;
6412 if (mComponent != null) {
6413 try {
6414 ai = pm.getActivityInfo(mComponent, flags);
6415 } catch (PackageManager.NameNotFoundException e) {
6416 // ignore
6417 }
6418 } else {
6419 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006420 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006421 if (info != null) {
6422 ai = info.activityInfo;
6423 }
6424 }
6425
6426 return ai;
6427 }
6428
6429 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006430 * Special function for use by the system to resolve service
6431 * intents to system apps. Throws an exception if there are
6432 * multiple potential matches to the Intent. Returns null if
6433 * there are no matches.
6434 * @hide
6435 */
6436 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6437 if (mComponent != null) {
6438 return mComponent;
6439 }
6440
6441 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6442 if (results == null) {
6443 return null;
6444 }
6445 ComponentName comp = null;
6446 for (int i=0; i<results.size(); i++) {
6447 ResolveInfo ri = results.get(i);
6448 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6449 continue;
6450 }
6451 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6452 ri.serviceInfo.name);
6453 if (comp != null) {
6454 throw new IllegalStateException("Multiple system services handle " + this
6455 + ": " + comp + ", " + foundComp);
6456 }
6457 comp = foundComp;
6458 }
6459 return comp;
6460 }
6461
6462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006463 * Set the general action to be performed.
6464 *
6465 * @param action An action name, such as ACTION_VIEW. Application-specific
6466 * actions should be prefixed with the vendor's package name.
6467 *
6468 * @return Returns the same Intent object, for chaining multiple calls
6469 * into a single statement.
6470 *
6471 * @see #getAction
6472 */
6473 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006474 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006475 return this;
6476 }
6477
6478 /**
6479 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006480 * clears any type that was previously set by {@link #setType} or
6481 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006482 *
Nick Pellyccae4122012-01-09 14:12:58 -08006483 * <p><em>Note: scheme matching in the Android framework is
6484 * case-sensitive, unlike the formal RFC. As a result,
6485 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006486 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006487 * {@link #setDataAndNormalize}
6488 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006489 *
Nick Pellyccae4122012-01-09 14:12:58 -08006490 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006491 *
6492 * @return Returns the same Intent object, for chaining multiple calls
6493 * into a single statement.
6494 *
6495 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006496 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006497 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006498 */
6499 public Intent setData(Uri data) {
6500 mData = data;
6501 mType = null;
6502 return this;
6503 }
6504
6505 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006506 * Normalize and set the data this intent is operating on.
6507 *
6508 * <p>This method automatically clears any type that was
6509 * previously set (for example, by {@link #setType}).
6510 *
6511 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006512 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006513 * so really this is just a convenience method for
6514 * <pre>
6515 * setData(data.normalize())
6516 * </pre>
6517 *
6518 * @param data The Uri of the data this intent is now targeting.
6519 *
6520 * @return Returns the same Intent object, for chaining multiple calls
6521 * into a single statement.
6522 *
6523 * @see #getData
6524 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006525 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006526 */
6527 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006528 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006529 }
6530
6531 /**
6532 * Set an explicit MIME data type.
6533 *
6534 * <p>This is used to create intents that only specify a type and not data,
6535 * for example to indicate the type of data to return.
6536 *
6537 * <p>This method automatically clears any data that was
6538 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006539 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006540 * <p><em>Note: MIME type matching in the Android framework is
6541 * case-sensitive, unlike formal RFC MIME types. As a result,
6542 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006543 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6544 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006545 *
6546 * @param type The MIME type of the data being handled by this intent.
6547 *
6548 * @return Returns the same Intent object, for chaining multiple calls
6549 * into a single statement.
6550 *
6551 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006552 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006553 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006554 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006555 */
6556 public Intent setType(String type) {
6557 mData = null;
6558 mType = type;
6559 return this;
6560 }
6561
6562 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006563 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006564 *
Nick Pellyccae4122012-01-09 14:12:58 -08006565 * <p>This is used to create intents that only specify a type and not data,
6566 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006567 *
Nick Pellyccae4122012-01-09 14:12:58 -08006568 * <p>This method automatically clears any data that was
6569 * previously set (for example by {@link #setData}).
6570 *
6571 * <p>The MIME type is normalized using
6572 * {@link #normalizeMimeType} before it is set,
6573 * so really this is just a convenience method for
6574 * <pre>
6575 * setType(Intent.normalizeMimeType(type))
6576 * </pre>
6577 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006578 * @param type The MIME type of the data being handled by this intent.
6579 *
6580 * @return Returns the same Intent object, for chaining multiple calls
6581 * into a single statement.
6582 *
Nick Pellyccae4122012-01-09 14:12:58 -08006583 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006584 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006585 * @see #normalizeMimeType
6586 */
6587 public Intent setTypeAndNormalize(String type) {
6588 return setType(normalizeMimeType(type));
6589 }
6590
6591 /**
6592 * (Usually optional) Set the data for the intent along with an explicit
6593 * MIME data type. This method should very rarely be used -- it allows you
6594 * to override the MIME type that would ordinarily be inferred from the
6595 * data with your own type given here.
6596 *
6597 * <p><em>Note: MIME type and Uri scheme matching in the
6598 * Android framework is case-sensitive, unlike the formal RFC definitions.
6599 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006600 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006601 * {@link #setDataAndTypeAndNormalize}
6602 * to ensure that they are converted to lower case.</em>
6603 *
6604 * @param data The Uri of the data this intent is now targeting.
6605 * @param type The MIME type of the data being handled by this intent.
6606 *
6607 * @return Returns the same Intent object, for chaining multiple calls
6608 * into a single statement.
6609 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006610 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006611 * @see #setData
6612 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006613 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006614 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006615 */
6616 public Intent setDataAndType(Uri data, String type) {
6617 mData = data;
6618 mType = type;
6619 return this;
6620 }
6621
6622 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006623 * (Usually optional) Normalize and set both the data Uri and an explicit
6624 * MIME data type. This method should very rarely be used -- it allows you
6625 * to override the MIME type that would ordinarily be inferred from the
6626 * data with your own type given here.
6627 *
6628 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006629 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006630 * before they are set, so really this is just a convenience method for
6631 * <pre>
6632 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6633 * </pre>
6634 *
6635 * @param data The Uri of the data this intent is now targeting.
6636 * @param type The MIME type of the data being handled by this intent.
6637 *
6638 * @return Returns the same Intent object, for chaining multiple calls
6639 * into a single statement.
6640 *
6641 * @see #setType
6642 * @see #setData
6643 * @see #setDataAndType
6644 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006645 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006646 */
6647 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006648 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006649 }
6650
6651 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006652 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006653 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006654 * activities that provide <em>all</em> of the requested categories will be
6655 * used.
6656 *
6657 * @param category The desired category. This can be either one of the
6658 * predefined Intent categories, or a custom category in your own
6659 * namespace.
6660 *
6661 * @return Returns the same Intent object, for chaining multiple calls
6662 * into a single statement.
6663 *
6664 * @see #hasCategory
6665 * @see #removeCategory
6666 */
6667 public Intent addCategory(String category) {
6668 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006669 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006670 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006671 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006672 return this;
6673 }
6674
6675 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006676 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006677 *
6678 * @param category The category to remove.
6679 *
6680 * @see #addCategory
6681 */
6682 public void removeCategory(String category) {
6683 if (mCategories != null) {
6684 mCategories.remove(category);
6685 if (mCategories.size() == 0) {
6686 mCategories = null;
6687 }
6688 }
6689 }
6690
6691 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006692 * Set a selector for this Intent. This is a modification to the kinds of
6693 * things the Intent will match. If the selector is set, it will be used
6694 * when trying to find entities that can handle the Intent, instead of the
6695 * main contents of the Intent. This allows you build an Intent containing
6696 * a generic protocol while targeting it more specifically.
6697 *
6698 * <p>An example of where this may be used is with things like
6699 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6700 * Intent that will launch the Browser application. However, the correct
6701 * main entry point of an application is actually {@link #ACTION_MAIN}
6702 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6703 * used to specify the actual Activity to launch. If you launch the browser
6704 * with something different, undesired behavior may happen if the user has
6705 * previously or later launches it the normal way, since they do not match.
6706 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6707 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6708 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6709 *
6710 * <p>Setting a selector does not impact the behavior of
6711 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6712 * desired behavior of a selector -- it does not impact the base meaning
6713 * of the Intent, just what kinds of things will be matched against it
6714 * when determining who can handle it.</p>
6715 *
6716 * <p>You can not use both a selector and {@link #setPackage(String)} on
6717 * the same base Intent.</p>
6718 *
6719 * @param selector The desired selector Intent; set to null to not use
6720 * a special selector.
6721 */
6722 public void setSelector(Intent selector) {
6723 if (selector == this) {
6724 throw new IllegalArgumentException(
6725 "Intent being set as a selector of itself");
6726 }
6727 if (selector != null && mPackage != null) {
6728 throw new IllegalArgumentException(
6729 "Can't set selector when package name is already set");
6730 }
6731 mSelector = selector;
6732 }
6733
6734 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006735 * Set a {@link ClipData} associated with this Intent. This replaces any
6736 * previously set ClipData.
6737 *
6738 * <p>The ClipData in an intent is not used for Intent matching or other
6739 * such operations. Semantically it is like extras, used to transmit
6740 * additional data with the Intent. The main feature of using this over
6741 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6742 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6743 * items included in the clip data. This is useful, in particular, if
6744 * you want to transmit an Intent containing multiple <code>content:</code>
6745 * URIs for which the recipient may not have global permission to access the
6746 * content provider.
6747 *
6748 * <p>If the ClipData contains items that are themselves Intents, any
6749 * grant flags in those Intents will be ignored. Only the top-level flags
6750 * of the main Intent are respected, and will be applied to all Uri or
6751 * Intent items in the clip (or sub-items of the clip).
6752 *
6753 * <p>The MIME type, label, and icon in the ClipData object are not
6754 * directly used by Intent. Applications should generally rely on the
6755 * MIME type of the Intent itself, not what it may find in the ClipData.
6756 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006757 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006758 *
6759 * @param clip The new clip to set. May be null to clear the current clip.
6760 */
6761 public void setClipData(ClipData clip) {
6762 mClipData = clip;
6763 }
6764
6765 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006766 * This is NOT a secure mechanism to identify the user who sent the intent.
6767 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6768 * who sent the intent.
6769 * @hide
6770 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01006771 public void prepareToLeaveUser(int userId) {
6772 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
6773 // We want mContentUserHint to refer to the original user, so don't do anything.
6774 if (mContentUserHint == UserHandle.USER_CURRENT) {
6775 mContentUserHint = userId;
6776 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006777 }
6778
6779 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006780 * Add extended data to the intent. The name must include a package
6781 * prefix, for example the app com.android.contacts would use names
6782 * like "com.android.contacts.ShowAll".
6783 *
6784 * @param name The name of the extra data, with package prefix.
6785 * @param value The boolean data value.
6786 *
6787 * @return Returns the same Intent object, for chaining multiple calls
6788 * into a single statement.
6789 *
6790 * @see #putExtras
6791 * @see #removeExtra
6792 * @see #getBooleanExtra(String, boolean)
6793 */
6794 public Intent putExtra(String name, boolean value) {
6795 if (mExtras == null) {
6796 mExtras = new Bundle();
6797 }
6798 mExtras.putBoolean(name, value);
6799 return this;
6800 }
6801
6802 /**
6803 * Add extended data to the intent. The name must include a package
6804 * prefix, for example the app com.android.contacts would use names
6805 * like "com.android.contacts.ShowAll".
6806 *
6807 * @param name The name of the extra data, with package prefix.
6808 * @param value The byte data value.
6809 *
6810 * @return Returns the same Intent object, for chaining multiple calls
6811 * into a single statement.
6812 *
6813 * @see #putExtras
6814 * @see #removeExtra
6815 * @see #getByteExtra(String, byte)
6816 */
6817 public Intent putExtra(String name, byte value) {
6818 if (mExtras == null) {
6819 mExtras = new Bundle();
6820 }
6821 mExtras.putByte(name, value);
6822 return this;
6823 }
6824
6825 /**
6826 * Add extended data to the intent. The name must include a package
6827 * prefix, for example the app com.android.contacts would use names
6828 * like "com.android.contacts.ShowAll".
6829 *
6830 * @param name The name of the extra data, with package prefix.
6831 * @param value The char data value.
6832 *
6833 * @return Returns the same Intent object, for chaining multiple calls
6834 * into a single statement.
6835 *
6836 * @see #putExtras
6837 * @see #removeExtra
6838 * @see #getCharExtra(String, char)
6839 */
6840 public Intent putExtra(String name, char value) {
6841 if (mExtras == null) {
6842 mExtras = new Bundle();
6843 }
6844 mExtras.putChar(name, value);
6845 return this;
6846 }
6847
6848 /**
6849 * Add extended data to the intent. The name must include a package
6850 * prefix, for example the app com.android.contacts would use names
6851 * like "com.android.contacts.ShowAll".
6852 *
6853 * @param name The name of the extra data, with package prefix.
6854 * @param value The short data value.
6855 *
6856 * @return Returns the same Intent object, for chaining multiple calls
6857 * into a single statement.
6858 *
6859 * @see #putExtras
6860 * @see #removeExtra
6861 * @see #getShortExtra(String, short)
6862 */
6863 public Intent putExtra(String name, short value) {
6864 if (mExtras == null) {
6865 mExtras = new Bundle();
6866 }
6867 mExtras.putShort(name, value);
6868 return this;
6869 }
6870
6871 /**
6872 * Add extended data to the intent. The name must include a package
6873 * prefix, for example the app com.android.contacts would use names
6874 * like "com.android.contacts.ShowAll".
6875 *
6876 * @param name The name of the extra data, with package prefix.
6877 * @param value The integer data value.
6878 *
6879 * @return Returns the same Intent object, for chaining multiple calls
6880 * into a single statement.
6881 *
6882 * @see #putExtras
6883 * @see #removeExtra
6884 * @see #getIntExtra(String, int)
6885 */
6886 public Intent putExtra(String name, int value) {
6887 if (mExtras == null) {
6888 mExtras = new Bundle();
6889 }
6890 mExtras.putInt(name, value);
6891 return this;
6892 }
6893
6894 /**
6895 * Add extended data to the intent. The name must include a package
6896 * prefix, for example the app com.android.contacts would use names
6897 * like "com.android.contacts.ShowAll".
6898 *
6899 * @param name The name of the extra data, with package prefix.
6900 * @param value The long data value.
6901 *
6902 * @return Returns the same Intent object, for chaining multiple calls
6903 * into a single statement.
6904 *
6905 * @see #putExtras
6906 * @see #removeExtra
6907 * @see #getLongExtra(String, long)
6908 */
6909 public Intent putExtra(String name, long value) {
6910 if (mExtras == null) {
6911 mExtras = new Bundle();
6912 }
6913 mExtras.putLong(name, value);
6914 return this;
6915 }
6916
6917 /**
6918 * Add extended data to the intent. The name must include a package
6919 * prefix, for example the app com.android.contacts would use names
6920 * like "com.android.contacts.ShowAll".
6921 *
6922 * @param name The name of the extra data, with package prefix.
6923 * @param value The float data value.
6924 *
6925 * @return Returns the same Intent object, for chaining multiple calls
6926 * into a single statement.
6927 *
6928 * @see #putExtras
6929 * @see #removeExtra
6930 * @see #getFloatExtra(String, float)
6931 */
6932 public Intent putExtra(String name, float value) {
6933 if (mExtras == null) {
6934 mExtras = new Bundle();
6935 }
6936 mExtras.putFloat(name, value);
6937 return this;
6938 }
6939
6940 /**
6941 * Add extended data to the intent. The name must include a package
6942 * prefix, for example the app com.android.contacts would use names
6943 * like "com.android.contacts.ShowAll".
6944 *
6945 * @param name The name of the extra data, with package prefix.
6946 * @param value The double data value.
6947 *
6948 * @return Returns the same Intent object, for chaining multiple calls
6949 * into a single statement.
6950 *
6951 * @see #putExtras
6952 * @see #removeExtra
6953 * @see #getDoubleExtra(String, double)
6954 */
6955 public Intent putExtra(String name, double value) {
6956 if (mExtras == null) {
6957 mExtras = new Bundle();
6958 }
6959 mExtras.putDouble(name, value);
6960 return this;
6961 }
6962
6963 /**
6964 * Add extended data to the intent. The name must include a package
6965 * prefix, for example the app com.android.contacts would use names
6966 * like "com.android.contacts.ShowAll".
6967 *
6968 * @param name The name of the extra data, with package prefix.
6969 * @param value The String data value.
6970 *
6971 * @return Returns the same Intent object, for chaining multiple calls
6972 * into a single statement.
6973 *
6974 * @see #putExtras
6975 * @see #removeExtra
6976 * @see #getStringExtra(String)
6977 */
6978 public Intent putExtra(String name, String value) {
6979 if (mExtras == null) {
6980 mExtras = new Bundle();
6981 }
6982 mExtras.putString(name, value);
6983 return this;
6984 }
6985
6986 /**
6987 * Add extended data to the intent. The name must include a package
6988 * prefix, for example the app com.android.contacts would use names
6989 * like "com.android.contacts.ShowAll".
6990 *
6991 * @param name The name of the extra data, with package prefix.
6992 * @param value The CharSequence data value.
6993 *
6994 * @return Returns the same Intent object, for chaining multiple calls
6995 * into a single statement.
6996 *
6997 * @see #putExtras
6998 * @see #removeExtra
6999 * @see #getCharSequenceExtra(String)
7000 */
7001 public Intent putExtra(String name, CharSequence value) {
7002 if (mExtras == null) {
7003 mExtras = new Bundle();
7004 }
7005 mExtras.putCharSequence(name, value);
7006 return this;
7007 }
7008
7009 /**
7010 * Add extended data to the intent. The name must include a package
7011 * prefix, for example the app com.android.contacts would use names
7012 * like "com.android.contacts.ShowAll".
7013 *
7014 * @param name The name of the extra data, with package prefix.
7015 * @param value The Parcelable data value.
7016 *
7017 * @return Returns the same Intent object, for chaining multiple calls
7018 * into a single statement.
7019 *
7020 * @see #putExtras
7021 * @see #removeExtra
7022 * @see #getParcelableExtra(String)
7023 */
7024 public Intent putExtra(String name, Parcelable value) {
7025 if (mExtras == null) {
7026 mExtras = new Bundle();
7027 }
7028 mExtras.putParcelable(name, value);
7029 return this;
7030 }
7031
7032 /**
7033 * Add extended data to the intent. The name must include a package
7034 * prefix, for example the app com.android.contacts would use names
7035 * like "com.android.contacts.ShowAll".
7036 *
7037 * @param name The name of the extra data, with package prefix.
7038 * @param value The Parcelable[] data value.
7039 *
7040 * @return Returns the same Intent object, for chaining multiple calls
7041 * into a single statement.
7042 *
7043 * @see #putExtras
7044 * @see #removeExtra
7045 * @see #getParcelableArrayExtra(String)
7046 */
7047 public Intent putExtra(String name, Parcelable[] value) {
7048 if (mExtras == null) {
7049 mExtras = new Bundle();
7050 }
7051 mExtras.putParcelableArray(name, value);
7052 return this;
7053 }
7054
7055 /**
7056 * Add extended data to the intent. The name must include a package
7057 * prefix, for example the app com.android.contacts would use names
7058 * like "com.android.contacts.ShowAll".
7059 *
7060 * @param name The name of the extra data, with package prefix.
7061 * @param value The ArrayList<Parcelable> data value.
7062 *
7063 * @return Returns the same Intent object, for chaining multiple calls
7064 * into a single statement.
7065 *
7066 * @see #putExtras
7067 * @see #removeExtra
7068 * @see #getParcelableArrayListExtra(String)
7069 */
7070 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7071 if (mExtras == null) {
7072 mExtras = new Bundle();
7073 }
7074 mExtras.putParcelableArrayList(name, value);
7075 return this;
7076 }
7077
7078 /**
7079 * Add extended data to the intent. The name must include a package
7080 * prefix, for example the app com.android.contacts would use names
7081 * like "com.android.contacts.ShowAll".
7082 *
7083 * @param name The name of the extra data, with package prefix.
7084 * @param value The ArrayList<Integer> data value.
7085 *
7086 * @return Returns the same Intent object, for chaining multiple calls
7087 * into a single statement.
7088 *
7089 * @see #putExtras
7090 * @see #removeExtra
7091 * @see #getIntegerArrayListExtra(String)
7092 */
7093 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7094 if (mExtras == null) {
7095 mExtras = new Bundle();
7096 }
7097 mExtras.putIntegerArrayList(name, value);
7098 return this;
7099 }
7100
7101 /**
7102 * Add extended data to the intent. The name must include a package
7103 * prefix, for example the app com.android.contacts would use names
7104 * like "com.android.contacts.ShowAll".
7105 *
7106 * @param name The name of the extra data, with package prefix.
7107 * @param value The ArrayList<String> data value.
7108 *
7109 * @return Returns the same Intent object, for chaining multiple calls
7110 * into a single statement.
7111 *
7112 * @see #putExtras
7113 * @see #removeExtra
7114 * @see #getStringArrayListExtra(String)
7115 */
7116 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7117 if (mExtras == null) {
7118 mExtras = new Bundle();
7119 }
7120 mExtras.putStringArrayList(name, value);
7121 return this;
7122 }
7123
7124 /**
7125 * Add extended data to the intent. The name must include a package
7126 * prefix, for example the app com.android.contacts would use names
7127 * like "com.android.contacts.ShowAll".
7128 *
7129 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007130 * @param value The ArrayList<CharSequence> data value.
7131 *
7132 * @return Returns the same Intent object, for chaining multiple calls
7133 * into a single statement.
7134 *
7135 * @see #putExtras
7136 * @see #removeExtra
7137 * @see #getCharSequenceArrayListExtra(String)
7138 */
7139 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7140 if (mExtras == null) {
7141 mExtras = new Bundle();
7142 }
7143 mExtras.putCharSequenceArrayList(name, value);
7144 return this;
7145 }
7146
7147 /**
7148 * Add extended data to the intent. The name must include a package
7149 * prefix, for example the app com.android.contacts would use names
7150 * like "com.android.contacts.ShowAll".
7151 *
7152 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007153 * @param value The Serializable data value.
7154 *
7155 * @return Returns the same Intent object, for chaining multiple calls
7156 * into a single statement.
7157 *
7158 * @see #putExtras
7159 * @see #removeExtra
7160 * @see #getSerializableExtra(String)
7161 */
7162 public Intent putExtra(String name, Serializable value) {
7163 if (mExtras == null) {
7164 mExtras = new Bundle();
7165 }
7166 mExtras.putSerializable(name, value);
7167 return this;
7168 }
7169
7170 /**
7171 * Add extended data to the intent. The name must include a package
7172 * prefix, for example the app com.android.contacts would use names
7173 * like "com.android.contacts.ShowAll".
7174 *
7175 * @param name The name of the extra data, with package prefix.
7176 * @param value The boolean array data value.
7177 *
7178 * @return Returns the same Intent object, for chaining multiple calls
7179 * into a single statement.
7180 *
7181 * @see #putExtras
7182 * @see #removeExtra
7183 * @see #getBooleanArrayExtra(String)
7184 */
7185 public Intent putExtra(String name, boolean[] value) {
7186 if (mExtras == null) {
7187 mExtras = new Bundle();
7188 }
7189 mExtras.putBooleanArray(name, value);
7190 return this;
7191 }
7192
7193 /**
7194 * Add extended data to the intent. The name must include a package
7195 * prefix, for example the app com.android.contacts would use names
7196 * like "com.android.contacts.ShowAll".
7197 *
7198 * @param name The name of the extra data, with package prefix.
7199 * @param value The byte array data value.
7200 *
7201 * @return Returns the same Intent object, for chaining multiple calls
7202 * into a single statement.
7203 *
7204 * @see #putExtras
7205 * @see #removeExtra
7206 * @see #getByteArrayExtra(String)
7207 */
7208 public Intent putExtra(String name, byte[] value) {
7209 if (mExtras == null) {
7210 mExtras = new Bundle();
7211 }
7212 mExtras.putByteArray(name, value);
7213 return this;
7214 }
7215
7216 /**
7217 * Add extended data to the intent. The name must include a package
7218 * prefix, for example the app com.android.contacts would use names
7219 * like "com.android.contacts.ShowAll".
7220 *
7221 * @param name The name of the extra data, with package prefix.
7222 * @param value The short array data value.
7223 *
7224 * @return Returns the same Intent object, for chaining multiple calls
7225 * into a single statement.
7226 *
7227 * @see #putExtras
7228 * @see #removeExtra
7229 * @see #getShortArrayExtra(String)
7230 */
7231 public Intent putExtra(String name, short[] value) {
7232 if (mExtras == null) {
7233 mExtras = new Bundle();
7234 }
7235 mExtras.putShortArray(name, value);
7236 return this;
7237 }
7238
7239 /**
7240 * Add extended data to the intent. The name must include a package
7241 * prefix, for example the app com.android.contacts would use names
7242 * like "com.android.contacts.ShowAll".
7243 *
7244 * @param name The name of the extra data, with package prefix.
7245 * @param value The char array data value.
7246 *
7247 * @return Returns the same Intent object, for chaining multiple calls
7248 * into a single statement.
7249 *
7250 * @see #putExtras
7251 * @see #removeExtra
7252 * @see #getCharArrayExtra(String)
7253 */
7254 public Intent putExtra(String name, char[] value) {
7255 if (mExtras == null) {
7256 mExtras = new Bundle();
7257 }
7258 mExtras.putCharArray(name, value);
7259 return this;
7260 }
7261
7262 /**
7263 * Add extended data to the intent. The name must include a package
7264 * prefix, for example the app com.android.contacts would use names
7265 * like "com.android.contacts.ShowAll".
7266 *
7267 * @param name The name of the extra data, with package prefix.
7268 * @param value The int array data value.
7269 *
7270 * @return Returns the same Intent object, for chaining multiple calls
7271 * into a single statement.
7272 *
7273 * @see #putExtras
7274 * @see #removeExtra
7275 * @see #getIntArrayExtra(String)
7276 */
7277 public Intent putExtra(String name, int[] value) {
7278 if (mExtras == null) {
7279 mExtras = new Bundle();
7280 }
7281 mExtras.putIntArray(name, value);
7282 return this;
7283 }
7284
7285 /**
7286 * Add extended data to the intent. The name must include a package
7287 * prefix, for example the app com.android.contacts would use names
7288 * like "com.android.contacts.ShowAll".
7289 *
7290 * @param name The name of the extra data, with package prefix.
7291 * @param value The byte array data value.
7292 *
7293 * @return Returns the same Intent object, for chaining multiple calls
7294 * into a single statement.
7295 *
7296 * @see #putExtras
7297 * @see #removeExtra
7298 * @see #getLongArrayExtra(String)
7299 */
7300 public Intent putExtra(String name, long[] value) {
7301 if (mExtras == null) {
7302 mExtras = new Bundle();
7303 }
7304 mExtras.putLongArray(name, value);
7305 return this;
7306 }
7307
7308 /**
7309 * Add extended data to the intent. The name must include a package
7310 * prefix, for example the app com.android.contacts would use names
7311 * like "com.android.contacts.ShowAll".
7312 *
7313 * @param name The name of the extra data, with package prefix.
7314 * @param value The float array data value.
7315 *
7316 * @return Returns the same Intent object, for chaining multiple calls
7317 * into a single statement.
7318 *
7319 * @see #putExtras
7320 * @see #removeExtra
7321 * @see #getFloatArrayExtra(String)
7322 */
7323 public Intent putExtra(String name, float[] value) {
7324 if (mExtras == null) {
7325 mExtras = new Bundle();
7326 }
7327 mExtras.putFloatArray(name, value);
7328 return this;
7329 }
7330
7331 /**
7332 * Add extended data to the intent. The name must include a package
7333 * prefix, for example the app com.android.contacts would use names
7334 * like "com.android.contacts.ShowAll".
7335 *
7336 * @param name The name of the extra data, with package prefix.
7337 * @param value The double array data value.
7338 *
7339 * @return Returns the same Intent object, for chaining multiple calls
7340 * into a single statement.
7341 *
7342 * @see #putExtras
7343 * @see #removeExtra
7344 * @see #getDoubleArrayExtra(String)
7345 */
7346 public Intent putExtra(String name, double[] value) {
7347 if (mExtras == null) {
7348 mExtras = new Bundle();
7349 }
7350 mExtras.putDoubleArray(name, value);
7351 return this;
7352 }
7353
7354 /**
7355 * Add extended data to the intent. The name must include a package
7356 * prefix, for example the app com.android.contacts would use names
7357 * like "com.android.contacts.ShowAll".
7358 *
7359 * @param name The name of the extra data, with package prefix.
7360 * @param value The String array data value.
7361 *
7362 * @return Returns the same Intent object, for chaining multiple calls
7363 * into a single statement.
7364 *
7365 * @see #putExtras
7366 * @see #removeExtra
7367 * @see #getStringArrayExtra(String)
7368 */
7369 public Intent putExtra(String name, String[] value) {
7370 if (mExtras == null) {
7371 mExtras = new Bundle();
7372 }
7373 mExtras.putStringArray(name, value);
7374 return this;
7375 }
7376
7377 /**
7378 * Add extended data to the intent. The name must include a package
7379 * prefix, for example the app com.android.contacts would use names
7380 * like "com.android.contacts.ShowAll".
7381 *
7382 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007383 * @param value The CharSequence array data value.
7384 *
7385 * @return Returns the same Intent object, for chaining multiple calls
7386 * into a single statement.
7387 *
7388 * @see #putExtras
7389 * @see #removeExtra
7390 * @see #getCharSequenceArrayExtra(String)
7391 */
7392 public Intent putExtra(String name, CharSequence[] value) {
7393 if (mExtras == null) {
7394 mExtras = new Bundle();
7395 }
7396 mExtras.putCharSequenceArray(name, value);
7397 return this;
7398 }
7399
7400 /**
7401 * Add extended data to the intent. The name must include a package
7402 * prefix, for example the app com.android.contacts would use names
7403 * like "com.android.contacts.ShowAll".
7404 *
7405 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007406 * @param value The Bundle data value.
7407 *
7408 * @return Returns the same Intent object, for chaining multiple calls
7409 * into a single statement.
7410 *
7411 * @see #putExtras
7412 * @see #removeExtra
7413 * @see #getBundleExtra(String)
7414 */
7415 public Intent putExtra(String name, Bundle value) {
7416 if (mExtras == null) {
7417 mExtras = new Bundle();
7418 }
7419 mExtras.putBundle(name, value);
7420 return this;
7421 }
7422
7423 /**
7424 * Add extended data to the intent. The name must include a package
7425 * prefix, for example the app com.android.contacts would use names
7426 * like "com.android.contacts.ShowAll".
7427 *
7428 * @param name The name of the extra data, with package prefix.
7429 * @param value The IBinder data value.
7430 *
7431 * @return Returns the same Intent object, for chaining multiple calls
7432 * into a single statement.
7433 *
7434 * @see #putExtras
7435 * @see #removeExtra
7436 * @see #getIBinderExtra(String)
7437 *
7438 * @deprecated
7439 * @hide
7440 */
7441 @Deprecated
7442 public Intent putExtra(String name, IBinder value) {
7443 if (mExtras == null) {
7444 mExtras = new Bundle();
7445 }
7446 mExtras.putIBinder(name, value);
7447 return this;
7448 }
7449
7450 /**
7451 * Copy all extras in 'src' in to this intent.
7452 *
7453 * @param src Contains the extras to copy.
7454 *
7455 * @see #putExtra
7456 */
7457 public Intent putExtras(Intent src) {
7458 if (src.mExtras != null) {
7459 if (mExtras == null) {
7460 mExtras = new Bundle(src.mExtras);
7461 } else {
7462 mExtras.putAll(src.mExtras);
7463 }
7464 }
7465 return this;
7466 }
7467
7468 /**
7469 * Add a set of extended data to the intent. The keys must include a package
7470 * prefix, for example the app com.android.contacts would use names
7471 * like "com.android.contacts.ShowAll".
7472 *
7473 * @param extras The Bundle of extras to add to this intent.
7474 *
7475 * @see #putExtra
7476 * @see #removeExtra
7477 */
7478 public Intent putExtras(Bundle extras) {
7479 if (mExtras == null) {
7480 mExtras = new Bundle();
7481 }
7482 mExtras.putAll(extras);
7483 return this;
7484 }
7485
7486 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007487 * Completely replace the extras in the Intent with the extras in the
7488 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007489 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007490 * @param src The exact extras contained in this Intent are copied
7491 * into the target intent, replacing any that were previously there.
7492 */
7493 public Intent replaceExtras(Intent src) {
7494 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7495 return this;
7496 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007497
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007498 /**
7499 * Completely replace the extras in the Intent with the given Bundle of
7500 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007501 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007502 * @param extras The new set of extras in the Intent, or null to erase
7503 * all extras.
7504 */
7505 public Intent replaceExtras(Bundle extras) {
7506 mExtras = extras != null ? new Bundle(extras) : null;
7507 return this;
7508 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007509
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007510 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007511 * Remove extended data from the intent.
7512 *
7513 * @see #putExtra
7514 */
7515 public void removeExtra(String name) {
7516 if (mExtras != null) {
7517 mExtras.remove(name);
7518 if (mExtras.size() == 0) {
7519 mExtras = null;
7520 }
7521 }
7522 }
7523
7524 /**
7525 * Set special flags controlling how this intent is handled. Most values
7526 * here depend on the type of component being executed by the Intent,
7527 * specifically the FLAG_ACTIVITY_* flags are all for use with
7528 * {@link Context#startActivity Context.startActivity()} and the
7529 * FLAG_RECEIVER_* flags are all for use with
7530 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7531 *
Scott Main7aee61f2011-02-08 11:25:01 -08007532 * <p>See the
7533 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7534 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007535 * the behavior of your application.
7536 *
7537 * @param flags The desired flags.
7538 *
7539 * @return Returns the same Intent object, for chaining multiple calls
7540 * into a single statement.
7541 *
7542 * @see #getFlags
7543 * @see #addFlags
7544 *
7545 * @see #FLAG_GRANT_READ_URI_PERMISSION
7546 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007547 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7548 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007549 * @see #FLAG_DEBUG_LOG_RESOLUTION
7550 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007551 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007552 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007553 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007554 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007555 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7556 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007557 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007558 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007559 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007560 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007561 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007562 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007563 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007564 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7565 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007566 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007567 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007568 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007569 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7570 */
7571 public Intent setFlags(int flags) {
7572 mFlags = flags;
7573 return this;
7574 }
7575
7576 /**
7577 * Add additional flags to the intent (or with existing flags
7578 * value).
7579 *
7580 * @param flags The new flags to set.
7581 *
7582 * @return Returns the same Intent object, for chaining multiple calls
7583 * into a single statement.
7584 *
7585 * @see #setFlags
7586 */
7587 public Intent addFlags(int flags) {
7588 mFlags |= flags;
7589 return this;
7590 }
7591
7592 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007593 * (Usually optional) Set an explicit application package name that limits
7594 * the components this Intent will resolve to. If left to the default
7595 * value of null, all components in all applications will considered.
7596 * If non-null, the Intent can only match the components in the given
7597 * application package.
7598 *
7599 * @param packageName The name of the application package to handle the
7600 * intent, or null to allow any application package.
7601 *
7602 * @return Returns the same Intent object, for chaining multiple calls
7603 * into a single statement.
7604 *
7605 * @see #getPackage
7606 * @see #resolveActivity
7607 */
7608 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007609 if (packageName != null && mSelector != null) {
7610 throw new IllegalArgumentException(
7611 "Can't set package name when selector is already set");
7612 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007613 mPackage = packageName;
7614 return this;
7615 }
7616
7617 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007618 * (Usually optional) Explicitly set the component to handle the intent.
7619 * If left with the default value of null, the system will determine the
7620 * appropriate class to use based on the other fields (action, data,
7621 * type, categories) in the Intent. If this class is defined, the
7622 * specified class will always be used regardless of the other fields. You
7623 * should only set this value when you know you absolutely want a specific
7624 * class to be used; otherwise it is better to let the system find the
7625 * appropriate class so that you will respect the installed applications
7626 * and user preferences.
7627 *
7628 * @param component The name of the application component to handle the
7629 * intent, or null to let the system find one for you.
7630 *
7631 * @return Returns the same Intent object, for chaining multiple calls
7632 * into a single statement.
7633 *
7634 * @see #setClass
7635 * @see #setClassName(Context, String)
7636 * @see #setClassName(String, String)
7637 * @see #getComponent
7638 * @see #resolveActivity
7639 */
7640 public Intent setComponent(ComponentName component) {
7641 mComponent = component;
7642 return this;
7643 }
7644
7645 /**
7646 * Convenience for calling {@link #setComponent} with an
7647 * explicit class name.
7648 *
7649 * @param packageContext A Context of the application package implementing
7650 * this class.
7651 * @param className The name of a class inside of the application package
7652 * that will be used as the component for this Intent.
7653 *
7654 * @return Returns the same Intent object, for chaining multiple calls
7655 * into a single statement.
7656 *
7657 * @see #setComponent
7658 * @see #setClass
7659 */
7660 public Intent setClassName(Context packageContext, String className) {
7661 mComponent = new ComponentName(packageContext, className);
7662 return this;
7663 }
7664
7665 /**
7666 * Convenience for calling {@link #setComponent} with an
7667 * explicit application package name and class name.
7668 *
7669 * @param packageName The name of the package implementing the desired
7670 * component.
7671 * @param className The name of a class inside of the application package
7672 * that will be used as the component for this Intent.
7673 *
7674 * @return Returns the same Intent object, for chaining multiple calls
7675 * into a single statement.
7676 *
7677 * @see #setComponent
7678 * @see #setClass
7679 */
7680 public Intent setClassName(String packageName, String className) {
7681 mComponent = new ComponentName(packageName, className);
7682 return this;
7683 }
7684
7685 /**
7686 * Convenience for calling {@link #setComponent(ComponentName)} with the
7687 * name returned by a {@link Class} object.
7688 *
7689 * @param packageContext A Context of the application package implementing
7690 * this class.
7691 * @param cls The class name to set, equivalent to
7692 * <code>setClassName(context, cls.getName())</code>.
7693 *
7694 * @return Returns the same Intent object, for chaining multiple calls
7695 * into a single statement.
7696 *
7697 * @see #setComponent
7698 */
7699 public Intent setClass(Context packageContext, Class<?> cls) {
7700 mComponent = new ComponentName(packageContext, cls);
7701 return this;
7702 }
7703
7704 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007705 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7706 * used as a hint to the receiver for animations and the like. Null means that there
7707 * is no source bounds.
7708 */
7709 public void setSourceBounds(Rect r) {
7710 if (r != null) {
7711 mSourceBounds = new Rect(r);
7712 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007713 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007714 }
7715 }
7716
Tor Norbyed9273d62013-05-30 15:59:53 -07007717 /** @hide */
7718 @IntDef(flag = true,
7719 value = {
7720 FILL_IN_ACTION,
7721 FILL_IN_DATA,
7722 FILL_IN_CATEGORIES,
7723 FILL_IN_COMPONENT,
7724 FILL_IN_PACKAGE,
7725 FILL_IN_SOURCE_BOUNDS,
7726 FILL_IN_SELECTOR,
7727 FILL_IN_CLIP_DATA
7728 })
7729 @Retention(RetentionPolicy.SOURCE)
7730 public @interface FillInFlags {}
7731
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007732 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007733 * Use with {@link #fillIn} to allow the current action value to be
7734 * overwritten, even if it is already set.
7735 */
7736 public static final int FILL_IN_ACTION = 1<<0;
7737
7738 /**
7739 * Use with {@link #fillIn} to allow the current data or type value
7740 * overwritten, even if it is already set.
7741 */
7742 public static final int FILL_IN_DATA = 1<<1;
7743
7744 /**
7745 * Use with {@link #fillIn} to allow the current categories to be
7746 * overwritten, even if they are already set.
7747 */
7748 public static final int FILL_IN_CATEGORIES = 1<<2;
7749
7750 /**
7751 * Use with {@link #fillIn} to allow the current component value to be
7752 * overwritten, even if it is already set.
7753 */
7754 public static final int FILL_IN_COMPONENT = 1<<3;
7755
7756 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007757 * Use with {@link #fillIn} to allow the current package value to be
7758 * overwritten, even if it is already set.
7759 */
7760 public static final int FILL_IN_PACKAGE = 1<<4;
7761
7762 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007763 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007764 * overwritten, even if it is already set.
7765 */
7766 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7767
7768 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007769 * Use with {@link #fillIn} to allow the current selector to be
7770 * overwritten, even if it is already set.
7771 */
7772 public static final int FILL_IN_SELECTOR = 1<<6;
7773
7774 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007775 * Use with {@link #fillIn} to allow the current ClipData to be
7776 * overwritten, even if it is already set.
7777 */
7778 public static final int FILL_IN_CLIP_DATA = 1<<7;
7779
7780 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 * Copy the contents of <var>other</var> in to this object, but only
7782 * where fields are not defined by this object. For purposes of a field
7783 * being defined, the following pieces of data in the Intent are
7784 * considered to be separate fields:
7785 *
7786 * <ul>
7787 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007788 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007789 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7790 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007791 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007792 * <li> component, as set by {@link #setComponent(ComponentName)} or
7793 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007794 * <li> source bounds, as set by {@link #setSourceBounds}.
7795 * <li> selector, as set by {@link #setSelector(Intent)}.
7796 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007797 * <li> each top-level name in the associated extras.
7798 * </ul>
7799 *
7800 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007801 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007802 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7803 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7804 * the restriction where the corresponding field will not be replaced if
7805 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007806 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007807 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7808 * is explicitly specified. The selector will only be copied if
7809 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007810 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007811 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7812 * and Intent B with {action="gotit", data-type="some/thing",
7813 * categories="one","two"}.
7814 *
7815 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7816 * containing: {action="gotit", data-type="some/thing",
7817 * categories="bar"}.
7818 *
7819 * @param other Another Intent whose values are to be used to fill in
7820 * the current one.
7821 * @param flags Options to control which fields can be filled in.
7822 *
7823 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007824 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007825 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7826 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7827 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007828 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007829 @FillInFlags
7830 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007831 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007832 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007833 if (other.mAction != null
7834 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007835 mAction = other.mAction;
7836 changes |= FILL_IN_ACTION;
7837 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007838 if ((other.mData != null || other.mType != null)
7839 && ((mData == null && mType == null)
7840 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007841 mData = other.mData;
7842 mType = other.mType;
7843 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007844 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007845 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007846 if (other.mCategories != null
7847 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007849 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007850 }
7851 changes |= FILL_IN_CATEGORIES;
7852 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007853 if (other.mPackage != null
7854 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007855 // Only do this if mSelector is not set.
7856 if (mSelector == null) {
7857 mPackage = other.mPackage;
7858 changes |= FILL_IN_PACKAGE;
7859 }
7860 }
7861 // Selector is special: it can only be set if explicitly allowed,
7862 // for the same reason as the component name.
7863 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7864 if (mPackage == null) {
7865 mSelector = new Intent(other.mSelector);
7866 mPackage = null;
7867 changes |= FILL_IN_SELECTOR;
7868 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007869 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007870 if (other.mClipData != null
7871 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7872 mClipData = other.mClipData;
7873 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007874 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007875 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007876 // Component is special: it can -only- be set if explicitly allowed,
7877 // since otherwise the sender could force the intent somewhere the
7878 // originator didn't intend.
7879 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007880 mComponent = other.mComponent;
7881 changes |= FILL_IN_COMPONENT;
7882 }
7883 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007884 if (other.mSourceBounds != null
7885 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7886 mSourceBounds = new Rect(other.mSourceBounds);
7887 changes |= FILL_IN_SOURCE_BOUNDS;
7888 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007889 if (mExtras == null) {
7890 if (other.mExtras != null) {
7891 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007892 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007893 }
7894 } else if (other.mExtras != null) {
7895 try {
7896 Bundle newb = new Bundle(other.mExtras);
7897 newb.putAll(mExtras);
7898 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007899 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007900 } catch (RuntimeException e) {
7901 // Modifying the extras can cause us to unparcel the contents
7902 // of the bundle, and if we do this in the system process that
7903 // may fail. We really should handle this (i.e., the Bundle
7904 // impl shouldn't be on top of a plain map), but for now just
7905 // ignore it and keep the original contents. :(
7906 Log.w("Intent", "Failure filling in extras", e);
7907 }
7908 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007909 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7910 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7911 mContentUserHint = other.mContentUserHint;
7912 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007913 return changes;
7914 }
7915
7916 /**
7917 * Wrapper class holding an Intent and implementing comparisons on it for
7918 * the purpose of filtering. The class implements its
7919 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7920 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7921 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7922 * on the wrapped Intent.
7923 */
7924 public static final class FilterComparison {
7925 private final Intent mIntent;
7926 private final int mHashCode;
7927
7928 public FilterComparison(Intent intent) {
7929 mIntent = intent;
7930 mHashCode = intent.filterHashCode();
7931 }
7932
7933 /**
7934 * Return the Intent that this FilterComparison represents.
7935 * @return Returns the Intent held by the FilterComparison. Do
7936 * not modify!
7937 */
7938 public Intent getIntent() {
7939 return mIntent;
7940 }
7941
7942 @Override
7943 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007944 if (obj instanceof FilterComparison) {
7945 Intent other = ((FilterComparison)obj).mIntent;
7946 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007947 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08007948 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007949 }
7950
7951 @Override
7952 public int hashCode() {
7953 return mHashCode;
7954 }
7955 }
7956
7957 /**
7958 * Determine if two intents are the same for the purposes of intent
7959 * resolution (filtering). That is, if their action, data, type,
7960 * class, and categories are the same. This does <em>not</em> compare
7961 * any extra data included in the intents.
7962 *
7963 * @param other The other Intent to compare against.
7964 *
7965 * @return Returns true if action, data, type, class, and categories
7966 * are the same.
7967 */
7968 public boolean filterEquals(Intent other) {
7969 if (other == null) {
7970 return false;
7971 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07007972 if (!Objects.equals(this.mAction, other.mAction)) return false;
7973 if (!Objects.equals(this.mData, other.mData)) return false;
7974 if (!Objects.equals(this.mType, other.mType)) return false;
7975 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
7976 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
7977 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007978
7979 return true;
7980 }
7981
7982 /**
7983 * Generate hash code that matches semantics of filterEquals().
7984 *
7985 * @return Returns the hash value of the action, data, type, class, and
7986 * categories.
7987 *
7988 * @see #filterEquals
7989 */
7990 public int filterHashCode() {
7991 int code = 0;
7992 if (mAction != null) {
7993 code += mAction.hashCode();
7994 }
7995 if (mData != null) {
7996 code += mData.hashCode();
7997 }
7998 if (mType != null) {
7999 code += mType.hashCode();
8000 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008001 if (mPackage != null) {
8002 code += mPackage.hashCode();
8003 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008004 if (mComponent != null) {
8005 code += mComponent.hashCode();
8006 }
8007 if (mCategories != null) {
8008 code += mCategories.hashCode();
8009 }
8010 return code;
8011 }
8012
8013 @Override
8014 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008015 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008016
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008017 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008018 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008019 b.append(" }");
8020
8021 return b.toString();
8022 }
8023
8024 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008025 public String toInsecureString() {
8026 StringBuilder b = new StringBuilder(128);
8027
8028 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008029 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008030 b.append(" }");
8031
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008032 return b.toString();
8033 }
Romain Guy4969af72009-06-17 10:53:19 -07008034
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008035 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008036 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008037 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008038
8039 b.append("Intent { ");
8040 toShortString(b, false, true, true, true);
8041 b.append(" }");
8042
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008043 return b.toString();
8044 }
8045
8046 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008047 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8048 StringBuilder b = new StringBuilder(128);
8049 toShortString(b, secure, comp, extras, clip);
8050 return b.toString();
8051 }
8052
8053 /** @hide */
8054 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8055 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008056 boolean first = true;
8057 if (mAction != null) {
8058 b.append("act=").append(mAction);
8059 first = false;
8060 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008061 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008062 if (!first) {
8063 b.append(' ');
8064 }
8065 first = false;
8066 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008067 for (int i=0; i<mCategories.size(); i++) {
8068 if (i > 0) b.append(',');
8069 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008071 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008072 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008073 if (mData != null) {
8074 if (!first) {
8075 b.append(' ');
8076 }
8077 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008078 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008079 if (secure) {
8080 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008081 } else {
8082 b.append(mData);
8083 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008084 }
8085 if (mType != null) {
8086 if (!first) {
8087 b.append(' ');
8088 }
8089 first = false;
8090 b.append("typ=").append(mType);
8091 }
8092 if (mFlags != 0) {
8093 if (!first) {
8094 b.append(' ');
8095 }
8096 first = false;
8097 b.append("flg=0x").append(Integer.toHexString(mFlags));
8098 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008099 if (mPackage != null) {
8100 if (!first) {
8101 b.append(' ');
8102 }
8103 first = false;
8104 b.append("pkg=").append(mPackage);
8105 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008106 if (comp && mComponent != null) {
8107 if (!first) {
8108 b.append(' ');
8109 }
8110 first = false;
8111 b.append("cmp=").append(mComponent.flattenToShortString());
8112 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008113 if (mSourceBounds != null) {
8114 if (!first) {
8115 b.append(' ');
8116 }
8117 first = false;
8118 b.append("bnds=").append(mSourceBounds.toShortString());
8119 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008120 if (mClipData != null) {
8121 if (!first) {
8122 b.append(' ');
8123 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008124 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008125 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008126 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008127 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008128 if (mClipData.getDescription() != null) {
8129 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8130 } else {
8131 first = true;
8132 }
8133 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008134 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008135 first = false;
8136 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008137 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008138 if (extras && mExtras != null) {
8139 if (!first) {
8140 b.append(' ');
8141 }
8142 first = false;
8143 b.append("(has extras)");
8144 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008145 if (mContentUserHint != UserHandle.USER_CURRENT) {
8146 if (!first) {
8147 b.append(' ');
8148 }
8149 first = false;
8150 b.append("u=").append(mContentUserHint);
8151 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008152 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008153 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008154 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008155 b.append("}");
8156 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008157 }
8158
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008159 /**
8160 * Call {@link #toUri} with 0 flags.
8161 * @deprecated Use {@link #toUri} instead.
8162 */
8163 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008164 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008165 return toUri(0);
8166 }
8167
8168 /**
8169 * Convert this Intent into a String holding a URI representation of it.
8170 * The returned URI string has been properly URI encoded, so it can be
8171 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8172 * Intent's data as the base URI, with an additional fragment describing
8173 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008174 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008175 * <p>You can convert the returned string back to an Intent with
8176 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008177 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008178 * @param flags Additional operating flags. Either 0,
8179 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008180 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008181 * @return Returns a URI encoding URI string describing the entire contents
8182 * of the Intent.
8183 */
8184 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008185 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008186 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8187 if (mPackage == null) {
8188 throw new IllegalArgumentException(
8189 "Intent must include an explicit package name to build an android-app: "
8190 + this);
8191 }
8192 uri.append("android-app://");
8193 uri.append(mPackage);
8194 String scheme = null;
8195 if (mData != null) {
8196 scheme = mData.getScheme();
8197 if (scheme != null) {
8198 uri.append('/');
8199 uri.append(scheme);
8200 String authority = mData.getEncodedAuthority();
8201 if (authority != null) {
8202 uri.append('/');
8203 uri.append(authority);
8204 String path = mData.getEncodedPath();
8205 if (path != null) {
8206 uri.append(path);
8207 }
8208 String queryParams = mData.getEncodedQuery();
8209 if (queryParams != null) {
8210 uri.append('?');
8211 uri.append(queryParams);
8212 }
8213 String fragment = mData.getEncodedFragment();
8214 if (fragment != null) {
8215 uri.append('#');
8216 uri.append(fragment);
8217 }
8218 }
8219 }
8220 }
8221 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8222 mPackage, flags);
8223 return uri.toString();
8224 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008225 String scheme = null;
8226 if (mData != null) {
8227 String data = mData.toString();
8228 if ((flags&URI_INTENT_SCHEME) != 0) {
8229 final int N = data.length();
8230 for (int i=0; i<N; i++) {
8231 char c = data.charAt(i);
8232 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8233 || c == '.' || c == '-') {
8234 continue;
8235 }
8236 if (c == ':' && i > 0) {
8237 // Valid scheme.
8238 scheme = data.substring(0, i);
8239 uri.append("intent:");
8240 data = data.substring(i+1);
8241 break;
8242 }
Tom Taylord4a47292009-12-21 13:59:18 -08008243
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008244 // No scheme.
8245 break;
8246 }
8247 }
8248 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008249
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008250 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8251 uri.append("intent:");
8252 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008253
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008254 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008255
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008256 return uri.toString();
8257 }
8258
8259 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8260 String defPackage, int flags) {
8261 StringBuilder frag = new StringBuilder(128);
8262
8263 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008264 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008265 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008266 // Note that for now we are not going to try to handle the
8267 // data part; not clear how to represent this as a URI, and
8268 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008269 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8270 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008271 }
8272
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008273 if (frag.length() > 0) {
8274 uri.append("#Intent;");
8275 uri.append(frag);
8276 uri.append("end");
8277 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008278 }
8279
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008280 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8281 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008282 if (scheme != null) {
8283 uri.append("scheme=").append(scheme).append(';');
8284 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008285 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008286 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008287 }
8288 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008289 for (int i=0; i<mCategories.size(); i++) {
8290 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008291 }
8292 }
8293 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008294 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008295 }
8296 if (mFlags != 0) {
8297 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8298 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008299 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008300 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8301 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008302 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008303 uri.append("component=").append(Uri.encode(
8304 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008306 if (mSourceBounds != null) {
8307 uri.append("sourceBounds=")
8308 .append(Uri.encode(mSourceBounds.flattenToString()))
8309 .append(';');
8310 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008311 if (mExtras != null) {
8312 for (String key : mExtras.keySet()) {
8313 final Object value = mExtras.get(key);
8314 char entryType =
8315 value instanceof String ? 'S' :
8316 value instanceof Boolean ? 'B' :
8317 value instanceof Byte ? 'b' :
8318 value instanceof Character ? 'c' :
8319 value instanceof Double ? 'd' :
8320 value instanceof Float ? 'f' :
8321 value instanceof Integer ? 'i' :
8322 value instanceof Long ? 'l' :
8323 value instanceof Short ? 's' :
8324 '\0';
8325
8326 if (entryType != '\0') {
8327 uri.append(entryType);
8328 uri.append('.');
8329 uri.append(Uri.encode(key));
8330 uri.append('=');
8331 uri.append(Uri.encode(value.toString()));
8332 uri.append(';');
8333 }
8334 }
8335 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008336 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008337
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008338 public int describeContents() {
8339 return (mExtras != null) ? mExtras.describeContents() : 0;
8340 }
8341
8342 public void writeToParcel(Parcel out, int flags) {
8343 out.writeString(mAction);
8344 Uri.writeToParcel(out, mData);
8345 out.writeString(mType);
8346 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008347 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008348 ComponentName.writeToParcel(mComponent, out);
8349
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008350 if (mSourceBounds != null) {
8351 out.writeInt(1);
8352 mSourceBounds.writeToParcel(out, flags);
8353 } else {
8354 out.writeInt(0);
8355 }
8356
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008357 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008358 final int N = mCategories.size();
8359 out.writeInt(N);
8360 for (int i=0; i<N; i++) {
8361 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008362 }
8363 } else {
8364 out.writeInt(0);
8365 }
8366
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008367 if (mSelector != null) {
8368 out.writeInt(1);
8369 mSelector.writeToParcel(out, flags);
8370 } else {
8371 out.writeInt(0);
8372 }
8373
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008374 if (mClipData != null) {
8375 out.writeInt(1);
8376 mClipData.writeToParcel(out, flags);
8377 } else {
8378 out.writeInt(0);
8379 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008380 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008381 out.writeBundle(mExtras);
8382 }
8383
8384 public static final Parcelable.Creator<Intent> CREATOR
8385 = new Parcelable.Creator<Intent>() {
8386 public Intent createFromParcel(Parcel in) {
8387 return new Intent(in);
8388 }
8389 public Intent[] newArray(int size) {
8390 return new Intent[size];
8391 }
8392 };
8393
Dianne Hackborneb034652009-09-07 00:49:58 -07008394 /** @hide */
8395 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008396 readFromParcel(in);
8397 }
8398
8399 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008400 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008401 mData = Uri.CREATOR.createFromParcel(in);
8402 mType = in.readString();
8403 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008404 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008405 mComponent = ComponentName.readFromParcel(in);
8406
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008407 if (in.readInt() != 0) {
8408 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8409 }
8410
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008411 int N = in.readInt();
8412 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008413 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008414 int i;
8415 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008416 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008417 }
8418 } else {
8419 mCategories = null;
8420 }
8421
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008422 if (in.readInt() != 0) {
8423 mSelector = new Intent(in);
8424 }
8425
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008426 if (in.readInt() != 0) {
8427 mClipData = new ClipData(in);
8428 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008429 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008430 mExtras = in.readBundle();
8431 }
8432
8433 /**
8434 * Parses the "intent" element (and its children) from XML and instantiates
8435 * an Intent object. The given XML parser should be located at the tag
8436 * where parsing should start (often named "intent"), from which the
8437 * basic action, data, type, and package and class name will be
8438 * retrieved. The function will then parse in to any child elements,
8439 * looking for <category android:name="xxx"> tags to add categories and
8440 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8441 * to the intent.
8442 *
8443 * @param resources The Resources to use when inflating resources.
8444 * @param parser The XML parser pointing at an "intent" tag.
8445 * @param attrs The AttributeSet interface for retrieving extended
8446 * attribute data at the current <var>parser</var> location.
8447 * @return An Intent object matching the XML data.
8448 * @throws XmlPullParserException If there was an XML parsing error.
8449 * @throws IOException If there was an I/O error.
8450 */
8451 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8452 throws XmlPullParserException, IOException {
8453 Intent intent = new Intent();
8454
8455 TypedArray sa = resources.obtainAttributes(attrs,
8456 com.android.internal.R.styleable.Intent);
8457
8458 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8459
8460 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8461 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8462 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8463
8464 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8465 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8466 if (packageName != null && className != null) {
8467 intent.setComponent(new ComponentName(packageName, className));
8468 }
8469
8470 sa.recycle();
8471
8472 int outerDepth = parser.getDepth();
8473 int type;
8474 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8475 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8476 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8477 continue;
8478 }
8479
8480 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008481 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008482 sa = resources.obtainAttributes(attrs,
8483 com.android.internal.R.styleable.IntentCategory);
8484 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8485 sa.recycle();
8486
8487 if (cat != null) {
8488 intent.addCategory(cat);
8489 }
8490 XmlUtils.skipCurrentTag(parser);
8491
Craig Mautner21d24a22014-04-23 11:45:37 -07008492 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008493 if (intent.mExtras == null) {
8494 intent.mExtras = new Bundle();
8495 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008496 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008497 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008498
8499 } else {
8500 XmlUtils.skipCurrentTag(parser);
8501 }
8502 }
8503
8504 return intent;
8505 }
Nick Pellyccae4122012-01-09 14:12:58 -08008506
Craig Mautner21d24a22014-04-23 11:45:37 -07008507 /** @hide */
8508 public void saveToXml(XmlSerializer out) throws IOException {
8509 if (mAction != null) {
8510 out.attribute(null, ATTR_ACTION, mAction);
8511 }
8512 if (mData != null) {
8513 out.attribute(null, ATTR_DATA, mData.toString());
8514 }
8515 if (mType != null) {
8516 out.attribute(null, ATTR_TYPE, mType);
8517 }
8518 if (mComponent != null) {
8519 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8520 }
8521 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8522
8523 if (mCategories != null) {
8524 out.startTag(null, TAG_CATEGORIES);
8525 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8526 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8527 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008528 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008529 }
8530 }
8531
8532 /** @hide */
8533 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8534 XmlPullParserException {
8535 Intent intent = new Intent();
8536 final int outerDepth = in.getDepth();
8537
8538 int attrCount = in.getAttributeCount();
8539 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8540 final String attrName = in.getAttributeName(attrNdx);
8541 final String attrValue = in.getAttributeValue(attrNdx);
8542 if (ATTR_ACTION.equals(attrName)) {
8543 intent.setAction(attrValue);
8544 } else if (ATTR_DATA.equals(attrName)) {
8545 intent.setData(Uri.parse(attrValue));
8546 } else if (ATTR_TYPE.equals(attrName)) {
8547 intent.setType(attrValue);
8548 } else if (ATTR_COMPONENT.equals(attrName)) {
8549 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8550 } else if (ATTR_FLAGS.equals(attrName)) {
8551 intent.setFlags(Integer.valueOf(attrValue, 16));
8552 } else {
8553 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8554 }
8555 }
8556
8557 int event;
8558 String name;
8559 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8560 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8561 if (event == XmlPullParser.START_TAG) {
8562 name = in.getName();
8563 if (TAG_CATEGORIES.equals(name)) {
8564 attrCount = in.getAttributeCount();
8565 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8566 intent.addCategory(in.getAttributeValue(attrNdx));
8567 }
8568 } else {
8569 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8570 XmlUtils.skipCurrentTag(in);
8571 }
8572 }
8573 }
8574
8575 return intent;
8576 }
8577
Nick Pellyccae4122012-01-09 14:12:58 -08008578 /**
8579 * Normalize a MIME data type.
8580 *
8581 * <p>A normalized MIME type has white-space trimmed,
8582 * content-type parameters removed, and is lower-case.
8583 * This aligns the type with Android best practices for
8584 * intent filtering.
8585 *
8586 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8587 * "text/x-vCard" becomes "text/x-vcard".
8588 *
8589 * <p>All MIME types received from outside Android (such as user input,
8590 * or external sources like Bluetooth, NFC, or the Internet) should
8591 * be normalized before they are used to create an Intent.
8592 *
8593 * @param type MIME data type to normalize
8594 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008595 * @see #setType
8596 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008597 */
8598 public static String normalizeMimeType(String type) {
8599 if (type == null) {
8600 return null;
8601 }
8602
Elliott Hughescb64d432013-08-02 10:00:44 -07008603 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008604
8605 final int semicolonIndex = type.indexOf(';');
8606 if (semicolonIndex != -1) {
8607 type = type.substring(0, semicolonIndex);
8608 }
8609 return type;
8610 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008611
8612 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008613 * Prepare this {@link Intent} to leave an app process.
8614 *
8615 * @hide
8616 */
8617 public void prepareToLeaveProcess() {
8618 setAllowFds(false);
8619
8620 if (mSelector != null) {
8621 mSelector.prepareToLeaveProcess();
8622 }
8623 if (mClipData != null) {
8624 mClipData.prepareToLeaveProcess();
8625 }
8626
8627 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8628 // There are several ACTION_MEDIA_* broadcasts that send file://
8629 // Uris, so only check common actions.
8630 if (ACTION_VIEW.equals(mAction) ||
8631 ACTION_EDIT.equals(mAction) ||
8632 ACTION_ATTACH_DATA.equals(mAction)) {
8633 mData.checkFileUriExposed("Intent.getData()");
8634 }
8635 }
8636 }
8637
8638 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008639 * @hide
8640 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008641 public void prepareToEnterProcess() {
8642 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008643 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8644 fixUris(mContentUserHint);
8645 mContentUserHint = UserHandle.USER_CURRENT;
8646 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008647 }
8648 }
8649
8650 /**
8651 * @hide
8652 */
8653 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008654 Uri data = getData();
8655 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008656 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008657 }
8658 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008659 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008660 }
8661 String action = getAction();
8662 if (ACTION_SEND.equals(action)) {
8663 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8664 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008665 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008666 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008667 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008668 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8669 if (streams != null) {
8670 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8671 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008672 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008673 }
8674 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8675 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008676 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8677 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8678 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8679 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8680 if (output != null) {
8681 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8682 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008683 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008684 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008685
8686 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008687 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008688 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8689 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008690 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008691 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008692 * @hide
8693 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008694 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008695 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008696 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008697
8698 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008699 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008700
8701 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008702 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008703 // Inspect contained intents to see if we need to migrate extras. We
8704 // don't promote ClipData to the parent, since ChooserActivity will
8705 // already start the picked item as the caller, and we can't combine
8706 // the flags in a safe way.
8707
8708 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008709 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008710 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8711 if (intent != null) {
8712 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008713 }
8714 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008715 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008716 try {
8717 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8718 if (intents != null) {
8719 for (int i = 0; i < intents.length; i++) {
8720 final Intent intent = (Intent) intents[i];
8721 if (intent != null) {
8722 migrated |= intent.migrateExtraStreamToClipData();
8723 }
8724 }
8725 }
8726 } catch (ClassCastException e) {
8727 }
8728 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008729
8730 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008731 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008732 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8733 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8734 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8735 if (stream != null || text != null || htmlText != null) {
8736 final ClipData clipData = new ClipData(
8737 null, new String[] { getType() },
8738 new ClipData.Item(text, htmlText, null, stream));
8739 setClipData(clipData);
8740 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008741 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008742 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008743 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008744 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008745
8746 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008747 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008748 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8749 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8750 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8751 int num = -1;
8752 if (streams != null) {
8753 num = streams.size();
8754 }
8755 if (texts != null) {
8756 if (num >= 0 && num != texts.size()) {
8757 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008758 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008759 }
8760 num = texts.size();
8761 }
8762 if (htmlTexts != null) {
8763 if (num >= 0 && num != htmlTexts.size()) {
8764 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008765 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008766 }
8767 num = htmlTexts.size();
8768 }
8769 if (num > 0) {
8770 final ClipData clipData = new ClipData(
8771 null, new String[] { getType() },
8772 makeClipItem(streams, texts, htmlTexts, 0));
8773
8774 for (int i = 1; i < num; i++) {
8775 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8776 }
8777
8778 setClipData(clipData);
8779 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008780 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008781 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008782 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008783 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008784 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8785 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8786 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8787 final Uri output;
8788 try {
8789 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8790 } catch (ClassCastException e) {
8791 return false;
8792 }
8793 if (output != null) {
8794 setClipData(ClipData.newRawUri("", output));
8795 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8796 return true;
8797 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008798 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008799
8800 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008801 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008802
8803 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8804 ArrayList<String> htmlTexts, int which) {
8805 Uri uri = streams != null ? streams.get(which) : null;
8806 CharSequence text = texts != null ? texts.get(which) : null;
8807 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8808 return new ClipData.Item(text, htmlText, null, uri);
8809 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008810
8811 /** @hide */
8812 public boolean isDocument() {
8813 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8814 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008815}