blob: b65d825b70a9ecd8304a665f11c61dd62868451c [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 Ganov9c165d72015-12-01 19:52:26 -08001612 * Activity action: Launch UI to review permissions for an app.
1613 * The system uses this intent if permission review for apps not
1614 * supporting the new runtime permissions model is enabled. In
1615 * this mode a permission review is required before any of the
1616 * app components can run.
1617 * <p>
1618 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1619 * permissions will be reviewed (mandatory).
1620 * </p>
1621 * <p>
1622 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1623 * be fired after the permission review (optional).
1624 * </p>
1625 * <p>
1626 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1627 * be invoked after the permission review (optional).
1628 * </p>
1629 * <p>
1630 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1631 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1632 * </p>
1633 * <p>
1634 * Output: Nothing.
1635 * </p>
1636 *
1637 * @see #EXTRA_PACKAGE_NAME
1638 * @see #EXTRA_INTENT
1639 * @see #EXTRA_REMOTE_CALLBACK
1640 * @see #EXTRA_RESULT_NEEDED
1641 *
1642 * @hide
1643 */
1644 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1645 public static final String ACTION_REVIEW_PERMISSIONS =
1646 "android.intent.action.REVIEW_PERMISSIONS";
1647
1648 /**
1649 * Intent extra: A callback for reporting remote result as a bundle.
1650 * <p>
1651 * Type: IRemoteCallback
1652 * </p>
1653 *
1654 * @hide
1655 */
1656 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1657
1658 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001659 * Intent extra: An app package name.
1660 * <p>
1661 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001662 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001663 *
1664 * @hide
1665 */
1666 @SystemApi
1667 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1668
1669 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001670 * Intent extra: An extra for specifying whether a result is needed.
1671 * <p>
1672 * Type: boolean
1673 * </p>
1674 *
1675 * @hide
1676 */
1677 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1678
1679 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001680 * Broadcast action that requests current permission granted information. It will respond
1681 * to the request by sending a broadcast with action defined by
1682 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001683 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1684 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1685 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001686 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001687 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1688 * number of permissions requested and the number of granted additional permissions
1689 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001690 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001691 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1692 * of localized permission group names that are granted in
1693 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001694 *
1695 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1696 * permissions and the total number of apps requesting runtime permissions will be the first
1697 * and second elements respectively of an int[] in the response as
1698 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1699 *
1700 * @hide
1701 */
1702 public static final String ACTION_GET_PERMISSIONS_COUNT
1703 = "android.intent.action.GET_PERMISSIONS_COUNT";
1704
1705 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001706 * Broadcast action that requests list of all apps that have runtime permissions. It will
1707 * respond to the request by sending a broadcast with action defined by
1708 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1709 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1710 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1711 * a null upon failure.
1712 *
1713 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1714 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1715 * will contain the list of app labels corresponding ot the apps in the first list.
1716 *
1717 * @hide
1718 */
1719 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1720 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1721
1722 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001723 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1724 * @hide
1725 */
1726 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1727 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1728
1729 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001730 * List of CharSequence of localized permission group labels.
1731 * @hide
1732 */
1733 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1734 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1735
1736 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001737 * String list of apps that have one or more runtime permissions.
1738 * @hide
1739 */
1740 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1741 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1742
1743 /**
1744 * String list of app labels for apps that have one or more runtime permissions.
1745 * @hide
1746 */
1747 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1748 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1749
1750 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001751 * Boolean list describing if the app is a system app for apps that have one or more runtime
1752 * permissions.
1753 * @hide
1754 */
1755 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1756 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1757
1758 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001759 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001760 * @hide
1761 */
1762 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1763 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1764
1765 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001766 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1767 * @hide
1768 */
1769 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1770 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1771
1772 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001773 * Activity action: Launch UI to manage which apps have a given permission.
1774 * <p>
1775 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1776 * to which will be managed by the launched UI.
1777 * </p>
1778 * <p>
1779 * Output: Nothing.
1780 * </p>
1781 *
1782 * @see #EXTRA_PERMISSION_NAME
1783 *
1784 * @hide
1785 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001786 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1787 public static final String ACTION_MANAGE_PERMISSION_APPS =
1788 "android.intent.action.MANAGE_PERMISSION_APPS";
1789
1790 /**
1791 * Intent extra: The name of a permission.
1792 * <p>
1793 * Type: String
1794 * </p>
1795 *
1796 * @hide
1797 */
1798 @SystemApi
1799 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1800
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001801 // ---------------------------------------------------------------------
1802 // ---------------------------------------------------------------------
1803 // Standard intent broadcast actions (see action variable).
1804
1805 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001806 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1807 * <p>
1808 * For historical reasons, the name of this broadcast action refers to the power
1809 * state of the screen but it is actually sent in response to changes in the
1810 * overall interactive state of the device.
1811 * </p><p>
1812 * This broadcast is sent when the device becomes non-interactive which may have
1813 * nothing to do with the screen turning off. To determine the
1814 * actual state of the screen, use {@link android.view.Display#getState}.
1815 * </p><p>
1816 * See {@link android.os.PowerManager#isInteractive} for details.
1817 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001818 * You <em>cannot</em> receive this through components declared in
1819 * manifests, only by explicitly registering for it with
1820 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1821 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001822 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001823 * <p class="note">This is a protected intent that can only be sent
1824 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001825 */
1826 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1827 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001828
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001829 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001830 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1831 * <p>
1832 * For historical reasons, the name of this broadcast action refers to the power
1833 * state of the screen but it is actually sent in response to changes in the
1834 * overall interactive state of the device.
1835 * </p><p>
1836 * This broadcast is sent when the device becomes interactive which may have
1837 * nothing to do with the screen turning on. To determine the
1838 * actual state of the screen, use {@link android.view.Display#getState}.
1839 * </p><p>
1840 * See {@link android.os.PowerManager#isInteractive} for details.
1841 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001842 * You <em>cannot</em> receive this through components declared in
1843 * manifests, only by explicitly registering for it with
1844 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1845 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001846 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001847 * <p class="note">This is a protected intent that can only be sent
1848 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001849 */
1850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1851 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001852
1853 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001854 * Broadcast Action: Sent after the system stops dreaming.
1855 *
1856 * <p class="note">This is a protected intent that can only be sent by the system.
1857 * It is only sent to registered receivers.</p>
1858 */
1859 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1860 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1861
1862 /**
1863 * Broadcast Action: Sent after the system starts dreaming.
1864 *
1865 * <p class="note">This is a protected intent that can only be sent by the system.
1866 * It is only sent to registered receivers.</p>
1867 */
1868 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1869 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1870
1871 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001872 * 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 -07001873 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001874 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001875 * <p class="note">This is a protected intent that can only be sent
1876 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001877 */
1878 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001879 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001880
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001881 /**
1882 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001883 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001884 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001885 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1886 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001887 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001888 * <p class="note">This is a protected intent that can only be sent
1889 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001890 */
1891 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1892 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1893 /**
1894 * Broadcast Action: The time was set.
1895 */
1896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1897 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1898 /**
1899 * Broadcast Action: The date has changed.
1900 */
1901 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1902 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1903 /**
1904 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1905 * <ul>
1906 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1907 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001908 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001909 * <p class="note">This is a protected intent that can only be sent
1910 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001911 */
1912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1913 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1914 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001915 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1916 * DNS entries should be tossed.
1917 * @hide
1918 */
1919 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1920 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1921 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001922 * Alarm Changed Action: This is broadcast when the AlarmClock
1923 * application's alarm is set or unset. It is used by the
1924 * AlarmClock application and the StatusBar service.
1925 * @hide
1926 */
1927 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1928 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001929
1930 /**
1931 * Broadcast Action: This is broadcast once, after the system has finished
1932 * booting and the user is in a "locked" state. A user is locked when their
1933 * credential-encrypted private app data storage is unavailable. Once the
1934 * user has entered their credentials (such as a lock pattern or PIN) for
1935 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1936 * sent.
1937 * <p>
1938 * You must hold the
1939 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1940 * order to receive this broadcast.
1941 * <p class="note">
1942 * This is a protected intent that can only be sent by the system.
1943 */
1944 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1945 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1946
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001947 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001948 * Broadcast Action: This is broadcast once, after the system has finished
1949 * booting. It can be used to perform application-specific initialization,
1950 * such as installing alarms. You must hold the
1951 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1952 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001953 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001954 * <p class="note">This is a protected intent that can only be sent
1955 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001956 */
1957 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1958 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001959
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001960 /**
1961 * Broadcast Action: This is broadcast when a user action should request a
1962 * temporary system dialog to dismiss. Some examples of temporary system
1963 * dialogs are the notification window-shade and the recent tasks dialog.
1964 */
1965 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1966 /**
1967 * Broadcast Action: Trigger the download and eventual installation
1968 * of a package.
1969 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001970 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001971 * <p class="note">This is a protected intent that can only be sent
1972 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001973 *
1974 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001976 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1978 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1979 /**
1980 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001981 * device. The data contains the name of the package. Note that the
1982 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001983 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001984 * <ul>
1985 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1986 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1987 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1988 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001989 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001990 * <p class="note">This is a protected intent that can only be sent
1991 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1995 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001996 * Broadcast Action: A new version of an application package has been
1997 * installed, replacing an existing version that was previously installed.
1998 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001999 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002000 * <ul>
2001 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2002 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002003 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002004 * <p class="note">This is a protected intent that can only be sent
2005 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002006 */
2007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2008 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2009 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002010 * Broadcast Action: A new version of your application has been installed
2011 * over an existing one. This is only sent to the application that was
2012 * replaced. It does not contain any additional data; to receive it, just
2013 * use an intent filter for this action.
2014 *
2015 * <p class="note">This is a protected intent that can only be sent
2016 * by the system.
2017 */
2018 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2019 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2020 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 * Broadcast Action: An existing application package has been removed from
2022 * the device. The data contains the name of the package. The package
2023 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002024 * <ul>
2025 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2026 * to the package.
2027 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2028 * application -- data and code -- is being removed.
2029 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2030 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2031 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002032 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002033 * <p class="note">This is a protected intent that can only be sent
2034 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035 */
2036 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2037 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2038 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002039 * Broadcast Action: An existing application package has been completely
2040 * removed from the device. The data contains the name of the package.
2041 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2042 * {@link #EXTRA_DATA_REMOVED} is true and
2043 * {@link #EXTRA_REPLACING} is false of that broadcast.
2044 *
2045 * <ul>
2046 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2047 * to the package.
2048 * </ul>
2049 *
2050 * <p class="note">This is a protected intent that can only be sent
2051 * by the system.
2052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2054 public static final String ACTION_PACKAGE_FULLY_REMOVED
2055 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2056 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002057 * Broadcast Action: An existing application package has been changed (e.g.
2058 * a component has been enabled or disabled). The data contains the name of
2059 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002060 * <ul>
2061 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002062 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002063 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002064 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2065 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002066 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002067 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002068 * <p class="note">This is a protected intent that can only be sent
2069 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002070 */
2071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2072 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2073 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002074 * @hide
2075 * Broadcast Action: Ask system services if there is any reason to
2076 * restart the given package. The data contains the name of the
2077 * package.
2078 * <ul>
2079 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2080 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2081 * </ul>
2082 *
2083 * <p class="note">This is a protected intent that can only be sent
2084 * by the system.
2085 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002086 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2088 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2089 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002090 * Broadcast Action: The user has restarted a package, and all of its
2091 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002092 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002093 * be removed. Note that the restarted package does <em>not</em>
2094 * receive this broadcast.
2095 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002096 * <ul>
2097 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2098 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002099 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002100 * <p class="note">This is a protected intent that can only be sent
2101 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002102 */
2103 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2104 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2105 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002106 * Broadcast Action: The user has cleared the data of a package. This should
2107 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002108 * its persistent data is erased and this broadcast sent.
2109 * Note that the cleared package does <em>not</em>
2110 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002111 * <ul>
2112 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2113 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002114 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002115 * <p class="note">This is a protected intent that can only be sent
2116 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002117 */
2118 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2119 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2120 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002121 * Broadcast Action: A user ID has been removed from the system. The user
2122 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002123 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002124 * <p class="note">This is a protected intent that can only be sent
2125 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002126 */
2127 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2128 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002129
2130 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002131 * Broadcast Action: Sent to the installer package of an application
2132 * when that application is first launched (that is the first time it
2133 * is moved out of the stopped state). The data contains the name of the package.
2134 *
2135 * <p class="note">This is a protected intent that can only be sent
2136 * by the system.
2137 */
2138 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2139 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2140
2141 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002142 * Broadcast Action: Sent to the system package verifier when a package
2143 * needs to be verified. The data contains the package URI.
2144 * <p class="note">
2145 * This is a protected intent that can only be sent by the system.
2146 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002147 */
2148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2149 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2150
2151 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002152 * Broadcast Action: Sent to the system package verifier when a package is
2153 * verified. The data contains the package URI.
2154 * <p class="note">
2155 * This is a protected intent that can only be sent by the system.
2156 */
2157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2158 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2159
2160 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002161 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2162 * needs to be verified. The data contains the filter data hosts to be verified against.
2163 * <p class="note">
2164 * This is a protected intent that can only be sent by the system.
2165 * </p>
2166 *
2167 * @hide
2168 */
2169 @SystemApi
2170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2171 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2172
2173 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002174 * Broadcast Action: Resources for a set of packages (which were
2175 * previously unavailable) are currently
2176 * available since the media on which they exist is available.
2177 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2178 * list of packages whose availability changed.
2179 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2180 * list of uids of packages whose availability changed.
2181 * Note that the
2182 * packages in this list do <em>not</em> receive this broadcast.
2183 * The specified set of packages are now available on the system.
2184 * <p>Includes the following extras:
2185 * <ul>
2186 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2187 * whose resources(were previously unavailable) are currently available.
2188 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2189 * packages whose resources(were previously unavailable)
2190 * are currently available.
2191 * </ul>
2192 *
2193 * <p class="note">This is a protected intent that can only be sent
2194 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002195 */
2196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002197 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2198 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002199
2200 /**
2201 * Broadcast Action: Resources for a set of packages are currently
2202 * unavailable since the media on which they exist is unavailable.
2203 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2204 * list of packages whose availability changed.
2205 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2206 * list of uids of packages whose availability changed.
2207 * The specified set of packages can no longer be
2208 * launched and are practically unavailable on the system.
2209 * <p>Inclues the following extras:
2210 * <ul>
2211 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2212 * whose resources are no longer available.
2213 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2214 * whose resources are no longer available.
2215 * </ul>
2216 *
2217 * <p class="note">This is a protected intent that can only be sent
2218 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002219 */
2220 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002221 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002222 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002223
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002224 /**
2225 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002226 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002227 * This should <em>only</em> be used to determine when the wallpaper
2228 * has changed to show the new wallpaper to the user. You should certainly
2229 * never, in response to this, change the wallpaper or other attributes of
2230 * it such as the suggested size. That would be crazy, right? You'd cause
2231 * all kinds of loops, especially if other apps are doing similar things,
2232 * right? Of course. So please don't do this.
2233 *
2234 * @deprecated Modern applications should use
2235 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2236 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2237 * shown behind their UI, rather than watching for this broadcast and
2238 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002239 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002240 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002241 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2242 /**
2243 * Broadcast Action: The current device {@link android.content.res.Configuration}
2244 * (orientation, locale, etc) has changed. When such a change happens, the
2245 * UIs (view hierarchy) will need to be rebuilt based on this new
2246 * information; for the most part, applications don't need to worry about
2247 * this, because the system will take care of stopping and restarting the
2248 * application to make sure it sees the new changes. Some system code that
2249 * can not be restarted will need to watch for this action and handle it
2250 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002251 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002252 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002253 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002254 * in manifests, only by explicitly registering for it with
2255 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2256 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002257 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002258 * <p class="note">This is a protected intent that can only be sent
2259 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002260 *
2261 * @see android.content.res.Configuration
2262 */
2263 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2264 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2265 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002266 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002267 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002268 * <p class="note">This is a protected intent that can only be sent
2269 * by the system.
2270 */
2271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2273 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002274 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2275 * charging state, level, and other information about the battery.
2276 * See {@link android.os.BatteryManager} for documentation on the
2277 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002278 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002279 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002280 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002281 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002282 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002283 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2284 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2285 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2286 * broadcasts that are sent and can be received through manifest
2287 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002288 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002289 * <p class="note">This is a protected intent that can only be sent
2290 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002291 */
2292 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2293 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2294 /**
2295 * Broadcast Action: Indicates low battery condition on the device.
2296 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002297 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002298 * <p class="note">This is a protected intent that can only be sent
2299 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002300 */
2301 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2302 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2303 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002304 * Broadcast Action: Indicates the battery is now okay after being low.
2305 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2306 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002307 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002308 * <p class="note">This is a protected intent that can only be sent
2309 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002310 */
2311 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2312 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2313 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002314 * Broadcast Action: External power has been connected to the device.
2315 * This is intended for applications that wish to register specifically to this notification.
2316 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2317 * stay active to receive this notification. This action can be used to implement actions
2318 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002319 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002320 * <p class="note">This is a protected intent that can only be sent
2321 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002322 */
2323 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002324 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002325 /**
2326 * Broadcast Action: External power has been removed from the device.
2327 * This is intended for applications that wish to register specifically to this notification.
2328 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2329 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002330 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002331 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002332 * <p class="note">This is a protected intent that can only be sent
2333 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002334 */
2335 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002336 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002337 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002338 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002339 * Broadcast Action: Device is shutting down.
2340 * This is broadcast when the device is being shut down (completely turned
2341 * off, not sleeping). Once the broadcast is complete, the final shutdown
2342 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002343 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002344 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002345 * <p class="note">This is a protected intent that can only be sent
2346 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002347 * <p>May include the following extras:
2348 * <ul>
2349 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2350 * shutdown is only for userspace processes. If not set, assumed to be false.
2351 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002352 */
2353 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002354 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002355 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002356 * Activity Action: Start this activity to request system shutdown.
2357 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002358 * to request confirmation from the user before shutting down. The optional boolean
2359 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2360 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002361 *
2362 * <p class="note">This is a protected intent that can only be sent
2363 * by the system.
2364 *
2365 * {@hide}
2366 */
2367 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2368 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002369 * Broadcast Action: A sticky broadcast that indicates low memory
2370 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002371 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002372 * <p class="note">This is a protected intent that can only be sent
2373 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002374 */
2375 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2376 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2377 /**
2378 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002379 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002380 * <p class="note">This is a protected intent that can only be sent
2381 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002382 */
2383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2384 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2385 /**
Jake Hambybb371632010-08-23 18:16:48 -07002386 * Broadcast Action: A sticky broadcast that indicates a memory full
2387 * condition on the device. This is intended for activities that want
2388 * to be able to fill the data partition completely, leaving only
2389 * enough free space to prevent system-wide SQLite failures.
2390 *
2391 * <p class="note">This is a protected intent that can only be sent
2392 * by the system.
2393 *
2394 * {@hide}
2395 */
2396 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2397 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2398 /**
2399 * Broadcast Action: Indicates memory full condition on the device
2400 * no longer exists.
2401 *
2402 * <p class="note">This is a protected intent that can only be sent
2403 * by the system.
2404 *
2405 * {@hide}
2406 */
2407 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2408 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2409 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002410 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2411 * and package management should be started.
2412 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2413 * notification.
2414 */
2415 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2416 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2417 /**
2418 * Broadcast Action: The device has entered USB Mass Storage mode.
2419 * This is used mainly for the USB Settings panel.
2420 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2421 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002422 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002423 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002424 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002425 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2426
2427 /**
2428 * Broadcast Action: The device has exited USB Mass Storage mode.
2429 * This is used mainly for the USB Settings panel.
2430 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2431 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002432 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002433 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002434 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002435 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2436
2437 /**
2438 * Broadcast Action: External media has been removed.
2439 * The path to the mount point for the removed media is contained in the Intent.mData field.
2440 */
2441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2442 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2443
2444 /**
2445 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002446 * 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 -07002447 */
2448 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2449 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2450
2451 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002452 * Broadcast Action: External media is present, and being disk-checked
2453 * 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 -08002454 */
2455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2456 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2457
2458 /**
2459 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2460 * 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 -08002461 */
2462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2463 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2464
2465 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002467 * 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 -07002468 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2469 * media was mounted read only.
2470 */
2471 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2472 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2473
2474 /**
2475 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002476 * 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 -07002477 */
2478 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2479 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2480
2481 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002482 * Broadcast Action: External media is no longer being shared via USB mass storage.
2483 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2484 *
2485 * @hide
2486 */
2487 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2488
2489 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002490 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2491 * The path to the mount point for the removed media is contained in the Intent.mData field.
2492 */
2493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2494 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2495
2496 /**
2497 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002498 * 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 -07002499 */
2500 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2501 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2502
2503 /**
2504 * Broadcast Action: User has expressed the desire to remove the external storage media.
2505 * Applications should close all files they have open within the mount point when they receive this intent.
2506 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2507 */
2508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2509 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2510
2511 /**
2512 * Broadcast Action: The media scanner has started scanning a directory.
2513 * The path to the directory being scanned is contained in the Intent.mData field.
2514 */
2515 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2516 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2517
2518 /**
2519 * Broadcast Action: The media scanner has finished scanning a directory.
2520 * The path to the scanned directory is contained in the Intent.mData field.
2521 */
2522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2523 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2524
2525 /**
2526 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2527 * The path to the file is contained in the Intent.mData field.
2528 */
2529 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2530 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2531
2532 /**
2533 * Broadcast Action: The "Media Button" was pressed. Includes a single
2534 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2535 * caused the broadcast.
2536 */
2537 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2538 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2539
2540 /**
2541 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2542 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2543 * caused the broadcast.
2544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2547
2548 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2549 // location; they are not general-purpose actions.
2550
2551 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002552 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002553 */
2554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2556 "android.intent.action.GTALK_CONNECTED";
2557
2558 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002559 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002560 */
2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2562 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2563 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002564
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002565 /**
2566 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002567 */
2568 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2569 public static final String ACTION_INPUT_METHOD_CHANGED =
2570 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002571
2572 /**
2573 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2574 * more radios have been turned off or on. The intent will have the following extra value:</p>
2575 * <ul>
2576 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2577 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2578 * turned off</li>
2579 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002580 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002581 * <p class="note">This is a protected intent that can only be sent
2582 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002583 */
2584 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2585 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2586
2587 /**
2588 * Broadcast Action: Some content providers have parts of their namespace
2589 * where they publish new events or items that the user may be especially
2590 * interested in. For these things, they may broadcast this action when the
2591 * set of interesting items change.
2592 *
2593 * For example, GmailProvider sends this notification when the set of unread
2594 * mail in the inbox changes.
2595 *
2596 * <p>The data of the intent identifies which part of which provider
2597 * changed. When queried through the content resolver, the data URI will
2598 * return the data set in question.
2599 *
2600 * <p>The intent will have the following extra values:
2601 * <ul>
2602 * <li><em>count</em> - The number of items in the data set. This is the
2603 * same as the number of items in the cursor returned by querying the
2604 * data URI. </li>
2605 * </ul>
2606 *
2607 * This intent will be sent at boot (if the count is non-zero) and when the
2608 * data set changes. It is possible for the data set to change without the
2609 * count changing (for example, if a new unread message arrives in the same
2610 * sync operation in which a message is archived). The phone should still
2611 * ring/vibrate/etc as normal in this case.
2612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 public static final String ACTION_PROVIDER_CHANGED =
2615 "android.intent.action.PROVIDER_CHANGED";
2616
2617 /**
2618 * Broadcast Action: Wired Headset plugged in or unplugged.
2619 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002620 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2621 * and documentation.
2622 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002623 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002624 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002625 */
2626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002627 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002628
2629 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002630 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2631 * <ul>
2632 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2633 * </ul>
2634 *
2635 * <p class="note">This is a protected intent that can only be sent
2636 * by the system.
2637 *
2638 * @hide
2639 */
2640 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2641 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2642 = "android.intent.action.ADVANCED_SETTINGS";
2643
2644 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002645 * Broadcast Action: Sent after application restrictions are changed.
2646 *
2647 * <p class="note">This is a protected intent that can only be sent
2648 * by the system.</p>
2649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2651 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2652 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2653
2654 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002655 * Broadcast Action: An outgoing call is about to be placed.
2656 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002657 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002658 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002659 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002660 * the phone number originally intended to be dialed.</li>
2661 * </ul>
2662 * <p>Once the broadcast is finished, the resultData is used as the actual
2663 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002664 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002665 * outgoing call in turn: for example, a parental control application
2666 * might verify that the user is authorized to place the call at that
2667 * time, then a number-rewriting application might add an area code if
2668 * one was not specified.</p>
2669 * <p>For consistency, any receiver whose purpose is to prohibit phone
2670 * calls should have a priority of 0, to ensure it will see the final
2671 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002672 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002673 * should have a positive priority.
2674 * Negative priorities are reserved for the system for this broadcast;
2675 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002676 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2677 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002678 * <p>Emergency calls cannot be intercepted using this mechanism, and
2679 * other calls cannot be modified to call emergency numbers using this
2680 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002681 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2682 * call to use their own service instead. Those apps should first prevent
2683 * the call from being placed by setting resultData to <code>null</code>
2684 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002685 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002686 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2687 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002688 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002689 * <p class="note">This is a protected intent that can only be sent
2690 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002691 */
2692 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2693 public static final String ACTION_NEW_OUTGOING_CALL =
2694 "android.intent.action.NEW_OUTGOING_CALL";
2695
2696 /**
2697 * Broadcast Action: Have the device reboot. This is only for use by
2698 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002699 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002700 * <p class="note">This is a protected intent that can only be sent
2701 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002702 */
2703 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2704 public static final String ACTION_REBOOT =
2705 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002706
Wei Huang97ecc9c2009-05-11 17:44:20 -07002707 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002708 * Broadcast Action: A sticky broadcast for changes in the physical
2709 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002710 *
2711 * <p>The intent will have the following extra values:
2712 * <ul>
2713 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002714 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002715 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002716 * <p>This is intended for monitoring the current physical dock state.
2717 * See {@link android.app.UiModeManager} for the normal API dealing with
2718 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2721 public static final String ACTION_DOCK_EVENT =
2722 "android.intent.action.DOCK_EVENT";
2723
2724 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002725 * Broadcast Action: A broadcast when idle maintenance can be started.
2726 * This means that the user is not interacting with the device and is
2727 * not expected to do so soon. Typical use of the idle maintenance is
2728 * to perform somehow expensive tasks that can be postponed at a moment
2729 * when they will not degrade user experience.
2730 * <p>
2731 * <p class="note">In order to keep the device responsive in case of an
2732 * unexpected user interaction, implementations of a maintenance task
2733 * should be interruptible. In such a scenario a broadcast with action
2734 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2735 * should not do the maintenance work in
2736 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2737 * maintenance service by {@link Context#startService(Intent)}. Also
2738 * you should hold a wake lock while your maintenance service is running
2739 * to prevent the device going to sleep.
2740 * </p>
2741 * <p>
2742 * <p class="note">This is a protected intent that can only be sent by
2743 * the system.
2744 * </p>
2745 *
2746 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002747 *
2748 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002749 */
2750 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2751 public static final String ACTION_IDLE_MAINTENANCE_START =
2752 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2753
2754 /**
2755 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2756 * This means that the user was not interacting with the device as a result
2757 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2758 * was sent and now the user started interacting with the device. Typical
2759 * use of the idle maintenance is to perform somehow expensive tasks that
2760 * can be postponed at a moment when they will not degrade user experience.
2761 * <p>
2762 * <p class="note">In order to keep the device responsive in case of an
2763 * unexpected user interaction, implementations of a maintenance task
2764 * should be interruptible. Hence, on receiving a broadcast with this
2765 * action, the maintenance task should be interrupted as soon as possible.
2766 * In other words, you should not do the maintenance work in
2767 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2768 * maintenance service that was started on receiving of
2769 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2770 * lock you acquired when your maintenance service started.
2771 * </p>
2772 * <p class="note">This is a protected intent that can only be sent
2773 * by the system.
2774 *
2775 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002776 *
2777 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780 public static final String ACTION_IDLE_MAINTENANCE_END =
2781 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2782
2783 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002784 * Broadcast Action: a remote intent is to be broadcasted.
2785 *
2786 * A remote intent is used for remote RPC between devices. The remote intent
2787 * is serialized and sent from one device to another device. The receiving
2788 * device parses the remote intent and broadcasts it. Note that anyone can
2789 * broadcast a remote intent. However, if the intent receiver of the remote intent
2790 * does not trust intent broadcasts from arbitrary intent senders, it should require
2791 * the sender to hold certain permissions so only trusted sender's broadcast will be
2792 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002793 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002794 */
2795 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002796 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002797
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002798 /**
2799 * Broadcast Action: hook for permforming cleanup after a system update.
2800 *
2801 * The broadcast is sent when the system is booting, before the
2802 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2803 * image. A receiver for this should do its work and then disable itself
2804 * so that it does not get run again at the next boot.
2805 * @hide
2806 */
2807 public static final String ACTION_PRE_BOOT_COMPLETED =
2808 "android.intent.action.PRE_BOOT_COMPLETED";
2809
Amith Yamasani13593602012-03-22 16:16:17 -07002810 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002811 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002812 * on restricted users. The broadcast intent contains an extra
2813 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2814 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2815 * String[] depending on the restriction type.<p/>
2816 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002817 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2818 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2819 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002820 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2821 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002822 * @see RestrictionEntry
2823 */
2824 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2825 "android.intent.action.GET_RESTRICTION_ENTRIES";
2826
2827 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002828 * Sent the first time a user is starting, to allow system apps to
2829 * perform one time initialization. (This will not be seen by third
2830 * party applications because a newly initialized user does not have any
2831 * third party applications installed for it.) This is sent early in
2832 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002833 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2834 * broadcast, since it is part of a visible user interaction; be as quick
2835 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002836 */
2837 public static final String ACTION_USER_INITIALIZE =
2838 "android.intent.action.USER_INITIALIZE";
2839
2840 /**
2841 * Sent when a user switch is happening, causing the process's user to be
2842 * brought to the foreground. This is only sent to receivers registered
2843 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2844 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002845 * foreground. This is sent as a foreground
2846 * broadcast, since it is part of a visible user interaction; be as quick
2847 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002848 */
2849 public static final String ACTION_USER_FOREGROUND =
2850 "android.intent.action.USER_FOREGROUND";
2851
2852 /**
2853 * Sent when a user switch is happening, causing the process's user to be
2854 * sent to the background. This is only sent to receivers registered
2855 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2856 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002857 * background. This is sent as a foreground
2858 * broadcast, since it is part of a visible user interaction; be as quick
2859 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002860 */
2861 public static final String ACTION_USER_BACKGROUND =
2862 "android.intent.action.USER_BACKGROUND";
2863
2864 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002865 * Broadcast sent to the system when a user is added. Carries an extra
2866 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2867 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002868 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002869 * @hide
2870 */
2871 public static final String ACTION_USER_ADDED =
2872 "android.intent.action.USER_ADDED";
2873
2874 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002875 * Broadcast sent by the system when a user is started. Carries an extra
2876 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002877 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002878 * that has been started. This is sent as a foreground
2879 * broadcast, since it is part of a visible user interaction; be as quick
2880 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002881 * @hide
2882 */
2883 public static final String ACTION_USER_STARTED =
2884 "android.intent.action.USER_STARTED";
2885
2886 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002887 * Broadcast sent when a user is in the process of starting. Carries an extra
2888 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2889 * sent to registered receivers, not manifest receivers. It is sent to all
2890 * users (including the one that is being started). You must hold
2891 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2892 * this broadcast. This is sent as a background broadcast, since
2893 * its result is not part of the primary UX flow; to safely keep track of
2894 * started/stopped state of a user you can use this in conjunction with
2895 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2896 * other user state broadcasts since those are foreground broadcasts so can
2897 * execute in a different order.
2898 * @hide
2899 */
2900 public static final String ACTION_USER_STARTING =
2901 "android.intent.action.USER_STARTING";
2902
2903 /**
2904 * Broadcast sent when a user is going to be stopped. Carries an extra
2905 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2906 * sent to registered receivers, not manifest receivers. It is sent to all
2907 * users (including the one that is being stopped). You must hold
2908 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2909 * this broadcast. The user will not stop until all receivers have
2910 * handled the broadcast. This is sent as a background broadcast, since
2911 * its result is not part of the primary UX flow; to safely keep track of
2912 * started/stopped state of a user you can use this in conjunction with
2913 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2914 * other user state broadcasts since those are foreground broadcasts so can
2915 * execute in a different order.
2916 * @hide
2917 */
2918 public static final String ACTION_USER_STOPPING =
2919 "android.intent.action.USER_STOPPING";
2920
2921 /**
2922 * Broadcast sent to the system when a user is stopped. Carries an extra
2923 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2924 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2925 * specific package. This is only sent to registered receivers, not manifest
2926 * receivers. It is sent to all running users <em>except</em> the one that
2927 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002928 * @hide
2929 */
2930 public static final String ACTION_USER_STOPPED =
2931 "android.intent.action.USER_STOPPED";
2932
2933 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002934 * 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 -07002935 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002936 * one that has been removed. The user will not be completely removed until all receivers have
2937 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002938 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002939 * @hide
2940 */
2941 public static final String ACTION_USER_REMOVED =
2942 "android.intent.action.USER_REMOVED";
2943
2944 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002945 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002946 * the userHandle of the user to become the current one. This is only sent to
2947 * registered receivers, not manifest receivers. It is sent to all running users.
2948 * You must hold
2949 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002950 * @hide
2951 */
2952 public static final String ACTION_USER_SWITCHED =
2953 "android.intent.action.USER_SWITCHED";
2954
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002955 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002956 * Broadcast Action: Sent when the credential-encrypted private storage has
2957 * become unlocked for the target user. This is only sent to registered
2958 * receivers, not manifest receivers.
2959 */
2960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2961 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2962
2963 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002964 * Broadcast sent to the system when a user's information changes. Carries an extra
2965 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07002966 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002967 * @hide
2968 */
2969 public static final String ACTION_USER_INFO_CHANGED =
2970 "android.intent.action.USER_INFO_CHANGED";
2971
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002972 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002973 * Broadcast sent to the primary user when an associated managed profile is added (the profile
2974 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01002975 * the UserHandle of the profile that was added. Only applications (for example Launchers)
2976 * that need to display merged content across both primary and managed profiles need to
2977 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002978 * not manifest receivers.
2979 */
2980 public static final String ACTION_MANAGED_PROFILE_ADDED =
2981 "android.intent.action.MANAGED_PROFILE_ADDED";
2982
2983 /**
2984 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01002985 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
2986 * Only applications (for example Launchers) that need to display merged content across both
2987 * primary and managed profiles need to worry about this broadcast. This is only sent to
2988 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01002989 */
2990 public static final String ACTION_MANAGED_PROFILE_REMOVED =
2991 "android.intent.action.MANAGED_PROFILE_REMOVED";
2992
2993 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04002994 * Sent when the user taps on the clock widget in the system's "quick settings" area.
2995 */
2996 public static final String ACTION_QUICK_CLOCK =
2997 "android.intent.action.QUICK_CLOCK";
2998
Michael Wright0087a142013-02-05 16:29:39 -08002999 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003000 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003001 * @hide
3002 */
3003 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3004 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3005
Justin Kohd378ad72013-04-01 12:18:26 -07003006 /**
3007 * Broadcast Action: A global button was pressed. Includes a single
3008 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3009 * caused the broadcast.
3010 * @hide
3011 */
3012 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3013
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003014 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003015 * Activity Action: Allow the user to select and return one or more existing
3016 * documents. When invoked, the system will display the various
3017 * {@link DocumentsProvider} instances installed on the device, letting the
3018 * user interactively navigate through them. These documents include local
3019 * media, such as photos and video, and documents provided by installed
3020 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003021 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003022 * Each document is represented as a {@code content://} URI backed by a
3023 * {@link DocumentsProvider}, which can be opened as a stream with
3024 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3025 * {@link android.provider.DocumentsContract.Document} metadata.
3026 * <p>
3027 * All selected documents are returned to the calling application with
3028 * persistable read and write permission grants. If you want to maintain
3029 * access to the documents across device reboots, you need to explicitly
3030 * take the persistable permissions using
3031 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3032 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003033 * Callers must indicate the acceptable document MIME types through
3034 * {@link #setType(String)}. For example, to select photos, use
3035 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3036 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3037 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003038 * <p>
3039 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003040 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3041 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003042 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003043 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3044 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003045 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003046 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003047 * Output: The URI of the item that was picked, returned in
3048 * {@link #getData()}. This must be a {@code content://} URI so that any
3049 * receiver can access it. If multiple documents were selected, they are
3050 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003051 *
3052 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003053 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003054 * @see #ACTION_CREATE_DOCUMENT
3055 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003056 */
3057 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3058 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3059
3060 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003061 * Activity Action: Allow the user to create a new document. When invoked,
3062 * the system will display the various {@link DocumentsProvider} instances
3063 * installed on the device, letting the user navigate through them. The
3064 * returned document may be a newly created document with no content, or it
3065 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003066 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003067 * Each document is represented as a {@code content://} URI backed by a
3068 * {@link DocumentsProvider}, which can be opened as a stream with
3069 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3070 * {@link android.provider.DocumentsContract.Document} metadata.
3071 * <p>
3072 * Callers must indicate the concrete MIME type of the document being
3073 * created by setting {@link #setType(String)}. This MIME type cannot be
3074 * changed after the document is created.
3075 * <p>
3076 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3077 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003078 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003079 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3080 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003081 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003082 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003083 * Output: The URI of the item that was created. This must be a
3084 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003085 *
3086 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003087 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003088 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003089 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003090 */
3091 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3092 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3093
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003094 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003095 * Activity Action: Allow the user to pick a directory subtree. When
3096 * invoked, the system will display the various {@link DocumentsProvider}
3097 * instances installed on the device, letting the user navigate through
3098 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003099 * <p>
3100 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003101 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3102 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3103 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003104 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003105 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003106 *
3107 * @see DocumentsContract
3108 */
3109 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003110 public static final String
3111 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003112
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003113 /** {@hide} */
3114 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3115
Christopher Tate6597e342015-02-17 12:15:25 -08003116 /**
3117 * Broadcast action: report that a settings element is being restored from backup. The intent
3118 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3119 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3120 * is the value of that settings entry prior to the restore operation. All of these values are
3121 * represented as strings.
3122 *
3123 * <p>This broadcast is sent only for settings provider entries known to require special handling
3124 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3125 * the provider's backup agent implementation.
3126 *
3127 * @see #EXTRA_SETTING_NAME
3128 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3129 * @see #EXTRA_SETTING_NEW_VALUE
3130 * {@hide}
3131 */
3132 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3133
3134 /** {@hide} */
3135 public static final String EXTRA_SETTING_NAME = "setting_name";
3136 /** {@hide} */
3137 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3138 /** {@hide} */
3139 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3140
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003141 /**
3142 * Activity Action: Process a piece of text.
3143 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3144 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3145 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3146 */
3147 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3148 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3149 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003150 * The name of the extra used to define the text to be processed, as a
3151 * CharSequence. Note that this may be a styled CharSequence, so you must use
3152 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003153 */
3154 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3155 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003156 * 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 +00003157 */
3158 public static final String EXTRA_PROCESS_TEXT_READONLY =
3159 "android.intent.extra.PROCESS_TEXT_READONLY";
3160
Bryce Leebc58f592015-09-25 16:43:01 -07003161 /**
3162 * Broadcast action: reports when a new thermal event has been reached. When the device
3163 * is reaching its maximum temperatue, the thermal level reported
3164 * {@hide}
3165 */
3166 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3167 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3168
3169 /** {@hide} */
3170 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3171
3172 /**
3173 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003174 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003175 * {@hide}
3176 */
3177 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3178
3179 /**
3180 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003181 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003182 * {@hide}
3183 */
3184 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3185
3186 /**
3187 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003188 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003189 * {@hide}
3190 */
3191 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3192
3193
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003194 // ---------------------------------------------------------------------
3195 // ---------------------------------------------------------------------
3196 // Standard intent categories (see addCategory()).
3197
3198 /**
3199 * Set if the activity should be an option for the default action
3200 * (center press) to perform on a piece of data. Setting this will
3201 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003202 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003203 * Intent when initiating an action -- it is for use in intent filters
3204 * specified in packages.
3205 */
3206 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3207 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3208 /**
3209 * Activities that can be safely invoked from a browser must support this
3210 * category. For example, if the user is viewing a web page or an e-mail
3211 * and clicks on a link in the text, the Intent generated execute that
3212 * link will require the BROWSABLE category, so that only activities
3213 * supporting this category will be considered as possible actions. By
3214 * supporting this category, you are promising that there is nothing
3215 * damaging (without user intervention) that can happen by invoking any
3216 * matching Intent.
3217 */
3218 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3219 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3220 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003221 * Categories for activities that can participate in voice interaction.
3222 * An activity that supports this category must be prepared to run with
3223 * no UI shown at all (though in some case it may have a UI shown), and
3224 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3225 */
3226 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3227 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3228 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003229 * Set if the activity should be considered as an alternative action to
3230 * the data the user is currently viewing. See also
3231 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3232 * applies to the selection in a list of items.
3233 *
3234 * <p>Supporting this category means that you would like your activity to be
3235 * displayed in the set of alternative things the user can do, usually as
3236 * part of the current activity's options menu. You will usually want to
3237 * include a specific label in the &lt;intent-filter&gt; of this action
3238 * describing to the user what it does.
3239 *
3240 * <p>The action of IntentFilter with this category is important in that it
3241 * describes the specific action the target will perform. This generally
3242 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3243 * a specific name such as "com.android.camera.action.CROP. Only one
3244 * alternative of any particular action will be shown to the user, so using
3245 * a specific action like this makes sure that your alternative will be
3246 * displayed while also allowing other applications to provide their own
3247 * overrides of that particular action.
3248 */
3249 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3250 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3251 /**
3252 * Set if the activity should be considered as an alternative selection
3253 * action to the data the user has currently selected. This is like
3254 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3255 * of items from which the user can select, giving them alternatives to the
3256 * default action that will be performed on it.
3257 */
3258 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3259 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3260 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003261 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003262 */
3263 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3264 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3265 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003266 * Should be displayed in the top-level launcher.
3267 */
3268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3269 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3270 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003271 * Indicates an activity optimized for Leanback mode, and that should
3272 * be displayed in the Leanback launcher.
3273 */
3274 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3275 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3276 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003277 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3278 * @hide
3279 */
3280 @SystemApi
3281 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3282 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003283 * Provides information about the package it is in; typically used if
3284 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3285 * a front-door to the user without having to be shown in the all apps list.
3286 */
3287 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3288 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3289 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003290 * This is the home activity, that is the first activity that is displayed
3291 * when the device boots.
3292 */
3293 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3294 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3295 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003296 * This is the home activity that is displayed when the device is finished setting up and ready
3297 * for use.
3298 * @hide
3299 */
3300 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3301 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3302 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003303 * This is the setup wizard activity, that is the first activity that is displayed
3304 * when the user sets up the device for the first time.
3305 * @hide
3306 */
3307 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3308 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3309 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003310 * This activity is a preference panel.
3311 */
3312 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3313 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3314 /**
3315 * This activity is a development preference panel.
3316 */
3317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3318 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3319 /**
3320 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003321 */
3322 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3323 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3324 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003325 * This activity allows the user to browse and download new applications.
3326 */
3327 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3328 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3329 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003330 * This activity may be exercised by the monkey or other automated test tools.
3331 */
3332 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3333 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3334 /**
3335 * To be used as a test (not part of the normal user experience).
3336 */
3337 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3338 /**
3339 * To be used as a unit test (run through the Test Harness).
3340 */
3341 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3342 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003343 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003344 * experience).
3345 */
3346 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003347
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003348 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003349 * Used to indicate that an intent only wants URIs that can be opened with
3350 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3351 * must support at least the columns defined in {@link OpenableColumns} when
3352 * queried.
3353 *
3354 * @see #ACTION_GET_CONTENT
3355 * @see #ACTION_OPEN_DOCUMENT
3356 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003357 */
3358 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3359 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3360
3361 /**
3362 * To be used as code under test for framework instrumentation tests.
3363 */
3364 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3365 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003366 /**
3367 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003368 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3369 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003370 */
3371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3372 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3373 /**
3374 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003375 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3376 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003377 */
3378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3379 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003380 /**
3381 * An activity to run when device is inserted into a analog (low end) dock.
3382 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3383 * information, see {@link android.app.UiModeManager}.
3384 */
3385 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3386 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3387
3388 /**
3389 * An activity to run when device is inserted into a digital (high end) dock.
3390 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3391 * information, see {@link android.app.UiModeManager}.
3392 */
3393 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3394 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003395
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003396 /**
3397 * Used to indicate that the activity can be used in a car environment.
3398 */
3399 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3400 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3401
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003402 // ---------------------------------------------------------------------
3403 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003404 // Application launch intent categories (see addCategory()).
3405
3406 /**
3407 * Used with {@link #ACTION_MAIN} to launch the browser application.
3408 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003409 * <p>NOTE: This should not be used as the primary key of an Intent,
3410 * since it will not result in the app launching with the correct
3411 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003412 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003413 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003414 */
3415 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3416 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3417
3418 /**
3419 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3420 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003421 * <p>NOTE: This should not be used as the primary key of an Intent,
3422 * since it will not result in the app launching with the correct
3423 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003424 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003425 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003426 */
3427 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3428 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3429
3430 /**
3431 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3432 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003433 * <p>NOTE: This should not be used as the primary key of an Intent,
3434 * since it will not result in the app launching with the correct
3435 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003436 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003437 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003438 */
3439 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3440 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3441
3442 /**
3443 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3444 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003445 * <p>NOTE: This should not be used as the primary key of an Intent,
3446 * since it will not result in the app launching with the correct
3447 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003448 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003449 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003450 */
3451 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3452 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3453
3454 /**
3455 * Used with {@link #ACTION_MAIN} to launch the email application.
3456 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003457 * <p>NOTE: This should not be used as the primary key of an Intent,
3458 * since it will not result in the app launching with the correct
3459 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003460 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003461 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003462 */
3463 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3464 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3465
3466 /**
3467 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3468 * The activity should be able to view and manipulate image and video files
3469 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003470 * <p>NOTE: This should not be used as the primary key of an Intent,
3471 * since it will not result in the app launching with the correct
3472 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003473 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003474 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003475 */
3476 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3477 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3478
3479 /**
3480 * Used with {@link #ACTION_MAIN} to launch the maps application.
3481 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003482 * <p>NOTE: This should not be used as the primary key of an Intent,
3483 * since it will not result in the app launching with the correct
3484 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003485 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003486 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003487 */
3488 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3489 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3490
3491 /**
3492 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3493 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003494 * <p>NOTE: This should not be used as the primary key of an Intent,
3495 * since it will not result in the app launching with the correct
3496 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003497 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003498 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003499 */
3500 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3501 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3502
3503 /**
3504 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003505 * The activity should be able to play, browse, or manipulate music files
3506 * stored on the device.
3507 * <p>NOTE: This should not be used as the primary key of an Intent,
3508 * since it will not result in the app launching with the correct
3509 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003510 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003511 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003512 */
3513 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3514 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3515
3516 // ---------------------------------------------------------------------
3517 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003518 // Standard extra data keys.
3519
3520 /**
3521 * The initial data to place in a newly created record. Use with
3522 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3523 * fields as would be given to the underlying ContentProvider.insert()
3524 * call.
3525 */
3526 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3527
3528 /**
3529 * A constant CharSequence that is associated with the Intent, used with
3530 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3531 * this may be a styled CharSequence, so you must use
3532 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3533 * retrieve it.
3534 */
3535 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3536
3537 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003538 * A constant String that is associated with the Intent, used with
3539 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3540 * as HTML formatted text. Note that you <em>must</em> also supply
3541 * {@link #EXTRA_TEXT}.
3542 */
3543 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3544
3545 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003546 * A content: URI holding a stream of data associated with the Intent,
3547 * used with {@link #ACTION_SEND} to supply the data being sent.
3548 */
3549 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3550
3551 /**
3552 * A String[] holding e-mail addresses that should be delivered to.
3553 */
3554 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3555
3556 /**
3557 * A String[] holding e-mail addresses that should be carbon copied.
3558 */
3559 public static final String EXTRA_CC = "android.intent.extra.CC";
3560
3561 /**
3562 * A String[] holding e-mail addresses that should be blind carbon copied.
3563 */
3564 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3565
3566 /**
3567 * A constant string holding the desired subject line of a message.
3568 */
3569 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3570
3571 /**
3572 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003573 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003574 */
3575 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3576
3577 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003578 * An int representing the user id to be used.
3579 *
3580 * @hide
3581 */
3582 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3583
3584 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003585 * An Intent[] describing additional, alternate choices you would like shown with
3586 * {@link #ACTION_CHOOSER}.
3587 *
3588 * <p>An app may be capable of providing several different payload types to complete a
3589 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3590 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3591 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3592 * photo data or a hosted link where the photos can be viewed.</p>
3593 *
3594 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3595 * first/primary/preferred intent in the set. Additional intents specified in
3596 * this extra are ordered; by default intents that appear earlier in the array will be
3597 * preferred over intents that appear later in the array as matches for the same
3598 * target component. To alter this preference, a calling app may also supply
3599 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3600 */
3601 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3602
3603 /**
3604 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3605 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3606 *
3607 * <p>An app preparing an action for another app to complete may wish to allow the user to
3608 * disambiguate between several options for completing the action based on the chosen target
3609 * or otherwise refine the action before it is invoked.
3610 * </p>
3611 *
3612 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3613 * <ul>
3614 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3615 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3616 * chosen target beyond the first</li>
3617 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3618 * should fill in and send once the disambiguation is complete</li>
3619 * </ul>
3620 */
3621 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3622 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3623
3624 /**
3625 * A {@link ResultReceiver} used to return data back to the sender.
3626 *
3627 * <p>Used to complete an app-specific
3628 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3629 *
3630 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3631 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3632 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3633 * when the user selects a target component from the chooser. It is up to the recipient
3634 * to send a result to this ResultReceiver to signal that disambiguation is complete
3635 * and that the chooser should invoke the user's choice.</p>
3636 *
3637 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3638 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3639 * to match and fill in the final Intent or ChooserTarget before starting it.
3640 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3641 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3642 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3643 *
3644 * <p>The result code passed to the ResultReceiver should be
3645 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3646 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3647 * the chooser should finish without starting a target.</p>
3648 */
3649 public static final String EXTRA_RESULT_RECEIVER
3650 = "android.intent.extra.RESULT_RECEIVER";
3651
3652 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003653 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003654 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003655 */
3656 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3657
3658 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003659 * A Parcelable[] of {@link Intent} or
3660 * {@link android.content.pm.LabeledIntent} objects as set with
3661 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3662 * a the front of the list of choices, when shown to the user with a
3663 * {@link #ACTION_CHOOSER}.
3664 */
3665 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3666
3667 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003668 * A Bundle forming a mapping of potential target package names to different extras Bundles
3669 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3670 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3671 * be currently installed on the device.
3672 *
3673 * <p>An application may choose to provide alternate extras for the case where a user
3674 * selects an activity from a predetermined set of target packages. If the activity
3675 * the user selects from the chooser belongs to a package with its package name as
3676 * a key in this bundle, the corresponding extras for that package will be merged with
3677 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3678 * extra has the same key as an extra already present in the intent it will overwrite
3679 * the extra from the intent.</p>
3680 *
3681 * <p><em>Examples:</em>
3682 * <ul>
3683 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3684 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3685 * parameters for that target.</li>
3686 * <li>An application may offer additional metadata for known targets of a given intent
3687 * to pass along information only relevant to that target such as account or content
3688 * identifiers already known to that application.</li>
3689 * </ul></p>
3690 */
3691 public static final String EXTRA_REPLACEMENT_EXTRAS =
3692 "android.intent.extra.REPLACEMENT_EXTRAS";
3693
3694 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003695 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3696 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3697 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3698 * {@link ComponentName} of the chosen component.
3699 *
3700 * <p>In some situations this callback may never come, for example if the user abandons
3701 * the chooser, switches to another task or any number of other reasons. Apps should not
3702 * be written assuming that this callback will always occur.</p>
3703 */
3704 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3705 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3706
3707 /**
3708 * The {@link ComponentName} chosen by the user to complete an action.
3709 *
3710 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3711 */
3712 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3713
3714 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003715 * A {@link android.view.KeyEvent} object containing the event that
3716 * triggered the creation of the Intent it is in.
3717 */
3718 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3719
3720 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003721 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3722 * before shutting down.
3723 *
3724 * {@hide}
3725 */
3726 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3727
3728 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003729 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3730 * requested by the user.
3731 *
3732 * {@hide}
3733 */
3734 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3735 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3736
3737 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003738 * 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 -07003739 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3740 * of restarting the application.
3741 */
3742 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3743
3744 /**
3745 * A String holding the phone number originally entered in
3746 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3747 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3748 */
3749 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003750
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003751 /**
3752 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3753 * intents to supply the uid the package had been assigned. Also an optional
3754 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3755 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3756 * purpose.
3757 */
3758 public static final String EXTRA_UID = "android.intent.extra.UID";
3759
3760 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003761 * @hide String array of package names.
3762 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003763 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003764 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3765
3766 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003767 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3768 * intents to indicate whether this represents a full uninstall (removing
3769 * both the code and its data) or a partial uninstall (leaving its data,
3770 * implying that this is an update).
3771 */
3772 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003773
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003774 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003775 * @hide
3776 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3777 * intents to indicate that at this point the package has been removed for
3778 * all users on the device.
3779 */
3780 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3781 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3782
3783 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003784 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3785 * intents to indicate that this is a replacement of the package, so this
3786 * broadcast will immediately be followed by an add broadcast for a
3787 * different version of the same package.
3788 */
3789 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003790
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003791 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003792 * Used as an int extra field in {@link android.app.AlarmManager} intents
3793 * to tell the application being invoked how many pending alarms are being
3794 * delievered with the intent. For one-shot alarms this will always be 1.
3795 * For recurring alarms, this might be greater than 1 if the device was
3796 * asleep or powered off at the time an earlier alarm would have been
3797 * delivered.
3798 */
3799 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003800
Jacek Surazski86b6c532009-05-13 14:38:28 +02003801 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003802 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3803 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003804 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3805 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003806 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3807 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3808 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003809 */
3810 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3811
3812 /**
3813 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3814 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003815 */
3816 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3817
3818 /**
3819 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3820 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003821 */
3822 public static final int EXTRA_DOCK_STATE_DESK = 1;
3823
3824 /**
3825 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3826 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003827 */
3828 public static final int EXTRA_DOCK_STATE_CAR = 2;
3829
3830 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003831 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3832 * to represent that the phone is in a analog (low end) dock.
3833 */
3834 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3835
3836 /**
3837 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3838 * to represent that the phone is in a digital (high end) dock.
3839 */
3840 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3841
3842 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003843 * Boolean that can be supplied as meta-data with a dock activity, to
3844 * indicate that the dock should take over the home key when it is active.
3845 */
3846 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003847
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003848 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003849 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3850 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003851 */
3852 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3853
3854 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003855 * Used in the extra field in the remote intent. It's astring token passed with the
3856 * remote intent.
3857 */
3858 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3859 "android.intent.extra.remote_intent_token";
3860
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003861 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003862 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003863 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003864 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003865 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003866 "android.intent.extra.changed_component_name";
3867
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003868 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003869 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003870 * and contains a string array of all of the components that have changed. If
3871 * the state of the overall package has changed, then it will contain an entry
3872 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003873 */
3874 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3875 "android.intent.extra.changed_component_name_list";
3876
3877 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003878 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003879 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3880 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003881 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003882 */
3883 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3884 "android.intent.extra.changed_package_list";
3885
3886 /**
3887 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003888 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3889 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003890 * and contains an integer array of uids of all of the components
3891 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003892 */
3893 public static final String EXTRA_CHANGED_UID_LIST =
3894 "android.intent.extra.changed_uid_list";
3895
3896 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003897 * @hide
3898 * Magic extra system code can use when binding, to give a label for
3899 * who it is that has bound to a service. This is an integer giving
3900 * a framework string resource that can be displayed to the user.
3901 */
3902 public static final String EXTRA_CLIENT_LABEL =
3903 "android.intent.extra.client_label";
3904
3905 /**
3906 * @hide
3907 * Magic extra system code can use when binding, to give a PendingIntent object
3908 * that can be launched for the user to disable the system's use of this
3909 * service.
3910 */
3911 public static final String EXTRA_CLIENT_INTENT =
3912 "android.intent.extra.client_intent";
3913
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003914 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003915 * Extra used to indicate that an intent should only return data that is on
3916 * the local device. This is a boolean extra; the default is false. If true,
3917 * an implementation should only allow the user to select data that is
3918 * already on the device, not requiring it be downloaded from a remote
3919 * service when opened.
3920 *
3921 * @see #ACTION_GET_CONTENT
3922 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003923 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003924 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08003925 */
3926 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003927 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07003928
Amith Yamasani13593602012-03-22 16:16:17 -07003929 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003930 * Extra used to indicate that an intent can allow the user to select and
3931 * return multiple items. This is a boolean extra; the default is false. If
3932 * true, an implementation is allowed to present the user with a UI where
3933 * they can pick multiple items that are all returned to the caller. When
3934 * this happens, they should be returned as the {@link #getClipData()} part
3935 * of the result Intent.
3936 *
3937 * @see #ACTION_GET_CONTENT
3938 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003939 */
3940 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003941 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08003942
3943 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003944 * The integer userHandle carried with broadcast intents related to addition, removal and
3945 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
3946 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
3947 *
Amith Yamasani13593602012-03-22 16:16:17 -07003948 * @hide
3949 */
Amith Yamasani2a003292012-08-14 18:25:45 -07003950 public static final String EXTRA_USER_HANDLE =
3951 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07003952
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003953 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003954 * The UserHandle carried with broadcasts intents related to addition and removal of managed
3955 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
3956 */
3957 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01003958 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003959
3960 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003961 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003962 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
3963 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003964 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003965 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
3966
3967 /**
3968 * Extra sent in the intent to the BroadcastReceiver that handles
3969 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
3970 * the restrictions as key/value pairs.
3971 */
3972 public static final String EXTRA_RESTRICTIONS_BUNDLE =
3973 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003974
Amith Yamasani86118ba2013-03-28 14:33:16 -07003975 /**
3976 * Extra used in the response from a BroadcastReceiver that handles
3977 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
3978 */
3979 public static final String EXTRA_RESTRICTIONS_INTENT =
3980 "android.intent.extra.restrictions_intent";
3981
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003982 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003983 * Extra used to communicate a set of acceptable MIME types. The type of the
3984 * extra is {@code String[]}. Values may be a combination of concrete MIME
3985 * types (such as "image/png") and/or partial MIME types (such as
3986 * "audio/*").
3987 *
3988 * @see #ACTION_GET_CONTENT
3989 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003990 */
3991 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
3992
Dianne Hackborn57a7f592013-07-22 18:21:32 -07003993 /**
3994 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
3995 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07003996 * When this is true, hardware devices can use this information to determine that
3997 * they shouldn't do a complete shutdown of their device since this is not a
3998 * complete shutdown down to the kernel, but only user space restarting.
3999 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004000 */
4001 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4002 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4003
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004004 /**
4005 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4006 * user has set their time format preferences to the 24 hour format.
4007 *
4008 * @hide for internal use only.
4009 */
4010 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4011 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4012
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004013 /** {@hide} */
4014 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4015
Rubin Xue8490f12015-06-25 12:17:48 +01004016 /** {@hide} */
4017 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4018
Santos Cordon15a13782015-03-31 18:32:31 -07004019 /**
4020 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4021 * activation request.
4022 * TODO: Add information about the structure and response data used with the pending intent.
4023 * @hide
4024 */
4025 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4026 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4027
Steve McKay6eaf38632015-08-04 10:11:01 -07004028 /** {@hide} */
4029 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4030
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004031 // ---------------------------------------------------------------------
4032 // ---------------------------------------------------------------------
4033 // Intent flags (see mFlags variable).
4034
Tor Norbyed9273d62013-05-30 15:59:53 -07004035 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004036 @IntDef(flag = true, value = {
4037 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4038 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004039 @Retention(RetentionPolicy.SOURCE)
4040 public @interface GrantUriMode {}
4041
Jeff Sharkey846318a2014-04-04 12:12:41 -07004042 /** @hide */
4043 @IntDef(flag = true, value = {
4044 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4045 @Retention(RetentionPolicy.SOURCE)
4046 public @interface AccessUriMode {}
4047
4048 /**
4049 * Test if given mode flags specify an access mode, which must be at least
4050 * read and/or write.
4051 *
4052 * @hide
4053 */
4054 public static boolean isAccessUriMode(int modeFlags) {
4055 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4056 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4057 }
4058
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004059 /**
4060 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004061 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004062 * specified in its ClipData. When applying to an Intent's ClipData,
4063 * all URIs as well as recursive traversals through data or other ClipData
4064 * in Intent items will be granted; only the grant flags of the top-level
4065 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004066 */
4067 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4068 /**
4069 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004070 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004071 * specified in its ClipData. When applying to an Intent's ClipData,
4072 * all URIs as well as recursive traversals through data or other ClipData
4073 * in Intent items will be granted; only the grant flags of the top-level
4074 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004075 */
4076 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4077 /**
4078 * Can be set by the caller to indicate that this Intent is coming from
4079 * a background operation, not from direct user interaction.
4080 */
4081 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4082 /**
4083 * A flag you can enable for debugging: when set, log messages will be
4084 * printed during the resolution of this intent to show you what has
4085 * been found to create the final resolved list.
4086 */
4087 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004088 /**
4089 * If set, this intent will not match any components in packages that
4090 * are currently stopped. If this is not set, then the default behavior
4091 * is to include such applications in the result.
4092 */
4093 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4094 /**
4095 * If set, this intent will always match any components in packages that
4096 * are currently stopped. This is the default behavior when
4097 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4098 * flags are set, this one wins (it allows overriding of exclude for
4099 * places where the framework may automatically set the exclude flag).
4100 */
4101 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004102
4103 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004104 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004105 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004106 * persisted across device reboots until explicitly revoked with
4107 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4108 * grant for possible persisting; the receiving application must call
4109 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4110 * actually persist.
4111 *
4112 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4113 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4114 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004115 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004116 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004117 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004118
4119 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004120 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4121 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4122 * applies to any URI that is a prefix match against the original granted
4123 * URI. (Without this flag, the URI must match exactly for access to be
4124 * granted.) Another URI is considered a prefix match only when scheme,
4125 * authority, and all path segments defined by the prefix are an exact
4126 * match.
4127 */
4128 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4129
4130 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004131 * If set, the new activity is not kept in the history stack. As soon as
4132 * the user navigates away from it, the activity is finished. This may also
4133 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4134 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004135 *
4136 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4137 * is never invoked when the current activity starts a new activity which
4138 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004139 */
4140 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4141 /**
4142 * If set, the activity will not be launched if it is already running
4143 * at the top of the history stack.
4144 */
4145 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4146 /**
4147 * If set, this activity will become the start of a new task on this
4148 * history stack. A task (from the activity that started it to the
4149 * next task activity) defines an atomic group of activities that the
4150 * user can move to. Tasks can be moved to the foreground and background;
4151 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004152 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004153 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4154 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004155 *
4156 * <p>This flag is generally used by activities that want
4157 * to present a "launcher" style behavior: they give the user a list of
4158 * separate things that can be done, which otherwise run completely
4159 * independently of the activity launching them.
4160 *
4161 * <p>When using this flag, if a task is already running for the activity
4162 * you are now starting, then a new activity will not be started; instead,
4163 * the current task will simply be brought to the front of the screen with
4164 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4165 * to disable this behavior.
4166 *
4167 * <p>This flag can not be used when the caller is requesting a result from
4168 * the activity being launched.
4169 */
4170 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4171 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004172 * This flag is used to create a new task and launch an activity into it.
4173 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4174 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4175 * search through existing tasks for ones matching this Intent. Only if no such
4176 * task is found would a new task be created. When paired with
4177 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4178 * the search for a matching task and unconditionally start a new task.
4179 *
4180 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4181 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004182 * top-level application launcher.</strong> Used in conjunction with
4183 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4184 * behavior of bringing an existing task to the foreground. When set,
4185 * a new task is <em>always</em> started to host the Activity for the
4186 * Intent, regardless of whether there is already an existing task running
4187 * the same thing.
4188 *
4189 * <p><strong>Because the default system does not include graphical task management,
4190 * you should not use this flag unless you provide some way for a user to
4191 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004192 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004193 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4194 * creating new document tasks.
4195 *
4196 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004197 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 *
Scott Main7aee61f2011-02-08 11:25:01 -08004199 * <p>See
4200 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4201 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004202 *
4203 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4204 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004205 */
4206 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4207 /**
4208 * If set, and the activity being launched is already running in the
4209 * current task, then instead of launching a new instance of that activity,
4210 * all of the other activities on top of it will be closed and this Intent
4211 * will be delivered to the (now on top) old activity as a new Intent.
4212 *
4213 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4214 * If D calls startActivity() with an Intent that resolves to the component
4215 * of activity B, then C and D will be finished and B receive the given
4216 * Intent, resulting in the stack now being: A, B.
4217 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004218 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004219 * either receive the new intent you are starting here in its
4220 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004221 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004222 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4223 * the same intent, then it will be finished and re-created; for all other
4224 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4225 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004226 *
4227 * <p>This launch mode can also be used to good effect in conjunction with
4228 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4229 * of a task, it will bring any currently running instance of that task
4230 * to the foreground, and then clear it to its root state. This is
4231 * especially useful, for example, when launching an activity from the
4232 * notification manager.
4233 *
Scott Main7aee61f2011-02-08 11:25:01 -08004234 * <p>See
4235 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4236 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004237 */
4238 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4239 /**
4240 * If set and this intent is being used to launch a new activity from an
4241 * existing one, then the reply target of the existing activity will be
4242 * transfered to the new activity. This way the new activity can call
4243 * {@link android.app.Activity#setResult} and have that result sent back to
4244 * the reply target of the original activity.
4245 */
4246 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4247 /**
4248 * If set and this intent is being used to launch a new activity from an
4249 * existing one, the current activity will not be counted as the top
4250 * activity for deciding whether the new intent should be delivered to
4251 * the top instead of starting a new one. The previous activity will
4252 * be used as the top, with the assumption being that the current activity
4253 * will finish itself immediately.
4254 */
4255 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4256 /**
4257 * If set, the new activity is not kept in the list of recently launched
4258 * activities.
4259 */
4260 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4261 /**
4262 * This flag is not normally set by application code, but set for you by
4263 * the system as described in the
4264 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4265 * launchMode} documentation for the singleTask mode.
4266 */
4267 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4268 /**
4269 * If set, and this activity is either being started in a new task or
4270 * bringing to the top an existing task, then it will be launched as
4271 * the front door of the task. This will result in the application of
4272 * any affinities needed to have that task in the proper state (either
4273 * moving activities to or from it), or simply resetting that task to
4274 * its initial state if needed.
4275 */
4276 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4277 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004278 * This flag is not normally set by application code, but set for you by
4279 * the system if this activity is being launched from history
4280 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004281 */
4282 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004283 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004284 * @deprecated As of API 21 this performs identically to
4285 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004286 */
4287 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004288 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004289 * This flag is used to open a document into a new task rooted at the activity launched
4290 * by this Intent. Through the use of this flag, or its equivalent attribute,
4291 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004292 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004293 *
Craig Mautner026596b2014-05-21 15:35:44 -07004294 * <p>The use of the activity attribute form of this,
4295 * {@link android.R.attr#documentLaunchMode}, is
4296 * preferred over the Intent flag described here. The attribute form allows the
4297 * Activity to specify multiple document behavior for all launchers of the Activity
4298 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004299 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004300 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4301 * it is kept after the activity is finished is different than the use of
4302 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4303 * this flag is being used to create a new recents entry, then by default that entry
4304 * will be removed once the activity is finished. You can modify this behavior with
4305 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4306 *
Craig Mautner026596b2014-05-21 15:35:44 -07004307 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4308 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4309 * equivalent of the Activity manifest specifying {@link
4310 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4311 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4312 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004313 *
Craig Mautner026596b2014-05-21 15:35:44 -07004314 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004315 *
Craig Mautner026596b2014-05-21 15:35:44 -07004316 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004317 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4318 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004319 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004320 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004321 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004322 * callback from occurring on the current frontmost activity before it is
4323 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004324 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004325 * <p>Typically, an activity can rely on that callback to indicate that an
4326 * explicit user action has caused their activity to be moved out of the
4327 * foreground. The callback marks an appropriate point in the activity's
4328 * lifecycle for it to dismiss any notifications that it intends to display
4329 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004330 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004331 * <p>If an activity is ever started via any non-user-driven events such as
4332 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4333 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004334 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004335 */
4336 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004337 /**
4338 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4339 * this flag will cause the launched activity to be brought to the front of its
4340 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004341 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004342 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4343 * If D calls startActivity() with an Intent that resolves to the component
4344 * of activity B, then B will be brought to the front of the history stack,
4345 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004346 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004347 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004348 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004349 */
4350 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004351 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004352 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4353 * this flag will prevent the system from applying an activity transition
4354 * animation to go to the next activity state. This doesn't mean an
4355 * animation will never run -- if another activity change happens that doesn't
4356 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004357 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004358 * when you are going to do a series of activity operations but the
4359 * animation seen by the user shouldn't be driven by the first activity
4360 * change but rather a later one.
4361 */
4362 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4363 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004364 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4365 * this flag will cause any existing task that would be associated with the
4366 * activity to be cleared before the activity is started. That is, the activity
4367 * becomes the new root of an otherwise empty task, and any old activities
4368 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4369 */
4370 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4371 /**
4372 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4373 * this flag will cause a newly launching task to be placed on top of the current
4374 * home activity task (if there is one). That is, pressing back from the task
4375 * will always return the user to home even if that was not the last activity they
4376 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4377 */
4378 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4379 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004380 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4381 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004382 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004383 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004384 * this flag. When set and the task's activity is finished, the recents
4385 * entry will remain in the interface for the user to re-launch it, like a
4386 * recents entry for a top-level application.
4387 * <p>
4388 * The receiving activity can override this request with
4389 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4390 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004391 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004392 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004393 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004394
4395 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004396 * If set, when sending a broadcast only registered receivers will be
4397 * called -- no BroadcastReceiver components will be launched.
4398 */
4399 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004400 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004401 * If set, when sending a broadcast the new broadcast will replace
4402 * any existing pending broadcast that matches it. Matching is defined
4403 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4404 * true for the intents of the two broadcasts. When a match is found,
4405 * the new broadcast (and receivers associated with it) will replace the
4406 * existing one in the pending broadcast list, remaining at the same
4407 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004408 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004409 * <p>This flag is most typically used with sticky broadcasts, which
4410 * only care about delivering the most recent values of the broadcast
4411 * to their receivers.
4412 */
4413 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4414 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004415 * If set, when sending a broadcast the recipient is allowed to run at
4416 * foreground priority, with a shorter timeout interval. During normal
4417 * broadcasts the receivers are not automatically hoisted out of the
4418 * background priority class.
4419 */
4420 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4421 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004422 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4423 * They can still propagate results through to later receivers, but they can not prevent
4424 * later receivers from seeing the broadcast.
4425 */
4426 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4427 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004428 * If set, when sending a broadcast <i>before boot has completed</i> only
4429 * registered receivers will be called -- no BroadcastReceiver components
4430 * will be launched. Sticky intent state will be recorded properly even
4431 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4432 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004433 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004434 * <p>This flag is only for use by system sevices as a convenience to
4435 * avoid having to implement a more complex mechanism around detection
4436 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004437 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004438 * @hide
4439 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004440 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004441 /**
4442 * Set when this broadcast is for a boot upgrade, a special mode that
4443 * allows the broadcast to be sent before the system is ready and launches
4444 * the app process with no providers running in it.
4445 * @hide
4446 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004447 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004448
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004449 /**
4450 * @hide Flags that can't be changed with PendingIntent.
4451 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004452 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4453 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4454 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004455
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004456 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004457 // ---------------------------------------------------------------------
4458 // toUri() and parseUri() options.
4459
4460 /**
4461 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4462 * always has the "intent:" scheme. This syntax can be used when you want
4463 * to later disambiguate between URIs that are intended to describe an
4464 * Intent vs. all others that should be treated as raw URIs. When used
4465 * with {@link #parseUri}, any other scheme will result in a generic
4466 * VIEW action for that raw URI.
4467 */
4468 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004469
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004470 /**
4471 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4472 * always has the "android-app:" scheme. This is a variation of
4473 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4474 * http/https URI being delivered to a specific package name. The format
4475 * is:
4476 *
4477 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004478 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004479 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004480 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4481 * you must also include a scheme; including a path also requires both a host and a scheme.
4482 * The final #Intent; fragment can be used without a scheme, host, or path.
4483 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004484 * used with intents that have a {@link #setSelector}, since the base intent
4485 * will always have an explicit package name.</p>
4486 *
4487 * <p>Some examples of how this scheme maps to Intent objects:</p>
4488 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4489 * <colgroup align="left" />
4490 * <colgroup align="left" />
4491 * <thead>
4492 * <tr><th>URI</th> <th>Intent</th></tr>
4493 * </thead>
4494 *
4495 * <tbody>
4496 * <tr><td><code>android-app://com.example.app</code></td>
4497 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4498 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4499 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4500 * </table></td>
4501 * </tr>
4502 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4503 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4504 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4505 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4506 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4507 * </table></td>
4508 * </tr>
4509 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4510 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4511 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4512 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4513 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4514 * </table></td>
4515 * </tr>
4516 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4517 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4518 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4519 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4520 * </table></td>
4521 * </tr>
4522 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4523 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4524 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4525 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4526 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4527 * </table></td>
4528 * </tr>
4529 * <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>
4530 * <td><table border="" style="margin:0" >
4531 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4532 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4533 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4534 * </table></td>
4535 * </tr>
4536 * </tbody>
4537 * </table>
4538 */
4539 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4540
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004541 /**
4542 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4543 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4544 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4545 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4546 * generated Intent can not cause unexpected data access to happen.
4547 *
4548 * <p>If you do not trust the source of the URI being parsed, you should still do further
4549 * processing to protect yourself from it. In particular, when using it to start an
4550 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4551 * that can handle it.</p>
4552 */
4553 public static final int URI_ALLOW_UNSAFE = 1<<2;
4554
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004555 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004556
4557 private String mAction;
4558 private Uri mData;
4559 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004560 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004561 private ComponentName mComponent;
4562 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004563 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004564 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004565 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004566 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004567 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004568 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004569
4570 // ---------------------------------------------------------------------
4571
4572 /**
4573 * Create an empty intent.
4574 */
4575 public Intent() {
4576 }
4577
4578 /**
4579 * Copy constructor.
4580 */
4581 public Intent(Intent o) {
4582 this.mAction = o.mAction;
4583 this.mData = o.mData;
4584 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004585 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004586 this.mComponent = o.mComponent;
4587 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004588 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004589 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004590 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004591 }
4592 if (o.mExtras != null) {
4593 this.mExtras = new Bundle(o.mExtras);
4594 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004595 if (o.mSourceBounds != null) {
4596 this.mSourceBounds = new Rect(o.mSourceBounds);
4597 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004598 if (o.mSelector != null) {
4599 this.mSelector = new Intent(o.mSelector);
4600 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004601 if (o.mClipData != null) {
4602 this.mClipData = new ClipData(o.mClipData);
4603 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004604 }
4605
4606 @Override
4607 public Object clone() {
4608 return new Intent(this);
4609 }
4610
4611 private Intent(Intent o, boolean all) {
4612 this.mAction = o.mAction;
4613 this.mData = o.mData;
4614 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004615 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004616 this.mComponent = o.mComponent;
4617 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004618 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004619 }
4620 }
4621
4622 /**
4623 * Make a clone of only the parts of the Intent that are relevant for
4624 * filter matching: the action, data, type, component, and categories.
4625 */
4626 public Intent cloneFilter() {
4627 return new Intent(this, false);
4628 }
4629
4630 /**
4631 * Create an intent with a given action. All other fields (data, type,
4632 * class) are null. Note that the action <em>must</em> be in a
4633 * namespace because Intents are used globally in the system -- for
4634 * example the system VIEW action is android.intent.action.VIEW; an
4635 * application's custom action would be something like
4636 * com.google.app.myapp.CUSTOM_ACTION.
4637 *
4638 * @param action The Intent action, such as ACTION_VIEW.
4639 */
4640 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004641 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004642 }
4643
4644 /**
4645 * Create an intent with a given action and for a given data url. Note
4646 * that the action <em>must</em> be in a namespace because Intents are
4647 * used globally in the system -- for example the system VIEW action is
4648 * android.intent.action.VIEW; an application's custom action would be
4649 * something like com.google.app.myapp.CUSTOM_ACTION.
4650 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004651 * <p><em>Note: scheme and host name matching in the Android framework is
4652 * case-sensitive, unlike the formal RFC. As a result,
4653 * you should always ensure that you write your Uri with these elements
4654 * using lower case letters, and normalize any Uris you receive from
4655 * outside of Android to ensure the scheme and host is lower case.</em></p>
4656 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004657 * @param action The Intent action, such as ACTION_VIEW.
4658 * @param uri The Intent data URI.
4659 */
4660 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004661 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004662 mData = uri;
4663 }
4664
4665 /**
4666 * Create an intent for a specific component. All other fields (action, data,
4667 * type, class) are null, though they can be modified later with explicit
4668 * calls. This provides a convenient way to create an intent that is
4669 * intended to execute a hard-coded class name, rather than relying on the
4670 * system to find an appropriate class for you; see {@link #setComponent}
4671 * for more information on the repercussions of this.
4672 *
4673 * @param packageContext A Context of the application package implementing
4674 * this class.
4675 * @param cls The component class that is to be used for the intent.
4676 *
4677 * @see #setClass
4678 * @see #setComponent
4679 * @see #Intent(String, android.net.Uri , Context, Class)
4680 */
4681 public Intent(Context packageContext, Class<?> cls) {
4682 mComponent = new ComponentName(packageContext, cls);
4683 }
4684
4685 /**
4686 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004687 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004688 * construct the Intent and then calling {@link #setClass} to set its
4689 * class.
4690 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004691 * <p><em>Note: scheme and host name matching in the Android framework is
4692 * case-sensitive, unlike the formal RFC. As a result,
4693 * you should always ensure that you write your Uri with these elements
4694 * using lower case letters, and normalize any Uris you receive from
4695 * outside of Android to ensure the scheme and host is lower case.</em></p>
4696 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004697 * @param action The Intent action, such as ACTION_VIEW.
4698 * @param uri The Intent data URI.
4699 * @param packageContext A Context of the application package implementing
4700 * this class.
4701 * @param cls The component class that is to be used for the intent.
4702 *
4703 * @see #Intent(String, android.net.Uri)
4704 * @see #Intent(Context, Class)
4705 * @see #setClass
4706 * @see #setComponent
4707 */
4708 public Intent(String action, Uri uri,
4709 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004710 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004711 mData = uri;
4712 mComponent = new ComponentName(packageContext, cls);
4713 }
4714
4715 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004716 * Create an intent to launch the main (root) activity of a task. This
4717 * is the Intent that is started when the application's is launched from
4718 * Home. For anything else that wants to launch an application in the
4719 * same way, it is important that they use an Intent structured the same
4720 * way, and can use this function to ensure this is the case.
4721 *
4722 * <p>The returned Intent has the given Activity component as its explicit
4723 * component, {@link #ACTION_MAIN} as its action, and includes the
4724 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4725 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4726 * to do that through {@link #addFlags(int)} on the returned Intent.
4727 *
4728 * @param mainActivity The main activity component that this Intent will
4729 * launch.
4730 * @return Returns a newly created Intent that can be used to launch the
4731 * activity as a main application entry.
4732 *
4733 * @see #setClass
4734 * @see #setComponent
4735 */
4736 public static Intent makeMainActivity(ComponentName mainActivity) {
4737 Intent intent = new Intent(ACTION_MAIN);
4738 intent.setComponent(mainActivity);
4739 intent.addCategory(CATEGORY_LAUNCHER);
4740 return intent;
4741 }
4742
4743 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004744 * Make an Intent for the main activity of an application, without
4745 * specifying a specific activity to run but giving a selector to find
4746 * the activity. This results in a final Intent that is structured
4747 * the same as when the application is launched from
4748 * Home. For anything else that wants to launch an application in the
4749 * same way, it is important that they use an Intent structured the same
4750 * way, and can use this function to ensure this is the case.
4751 *
4752 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4753 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4754 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4755 * to do that through {@link #addFlags(int)} on the returned Intent.
4756 *
4757 * @param selectorAction The action name of the Intent's selector.
4758 * @param selectorCategory The name of a category to add to the Intent's
4759 * selector.
4760 * @return Returns a newly created Intent that can be used to launch the
4761 * activity as a main application entry.
4762 *
4763 * @see #setSelector(Intent)
4764 */
4765 public static Intent makeMainSelectorActivity(String selectorAction,
4766 String selectorCategory) {
4767 Intent intent = new Intent(ACTION_MAIN);
4768 intent.addCategory(CATEGORY_LAUNCHER);
4769 Intent selector = new Intent();
4770 selector.setAction(selectorAction);
4771 selector.addCategory(selectorCategory);
4772 intent.setSelector(selector);
4773 return intent;
4774 }
4775
4776 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004777 * Make an Intent that can be used to re-launch an application's task
4778 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4779 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4780 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4781 *
4782 * @param mainActivity The activity component that is the root of the
4783 * task; this is the activity that has been published in the application's
4784 * manifest as the main launcher icon.
4785 *
4786 * @return Returns a newly created Intent that can be used to relaunch the
4787 * activity's task in its root state.
4788 */
4789 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4790 Intent intent = makeMainActivity(mainActivity);
4791 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4792 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4793 return intent;
4794 }
4795
4796 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004797 * Call {@link #parseUri} with 0 flags.
4798 * @deprecated Use {@link #parseUri} instead.
4799 */
4800 @Deprecated
4801 public static Intent getIntent(String uri) throws URISyntaxException {
4802 return parseUri(uri, 0);
4803 }
Tom Taylord4a47292009-12-21 13:59:18 -08004804
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004805 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004806 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004807 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004808 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004809 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004810 *
4811 * <p>The URI given here must not be relative -- that is, it must include
4812 * the scheme and full path.
4813 *
4814 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004815 * @param flags Additional processing flags. Either 0,
4816 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004817 *
4818 * @return Intent The newly created Intent object.
4819 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004820 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4821 * it bad (as parsed by the Uri class) or the Intent data within the
4822 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004823 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004824 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004825 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004826 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004827 int i = 0;
4828 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004829 final boolean androidApp = uri.startsWith("android-app:");
4830
4831 // Validate intent scheme if requested.
4832 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
4833 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004834 Intent intent = new Intent(ACTION_VIEW);
4835 try {
4836 intent.setData(Uri.parse(uri));
4837 } catch (IllegalArgumentException e) {
4838 throw new URISyntaxException(uri, e.getMessage());
4839 }
4840 return intent;
4841 }
4842 }
Tom Taylord4a47292009-12-21 13:59:18 -08004843
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004844 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004845 // simple case
4846 if (i == -1) {
4847 if (!androidApp) {
4848 return new Intent(ACTION_VIEW, Uri.parse(uri));
4849 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004850
4851 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004852 } else if (!uri.startsWith("#Intent;", i)) {
4853 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004854 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004855 } else {
4856 i = -1;
4857 }
4858 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004859
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004860 // new format
4861 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004862 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004863 boolean explicitAction = false;
4864 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004865
4866 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004867 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004868 String data;
4869 if (i >= 0) {
4870 data = uri.substring(0, i);
4871 i += 8; // length of "#Intent;"
4872 } else {
4873 data = uri;
4874 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004875
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004876 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004877 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004878 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004879 if (eq < 0) eq = i-1;
4880 int semi = uri.indexOf(';', i);
4881 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004882
4883 // action
4884 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004885 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004886 if (!inSelector) {
4887 explicitAction = true;
4888 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004889 }
4890
4891 // categories
4892 else if (uri.startsWith("category=", i)) {
4893 intent.addCategory(value);
4894 }
4895
4896 // type
4897 else if (uri.startsWith("type=", i)) {
4898 intent.mType = value;
4899 }
4900
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004901 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004902 else if (uri.startsWith("launchFlags=", i)) {
4903 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004904 if ((flags& URI_ALLOW_UNSAFE) == 0) {
4905 intent.mFlags &= ~IMMUTABLE_FLAGS;
4906 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004907 }
4908
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004909 // package
4910 else if (uri.startsWith("package=", i)) {
4911 intent.mPackage = value;
4912 }
4913
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004914 // component
4915 else if (uri.startsWith("component=", i)) {
4916 intent.mComponent = ComponentName.unflattenFromString(value);
4917 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004918
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004919 // scheme
4920 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004921 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004922 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004923 } else {
4924 scheme = value;
4925 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004926 }
4927
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004928 // source bounds
4929 else if (uri.startsWith("sourceBounds=", i)) {
4930 intent.mSourceBounds = Rect.unflattenFromString(value);
4931 }
4932
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004933 // selector
4934 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
4935 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004936 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004937 }
4938
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004939 // extra
4940 else {
4941 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004942 // create Bundle if it doesn't already exist
4943 if (intent.mExtras == null) intent.mExtras = new Bundle();
4944 Bundle b = intent.mExtras;
4945 // add EXTRA
4946 if (uri.startsWith("S.", i)) b.putString(key, value);
4947 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
4948 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
4949 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
4950 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
4951 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
4952 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
4953 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
4954 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
4955 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
4956 }
The Android Open Source Project10592532009-03-18 17:39:46 -07004957
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004958 // move to the next item
4959 i = semi + 1;
4960 }
4961
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004962 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004963 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004964 if (baseIntent.mPackage == null) {
4965 baseIntent.setSelector(intent);
4966 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004967 intent = baseIntent;
4968 }
4969
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004970 if (data != null) {
4971 if (data.startsWith("intent:")) {
4972 data = data.substring(7);
4973 if (scheme != null) {
4974 data = scheme + ':' + data;
4975 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004976 } else if (data.startsWith("android-app:")) {
4977 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
4978 // Correctly formed android-app, first part is package name.
4979 int end = data.indexOf('/', 14);
4980 if (end < 0) {
4981 // All we have is a package name.
4982 intent.mPackage = data.substring(14);
4983 if (!explicitAction) {
4984 intent.setAction(ACTION_MAIN);
4985 }
4986 data = "";
4987 } else {
4988 // Target the Intent at the given package name always.
4989 String authority = null;
4990 intent.mPackage = data.substring(14, end);
4991 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004992 if ((end+1) < data.length()) {
4993 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
4994 // Found a scheme, remember it.
4995 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004996 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08004997 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
4998 // Found a authority, remember it.
4999 authority = data.substring(end+1, newEnd);
5000 end = newEnd;
5001 }
5002 } else {
5003 // All we have is a scheme.
5004 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005005 }
5006 }
5007 if (scheme == null) {
5008 // If there was no scheme, then this just targets the package.
5009 if (!explicitAction) {
5010 intent.setAction(ACTION_MAIN);
5011 }
5012 data = "";
5013 } else if (authority == null) {
5014 data = scheme + ":";
5015 } else {
5016 data = scheme + "://" + authority + data.substring(end);
5017 }
5018 }
5019 } else {
5020 data = "";
5021 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005022 }
Tom Taylord4a47292009-12-21 13:59:18 -08005023
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005024 if (data.length() > 0) {
5025 try {
5026 intent.mData = Uri.parse(data);
5027 } catch (IllegalArgumentException e) {
5028 throw new URISyntaxException(uri, e.getMessage());
5029 }
5030 }
5031 }
Tom Taylord4a47292009-12-21 13:59:18 -08005032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005033 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005034
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005035 } catch (IndexOutOfBoundsException e) {
5036 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5037 }
5038 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005039
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005040 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005041 return getIntentOld(uri, 0);
5042 }
5043
5044 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005045 Intent intent;
5046
5047 int i = uri.lastIndexOf('#');
5048 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005049 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005050 final int intentFragmentStart = i;
5051 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005052
5053 i++;
5054
5055 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005056 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005057 i += 7;
5058 int j = uri.indexOf(')', i);
5059 action = uri.substring(i, j);
5060 i = j + 1;
5061 }
5062
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005063 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005064
5065 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005066 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005067 i += 11;
5068 int j = uri.indexOf(')', i);
5069 while (i < j) {
5070 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005071 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005072 if (i < sep) {
5073 intent.addCategory(uri.substring(i, sep));
5074 }
5075 i = sep + 1;
5076 }
5077 i = j + 1;
5078 }
5079
5080 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005081 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005082 i += 5;
5083 int j = uri.indexOf(')', i);
5084 intent.mType = uri.substring(i, j);
5085 i = j + 1;
5086 }
5087
5088 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005089 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005090 i += 12;
5091 int j = uri.indexOf(')', i);
5092 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005093 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5094 intent.mFlags &= ~IMMUTABLE_FLAGS;
5095 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005096 i = j + 1;
5097 }
5098
5099 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005100 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005101 i += 10;
5102 int j = uri.indexOf(')', i);
5103 int sep = uri.indexOf('!', i);
5104 if (sep >= 0 && sep < j) {
5105 String pkg = uri.substring(i, sep);
5106 String cls = uri.substring(sep + 1, j);
5107 intent.mComponent = new ComponentName(pkg, cls);
5108 }
5109 i = j + 1;
5110 }
5111
5112 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005113 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005114 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005115
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005116 final int closeParen = uri.indexOf(')', i);
5117 if (closeParen == -1) throw new URISyntaxException(uri,
5118 "EXTRA missing trailing ')'", i);
5119
5120 while (i < closeParen) {
5121 // fetch the key value
5122 int j = uri.indexOf('=', i);
5123 if (j <= i + 1 || i >= closeParen) {
5124 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5125 }
5126 char type = uri.charAt(i);
5127 i++;
5128 String key = uri.substring(i, j);
5129 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005130
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005131 // get type-value
5132 j = uri.indexOf('!', i);
5133 if (j == -1 || j >= closeParen) j = closeParen;
5134 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5135 String value = uri.substring(i, j);
5136 i = j;
5137
5138 // create Bundle if it doesn't already exist
5139 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005140
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005141 // add item to bundle
5142 try {
5143 switch (type) {
5144 case 'S':
5145 intent.mExtras.putString(key, Uri.decode(value));
5146 break;
5147 case 'B':
5148 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5149 break;
5150 case 'b':
5151 intent.mExtras.putByte(key, Byte.parseByte(value));
5152 break;
5153 case 'c':
5154 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5155 break;
5156 case 'd':
5157 intent.mExtras.putDouble(key, Double.parseDouble(value));
5158 break;
5159 case 'f':
5160 intent.mExtras.putFloat(key, Float.parseFloat(value));
5161 break;
5162 case 'i':
5163 intent.mExtras.putInt(key, Integer.parseInt(value));
5164 break;
5165 case 'l':
5166 intent.mExtras.putLong(key, Long.parseLong(value));
5167 break;
5168 case 's':
5169 intent.mExtras.putShort(key, Short.parseShort(value));
5170 break;
5171 default:
5172 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5173 }
5174 } catch (NumberFormatException e) {
5175 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5176 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005177
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005178 char ch = uri.charAt(i);
5179 if (ch == ')') break;
5180 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5181 i++;
5182 }
5183 }
5184
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005185 if (isIntentFragment) {
5186 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5187 } else {
5188 intent.mData = Uri.parse(uri);
5189 }
Tom Taylord4a47292009-12-21 13:59:18 -08005190
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005191 if (intent.mAction == null) {
5192 // By default, if no action is specified, then use VIEW.
5193 intent.mAction = ACTION_VIEW;
5194 }
5195
5196 } else {
5197 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5198 }
5199
5200 return intent;
5201 }
5202
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005203 /** @hide */
5204 public interface CommandOptionHandler {
5205 boolean handleOption(String opt, ShellCommand cmd);
5206 }
5207
5208 /** @hide */
5209 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5210 throws URISyntaxException {
5211 Intent intent = new Intent();
5212 Intent baseIntent = intent;
5213 boolean hasIntentInfo = false;
5214
5215 Uri data = null;
5216 String type = null;
5217
5218 String opt;
5219 while ((opt=cmd.getNextOption()) != null) {
5220 switch (opt) {
5221 case "-a":
5222 intent.setAction(cmd.getNextArgRequired());
5223 if (intent == baseIntent) {
5224 hasIntentInfo = true;
5225 }
5226 break;
5227 case "-d":
5228 data = Uri.parse(cmd.getNextArgRequired());
5229 if (intent == baseIntent) {
5230 hasIntentInfo = true;
5231 }
5232 break;
5233 case "-t":
5234 type = cmd.getNextArgRequired();
5235 if (intent == baseIntent) {
5236 hasIntentInfo = true;
5237 }
5238 break;
5239 case "-c":
5240 intent.addCategory(cmd.getNextArgRequired());
5241 if (intent == baseIntent) {
5242 hasIntentInfo = true;
5243 }
5244 break;
5245 case "-e":
5246 case "--es": {
5247 String key = cmd.getNextArgRequired();
5248 String value = cmd.getNextArgRequired();
5249 intent.putExtra(key, value);
5250 }
5251 break;
5252 case "--esn": {
5253 String key = cmd.getNextArgRequired();
5254 intent.putExtra(key, (String) null);
5255 }
5256 break;
5257 case "--ei": {
5258 String key = cmd.getNextArgRequired();
5259 String value = cmd.getNextArgRequired();
5260 intent.putExtra(key, Integer.decode(value));
5261 }
5262 break;
5263 case "--eu": {
5264 String key = cmd.getNextArgRequired();
5265 String value = cmd.getNextArgRequired();
5266 intent.putExtra(key, Uri.parse(value));
5267 }
5268 break;
5269 case "--ecn": {
5270 String key = cmd.getNextArgRequired();
5271 String value = cmd.getNextArgRequired();
5272 ComponentName cn = ComponentName.unflattenFromString(value);
5273 if (cn == null)
5274 throw new IllegalArgumentException("Bad component name: " + value);
5275 intent.putExtra(key, cn);
5276 }
5277 break;
5278 case "--eia": {
5279 String key = cmd.getNextArgRequired();
5280 String value = cmd.getNextArgRequired();
5281 String[] strings = value.split(",");
5282 int[] list = new int[strings.length];
5283 for (int i = 0; i < strings.length; i++) {
5284 list[i] = Integer.decode(strings[i]);
5285 }
5286 intent.putExtra(key, list);
5287 }
5288 break;
5289 case "--eial": {
5290 String key = cmd.getNextArgRequired();
5291 String value = cmd.getNextArgRequired();
5292 String[] strings = value.split(",");
5293 ArrayList<Integer> list = new ArrayList<>(strings.length);
5294 for (int i = 0; i < strings.length; i++) {
5295 list.add(Integer.decode(strings[i]));
5296 }
5297 intent.putExtra(key, list);
5298 }
5299 break;
5300 case "--el": {
5301 String key = cmd.getNextArgRequired();
5302 String value = cmd.getNextArgRequired();
5303 intent.putExtra(key, Long.valueOf(value));
5304 }
5305 break;
5306 case "--ela": {
5307 String key = cmd.getNextArgRequired();
5308 String value = cmd.getNextArgRequired();
5309 String[] strings = value.split(",");
5310 long[] list = new long[strings.length];
5311 for (int i = 0; i < strings.length; i++) {
5312 list[i] = Long.valueOf(strings[i]);
5313 }
5314 intent.putExtra(key, list);
5315 hasIntentInfo = true;
5316 }
5317 break;
5318 case "--elal": {
5319 String key = cmd.getNextArgRequired();
5320 String value = cmd.getNextArgRequired();
5321 String[] strings = value.split(",");
5322 ArrayList<Long> list = new ArrayList<>(strings.length);
5323 for (int i = 0; i < strings.length; i++) {
5324 list.add(Long.valueOf(strings[i]));
5325 }
5326 intent.putExtra(key, list);
5327 hasIntentInfo = true;
5328 }
5329 break;
5330 case "--ef": {
5331 String key = cmd.getNextArgRequired();
5332 String value = cmd.getNextArgRequired();
5333 intent.putExtra(key, Float.valueOf(value));
5334 hasIntentInfo = true;
5335 }
5336 break;
5337 case "--efa": {
5338 String key = cmd.getNextArgRequired();
5339 String value = cmd.getNextArgRequired();
5340 String[] strings = value.split(",");
5341 float[] list = new float[strings.length];
5342 for (int i = 0; i < strings.length; i++) {
5343 list[i] = Float.valueOf(strings[i]);
5344 }
5345 intent.putExtra(key, list);
5346 hasIntentInfo = true;
5347 }
5348 break;
5349 case "--efal": {
5350 String key = cmd.getNextArgRequired();
5351 String value = cmd.getNextArgRequired();
5352 String[] strings = value.split(",");
5353 ArrayList<Float> list = new ArrayList<>(strings.length);
5354 for (int i = 0; i < strings.length; i++) {
5355 list.add(Float.valueOf(strings[i]));
5356 }
5357 intent.putExtra(key, list);
5358 hasIntentInfo = true;
5359 }
5360 break;
5361 case "--esa": {
5362 String key = cmd.getNextArgRequired();
5363 String value = cmd.getNextArgRequired();
5364 // Split on commas unless they are preceeded by an escape.
5365 // The escape character must be escaped for the string and
5366 // again for the regex, thus four escape characters become one.
5367 String[] strings = value.split("(?<!\\\\),");
5368 intent.putExtra(key, strings);
5369 hasIntentInfo = true;
5370 }
5371 break;
5372 case "--esal": {
5373 String key = cmd.getNextArgRequired();
5374 String value = cmd.getNextArgRequired();
5375 // Split on commas unless they are preceeded by an escape.
5376 // The escape character must be escaped for the string and
5377 // again for the regex, thus four escape characters become one.
5378 String[] strings = value.split("(?<!\\\\),");
5379 ArrayList<String> list = new ArrayList<>(strings.length);
5380 for (int i = 0; i < strings.length; i++) {
5381 list.add(strings[i]);
5382 }
5383 intent.putExtra(key, list);
5384 hasIntentInfo = true;
5385 }
5386 break;
5387 case "--ez": {
5388 String key = cmd.getNextArgRequired();
5389 String value = cmd.getNextArgRequired().toLowerCase();
5390 // Boolean.valueOf() results in false for anything that is not "true", which is
5391 // error-prone in shell commands
5392 boolean arg;
5393 if ("true".equals(value) || "t".equals(value)) {
5394 arg = true;
5395 } else if ("false".equals(value) || "f".equals(value)) {
5396 arg = false;
5397 } else {
5398 try {
5399 arg = Integer.decode(value) != 0;
5400 } catch (NumberFormatException ex) {
5401 throw new IllegalArgumentException("Invalid boolean value: " + value);
5402 }
5403 }
5404
5405 intent.putExtra(key, arg);
5406 }
5407 break;
5408 case "-n": {
5409 String str = cmd.getNextArgRequired();
5410 ComponentName cn = ComponentName.unflattenFromString(str);
5411 if (cn == null)
5412 throw new IllegalArgumentException("Bad component name: " + str);
5413 intent.setComponent(cn);
5414 if (intent == baseIntent) {
5415 hasIntentInfo = true;
5416 }
5417 }
5418 break;
5419 case "-p": {
5420 String str = cmd.getNextArgRequired();
5421 intent.setPackage(str);
5422 if (intent == baseIntent) {
5423 hasIntentInfo = true;
5424 }
5425 }
5426 break;
5427 case "-f":
5428 String str = cmd.getNextArgRequired();
5429 intent.setFlags(Integer.decode(str).intValue());
5430 break;
5431 case "--grant-read-uri-permission":
5432 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5433 break;
5434 case "--grant-write-uri-permission":
5435 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5436 break;
5437 case "--grant-persistable-uri-permission":
5438 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5439 break;
5440 case "--grant-prefix-uri-permission":
5441 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5442 break;
5443 case "--exclude-stopped-packages":
5444 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5445 break;
5446 case "--include-stopped-packages":
5447 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5448 break;
5449 case "--debug-log-resolution":
5450 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5451 break;
5452 case "--activity-brought-to-front":
5453 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5454 break;
5455 case "--activity-clear-top":
5456 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5457 break;
5458 case "--activity-clear-when-task-reset":
5459 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5460 break;
5461 case "--activity-exclude-from-recents":
5462 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5463 break;
5464 case "--activity-launched-from-history":
5465 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5466 break;
5467 case "--activity-multiple-task":
5468 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5469 break;
5470 case "--activity-no-animation":
5471 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5472 break;
5473 case "--activity-no-history":
5474 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5475 break;
5476 case "--activity-no-user-action":
5477 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5478 break;
5479 case "--activity-previous-is-top":
5480 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5481 break;
5482 case "--activity-reorder-to-front":
5483 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5484 break;
5485 case "--activity-reset-task-if-needed":
5486 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5487 break;
5488 case "--activity-single-top":
5489 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5490 break;
5491 case "--activity-clear-task":
5492 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5493 break;
5494 case "--activity-task-on-home":
5495 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5496 break;
5497 case "--receiver-registered-only":
5498 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5499 break;
5500 case "--receiver-replace-pending":
5501 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5502 break;
5503 case "--selector":
5504 intent.setDataAndType(data, type);
5505 intent = new Intent();
5506 break;
5507 default:
5508 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5509 // Okay, caller handled this option.
5510 } else {
5511 throw new IllegalArgumentException("Unknown option: " + opt);
5512 }
5513 break;
5514 }
5515 }
5516 intent.setDataAndType(data, type);
5517
5518 final boolean hasSelector = intent != baseIntent;
5519 if (hasSelector) {
5520 // A selector was specified; fix up.
5521 baseIntent.setSelector(intent);
5522 intent = baseIntent;
5523 }
5524
5525 String arg = cmd.getNextArg();
5526 baseIntent = null;
5527 if (arg == null) {
5528 if (hasSelector) {
5529 // If a selector has been specified, and no arguments
5530 // have been supplied for the main Intent, then we can
5531 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5532 // need to have a component name specified yet, the
5533 // selector will take care of that.
5534 baseIntent = new Intent(Intent.ACTION_MAIN);
5535 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5536 }
5537 } else if (arg.indexOf(':') >= 0) {
5538 // The argument is a URI. Fully parse it, and use that result
5539 // to fill in any data not specified so far.
5540 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5541 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5542 } else if (arg.indexOf('/') >= 0) {
5543 // The argument is a component name. Build an Intent to launch
5544 // it.
5545 baseIntent = new Intent(Intent.ACTION_MAIN);
5546 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5547 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5548 } else {
5549 // Assume the argument is a package name.
5550 baseIntent = new Intent(Intent.ACTION_MAIN);
5551 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5552 baseIntent.setPackage(arg);
5553 }
5554 if (baseIntent != null) {
5555 Bundle extras = intent.getExtras();
5556 intent.replaceExtras((Bundle)null);
5557 Bundle uriExtras = baseIntent.getExtras();
5558 baseIntent.replaceExtras((Bundle)null);
5559 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5560 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5561 for (String c : cats) {
5562 baseIntent.removeCategory(c);
5563 }
5564 }
5565 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5566 if (extras == null) {
5567 extras = uriExtras;
5568 } else if (uriExtras != null) {
5569 uriExtras.putAll(extras);
5570 extras = uriExtras;
5571 }
5572 intent.replaceExtras(extras);
5573 hasIntentInfo = true;
5574 }
5575
5576 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5577 return intent;
5578 }
5579
5580 /** @hide */
5581 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5582 final String[] lines = new String[] {
5583 "<INTENT> specifications include these flags and arguments:",
5584 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5585 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5586 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5587 " [--esn <EXTRA_KEY> ...]",
5588 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5589 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5590 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5591 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5592 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5593 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5594 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5595 " (mutiple extras passed as Integer[])",
5596 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5597 " (mutiple extras passed as List<Integer>)",
5598 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5599 " (mutiple extras passed as Long[])",
5600 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5601 " (mutiple extras passed as List<Long>)",
5602 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5603 " (mutiple extras passed as Float[])",
5604 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5605 " (mutiple extras passed as List<Float>)",
5606 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5607 " (mutiple extras passed as String[]; to embed a comma into a string,",
5608 " escape it using \"\\,\")",
5609 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5610 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5611 " escape it using \"\\,\")",
5612 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5613 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5614 " [--debug-log-resolution] [--exclude-stopped-packages]",
5615 " [--include-stopped-packages]",
5616 " [--activity-brought-to-front] [--activity-clear-top]",
5617 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5618 " [--activity-launched-from-history] [--activity-multiple-task]",
5619 " [--activity-no-animation] [--activity-no-history]",
5620 " [--activity-no-user-action] [--activity-previous-is-top]",
5621 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5622 " [--activity-single-top] [--activity-clear-task]",
5623 " [--activity-task-on-home]",
5624 " [--receiver-registered-only] [--receiver-replace-pending]",
5625 " [--selector]",
5626 " [<URI> | <PACKAGE> | <COMPONENT>]"
5627 };
5628 for (String line : lines) {
5629 pw.print(prefix);
5630 pw.println(line);
5631 }
5632 }
5633
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005634 /**
5635 * Retrieve the general action to be performed, such as
5636 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5637 * the information in the intent should be interpreted -- most importantly,
5638 * what to do with the data returned by {@link #getData}.
5639 *
5640 * @return The action of this intent or null if none is specified.
5641 *
5642 * @see #setAction
5643 */
5644 public String getAction() {
5645 return mAction;
5646 }
5647
5648 /**
5649 * Retrieve data this intent is operating on. This URI specifies the name
5650 * of the data; often it uses the content: scheme, specifying data in a
5651 * content provider. Other schemes may be handled by specific activities,
5652 * such as http: by the web browser.
5653 *
5654 * @return The URI of the data this intent is targeting or null.
5655 *
5656 * @see #getScheme
5657 * @see #setData
5658 */
5659 public Uri getData() {
5660 return mData;
5661 }
5662
5663 /**
5664 * The same as {@link #getData()}, but returns the URI as an encoded
5665 * String.
5666 */
5667 public String getDataString() {
5668 return mData != null ? mData.toString() : null;
5669 }
5670
5671 /**
5672 * Return the scheme portion of the intent's data. If the data is null or
5673 * does not include a scheme, null is returned. Otherwise, the scheme
5674 * prefix without the final ':' is returned, i.e. "http".
5675 *
5676 * <p>This is the same as calling getData().getScheme() (and checking for
5677 * null data).
5678 *
5679 * @return The scheme of this intent.
5680 *
5681 * @see #getData
5682 */
5683 public String getScheme() {
5684 return mData != null ? mData.getScheme() : null;
5685 }
5686
5687 /**
5688 * Retrieve any explicit MIME type included in the intent. This is usually
5689 * null, as the type is determined by the intent data.
5690 *
5691 * @return If a type was manually set, it is returned; else null is
5692 * returned.
5693 *
5694 * @see #resolveType(ContentResolver)
5695 * @see #setType
5696 */
5697 public String getType() {
5698 return mType;
5699 }
5700
5701 /**
5702 * Return the MIME data type of this intent. If the type field is
5703 * explicitly set, that is simply returned. Otherwise, if the data is set,
5704 * the type of that data is returned. If neither fields are set, a null is
5705 * returned.
5706 *
5707 * @return The MIME type of this intent.
5708 *
5709 * @see #getType
5710 * @see #resolveType(ContentResolver)
5711 */
5712 public String resolveType(Context context) {
5713 return resolveType(context.getContentResolver());
5714 }
5715
5716 /**
5717 * Return the MIME data type of this intent. If the type field is
5718 * explicitly set, that is simply returned. Otherwise, if the data is set,
5719 * the type of that data is returned. If neither fields are set, a null is
5720 * returned.
5721 *
5722 * @param resolver A ContentResolver that can be used to determine the MIME
5723 * type of the intent's data.
5724 *
5725 * @return The MIME type of this intent.
5726 *
5727 * @see #getType
5728 * @see #resolveType(Context)
5729 */
5730 public String resolveType(ContentResolver resolver) {
5731 if (mType != null) {
5732 return mType;
5733 }
5734 if (mData != null) {
5735 if ("content".equals(mData.getScheme())) {
5736 return resolver.getType(mData);
5737 }
5738 }
5739 return null;
5740 }
5741
5742 /**
5743 * Return the MIME data type of this intent, only if it will be needed for
5744 * intent resolution. This is not generally useful for application code;
5745 * it is used by the frameworks for communicating with back-end system
5746 * services.
5747 *
5748 * @param resolver A ContentResolver that can be used to determine the MIME
5749 * type of the intent's data.
5750 *
5751 * @return The MIME type of this intent, or null if it is unknown or not
5752 * needed.
5753 */
5754 public String resolveTypeIfNeeded(ContentResolver resolver) {
5755 if (mComponent != null) {
5756 return mType;
5757 }
5758 return resolveType(resolver);
5759 }
5760
5761 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005762 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 *
5764 * @param category The category to check.
5765 *
5766 * @return boolean True if the intent contains the category, else false.
5767 *
5768 * @see #getCategories
5769 * @see #addCategory
5770 */
5771 public boolean hasCategory(String category) {
5772 return mCategories != null && mCategories.contains(category);
5773 }
5774
5775 /**
5776 * Return the set of all categories in the intent. If there are no categories,
5777 * returns NULL.
5778 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005779 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005780 *
5781 * @see #hasCategory
5782 * @see #addCategory
5783 */
5784 public Set<String> getCategories() {
5785 return mCategories;
5786 }
5787
5788 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005789 * Return the specific selector associated with this Intent. If there is
5790 * none, returns null. See {@link #setSelector} for more information.
5791 *
5792 * @see #setSelector
5793 */
5794 public Intent getSelector() {
5795 return mSelector;
5796 }
5797
5798 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005799 * Return the {@link ClipData} associated with this Intent. If there is
5800 * none, returns null. See {@link #setClipData} for more information.
5801 *
John Spurlock125d1332013-11-25 11:58:37 -05005802 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005803 */
5804 public ClipData getClipData() {
5805 return mClipData;
5806 }
5807
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005808 /** @hide */
5809 public int getContentUserHint() {
5810 return mContentUserHint;
5811 }
5812
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005813 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005814 * Sets the ClassLoader that will be used when unmarshalling
5815 * any Parcelable values from the extras of this Intent.
5816 *
5817 * @param loader a ClassLoader, or null to use the default loader
5818 * at the time of unmarshalling.
5819 */
5820 public void setExtrasClassLoader(ClassLoader loader) {
5821 if (mExtras != null) {
5822 mExtras.setClassLoader(loader);
5823 }
5824 }
5825
5826 /**
5827 * Returns true if an extra value is associated with the given name.
5828 * @param name the extra's name
5829 * @return true if the given extra is present.
5830 */
5831 public boolean hasExtra(String name) {
5832 return mExtras != null && mExtras.containsKey(name);
5833 }
5834
5835 /**
5836 * Returns true if the Intent's extras contain a parcelled file descriptor.
5837 * @return true if the Intent contains a parcelled file descriptor.
5838 */
5839 public boolean hasFileDescriptors() {
5840 return mExtras != null && mExtras.hasFileDescriptors();
5841 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005842
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04005843 /** @hide */
5844 public void setAllowFds(boolean allowFds) {
5845 if (mExtras != null) {
5846 mExtras.setAllowFds(allowFds);
5847 }
5848 }
5849
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005850 /**
5851 * Retrieve extended data from the intent.
5852 *
5853 * @param name The name of the desired item.
5854 *
5855 * @return the value of an item that previously added with putExtra()
5856 * or null if none was found.
5857 *
5858 * @deprecated
5859 * @hide
5860 */
5861 @Deprecated
5862 public Object getExtra(String name) {
5863 return getExtra(name, null);
5864 }
5865
5866 /**
5867 * Retrieve extended data from the intent.
5868 *
5869 * @param name The name of the desired item.
5870 * @param defaultValue the value to be returned if no value of the desired
5871 * type is stored with the given name.
5872 *
5873 * @return the value of an item that previously added with putExtra()
5874 * or the default value if none was found.
5875 *
5876 * @see #putExtra(String, boolean)
5877 */
5878 public boolean getBooleanExtra(String name, boolean defaultValue) {
5879 return mExtras == null ? defaultValue :
5880 mExtras.getBoolean(name, defaultValue);
5881 }
5882
5883 /**
5884 * Retrieve extended data from the intent.
5885 *
5886 * @param name The name of the desired item.
5887 * @param defaultValue the value to be returned if no value of the desired
5888 * type is stored with the given name.
5889 *
5890 * @return the value of an item that previously added with putExtra()
5891 * or the default value if none was found.
5892 *
5893 * @see #putExtra(String, byte)
5894 */
5895 public byte getByteExtra(String name, byte defaultValue) {
5896 return mExtras == null ? defaultValue :
5897 mExtras.getByte(name, defaultValue);
5898 }
5899
5900 /**
5901 * Retrieve extended data from the intent.
5902 *
5903 * @param name The name of the desired item.
5904 * @param defaultValue the value to be returned if no value of the desired
5905 * type is stored with the given name.
5906 *
5907 * @return the value of an item that previously added with putExtra()
5908 * or the default value if none was found.
5909 *
5910 * @see #putExtra(String, short)
5911 */
5912 public short getShortExtra(String name, short defaultValue) {
5913 return mExtras == null ? defaultValue :
5914 mExtras.getShort(name, defaultValue);
5915 }
5916
5917 /**
5918 * Retrieve extended data from the intent.
5919 *
5920 * @param name The name of the desired item.
5921 * @param defaultValue the value to be returned if no value of the desired
5922 * type is stored with the given name.
5923 *
5924 * @return the value of an item that previously added with putExtra()
5925 * or the default value if none was found.
5926 *
5927 * @see #putExtra(String, char)
5928 */
5929 public char getCharExtra(String name, char defaultValue) {
5930 return mExtras == null ? defaultValue :
5931 mExtras.getChar(name, defaultValue);
5932 }
5933
5934 /**
5935 * Retrieve extended data from the intent.
5936 *
5937 * @param name The name of the desired item.
5938 * @param defaultValue the value to be returned if no value of the desired
5939 * type is stored with the given name.
5940 *
5941 * @return the value of an item that previously added with putExtra()
5942 * or the default value if none was found.
5943 *
5944 * @see #putExtra(String, int)
5945 */
5946 public int getIntExtra(String name, int defaultValue) {
5947 return mExtras == null ? defaultValue :
5948 mExtras.getInt(name, defaultValue);
5949 }
5950
5951 /**
5952 * Retrieve extended data from the intent.
5953 *
5954 * @param name The name of the desired item.
5955 * @param defaultValue the value to be returned if no value of the desired
5956 * type is stored with the given name.
5957 *
5958 * @return the value of an item that previously added with putExtra()
5959 * or the default value if none was found.
5960 *
5961 * @see #putExtra(String, long)
5962 */
5963 public long getLongExtra(String name, long defaultValue) {
5964 return mExtras == null ? defaultValue :
5965 mExtras.getLong(name, defaultValue);
5966 }
5967
5968 /**
5969 * Retrieve extended data from the intent.
5970 *
5971 * @param name The name of the desired item.
5972 * @param defaultValue the value to be returned if no value of the desired
5973 * type is stored with the given name.
5974 *
5975 * @return the value of an item that previously added with putExtra(),
5976 * or the default value if no such item is present
5977 *
5978 * @see #putExtra(String, float)
5979 */
5980 public float getFloatExtra(String name, float defaultValue) {
5981 return mExtras == null ? defaultValue :
5982 mExtras.getFloat(name, defaultValue);
5983 }
5984
5985 /**
5986 * Retrieve extended data from the intent.
5987 *
5988 * @param name The name of the desired item.
5989 * @param defaultValue the value to be returned if no value of the desired
5990 * type is stored with the given name.
5991 *
5992 * @return the value of an item that previously added with putExtra()
5993 * or the default value if none was found.
5994 *
5995 * @see #putExtra(String, double)
5996 */
5997 public double getDoubleExtra(String name, double defaultValue) {
5998 return mExtras == null ? defaultValue :
5999 mExtras.getDouble(name, defaultValue);
6000 }
6001
6002 /**
6003 * Retrieve extended data from the intent.
6004 *
6005 * @param name The name of the desired item.
6006 *
6007 * @return the value of an item that previously added with putExtra()
6008 * or null if no String value was found.
6009 *
6010 * @see #putExtra(String, String)
6011 */
6012 public String getStringExtra(String name) {
6013 return mExtras == null ? null : mExtras.getString(name);
6014 }
6015
6016 /**
6017 * Retrieve extended data from the intent.
6018 *
6019 * @param name The name of the desired item.
6020 *
6021 * @return the value of an item that previously added with putExtra()
6022 * or null if no CharSequence value was found.
6023 *
6024 * @see #putExtra(String, CharSequence)
6025 */
6026 public CharSequence getCharSequenceExtra(String name) {
6027 return mExtras == null ? null : mExtras.getCharSequence(name);
6028 }
6029
6030 /**
6031 * Retrieve extended data from the intent.
6032 *
6033 * @param name The name of the desired item.
6034 *
6035 * @return the value of an item that previously added with putExtra()
6036 * or null if no Parcelable value was found.
6037 *
6038 * @see #putExtra(String, Parcelable)
6039 */
6040 public <T extends Parcelable> T getParcelableExtra(String name) {
6041 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6042 }
6043
6044 /**
6045 * Retrieve extended data from the intent.
6046 *
6047 * @param name The name of the desired item.
6048 *
6049 * @return the value of an item that previously added with putExtra()
6050 * or null if no Parcelable[] value was found.
6051 *
6052 * @see #putExtra(String, Parcelable[])
6053 */
6054 public Parcelable[] getParcelableArrayExtra(String name) {
6055 return mExtras == null ? null : mExtras.getParcelableArray(name);
6056 }
6057
6058 /**
6059 * Retrieve extended data from the intent.
6060 *
6061 * @param name The name of the desired item.
6062 *
6063 * @return the value of an item that previously added with putExtra()
6064 * or null if no ArrayList<Parcelable> value was found.
6065 *
6066 * @see #putParcelableArrayListExtra(String, ArrayList)
6067 */
6068 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6069 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6070 }
6071
6072 /**
6073 * Retrieve extended data from the intent.
6074 *
6075 * @param name The name of the desired item.
6076 *
6077 * @return the value of an item that previously added with putExtra()
6078 * or null if no Serializable value was found.
6079 *
6080 * @see #putExtra(String, Serializable)
6081 */
6082 public Serializable getSerializableExtra(String name) {
6083 return mExtras == null ? null : mExtras.getSerializable(name);
6084 }
6085
6086 /**
6087 * Retrieve extended data from the intent.
6088 *
6089 * @param name The name of the desired item.
6090 *
6091 * @return the value of an item that previously added with putExtra()
6092 * or null if no ArrayList<Integer> value was found.
6093 *
6094 * @see #putIntegerArrayListExtra(String, ArrayList)
6095 */
6096 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6097 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6098 }
6099
6100 /**
6101 * Retrieve extended data from the intent.
6102 *
6103 * @param name The name of the desired item.
6104 *
6105 * @return the value of an item that previously added with putExtra()
6106 * or null if no ArrayList<String> value was found.
6107 *
6108 * @see #putStringArrayListExtra(String, ArrayList)
6109 */
6110 public ArrayList<String> getStringArrayListExtra(String name) {
6111 return mExtras == null ? null : mExtras.getStringArrayList(name);
6112 }
6113
6114 /**
6115 * Retrieve extended data from the intent.
6116 *
6117 * @param name The name of the desired item.
6118 *
6119 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006120 * or null if no ArrayList<CharSequence> value was found.
6121 *
6122 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6123 */
6124 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6125 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6126 }
6127
6128 /**
6129 * Retrieve extended data from the intent.
6130 *
6131 * @param name The name of the desired item.
6132 *
6133 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006134 * or null if no boolean array value was found.
6135 *
6136 * @see #putExtra(String, boolean[])
6137 */
6138 public boolean[] getBooleanArrayExtra(String name) {
6139 return mExtras == null ? null : mExtras.getBooleanArray(name);
6140 }
6141
6142 /**
6143 * Retrieve extended data from the intent.
6144 *
6145 * @param name The name of the desired item.
6146 *
6147 * @return the value of an item that previously added with putExtra()
6148 * or null if no byte array value was found.
6149 *
6150 * @see #putExtra(String, byte[])
6151 */
6152 public byte[] getByteArrayExtra(String name) {
6153 return mExtras == null ? null : mExtras.getByteArray(name);
6154 }
6155
6156 /**
6157 * Retrieve extended data from the intent.
6158 *
6159 * @param name The name of the desired item.
6160 *
6161 * @return the value of an item that previously added with putExtra()
6162 * or null if no short array value was found.
6163 *
6164 * @see #putExtra(String, short[])
6165 */
6166 public short[] getShortArrayExtra(String name) {
6167 return mExtras == null ? null : mExtras.getShortArray(name);
6168 }
6169
6170 /**
6171 * Retrieve extended data from the intent.
6172 *
6173 * @param name The name of the desired item.
6174 *
6175 * @return the value of an item that previously added with putExtra()
6176 * or null if no char array value was found.
6177 *
6178 * @see #putExtra(String, char[])
6179 */
6180 public char[] getCharArrayExtra(String name) {
6181 return mExtras == null ? null : mExtras.getCharArray(name);
6182 }
6183
6184 /**
6185 * Retrieve extended data from the intent.
6186 *
6187 * @param name The name of the desired item.
6188 *
6189 * @return the value of an item that previously added with putExtra()
6190 * or null if no int array value was found.
6191 *
6192 * @see #putExtra(String, int[])
6193 */
6194 public int[] getIntArrayExtra(String name) {
6195 return mExtras == null ? null : mExtras.getIntArray(name);
6196 }
6197
6198 /**
6199 * Retrieve extended data from the intent.
6200 *
6201 * @param name The name of the desired item.
6202 *
6203 * @return the value of an item that previously added with putExtra()
6204 * or null if no long array value was found.
6205 *
6206 * @see #putExtra(String, long[])
6207 */
6208 public long[] getLongArrayExtra(String name) {
6209 return mExtras == null ? null : mExtras.getLongArray(name);
6210 }
6211
6212 /**
6213 * Retrieve extended data from the intent.
6214 *
6215 * @param name The name of the desired item.
6216 *
6217 * @return the value of an item that previously added with putExtra()
6218 * or null if no float array value was found.
6219 *
6220 * @see #putExtra(String, float[])
6221 */
6222 public float[] getFloatArrayExtra(String name) {
6223 return mExtras == null ? null : mExtras.getFloatArray(name);
6224 }
6225
6226 /**
6227 * Retrieve extended data from the intent.
6228 *
6229 * @param name The name of the desired item.
6230 *
6231 * @return the value of an item that previously added with putExtra()
6232 * or null if no double array value was found.
6233 *
6234 * @see #putExtra(String, double[])
6235 */
6236 public double[] getDoubleArrayExtra(String name) {
6237 return mExtras == null ? null : mExtras.getDoubleArray(name);
6238 }
6239
6240 /**
6241 * Retrieve extended data from the intent.
6242 *
6243 * @param name The name of the desired item.
6244 *
6245 * @return the value of an item that previously added with putExtra()
6246 * or null if no String array value was found.
6247 *
6248 * @see #putExtra(String, String[])
6249 */
6250 public String[] getStringArrayExtra(String name) {
6251 return mExtras == null ? null : mExtras.getStringArray(name);
6252 }
6253
6254 /**
6255 * Retrieve extended data from the intent.
6256 *
6257 * @param name The name of the desired item.
6258 *
6259 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006260 * or null if no CharSequence array value was found.
6261 *
6262 * @see #putExtra(String, CharSequence[])
6263 */
6264 public CharSequence[] getCharSequenceArrayExtra(String name) {
6265 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6266 }
6267
6268 /**
6269 * Retrieve extended data from the intent.
6270 *
6271 * @param name The name of the desired item.
6272 *
6273 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006274 * or null if no Bundle value was found.
6275 *
6276 * @see #putExtra(String, Bundle)
6277 */
6278 public Bundle getBundleExtra(String name) {
6279 return mExtras == null ? null : mExtras.getBundle(name);
6280 }
6281
6282 /**
6283 * Retrieve extended data from the intent.
6284 *
6285 * @param name The name of the desired item.
6286 *
6287 * @return the value of an item that previously added with putExtra()
6288 * or null if no IBinder value was found.
6289 *
6290 * @see #putExtra(String, IBinder)
6291 *
6292 * @deprecated
6293 * @hide
6294 */
6295 @Deprecated
6296 public IBinder getIBinderExtra(String name) {
6297 return mExtras == null ? null : mExtras.getIBinder(name);
6298 }
6299
6300 /**
6301 * Retrieve extended data from the intent.
6302 *
6303 * @param name The name of the desired item.
6304 * @param defaultValue The default value to return in case no item is
6305 * associated with the key 'name'
6306 *
6307 * @return the value of an item that previously added with putExtra()
6308 * or defaultValue if none was found.
6309 *
6310 * @see #putExtra
6311 *
6312 * @deprecated
6313 * @hide
6314 */
6315 @Deprecated
6316 public Object getExtra(String name, Object defaultValue) {
6317 Object result = defaultValue;
6318 if (mExtras != null) {
6319 Object result2 = mExtras.get(name);
6320 if (result2 != null) {
6321 result = result2;
6322 }
6323 }
6324
6325 return result;
6326 }
6327
6328 /**
6329 * Retrieves a map of extended data from the intent.
6330 *
6331 * @return the map of all extras previously added with putExtra(),
6332 * or null if none have been added.
6333 */
6334 public Bundle getExtras() {
6335 return (mExtras != null)
6336 ? new Bundle(mExtras)
6337 : null;
6338 }
6339
6340 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006341 * Filter extras to only basic types.
6342 * @hide
6343 */
6344 public void removeUnsafeExtras() {
6345 if (mExtras != null) {
6346 mExtras.filterValues();
6347 }
6348 }
6349
6350 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006351 * Retrieve any special flags associated with this intent. You will
6352 * normally just set them with {@link #setFlags} and let the system
6353 * take the appropriate action with them.
6354 *
6355 * @return int The currently set flags.
6356 *
6357 * @see #setFlags
6358 */
6359 public int getFlags() {
6360 return mFlags;
6361 }
6362
Dianne Hackborne7f97212011-02-24 14:40:20 -08006363 /** @hide */
6364 public boolean isExcludingStopped() {
6365 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6366 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6367 }
6368
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006369 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006370 * Retrieve the application package name this Intent is limited to. When
6371 * resolving an Intent, if non-null this limits the resolution to only
6372 * components in the given application package.
6373 *
6374 * @return The name of the application package for the Intent.
6375 *
6376 * @see #resolveActivity
6377 * @see #setPackage
6378 */
6379 public String getPackage() {
6380 return mPackage;
6381 }
6382
6383 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006384 * Retrieve the concrete component associated with the intent. When receiving
6385 * an intent, this is the component that was found to best handle it (that is,
6386 * yourself) and will always be non-null; in all other cases it will be
6387 * null unless explicitly set.
6388 *
6389 * @return The name of the application component to handle the intent.
6390 *
6391 * @see #resolveActivity
6392 * @see #setComponent
6393 */
6394 public ComponentName getComponent() {
6395 return mComponent;
6396 }
6397
6398 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006399 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6400 * used as a hint to the receiver for animations and the like. Null means that there
6401 * is no source bounds.
6402 */
6403 public Rect getSourceBounds() {
6404 return mSourceBounds;
6405 }
6406
6407 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006408 * Return the Activity component that should be used to handle this intent.
6409 * The appropriate component is determined based on the information in the
6410 * intent, evaluated as follows:
6411 *
6412 * <p>If {@link #getComponent} returns an explicit class, that is returned
6413 * without any further consideration.
6414 *
6415 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6416 * category to be considered.
6417 *
6418 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6419 * action.
6420 *
6421 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6422 * this type.
6423 *
6424 * <p>If {@link #addCategory} has added any categories, the activity must
6425 * handle ALL of the categories specified.
6426 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006427 * <p>If {@link #getPackage} is non-NULL, only activity components in
6428 * that application package will be considered.
6429 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006430 * <p>If there are no activities that satisfy all of these conditions, a
6431 * null string is returned.
6432 *
6433 * <p>If multiple activities are found to satisfy the intent, the one with
6434 * the highest priority will be used. If there are multiple activities
6435 * with the same priority, the system will either pick the best activity
6436 * based on user preference, or resolve to a system class that will allow
6437 * the user to pick an activity and forward from there.
6438 *
6439 * <p>This method is implemented simply by calling
6440 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6441 * true.</p>
6442 * <p> This API is called for you as part of starting an activity from an
6443 * intent. You do not normally need to call it yourself.</p>
6444 *
6445 * @param pm The package manager with which to resolve the Intent.
6446 *
6447 * @return Name of the component implementing an activity that can
6448 * display the intent.
6449 *
6450 * @see #setComponent
6451 * @see #getComponent
6452 * @see #resolveActivityInfo
6453 */
6454 public ComponentName resolveActivity(PackageManager pm) {
6455 if (mComponent != null) {
6456 return mComponent;
6457 }
6458
6459 ResolveInfo info = pm.resolveActivity(
6460 this, PackageManager.MATCH_DEFAULT_ONLY);
6461 if (info != null) {
6462 return new ComponentName(
6463 info.activityInfo.applicationInfo.packageName,
6464 info.activityInfo.name);
6465 }
6466
6467 return null;
6468 }
6469
6470 /**
6471 * Resolve the Intent into an {@link ActivityInfo}
6472 * describing the activity that should execute the intent. Resolution
6473 * follows the same rules as described for {@link #resolveActivity}, but
6474 * you get back the completely information about the resolved activity
6475 * instead of just its class name.
6476 *
6477 * @param pm The package manager with which to resolve the Intent.
6478 * @param flags Addition information to retrieve as per
6479 * {@link PackageManager#getActivityInfo(ComponentName, int)
6480 * PackageManager.getActivityInfo()}.
6481 *
6482 * @return PackageManager.ActivityInfo
6483 *
6484 * @see #resolveActivity
6485 */
6486 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6487 ActivityInfo ai = null;
6488 if (mComponent != null) {
6489 try {
6490 ai = pm.getActivityInfo(mComponent, flags);
6491 } catch (PackageManager.NameNotFoundException e) {
6492 // ignore
6493 }
6494 } else {
6495 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006496 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006497 if (info != null) {
6498 ai = info.activityInfo;
6499 }
6500 }
6501
6502 return ai;
6503 }
6504
6505 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006506 * Special function for use by the system to resolve service
6507 * intents to system apps. Throws an exception if there are
6508 * multiple potential matches to the Intent. Returns null if
6509 * there are no matches.
6510 * @hide
6511 */
6512 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6513 if (mComponent != null) {
6514 return mComponent;
6515 }
6516
6517 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6518 if (results == null) {
6519 return null;
6520 }
6521 ComponentName comp = null;
6522 for (int i=0; i<results.size(); i++) {
6523 ResolveInfo ri = results.get(i);
6524 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6525 continue;
6526 }
6527 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6528 ri.serviceInfo.name);
6529 if (comp != null) {
6530 throw new IllegalStateException("Multiple system services handle " + this
6531 + ": " + comp + ", " + foundComp);
6532 }
6533 comp = foundComp;
6534 }
6535 return comp;
6536 }
6537
6538 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006539 * Set the general action to be performed.
6540 *
6541 * @param action An action name, such as ACTION_VIEW. Application-specific
6542 * actions should be prefixed with the vendor's package name.
6543 *
6544 * @return Returns the same Intent object, for chaining multiple calls
6545 * into a single statement.
6546 *
6547 * @see #getAction
6548 */
6549 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006550 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006551 return this;
6552 }
6553
6554 /**
6555 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006556 * clears any type that was previously set by {@link #setType} or
6557 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006558 *
Nick Pellyccae4122012-01-09 14:12:58 -08006559 * <p><em>Note: scheme matching in the Android framework is
6560 * case-sensitive, unlike the formal RFC. As a result,
6561 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006562 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006563 * {@link #setDataAndNormalize}
6564 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006565 *
Nick Pellyccae4122012-01-09 14:12:58 -08006566 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006567 *
6568 * @return Returns the same Intent object, for chaining multiple calls
6569 * into a single statement.
6570 *
6571 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006572 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006573 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006574 */
6575 public Intent setData(Uri data) {
6576 mData = data;
6577 mType = null;
6578 return this;
6579 }
6580
6581 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006582 * Normalize and set the data this intent is operating on.
6583 *
6584 * <p>This method automatically clears any type that was
6585 * previously set (for example, by {@link #setType}).
6586 *
6587 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006588 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006589 * so really this is just a convenience method for
6590 * <pre>
6591 * setData(data.normalize())
6592 * </pre>
6593 *
6594 * @param data The Uri of the data this intent is now targeting.
6595 *
6596 * @return Returns the same Intent object, for chaining multiple calls
6597 * into a single statement.
6598 *
6599 * @see #getData
6600 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006601 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006602 */
6603 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006604 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006605 }
6606
6607 /**
6608 * Set an explicit MIME data type.
6609 *
6610 * <p>This is used to create intents that only specify a type and not data,
6611 * for example to indicate the type of data to return.
6612 *
6613 * <p>This method automatically clears any data that was
6614 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006615 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006616 * <p><em>Note: MIME type matching in the Android framework is
6617 * case-sensitive, unlike formal RFC MIME types. As a result,
6618 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006619 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6620 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006621 *
6622 * @param type The MIME type of the data being handled by this intent.
6623 *
6624 * @return Returns the same Intent object, for chaining multiple calls
6625 * into a single statement.
6626 *
6627 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006628 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006629 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006630 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006631 */
6632 public Intent setType(String type) {
6633 mData = null;
6634 mType = type;
6635 return this;
6636 }
6637
6638 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006639 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006640 *
Nick Pellyccae4122012-01-09 14:12:58 -08006641 * <p>This is used to create intents that only specify a type and not data,
6642 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006643 *
Nick Pellyccae4122012-01-09 14:12:58 -08006644 * <p>This method automatically clears any data that was
6645 * previously set (for example by {@link #setData}).
6646 *
6647 * <p>The MIME type is normalized using
6648 * {@link #normalizeMimeType} before it is set,
6649 * so really this is just a convenience method for
6650 * <pre>
6651 * setType(Intent.normalizeMimeType(type))
6652 * </pre>
6653 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006654 * @param type The MIME type of the data being handled by this intent.
6655 *
6656 * @return Returns the same Intent object, for chaining multiple calls
6657 * into a single statement.
6658 *
Nick Pellyccae4122012-01-09 14:12:58 -08006659 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006660 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006661 * @see #normalizeMimeType
6662 */
6663 public Intent setTypeAndNormalize(String type) {
6664 return setType(normalizeMimeType(type));
6665 }
6666
6667 /**
6668 * (Usually optional) Set the data for the intent along with an explicit
6669 * MIME data type. This method should very rarely be used -- it allows you
6670 * to override the MIME type that would ordinarily be inferred from the
6671 * data with your own type given here.
6672 *
6673 * <p><em>Note: MIME type and Uri scheme matching in the
6674 * Android framework is case-sensitive, unlike the formal RFC definitions.
6675 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006676 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006677 * {@link #setDataAndTypeAndNormalize}
6678 * to ensure that they are converted to lower case.</em>
6679 *
6680 * @param data The Uri of the data this intent is now targeting.
6681 * @param type The MIME type of the data being handled by this intent.
6682 *
6683 * @return Returns the same Intent object, for chaining multiple calls
6684 * into a single statement.
6685 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006686 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006687 * @see #setData
6688 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006689 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006690 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006691 */
6692 public Intent setDataAndType(Uri data, String type) {
6693 mData = data;
6694 mType = type;
6695 return this;
6696 }
6697
6698 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006699 * (Usually optional) Normalize and set both the data Uri and an explicit
6700 * MIME data type. This method should very rarely be used -- it allows you
6701 * to override the MIME type that would ordinarily be inferred from the
6702 * data with your own type given here.
6703 *
6704 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006705 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006706 * before they are set, so really this is just a convenience method for
6707 * <pre>
6708 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6709 * </pre>
6710 *
6711 * @param data The Uri of the data this intent is now targeting.
6712 * @param type The MIME type of the data being handled by this intent.
6713 *
6714 * @return Returns the same Intent object, for chaining multiple calls
6715 * into a single statement.
6716 *
6717 * @see #setType
6718 * @see #setData
6719 * @see #setDataAndType
6720 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006721 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006722 */
6723 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006724 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006725 }
6726
6727 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006728 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006729 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006730 * activities that provide <em>all</em> of the requested categories will be
6731 * used.
6732 *
6733 * @param category The desired category. This can be either one of the
6734 * predefined Intent categories, or a custom category in your own
6735 * namespace.
6736 *
6737 * @return Returns the same Intent object, for chaining multiple calls
6738 * into a single statement.
6739 *
6740 * @see #hasCategory
6741 * @see #removeCategory
6742 */
6743 public Intent addCategory(String category) {
6744 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006745 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006746 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006747 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006748 return this;
6749 }
6750
6751 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006752 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006753 *
6754 * @param category The category to remove.
6755 *
6756 * @see #addCategory
6757 */
6758 public void removeCategory(String category) {
6759 if (mCategories != null) {
6760 mCategories.remove(category);
6761 if (mCategories.size() == 0) {
6762 mCategories = null;
6763 }
6764 }
6765 }
6766
6767 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006768 * Set a selector for this Intent. This is a modification to the kinds of
6769 * things the Intent will match. If the selector is set, it will be used
6770 * when trying to find entities that can handle the Intent, instead of the
6771 * main contents of the Intent. This allows you build an Intent containing
6772 * a generic protocol while targeting it more specifically.
6773 *
6774 * <p>An example of where this may be used is with things like
6775 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6776 * Intent that will launch the Browser application. However, the correct
6777 * main entry point of an application is actually {@link #ACTION_MAIN}
6778 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6779 * used to specify the actual Activity to launch. If you launch the browser
6780 * with something different, undesired behavior may happen if the user has
6781 * previously or later launches it the normal way, since they do not match.
6782 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6783 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6784 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6785 *
6786 * <p>Setting a selector does not impact the behavior of
6787 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6788 * desired behavior of a selector -- it does not impact the base meaning
6789 * of the Intent, just what kinds of things will be matched against it
6790 * when determining who can handle it.</p>
6791 *
6792 * <p>You can not use both a selector and {@link #setPackage(String)} on
6793 * the same base Intent.</p>
6794 *
6795 * @param selector The desired selector Intent; set to null to not use
6796 * a special selector.
6797 */
6798 public void setSelector(Intent selector) {
6799 if (selector == this) {
6800 throw new IllegalArgumentException(
6801 "Intent being set as a selector of itself");
6802 }
6803 if (selector != null && mPackage != null) {
6804 throw new IllegalArgumentException(
6805 "Can't set selector when package name is already set");
6806 }
6807 mSelector = selector;
6808 }
6809
6810 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006811 * Set a {@link ClipData} associated with this Intent. This replaces any
6812 * previously set ClipData.
6813 *
6814 * <p>The ClipData in an intent is not used for Intent matching or other
6815 * such operations. Semantically it is like extras, used to transmit
6816 * additional data with the Intent. The main feature of using this over
6817 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6818 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6819 * items included in the clip data. This is useful, in particular, if
6820 * you want to transmit an Intent containing multiple <code>content:</code>
6821 * URIs for which the recipient may not have global permission to access the
6822 * content provider.
6823 *
6824 * <p>If the ClipData contains items that are themselves Intents, any
6825 * grant flags in those Intents will be ignored. Only the top-level flags
6826 * of the main Intent are respected, and will be applied to all Uri or
6827 * Intent items in the clip (or sub-items of the clip).
6828 *
6829 * <p>The MIME type, label, and icon in the ClipData object are not
6830 * directly used by Intent. Applications should generally rely on the
6831 * MIME type of the Intent itself, not what it may find in the ClipData.
6832 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05006833 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006834 *
6835 * @param clip The new clip to set. May be null to clear the current clip.
6836 */
6837 public void setClipData(ClipData clip) {
6838 mClipData = clip;
6839 }
6840
6841 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006842 * This is NOT a secure mechanism to identify the user who sent the intent.
6843 * When the intent is sent to a different user, it is used to fix uris by adding the userId
6844 * who sent the intent.
6845 * @hide
6846 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01006847 public void prepareToLeaveUser(int userId) {
6848 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
6849 // We want mContentUserHint to refer to the original user, so don't do anything.
6850 if (mContentUserHint == UserHandle.USER_CURRENT) {
6851 mContentUserHint = userId;
6852 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006853 }
6854
6855 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006856 * Add extended data to the intent. The name must include a package
6857 * prefix, for example the app com.android.contacts would use names
6858 * like "com.android.contacts.ShowAll".
6859 *
6860 * @param name The name of the extra data, with package prefix.
6861 * @param value The boolean data value.
6862 *
6863 * @return Returns the same Intent object, for chaining multiple calls
6864 * into a single statement.
6865 *
6866 * @see #putExtras
6867 * @see #removeExtra
6868 * @see #getBooleanExtra(String, boolean)
6869 */
6870 public Intent putExtra(String name, boolean value) {
6871 if (mExtras == null) {
6872 mExtras = new Bundle();
6873 }
6874 mExtras.putBoolean(name, value);
6875 return this;
6876 }
6877
6878 /**
6879 * Add extended data to the intent. The name must include a package
6880 * prefix, for example the app com.android.contacts would use names
6881 * like "com.android.contacts.ShowAll".
6882 *
6883 * @param name The name of the extra data, with package prefix.
6884 * @param value The byte data value.
6885 *
6886 * @return Returns the same Intent object, for chaining multiple calls
6887 * into a single statement.
6888 *
6889 * @see #putExtras
6890 * @see #removeExtra
6891 * @see #getByteExtra(String, byte)
6892 */
6893 public Intent putExtra(String name, byte value) {
6894 if (mExtras == null) {
6895 mExtras = new Bundle();
6896 }
6897 mExtras.putByte(name, value);
6898 return this;
6899 }
6900
6901 /**
6902 * Add extended data to the intent. The name must include a package
6903 * prefix, for example the app com.android.contacts would use names
6904 * like "com.android.contacts.ShowAll".
6905 *
6906 * @param name The name of the extra data, with package prefix.
6907 * @param value The char data value.
6908 *
6909 * @return Returns the same Intent object, for chaining multiple calls
6910 * into a single statement.
6911 *
6912 * @see #putExtras
6913 * @see #removeExtra
6914 * @see #getCharExtra(String, char)
6915 */
6916 public Intent putExtra(String name, char value) {
6917 if (mExtras == null) {
6918 mExtras = new Bundle();
6919 }
6920 mExtras.putChar(name, value);
6921 return this;
6922 }
6923
6924 /**
6925 * Add extended data to the intent. The name must include a package
6926 * prefix, for example the app com.android.contacts would use names
6927 * like "com.android.contacts.ShowAll".
6928 *
6929 * @param name The name of the extra data, with package prefix.
6930 * @param value The short data value.
6931 *
6932 * @return Returns the same Intent object, for chaining multiple calls
6933 * into a single statement.
6934 *
6935 * @see #putExtras
6936 * @see #removeExtra
6937 * @see #getShortExtra(String, short)
6938 */
6939 public Intent putExtra(String name, short value) {
6940 if (mExtras == null) {
6941 mExtras = new Bundle();
6942 }
6943 mExtras.putShort(name, value);
6944 return this;
6945 }
6946
6947 /**
6948 * Add extended data to the intent. The name must include a package
6949 * prefix, for example the app com.android.contacts would use names
6950 * like "com.android.contacts.ShowAll".
6951 *
6952 * @param name The name of the extra data, with package prefix.
6953 * @param value The integer data value.
6954 *
6955 * @return Returns the same Intent object, for chaining multiple calls
6956 * into a single statement.
6957 *
6958 * @see #putExtras
6959 * @see #removeExtra
6960 * @see #getIntExtra(String, int)
6961 */
6962 public Intent putExtra(String name, int value) {
6963 if (mExtras == null) {
6964 mExtras = new Bundle();
6965 }
6966 mExtras.putInt(name, value);
6967 return this;
6968 }
6969
6970 /**
6971 * Add extended data to the intent. The name must include a package
6972 * prefix, for example the app com.android.contacts would use names
6973 * like "com.android.contacts.ShowAll".
6974 *
6975 * @param name The name of the extra data, with package prefix.
6976 * @param value The long data value.
6977 *
6978 * @return Returns the same Intent object, for chaining multiple calls
6979 * into a single statement.
6980 *
6981 * @see #putExtras
6982 * @see #removeExtra
6983 * @see #getLongExtra(String, long)
6984 */
6985 public Intent putExtra(String name, long value) {
6986 if (mExtras == null) {
6987 mExtras = new Bundle();
6988 }
6989 mExtras.putLong(name, value);
6990 return this;
6991 }
6992
6993 /**
6994 * Add extended data to the intent. The name must include a package
6995 * prefix, for example the app com.android.contacts would use names
6996 * like "com.android.contacts.ShowAll".
6997 *
6998 * @param name The name of the extra data, with package prefix.
6999 * @param value The float data value.
7000 *
7001 * @return Returns the same Intent object, for chaining multiple calls
7002 * into a single statement.
7003 *
7004 * @see #putExtras
7005 * @see #removeExtra
7006 * @see #getFloatExtra(String, float)
7007 */
7008 public Intent putExtra(String name, float value) {
7009 if (mExtras == null) {
7010 mExtras = new Bundle();
7011 }
7012 mExtras.putFloat(name, value);
7013 return this;
7014 }
7015
7016 /**
7017 * Add extended data to the intent. The name must include a package
7018 * prefix, for example the app com.android.contacts would use names
7019 * like "com.android.contacts.ShowAll".
7020 *
7021 * @param name The name of the extra data, with package prefix.
7022 * @param value The double data value.
7023 *
7024 * @return Returns the same Intent object, for chaining multiple calls
7025 * into a single statement.
7026 *
7027 * @see #putExtras
7028 * @see #removeExtra
7029 * @see #getDoubleExtra(String, double)
7030 */
7031 public Intent putExtra(String name, double value) {
7032 if (mExtras == null) {
7033 mExtras = new Bundle();
7034 }
7035 mExtras.putDouble(name, value);
7036 return this;
7037 }
7038
7039 /**
7040 * Add extended data to the intent. The name must include a package
7041 * prefix, for example the app com.android.contacts would use names
7042 * like "com.android.contacts.ShowAll".
7043 *
7044 * @param name The name of the extra data, with package prefix.
7045 * @param value The String data value.
7046 *
7047 * @return Returns the same Intent object, for chaining multiple calls
7048 * into a single statement.
7049 *
7050 * @see #putExtras
7051 * @see #removeExtra
7052 * @see #getStringExtra(String)
7053 */
7054 public Intent putExtra(String name, String value) {
7055 if (mExtras == null) {
7056 mExtras = new Bundle();
7057 }
7058 mExtras.putString(name, value);
7059 return this;
7060 }
7061
7062 /**
7063 * Add extended data to the intent. The name must include a package
7064 * prefix, for example the app com.android.contacts would use names
7065 * like "com.android.contacts.ShowAll".
7066 *
7067 * @param name The name of the extra data, with package prefix.
7068 * @param value The CharSequence data value.
7069 *
7070 * @return Returns the same Intent object, for chaining multiple calls
7071 * into a single statement.
7072 *
7073 * @see #putExtras
7074 * @see #removeExtra
7075 * @see #getCharSequenceExtra(String)
7076 */
7077 public Intent putExtra(String name, CharSequence value) {
7078 if (mExtras == null) {
7079 mExtras = new Bundle();
7080 }
7081 mExtras.putCharSequence(name, value);
7082 return this;
7083 }
7084
7085 /**
7086 * Add extended data to the intent. The name must include a package
7087 * prefix, for example the app com.android.contacts would use names
7088 * like "com.android.contacts.ShowAll".
7089 *
7090 * @param name The name of the extra data, with package prefix.
7091 * @param value The Parcelable data value.
7092 *
7093 * @return Returns the same Intent object, for chaining multiple calls
7094 * into a single statement.
7095 *
7096 * @see #putExtras
7097 * @see #removeExtra
7098 * @see #getParcelableExtra(String)
7099 */
7100 public Intent putExtra(String name, Parcelable value) {
7101 if (mExtras == null) {
7102 mExtras = new Bundle();
7103 }
7104 mExtras.putParcelable(name, value);
7105 return this;
7106 }
7107
7108 /**
7109 * Add extended data to the intent. The name must include a package
7110 * prefix, for example the app com.android.contacts would use names
7111 * like "com.android.contacts.ShowAll".
7112 *
7113 * @param name The name of the extra data, with package prefix.
7114 * @param value The Parcelable[] data value.
7115 *
7116 * @return Returns the same Intent object, for chaining multiple calls
7117 * into a single statement.
7118 *
7119 * @see #putExtras
7120 * @see #removeExtra
7121 * @see #getParcelableArrayExtra(String)
7122 */
7123 public Intent putExtra(String name, Parcelable[] value) {
7124 if (mExtras == null) {
7125 mExtras = new Bundle();
7126 }
7127 mExtras.putParcelableArray(name, value);
7128 return this;
7129 }
7130
7131 /**
7132 * Add extended data to the intent. The name must include a package
7133 * prefix, for example the app com.android.contacts would use names
7134 * like "com.android.contacts.ShowAll".
7135 *
7136 * @param name The name of the extra data, with package prefix.
7137 * @param value The ArrayList<Parcelable> data value.
7138 *
7139 * @return Returns the same Intent object, for chaining multiple calls
7140 * into a single statement.
7141 *
7142 * @see #putExtras
7143 * @see #removeExtra
7144 * @see #getParcelableArrayListExtra(String)
7145 */
7146 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7147 if (mExtras == null) {
7148 mExtras = new Bundle();
7149 }
7150 mExtras.putParcelableArrayList(name, value);
7151 return this;
7152 }
7153
7154 /**
7155 * Add extended data to the intent. The name must include a package
7156 * prefix, for example the app com.android.contacts would use names
7157 * like "com.android.contacts.ShowAll".
7158 *
7159 * @param name The name of the extra data, with package prefix.
7160 * @param value The ArrayList<Integer> data value.
7161 *
7162 * @return Returns the same Intent object, for chaining multiple calls
7163 * into a single statement.
7164 *
7165 * @see #putExtras
7166 * @see #removeExtra
7167 * @see #getIntegerArrayListExtra(String)
7168 */
7169 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7170 if (mExtras == null) {
7171 mExtras = new Bundle();
7172 }
7173 mExtras.putIntegerArrayList(name, value);
7174 return this;
7175 }
7176
7177 /**
7178 * Add extended data to the intent. The name must include a package
7179 * prefix, for example the app com.android.contacts would use names
7180 * like "com.android.contacts.ShowAll".
7181 *
7182 * @param name The name of the extra data, with package prefix.
7183 * @param value The ArrayList<String> data value.
7184 *
7185 * @return Returns the same Intent object, for chaining multiple calls
7186 * into a single statement.
7187 *
7188 * @see #putExtras
7189 * @see #removeExtra
7190 * @see #getStringArrayListExtra(String)
7191 */
7192 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7193 if (mExtras == null) {
7194 mExtras = new Bundle();
7195 }
7196 mExtras.putStringArrayList(name, value);
7197 return this;
7198 }
7199
7200 /**
7201 * Add extended data to the intent. The name must include a package
7202 * prefix, for example the app com.android.contacts would use names
7203 * like "com.android.contacts.ShowAll".
7204 *
7205 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007206 * @param value The ArrayList<CharSequence> data value.
7207 *
7208 * @return Returns the same Intent object, for chaining multiple calls
7209 * into a single statement.
7210 *
7211 * @see #putExtras
7212 * @see #removeExtra
7213 * @see #getCharSequenceArrayListExtra(String)
7214 */
7215 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7216 if (mExtras == null) {
7217 mExtras = new Bundle();
7218 }
7219 mExtras.putCharSequenceArrayList(name, value);
7220 return this;
7221 }
7222
7223 /**
7224 * Add extended data to the intent. The name must include a package
7225 * prefix, for example the app com.android.contacts would use names
7226 * like "com.android.contacts.ShowAll".
7227 *
7228 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007229 * @param value The Serializable data value.
7230 *
7231 * @return Returns the same Intent object, for chaining multiple calls
7232 * into a single statement.
7233 *
7234 * @see #putExtras
7235 * @see #removeExtra
7236 * @see #getSerializableExtra(String)
7237 */
7238 public Intent putExtra(String name, Serializable value) {
7239 if (mExtras == null) {
7240 mExtras = new Bundle();
7241 }
7242 mExtras.putSerializable(name, value);
7243 return this;
7244 }
7245
7246 /**
7247 * Add extended data to the intent. The name must include a package
7248 * prefix, for example the app com.android.contacts would use names
7249 * like "com.android.contacts.ShowAll".
7250 *
7251 * @param name The name of the extra data, with package prefix.
7252 * @param value The boolean array data value.
7253 *
7254 * @return Returns the same Intent object, for chaining multiple calls
7255 * into a single statement.
7256 *
7257 * @see #putExtras
7258 * @see #removeExtra
7259 * @see #getBooleanArrayExtra(String)
7260 */
7261 public Intent putExtra(String name, boolean[] value) {
7262 if (mExtras == null) {
7263 mExtras = new Bundle();
7264 }
7265 mExtras.putBooleanArray(name, value);
7266 return this;
7267 }
7268
7269 /**
7270 * Add extended data to the intent. The name must include a package
7271 * prefix, for example the app com.android.contacts would use names
7272 * like "com.android.contacts.ShowAll".
7273 *
7274 * @param name The name of the extra data, with package prefix.
7275 * @param value The byte array data value.
7276 *
7277 * @return Returns the same Intent object, for chaining multiple calls
7278 * into a single statement.
7279 *
7280 * @see #putExtras
7281 * @see #removeExtra
7282 * @see #getByteArrayExtra(String)
7283 */
7284 public Intent putExtra(String name, byte[] value) {
7285 if (mExtras == null) {
7286 mExtras = new Bundle();
7287 }
7288 mExtras.putByteArray(name, value);
7289 return this;
7290 }
7291
7292 /**
7293 * Add extended data to the intent. The name must include a package
7294 * prefix, for example the app com.android.contacts would use names
7295 * like "com.android.contacts.ShowAll".
7296 *
7297 * @param name The name of the extra data, with package prefix.
7298 * @param value The short array data value.
7299 *
7300 * @return Returns the same Intent object, for chaining multiple calls
7301 * into a single statement.
7302 *
7303 * @see #putExtras
7304 * @see #removeExtra
7305 * @see #getShortArrayExtra(String)
7306 */
7307 public Intent putExtra(String name, short[] value) {
7308 if (mExtras == null) {
7309 mExtras = new Bundle();
7310 }
7311 mExtras.putShortArray(name, value);
7312 return this;
7313 }
7314
7315 /**
7316 * Add extended data to the intent. The name must include a package
7317 * prefix, for example the app com.android.contacts would use names
7318 * like "com.android.contacts.ShowAll".
7319 *
7320 * @param name The name of the extra data, with package prefix.
7321 * @param value The char array data value.
7322 *
7323 * @return Returns the same Intent object, for chaining multiple calls
7324 * into a single statement.
7325 *
7326 * @see #putExtras
7327 * @see #removeExtra
7328 * @see #getCharArrayExtra(String)
7329 */
7330 public Intent putExtra(String name, char[] value) {
7331 if (mExtras == null) {
7332 mExtras = new Bundle();
7333 }
7334 mExtras.putCharArray(name, value);
7335 return this;
7336 }
7337
7338 /**
7339 * Add extended data to the intent. The name must include a package
7340 * prefix, for example the app com.android.contacts would use names
7341 * like "com.android.contacts.ShowAll".
7342 *
7343 * @param name The name of the extra data, with package prefix.
7344 * @param value The int array data value.
7345 *
7346 * @return Returns the same Intent object, for chaining multiple calls
7347 * into a single statement.
7348 *
7349 * @see #putExtras
7350 * @see #removeExtra
7351 * @see #getIntArrayExtra(String)
7352 */
7353 public Intent putExtra(String name, int[] value) {
7354 if (mExtras == null) {
7355 mExtras = new Bundle();
7356 }
7357 mExtras.putIntArray(name, value);
7358 return this;
7359 }
7360
7361 /**
7362 * Add extended data to the intent. The name must include a package
7363 * prefix, for example the app com.android.contacts would use names
7364 * like "com.android.contacts.ShowAll".
7365 *
7366 * @param name The name of the extra data, with package prefix.
7367 * @param value The byte array data value.
7368 *
7369 * @return Returns the same Intent object, for chaining multiple calls
7370 * into a single statement.
7371 *
7372 * @see #putExtras
7373 * @see #removeExtra
7374 * @see #getLongArrayExtra(String)
7375 */
7376 public Intent putExtra(String name, long[] value) {
7377 if (mExtras == null) {
7378 mExtras = new Bundle();
7379 }
7380 mExtras.putLongArray(name, value);
7381 return this;
7382 }
7383
7384 /**
7385 * Add extended data to the intent. The name must include a package
7386 * prefix, for example the app com.android.contacts would use names
7387 * like "com.android.contacts.ShowAll".
7388 *
7389 * @param name The name of the extra data, with package prefix.
7390 * @param value The float array data value.
7391 *
7392 * @return Returns the same Intent object, for chaining multiple calls
7393 * into a single statement.
7394 *
7395 * @see #putExtras
7396 * @see #removeExtra
7397 * @see #getFloatArrayExtra(String)
7398 */
7399 public Intent putExtra(String name, float[] value) {
7400 if (mExtras == null) {
7401 mExtras = new Bundle();
7402 }
7403 mExtras.putFloatArray(name, value);
7404 return this;
7405 }
7406
7407 /**
7408 * Add extended data to the intent. The name must include a package
7409 * prefix, for example the app com.android.contacts would use names
7410 * like "com.android.contacts.ShowAll".
7411 *
7412 * @param name The name of the extra data, with package prefix.
7413 * @param value The double array data value.
7414 *
7415 * @return Returns the same Intent object, for chaining multiple calls
7416 * into a single statement.
7417 *
7418 * @see #putExtras
7419 * @see #removeExtra
7420 * @see #getDoubleArrayExtra(String)
7421 */
7422 public Intent putExtra(String name, double[] value) {
7423 if (mExtras == null) {
7424 mExtras = new Bundle();
7425 }
7426 mExtras.putDoubleArray(name, value);
7427 return this;
7428 }
7429
7430 /**
7431 * Add extended data to the intent. The name must include a package
7432 * prefix, for example the app com.android.contacts would use names
7433 * like "com.android.contacts.ShowAll".
7434 *
7435 * @param name The name of the extra data, with package prefix.
7436 * @param value The String array data value.
7437 *
7438 * @return Returns the same Intent object, for chaining multiple calls
7439 * into a single statement.
7440 *
7441 * @see #putExtras
7442 * @see #removeExtra
7443 * @see #getStringArrayExtra(String)
7444 */
7445 public Intent putExtra(String name, String[] value) {
7446 if (mExtras == null) {
7447 mExtras = new Bundle();
7448 }
7449 mExtras.putStringArray(name, value);
7450 return this;
7451 }
7452
7453 /**
7454 * Add extended data to the intent. The name must include a package
7455 * prefix, for example the app com.android.contacts would use names
7456 * like "com.android.contacts.ShowAll".
7457 *
7458 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007459 * @param value The CharSequence array data value.
7460 *
7461 * @return Returns the same Intent object, for chaining multiple calls
7462 * into a single statement.
7463 *
7464 * @see #putExtras
7465 * @see #removeExtra
7466 * @see #getCharSequenceArrayExtra(String)
7467 */
7468 public Intent putExtra(String name, CharSequence[] value) {
7469 if (mExtras == null) {
7470 mExtras = new Bundle();
7471 }
7472 mExtras.putCharSequenceArray(name, value);
7473 return this;
7474 }
7475
7476 /**
7477 * Add extended data to the intent. The name must include a package
7478 * prefix, for example the app com.android.contacts would use names
7479 * like "com.android.contacts.ShowAll".
7480 *
7481 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007482 * @param value The Bundle data value.
7483 *
7484 * @return Returns the same Intent object, for chaining multiple calls
7485 * into a single statement.
7486 *
7487 * @see #putExtras
7488 * @see #removeExtra
7489 * @see #getBundleExtra(String)
7490 */
7491 public Intent putExtra(String name, Bundle value) {
7492 if (mExtras == null) {
7493 mExtras = new Bundle();
7494 }
7495 mExtras.putBundle(name, value);
7496 return this;
7497 }
7498
7499 /**
7500 * Add extended data to the intent. The name must include a package
7501 * prefix, for example the app com.android.contacts would use names
7502 * like "com.android.contacts.ShowAll".
7503 *
7504 * @param name The name of the extra data, with package prefix.
7505 * @param value The IBinder data value.
7506 *
7507 * @return Returns the same Intent object, for chaining multiple calls
7508 * into a single statement.
7509 *
7510 * @see #putExtras
7511 * @see #removeExtra
7512 * @see #getIBinderExtra(String)
7513 *
7514 * @deprecated
7515 * @hide
7516 */
7517 @Deprecated
7518 public Intent putExtra(String name, IBinder value) {
7519 if (mExtras == null) {
7520 mExtras = new Bundle();
7521 }
7522 mExtras.putIBinder(name, value);
7523 return this;
7524 }
7525
7526 /**
7527 * Copy all extras in 'src' in to this intent.
7528 *
7529 * @param src Contains the extras to copy.
7530 *
7531 * @see #putExtra
7532 */
7533 public Intent putExtras(Intent src) {
7534 if (src.mExtras != null) {
7535 if (mExtras == null) {
7536 mExtras = new Bundle(src.mExtras);
7537 } else {
7538 mExtras.putAll(src.mExtras);
7539 }
7540 }
7541 return this;
7542 }
7543
7544 /**
7545 * Add a set of extended data to the intent. The keys must include a package
7546 * prefix, for example the app com.android.contacts would use names
7547 * like "com.android.contacts.ShowAll".
7548 *
7549 * @param extras The Bundle of extras to add to this intent.
7550 *
7551 * @see #putExtra
7552 * @see #removeExtra
7553 */
7554 public Intent putExtras(Bundle extras) {
7555 if (mExtras == null) {
7556 mExtras = new Bundle();
7557 }
7558 mExtras.putAll(extras);
7559 return this;
7560 }
7561
7562 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007563 * Completely replace the extras in the Intent with the extras in the
7564 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007565 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007566 * @param src The exact extras contained in this Intent are copied
7567 * into the target intent, replacing any that were previously there.
7568 */
7569 public Intent replaceExtras(Intent src) {
7570 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7571 return this;
7572 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007573
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007574 /**
7575 * Completely replace the extras in the Intent with the given Bundle of
7576 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007577 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007578 * @param extras The new set of extras in the Intent, or null to erase
7579 * all extras.
7580 */
7581 public Intent replaceExtras(Bundle extras) {
7582 mExtras = extras != null ? new Bundle(extras) : null;
7583 return this;
7584 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007585
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007586 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007587 * Remove extended data from the intent.
7588 *
7589 * @see #putExtra
7590 */
7591 public void removeExtra(String name) {
7592 if (mExtras != null) {
7593 mExtras.remove(name);
7594 if (mExtras.size() == 0) {
7595 mExtras = null;
7596 }
7597 }
7598 }
7599
7600 /**
7601 * Set special flags controlling how this intent is handled. Most values
7602 * here depend on the type of component being executed by the Intent,
7603 * specifically the FLAG_ACTIVITY_* flags are all for use with
7604 * {@link Context#startActivity Context.startActivity()} and the
7605 * FLAG_RECEIVER_* flags are all for use with
7606 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7607 *
Scott Main7aee61f2011-02-08 11:25:01 -08007608 * <p>See the
7609 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7610 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007611 * the behavior of your application.
7612 *
7613 * @param flags The desired flags.
7614 *
7615 * @return Returns the same Intent object, for chaining multiple calls
7616 * into a single statement.
7617 *
7618 * @see #getFlags
7619 * @see #addFlags
7620 *
7621 * @see #FLAG_GRANT_READ_URI_PERMISSION
7622 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007623 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7624 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007625 * @see #FLAG_DEBUG_LOG_RESOLUTION
7626 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007627 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007628 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007629 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007630 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007631 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7632 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007633 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007634 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007635 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007636 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007637 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007638 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007639 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007640 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7641 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007642 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007643 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007644 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007645 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7646 */
7647 public Intent setFlags(int flags) {
7648 mFlags = flags;
7649 return this;
7650 }
7651
7652 /**
7653 * Add additional flags to the intent (or with existing flags
7654 * value).
7655 *
7656 * @param flags The new flags to set.
7657 *
7658 * @return Returns the same Intent object, for chaining multiple calls
7659 * into a single statement.
7660 *
7661 * @see #setFlags
7662 */
7663 public Intent addFlags(int flags) {
7664 mFlags |= flags;
7665 return this;
7666 }
7667
7668 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007669 * (Usually optional) Set an explicit application package name that limits
7670 * the components this Intent will resolve to. If left to the default
7671 * value of null, all components in all applications will considered.
7672 * If non-null, the Intent can only match the components in the given
7673 * application package.
7674 *
7675 * @param packageName The name of the application package to handle the
7676 * intent, or null to allow any application package.
7677 *
7678 * @return Returns the same Intent object, for chaining multiple calls
7679 * into a single statement.
7680 *
7681 * @see #getPackage
7682 * @see #resolveActivity
7683 */
7684 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007685 if (packageName != null && mSelector != null) {
7686 throw new IllegalArgumentException(
7687 "Can't set package name when selector is already set");
7688 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007689 mPackage = packageName;
7690 return this;
7691 }
7692
7693 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007694 * (Usually optional) Explicitly set the component to handle the intent.
7695 * If left with the default value of null, the system will determine the
7696 * appropriate class to use based on the other fields (action, data,
7697 * type, categories) in the Intent. If this class is defined, the
7698 * specified class will always be used regardless of the other fields. You
7699 * should only set this value when you know you absolutely want a specific
7700 * class to be used; otherwise it is better to let the system find the
7701 * appropriate class so that you will respect the installed applications
7702 * and user preferences.
7703 *
7704 * @param component The name of the application component to handle the
7705 * intent, or null to let the system find one for you.
7706 *
7707 * @return Returns the same Intent object, for chaining multiple calls
7708 * into a single statement.
7709 *
7710 * @see #setClass
7711 * @see #setClassName(Context, String)
7712 * @see #setClassName(String, String)
7713 * @see #getComponent
7714 * @see #resolveActivity
7715 */
7716 public Intent setComponent(ComponentName component) {
7717 mComponent = component;
7718 return this;
7719 }
7720
7721 /**
7722 * Convenience for calling {@link #setComponent} with an
7723 * explicit class name.
7724 *
7725 * @param packageContext A Context of the application package implementing
7726 * this class.
7727 * @param className The name of a class inside of the application package
7728 * that will be used as the component for this Intent.
7729 *
7730 * @return Returns the same Intent object, for chaining multiple calls
7731 * into a single statement.
7732 *
7733 * @see #setComponent
7734 * @see #setClass
7735 */
7736 public Intent setClassName(Context packageContext, String className) {
7737 mComponent = new ComponentName(packageContext, className);
7738 return this;
7739 }
7740
7741 /**
7742 * Convenience for calling {@link #setComponent} with an
7743 * explicit application package name and class name.
7744 *
7745 * @param packageName The name of the package implementing the desired
7746 * component.
7747 * @param className The name of a class inside of the application package
7748 * that will be used as the component for this Intent.
7749 *
7750 * @return Returns the same Intent object, for chaining multiple calls
7751 * into a single statement.
7752 *
7753 * @see #setComponent
7754 * @see #setClass
7755 */
7756 public Intent setClassName(String packageName, String className) {
7757 mComponent = new ComponentName(packageName, className);
7758 return this;
7759 }
7760
7761 /**
7762 * Convenience for calling {@link #setComponent(ComponentName)} with the
7763 * name returned by a {@link Class} object.
7764 *
7765 * @param packageContext A Context of the application package implementing
7766 * this class.
7767 * @param cls The class name to set, equivalent to
7768 * <code>setClassName(context, cls.getName())</code>.
7769 *
7770 * @return Returns the same Intent object, for chaining multiple calls
7771 * into a single statement.
7772 *
7773 * @see #setComponent
7774 */
7775 public Intent setClass(Context packageContext, Class<?> cls) {
7776 mComponent = new ComponentName(packageContext, cls);
7777 return this;
7778 }
7779
7780 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007781 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7782 * used as a hint to the receiver for animations and the like. Null means that there
7783 * is no source bounds.
7784 */
7785 public void setSourceBounds(Rect r) {
7786 if (r != null) {
7787 mSourceBounds = new Rect(r);
7788 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007789 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007790 }
7791 }
7792
Tor Norbyed9273d62013-05-30 15:59:53 -07007793 /** @hide */
7794 @IntDef(flag = true,
7795 value = {
7796 FILL_IN_ACTION,
7797 FILL_IN_DATA,
7798 FILL_IN_CATEGORIES,
7799 FILL_IN_COMPONENT,
7800 FILL_IN_PACKAGE,
7801 FILL_IN_SOURCE_BOUNDS,
7802 FILL_IN_SELECTOR,
7803 FILL_IN_CLIP_DATA
7804 })
7805 @Retention(RetentionPolicy.SOURCE)
7806 public @interface FillInFlags {}
7807
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007808 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007809 * Use with {@link #fillIn} to allow the current action value to be
7810 * overwritten, even if it is already set.
7811 */
7812 public static final int FILL_IN_ACTION = 1<<0;
7813
7814 /**
7815 * Use with {@link #fillIn} to allow the current data or type value
7816 * overwritten, even if it is already set.
7817 */
7818 public static final int FILL_IN_DATA = 1<<1;
7819
7820 /**
7821 * Use with {@link #fillIn} to allow the current categories to be
7822 * overwritten, even if they are already set.
7823 */
7824 public static final int FILL_IN_CATEGORIES = 1<<2;
7825
7826 /**
7827 * Use with {@link #fillIn} to allow the current component value to be
7828 * overwritten, even if it is already set.
7829 */
7830 public static final int FILL_IN_COMPONENT = 1<<3;
7831
7832 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007833 * Use with {@link #fillIn} to allow the current package value to be
7834 * overwritten, even if it is already set.
7835 */
7836 public static final int FILL_IN_PACKAGE = 1<<4;
7837
7838 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007839 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007840 * overwritten, even if it is already set.
7841 */
7842 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
7843
7844 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007845 * Use with {@link #fillIn} to allow the current selector to be
7846 * overwritten, even if it is already set.
7847 */
7848 public static final int FILL_IN_SELECTOR = 1<<6;
7849
7850 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007851 * Use with {@link #fillIn} to allow the current ClipData to be
7852 * overwritten, even if it is already set.
7853 */
7854 public static final int FILL_IN_CLIP_DATA = 1<<7;
7855
7856 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007857 * Copy the contents of <var>other</var> in to this object, but only
7858 * where fields are not defined by this object. For purposes of a field
7859 * being defined, the following pieces of data in the Intent are
7860 * considered to be separate fields:
7861 *
7862 * <ul>
7863 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08007864 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007865 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
7866 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007867 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007868 * <li> component, as set by {@link #setComponent(ComponentName)} or
7869 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007870 * <li> source bounds, as set by {@link #setSourceBounds}.
7871 * <li> selector, as set by {@link #setSelector(Intent)}.
7872 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007873 * <li> each top-level name in the associated extras.
7874 * </ul>
7875 *
7876 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007877 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007878 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7879 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
7880 * the restriction where the corresponding field will not be replaced if
7881 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007882 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007883 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
7884 * is explicitly specified. The selector will only be copied if
7885 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07007886 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007887 * <p>For example, consider Intent A with {data="foo", categories="bar"}
7888 * and Intent B with {action="gotit", data-type="some/thing",
7889 * categories="one","two"}.
7890 *
7891 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
7892 * containing: {action="gotit", data-type="some/thing",
7893 * categories="bar"}.
7894 *
7895 * @param other Another Intent whose values are to be used to fill in
7896 * the current one.
7897 * @param flags Options to control which fields can be filled in.
7898 *
7899 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007900 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07007901 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
7902 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
7903 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007904 */
Tor Norbyed9273d62013-05-30 15:59:53 -07007905 @FillInFlags
7906 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007907 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007908 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007909 if (other.mAction != null
7910 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007911 mAction = other.mAction;
7912 changes |= FILL_IN_ACTION;
7913 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007914 if ((other.mData != null || other.mType != null)
7915 && ((mData == null && mType == null)
7916 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007917 mData = other.mData;
7918 mType = other.mType;
7919 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007920 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007921 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007922 if (other.mCategories != null
7923 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007924 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07007925 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007926 }
7927 changes |= FILL_IN_CATEGORIES;
7928 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007929 if (other.mPackage != null
7930 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007931 // Only do this if mSelector is not set.
7932 if (mSelector == null) {
7933 mPackage = other.mPackage;
7934 changes |= FILL_IN_PACKAGE;
7935 }
7936 }
7937 // Selector is special: it can only be set if explicitly allowed,
7938 // for the same reason as the component name.
7939 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
7940 if (mPackage == null) {
7941 mSelector = new Intent(other.mSelector);
7942 mPackage = null;
7943 changes |= FILL_IN_SELECTOR;
7944 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007945 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007946 if (other.mClipData != null
7947 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
7948 mClipData = other.mClipData;
7949 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007950 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007951 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007952 // Component is special: it can -only- be set if explicitly allowed,
7953 // since otherwise the sender could force the intent somewhere the
7954 // originator didn't intend.
7955 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007956 mComponent = other.mComponent;
7957 changes |= FILL_IN_COMPONENT;
7958 }
7959 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007960 if (other.mSourceBounds != null
7961 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
7962 mSourceBounds = new Rect(other.mSourceBounds);
7963 changes |= FILL_IN_SOURCE_BOUNDS;
7964 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007965 if (mExtras == null) {
7966 if (other.mExtras != null) {
7967 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007968 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007969 }
7970 } else if (other.mExtras != null) {
7971 try {
7972 Bundle newb = new Bundle(other.mExtras);
7973 newb.putAll(mExtras);
7974 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007975 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007976 } catch (RuntimeException e) {
7977 // Modifying the extras can cause us to unparcel the contents
7978 // of the bundle, and if we do this in the system process that
7979 // may fail. We really should handle this (i.e., the Bundle
7980 // impl shouldn't be on top of a plain map), but for now just
7981 // ignore it and keep the original contents. :(
7982 Log.w("Intent", "Failure filling in extras", e);
7983 }
7984 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007985 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
7986 && other.mContentUserHint != UserHandle.USER_CURRENT) {
7987 mContentUserHint = other.mContentUserHint;
7988 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007989 return changes;
7990 }
7991
7992 /**
7993 * Wrapper class holding an Intent and implementing comparisons on it for
7994 * the purpose of filtering. The class implements its
7995 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
7996 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
7997 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
7998 * on the wrapped Intent.
7999 */
8000 public static final class FilterComparison {
8001 private final Intent mIntent;
8002 private final int mHashCode;
8003
8004 public FilterComparison(Intent intent) {
8005 mIntent = intent;
8006 mHashCode = intent.filterHashCode();
8007 }
8008
8009 /**
8010 * Return the Intent that this FilterComparison represents.
8011 * @return Returns the Intent held by the FilterComparison. Do
8012 * not modify!
8013 */
8014 public Intent getIntent() {
8015 return mIntent;
8016 }
8017
8018 @Override
8019 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008020 if (obj instanceof FilterComparison) {
8021 Intent other = ((FilterComparison)obj).mIntent;
8022 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008023 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008024 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008025 }
8026
8027 @Override
8028 public int hashCode() {
8029 return mHashCode;
8030 }
8031 }
8032
8033 /**
8034 * Determine if two intents are the same for the purposes of intent
8035 * resolution (filtering). That is, if their action, data, type,
8036 * class, and categories are the same. This does <em>not</em> compare
8037 * any extra data included in the intents.
8038 *
8039 * @param other The other Intent to compare against.
8040 *
8041 * @return Returns true if action, data, type, class, and categories
8042 * are the same.
8043 */
8044 public boolean filterEquals(Intent other) {
8045 if (other == null) {
8046 return false;
8047 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008048 if (!Objects.equals(this.mAction, other.mAction)) return false;
8049 if (!Objects.equals(this.mData, other.mData)) return false;
8050 if (!Objects.equals(this.mType, other.mType)) return false;
8051 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8052 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8053 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008054
8055 return true;
8056 }
8057
8058 /**
8059 * Generate hash code that matches semantics of filterEquals().
8060 *
8061 * @return Returns the hash value of the action, data, type, class, and
8062 * categories.
8063 *
8064 * @see #filterEquals
8065 */
8066 public int filterHashCode() {
8067 int code = 0;
8068 if (mAction != null) {
8069 code += mAction.hashCode();
8070 }
8071 if (mData != null) {
8072 code += mData.hashCode();
8073 }
8074 if (mType != null) {
8075 code += mType.hashCode();
8076 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008077 if (mPackage != null) {
8078 code += mPackage.hashCode();
8079 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008080 if (mComponent != null) {
8081 code += mComponent.hashCode();
8082 }
8083 if (mCategories != null) {
8084 code += mCategories.hashCode();
8085 }
8086 return code;
8087 }
8088
8089 @Override
8090 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008091 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008092
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008093 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008094 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008095 b.append(" }");
8096
8097 return b.toString();
8098 }
8099
8100 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008101 public String toInsecureString() {
8102 StringBuilder b = new StringBuilder(128);
8103
8104 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008105 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008106 b.append(" }");
8107
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008108 return b.toString();
8109 }
Romain Guy4969af72009-06-17 10:53:19 -07008110
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008111 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008112 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008113 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008114
8115 b.append("Intent { ");
8116 toShortString(b, false, true, true, true);
8117 b.append(" }");
8118
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008119 return b.toString();
8120 }
8121
8122 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008123 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8124 StringBuilder b = new StringBuilder(128);
8125 toShortString(b, secure, comp, extras, clip);
8126 return b.toString();
8127 }
8128
8129 /** @hide */
8130 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8131 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008132 boolean first = true;
8133 if (mAction != null) {
8134 b.append("act=").append(mAction);
8135 first = false;
8136 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008137 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008138 if (!first) {
8139 b.append(' ');
8140 }
8141 first = false;
8142 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008143 for (int i=0; i<mCategories.size(); i++) {
8144 if (i > 0) b.append(',');
8145 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008146 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008147 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008148 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008149 if (mData != null) {
8150 if (!first) {
8151 b.append(' ');
8152 }
8153 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008154 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008155 if (secure) {
8156 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008157 } else {
8158 b.append(mData);
8159 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008160 }
8161 if (mType != null) {
8162 if (!first) {
8163 b.append(' ');
8164 }
8165 first = false;
8166 b.append("typ=").append(mType);
8167 }
8168 if (mFlags != 0) {
8169 if (!first) {
8170 b.append(' ');
8171 }
8172 first = false;
8173 b.append("flg=0x").append(Integer.toHexString(mFlags));
8174 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008175 if (mPackage != null) {
8176 if (!first) {
8177 b.append(' ');
8178 }
8179 first = false;
8180 b.append("pkg=").append(mPackage);
8181 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008182 if (comp && mComponent != null) {
8183 if (!first) {
8184 b.append(' ');
8185 }
8186 first = false;
8187 b.append("cmp=").append(mComponent.flattenToShortString());
8188 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008189 if (mSourceBounds != null) {
8190 if (!first) {
8191 b.append(' ');
8192 }
8193 first = false;
8194 b.append("bnds=").append(mSourceBounds.toShortString());
8195 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008196 if (mClipData != null) {
8197 if (!first) {
8198 b.append(' ');
8199 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008200 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008201 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008202 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008203 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008204 if (mClipData.getDescription() != null) {
8205 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8206 } else {
8207 first = true;
8208 }
8209 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008210 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008211 first = false;
8212 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008213 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008214 if (extras && mExtras != null) {
8215 if (!first) {
8216 b.append(' ');
8217 }
8218 first = false;
8219 b.append("(has extras)");
8220 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008221 if (mContentUserHint != UserHandle.USER_CURRENT) {
8222 if (!first) {
8223 b.append(' ');
8224 }
8225 first = false;
8226 b.append("u=").append(mContentUserHint);
8227 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008228 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008229 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008230 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008231 b.append("}");
8232 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008233 }
8234
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008235 /**
8236 * Call {@link #toUri} with 0 flags.
8237 * @deprecated Use {@link #toUri} instead.
8238 */
8239 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008240 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008241 return toUri(0);
8242 }
8243
8244 /**
8245 * Convert this Intent into a String holding a URI representation of it.
8246 * The returned URI string has been properly URI encoded, so it can be
8247 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8248 * Intent's data as the base URI, with an additional fragment describing
8249 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008250 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008251 * <p>You can convert the returned string back to an Intent with
8252 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008253 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008254 * @param flags Additional operating flags. Either 0,
8255 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008256 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008257 * @return Returns a URI encoding URI string describing the entire contents
8258 * of the Intent.
8259 */
8260 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008261 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008262 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8263 if (mPackage == null) {
8264 throw new IllegalArgumentException(
8265 "Intent must include an explicit package name to build an android-app: "
8266 + this);
8267 }
8268 uri.append("android-app://");
8269 uri.append(mPackage);
8270 String scheme = null;
8271 if (mData != null) {
8272 scheme = mData.getScheme();
8273 if (scheme != null) {
8274 uri.append('/');
8275 uri.append(scheme);
8276 String authority = mData.getEncodedAuthority();
8277 if (authority != null) {
8278 uri.append('/');
8279 uri.append(authority);
8280 String path = mData.getEncodedPath();
8281 if (path != null) {
8282 uri.append(path);
8283 }
8284 String queryParams = mData.getEncodedQuery();
8285 if (queryParams != null) {
8286 uri.append('?');
8287 uri.append(queryParams);
8288 }
8289 String fragment = mData.getEncodedFragment();
8290 if (fragment != null) {
8291 uri.append('#');
8292 uri.append(fragment);
8293 }
8294 }
8295 }
8296 }
8297 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8298 mPackage, flags);
8299 return uri.toString();
8300 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008301 String scheme = null;
8302 if (mData != null) {
8303 String data = mData.toString();
8304 if ((flags&URI_INTENT_SCHEME) != 0) {
8305 final int N = data.length();
8306 for (int i=0; i<N; i++) {
8307 char c = data.charAt(i);
8308 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8309 || c == '.' || c == '-') {
8310 continue;
8311 }
8312 if (c == ':' && i > 0) {
8313 // Valid scheme.
8314 scheme = data.substring(0, i);
8315 uri.append("intent:");
8316 data = data.substring(i+1);
8317 break;
8318 }
Tom Taylord4a47292009-12-21 13:59:18 -08008319
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008320 // No scheme.
8321 break;
8322 }
8323 }
8324 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008325
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008326 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8327 uri.append("intent:");
8328 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008329
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008330 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008331
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008332 return uri.toString();
8333 }
8334
8335 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8336 String defPackage, int flags) {
8337 StringBuilder frag = new StringBuilder(128);
8338
8339 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008340 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008341 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008342 // Note that for now we are not going to try to handle the
8343 // data part; not clear how to represent this as a URI, and
8344 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008345 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8346 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008347 }
8348
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008349 if (frag.length() > 0) {
8350 uri.append("#Intent;");
8351 uri.append(frag);
8352 uri.append("end");
8353 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008354 }
8355
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008356 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8357 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008358 if (scheme != null) {
8359 uri.append("scheme=").append(scheme).append(';');
8360 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008361 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008362 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008363 }
8364 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008365 for (int i=0; i<mCategories.size(); i++) {
8366 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008367 }
8368 }
8369 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008370 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008371 }
8372 if (mFlags != 0) {
8373 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8374 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008375 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008376 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8377 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008378 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008379 uri.append("component=").append(Uri.encode(
8380 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008381 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008382 if (mSourceBounds != null) {
8383 uri.append("sourceBounds=")
8384 .append(Uri.encode(mSourceBounds.flattenToString()))
8385 .append(';');
8386 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008387 if (mExtras != null) {
8388 for (String key : mExtras.keySet()) {
8389 final Object value = mExtras.get(key);
8390 char entryType =
8391 value instanceof String ? 'S' :
8392 value instanceof Boolean ? 'B' :
8393 value instanceof Byte ? 'b' :
8394 value instanceof Character ? 'c' :
8395 value instanceof Double ? 'd' :
8396 value instanceof Float ? 'f' :
8397 value instanceof Integer ? 'i' :
8398 value instanceof Long ? 'l' :
8399 value instanceof Short ? 's' :
8400 '\0';
8401
8402 if (entryType != '\0') {
8403 uri.append(entryType);
8404 uri.append('.');
8405 uri.append(Uri.encode(key));
8406 uri.append('=');
8407 uri.append(Uri.encode(value.toString()));
8408 uri.append(';');
8409 }
8410 }
8411 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008412 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008414 public int describeContents() {
8415 return (mExtras != null) ? mExtras.describeContents() : 0;
8416 }
8417
8418 public void writeToParcel(Parcel out, int flags) {
8419 out.writeString(mAction);
8420 Uri.writeToParcel(out, mData);
8421 out.writeString(mType);
8422 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008423 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008424 ComponentName.writeToParcel(mComponent, out);
8425
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008426 if (mSourceBounds != null) {
8427 out.writeInt(1);
8428 mSourceBounds.writeToParcel(out, flags);
8429 } else {
8430 out.writeInt(0);
8431 }
8432
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008433 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008434 final int N = mCategories.size();
8435 out.writeInt(N);
8436 for (int i=0; i<N; i++) {
8437 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008438 }
8439 } else {
8440 out.writeInt(0);
8441 }
8442
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008443 if (mSelector != null) {
8444 out.writeInt(1);
8445 mSelector.writeToParcel(out, flags);
8446 } else {
8447 out.writeInt(0);
8448 }
8449
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008450 if (mClipData != null) {
8451 out.writeInt(1);
8452 mClipData.writeToParcel(out, flags);
8453 } else {
8454 out.writeInt(0);
8455 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008456 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008457 out.writeBundle(mExtras);
8458 }
8459
8460 public static final Parcelable.Creator<Intent> CREATOR
8461 = new Parcelable.Creator<Intent>() {
8462 public Intent createFromParcel(Parcel in) {
8463 return new Intent(in);
8464 }
8465 public Intent[] newArray(int size) {
8466 return new Intent[size];
8467 }
8468 };
8469
Dianne Hackborneb034652009-09-07 00:49:58 -07008470 /** @hide */
8471 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008472 readFromParcel(in);
8473 }
8474
8475 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008476 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008477 mData = Uri.CREATOR.createFromParcel(in);
8478 mType = in.readString();
8479 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008480 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008481 mComponent = ComponentName.readFromParcel(in);
8482
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008483 if (in.readInt() != 0) {
8484 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8485 }
8486
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008487 int N = in.readInt();
8488 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008489 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008490 int i;
8491 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008492 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008493 }
8494 } else {
8495 mCategories = null;
8496 }
8497
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008498 if (in.readInt() != 0) {
8499 mSelector = new Intent(in);
8500 }
8501
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008502 if (in.readInt() != 0) {
8503 mClipData = new ClipData(in);
8504 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008505 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008506 mExtras = in.readBundle();
8507 }
8508
8509 /**
8510 * Parses the "intent" element (and its children) from XML and instantiates
8511 * an Intent object. The given XML parser should be located at the tag
8512 * where parsing should start (often named "intent"), from which the
8513 * basic action, data, type, and package and class name will be
8514 * retrieved. The function will then parse in to any child elements,
8515 * looking for <category android:name="xxx"> tags to add categories and
8516 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8517 * to the intent.
8518 *
8519 * @param resources The Resources to use when inflating resources.
8520 * @param parser The XML parser pointing at an "intent" tag.
8521 * @param attrs The AttributeSet interface for retrieving extended
8522 * attribute data at the current <var>parser</var> location.
8523 * @return An Intent object matching the XML data.
8524 * @throws XmlPullParserException If there was an XML parsing error.
8525 * @throws IOException If there was an I/O error.
8526 */
8527 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8528 throws XmlPullParserException, IOException {
8529 Intent intent = new Intent();
8530
8531 TypedArray sa = resources.obtainAttributes(attrs,
8532 com.android.internal.R.styleable.Intent);
8533
8534 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8535
8536 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8537 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8538 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8539
8540 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8541 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8542 if (packageName != null && className != null) {
8543 intent.setComponent(new ComponentName(packageName, className));
8544 }
8545
8546 sa.recycle();
8547
8548 int outerDepth = parser.getDepth();
8549 int type;
8550 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8551 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8552 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8553 continue;
8554 }
8555
8556 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008557 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 sa = resources.obtainAttributes(attrs,
8559 com.android.internal.R.styleable.IntentCategory);
8560 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8561 sa.recycle();
8562
8563 if (cat != null) {
8564 intent.addCategory(cat);
8565 }
8566 XmlUtils.skipCurrentTag(parser);
8567
Craig Mautner21d24a22014-04-23 11:45:37 -07008568 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008569 if (intent.mExtras == null) {
8570 intent.mExtras = new Bundle();
8571 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008572 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008573 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008574
8575 } else {
8576 XmlUtils.skipCurrentTag(parser);
8577 }
8578 }
8579
8580 return intent;
8581 }
Nick Pellyccae4122012-01-09 14:12:58 -08008582
Craig Mautner21d24a22014-04-23 11:45:37 -07008583 /** @hide */
8584 public void saveToXml(XmlSerializer out) throws IOException {
8585 if (mAction != null) {
8586 out.attribute(null, ATTR_ACTION, mAction);
8587 }
8588 if (mData != null) {
8589 out.attribute(null, ATTR_DATA, mData.toString());
8590 }
8591 if (mType != null) {
8592 out.attribute(null, ATTR_TYPE, mType);
8593 }
8594 if (mComponent != null) {
8595 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8596 }
8597 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8598
8599 if (mCategories != null) {
8600 out.startTag(null, TAG_CATEGORIES);
8601 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8602 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8603 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008604 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008605 }
8606 }
8607
8608 /** @hide */
8609 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8610 XmlPullParserException {
8611 Intent intent = new Intent();
8612 final int outerDepth = in.getDepth();
8613
8614 int attrCount = in.getAttributeCount();
8615 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8616 final String attrName = in.getAttributeName(attrNdx);
8617 final String attrValue = in.getAttributeValue(attrNdx);
8618 if (ATTR_ACTION.equals(attrName)) {
8619 intent.setAction(attrValue);
8620 } else if (ATTR_DATA.equals(attrName)) {
8621 intent.setData(Uri.parse(attrValue));
8622 } else if (ATTR_TYPE.equals(attrName)) {
8623 intent.setType(attrValue);
8624 } else if (ATTR_COMPONENT.equals(attrName)) {
8625 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8626 } else if (ATTR_FLAGS.equals(attrName)) {
8627 intent.setFlags(Integer.valueOf(attrValue, 16));
8628 } else {
8629 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8630 }
8631 }
8632
8633 int event;
8634 String name;
8635 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8636 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8637 if (event == XmlPullParser.START_TAG) {
8638 name = in.getName();
8639 if (TAG_CATEGORIES.equals(name)) {
8640 attrCount = in.getAttributeCount();
8641 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8642 intent.addCategory(in.getAttributeValue(attrNdx));
8643 }
8644 } else {
8645 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8646 XmlUtils.skipCurrentTag(in);
8647 }
8648 }
8649 }
8650
8651 return intent;
8652 }
8653
Nick Pellyccae4122012-01-09 14:12:58 -08008654 /**
8655 * Normalize a MIME data type.
8656 *
8657 * <p>A normalized MIME type has white-space trimmed,
8658 * content-type parameters removed, and is lower-case.
8659 * This aligns the type with Android best practices for
8660 * intent filtering.
8661 *
8662 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8663 * "text/x-vCard" becomes "text/x-vcard".
8664 *
8665 * <p>All MIME types received from outside Android (such as user input,
8666 * or external sources like Bluetooth, NFC, or the Internet) should
8667 * be normalized before they are used to create an Intent.
8668 *
8669 * @param type MIME data type to normalize
8670 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008671 * @see #setType
8672 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008673 */
8674 public static String normalizeMimeType(String type) {
8675 if (type == null) {
8676 return null;
8677 }
8678
Elliott Hughescb64d432013-08-02 10:00:44 -07008679 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008680
8681 final int semicolonIndex = type.indexOf(';');
8682 if (semicolonIndex != -1) {
8683 type = type.substring(0, semicolonIndex);
8684 }
8685 return type;
8686 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008687
8688 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008689 * Prepare this {@link Intent} to leave an app process.
8690 *
8691 * @hide
8692 */
8693 public void prepareToLeaveProcess() {
8694 setAllowFds(false);
8695
8696 if (mSelector != null) {
8697 mSelector.prepareToLeaveProcess();
8698 }
8699 if (mClipData != null) {
8700 mClipData.prepareToLeaveProcess();
8701 }
8702
8703 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8704 // There are several ACTION_MEDIA_* broadcasts that send file://
8705 // Uris, so only check common actions.
8706 if (ACTION_VIEW.equals(mAction) ||
8707 ACTION_EDIT.equals(mAction) ||
8708 ACTION_ATTACH_DATA.equals(mAction)) {
8709 mData.checkFileUriExposed("Intent.getData()");
8710 }
8711 }
8712 }
8713
8714 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008715 * @hide
8716 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008717 public void prepareToEnterProcess() {
8718 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008719 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8720 fixUris(mContentUserHint);
8721 mContentUserHint = UserHandle.USER_CURRENT;
8722 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008723 }
8724 }
8725
8726 /**
8727 * @hide
8728 */
8729 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008730 Uri data = getData();
8731 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008732 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008733 }
8734 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008735 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008736 }
8737 String action = getAction();
8738 if (ACTION_SEND.equals(action)) {
8739 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8740 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008741 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008742 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008743 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008744 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8745 if (streams != null) {
8746 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8747 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008748 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008749 }
8750 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8751 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008752 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8753 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8754 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8755 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8756 if (output != null) {
8757 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8758 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008759 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008760 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008761
8762 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008763 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008764 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8765 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008766 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008767 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008768 * @hide
8769 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008770 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008771 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008772 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008773
8774 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008775 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008776
8777 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008778 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008779 // Inspect contained intents to see if we need to migrate extras. We
8780 // don't promote ClipData to the parent, since ChooserActivity will
8781 // already start the picked item as the caller, and we can't combine
8782 // the flags in a safe way.
8783
8784 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008785 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008786 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8787 if (intent != null) {
8788 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008789 }
8790 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008791 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008792 try {
8793 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8794 if (intents != null) {
8795 for (int i = 0; i < intents.length; i++) {
8796 final Intent intent = (Intent) intents[i];
8797 if (intent != null) {
8798 migrated |= intent.migrateExtraStreamToClipData();
8799 }
8800 }
8801 }
8802 } catch (ClassCastException e) {
8803 }
8804 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008805
8806 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008807 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008808 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8809 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8810 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8811 if (stream != null || text != null || htmlText != null) {
8812 final ClipData clipData = new ClipData(
8813 null, new String[] { getType() },
8814 new ClipData.Item(text, htmlText, null, stream));
8815 setClipData(clipData);
8816 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008817 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008818 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008819 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008820 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008821
8822 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008823 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008824 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8825 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8826 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8827 int num = -1;
8828 if (streams != null) {
8829 num = streams.size();
8830 }
8831 if (texts != null) {
8832 if (num >= 0 && num != texts.size()) {
8833 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008834 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008835 }
8836 num = texts.size();
8837 }
8838 if (htmlTexts != null) {
8839 if (num >= 0 && num != htmlTexts.size()) {
8840 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008841 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008842 }
8843 num = htmlTexts.size();
8844 }
8845 if (num > 0) {
8846 final ClipData clipData = new ClipData(
8847 null, new String[] { getType() },
8848 makeClipItem(streams, texts, htmlTexts, 0));
8849
8850 for (int i = 1; i < num; i++) {
8851 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
8852 }
8853
8854 setClipData(clipData);
8855 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008856 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008857 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008858 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008859 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008860 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8861 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8862 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8863 final Uri output;
8864 try {
8865 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8866 } catch (ClassCastException e) {
8867 return false;
8868 }
8869 if (output != null) {
8870 setClipData(ClipData.newRawUri("", output));
8871 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
8872 return true;
8873 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008874 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008875
8876 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008877 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07008878
8879 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
8880 ArrayList<String> htmlTexts, int which) {
8881 Uri uri = streams != null ? streams.get(which) : null;
8882 CharSequence text = texts != null ? texts.get(which) : null;
8883 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
8884 return new ClipData.Item(text, htmlText, null, uri);
8885 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07008886
8887 /** @hide */
8888 public boolean isDocument() {
8889 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
8890 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008891}