blob: 1e7512d4b9879ef4428a5d4f55c1f7e90703f035 [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}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000544 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
545 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * <li> {@link #ACTION_UID_REMOVED}
547 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700548 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700549 * <li> {@link #ACTION_POWER_DISCONNECTED}
550 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700551 * </ul>
552 *
553 * <h3>Standard Categories</h3>
554 *
555 * <p>These are the current standard categories that can be used to further
556 * clarify an Intent via {@link #addCategory}.
557 *
558 * <ul>
559 * <li> {@link #CATEGORY_DEFAULT}
560 * <li> {@link #CATEGORY_BROWSABLE}
561 * <li> {@link #CATEGORY_TAB}
562 * <li> {@link #CATEGORY_ALTERNATIVE}
563 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
564 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700566 * <li> {@link #CATEGORY_HOME}
567 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700568 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400569 * <li> {@link #CATEGORY_CAR_DOCK}
570 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500571 * <li> {@link #CATEGORY_LE_DESK_DOCK}
572 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200573 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700574 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * </ul>
576 *
577 * <h3>Standard Extra Data</h3>
578 *
579 * <p>These are the current standard fields that can be used as extra data via
580 * {@link #putExtra}.
581 *
582 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800583 * <li> {@link #EXTRA_ALARM_COUNT}
584 * <li> {@link #EXTRA_BCC}
585 * <li> {@link #EXTRA_CC}
586 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
587 * <li> {@link #EXTRA_DATA_REMOVED}
588 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500589 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
590 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_DOCK_STATE_CAR}
592 * <li> {@link #EXTRA_DOCK_STATE_DESK}
593 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
594 * <li> {@link #EXTRA_DONT_KILL_APP}
595 * <li> {@link #EXTRA_EMAIL}
596 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700597 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700599 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700601 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
603 * <li> {@link #EXTRA_REPLACING}
604 * <li> {@link #EXTRA_SHORTCUT_ICON}
605 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
606 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_SHORTCUT_NAME}
609 * <li> {@link #EXTRA_SUBJECT}
610 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700611 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_TITLE}
613 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * </ul>
615 *
616 * <h3>Flags</h3>
617 *
618 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800619 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
620 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800622public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700623 private static final String ATTR_ACTION = "action";
624 private static final String TAG_CATEGORIES = "categories";
625 private static final String ATTR_CATEGORY = "category";
626 private static final String TAG_EXTRA = "extra";
627 private static final String ATTR_TYPE = "type";
628 private static final String ATTR_COMPONENT = "component";
629 private static final String ATTR_DATA = "data";
630 private static final String ATTR_FLAGS = "flags";
631
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 // ---------------------------------------------------------------------
633 // ---------------------------------------------------------------------
634 // Standard intent activity actions (see action variable).
635
636 /**
637 * Activity Action: Start as a main entry point, does not expect to
638 * receive data.
639 * <p>Input: nothing
640 * <p>Output: nothing
641 */
642 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
643 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700645 /**
646 * Activity Action: Display the data to the user. This is the most common
647 * action performed on data -- it is the generic action you can use on
648 * a piece of data to get the most reasonable thing to occur. For example,
649 * when used on a contacts entry it will view the entry; when used on a
650 * mailto: URI it will bring up a compose window filled with the information
651 * supplied by the URI; when used with a tel: URI it will invoke the
652 * dialer.
653 * <p>Input: {@link #getData} is URI from which to retrieve data.
654 * <p>Output: nothing.
655 */
656 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
657 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700659 /**
660 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
661 * performed on a piece of data.
662 */
663 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
Steve McKayc78bcb82015-07-31 14:35:22 -0700666 * Activity Action: Quick view the data.
667 * <p>Input: {@link #getData} is URI from which to retrieve data.
668 * <p>Output: nothing.
669 * @hide
670 */
671 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
672 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
673
674 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700675 * Used to indicate that some piece of data should be attached to some other
676 * place. For example, image data could be attached to a contact. It is up
677 * to the recipient to decide where the data should be attached; the intent
678 * does not specify the ultimate destination.
679 * <p>Input: {@link #getData} is URI of data to be attached.
680 * <p>Output: nothing.
681 */
682 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
683 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800684
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700685 /**
686 * Activity Action: Provide explicit editable access to the given data.
687 * <p>Input: {@link #getData} is URI of data to be edited.
688 * <p>Output: nothing.
689 */
690 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
691 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800692
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700693 /**
694 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
695 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
696 * The extras can contain type specific data to pass through to the editing/creating
697 * activity.
698 * <p>Output: The URI of the item that was picked. This must be a content:
699 * URI so that any receiver can access it.
700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800703
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 /**
705 * Activity Action: Pick an item from the data, returning what was selected.
706 * <p>Input: {@link #getData} is URI containing a directory of data
707 * (vnd.android.cursor.dir/*) from which to pick an item.
708 * <p>Output: The URI of the item that was picked.
709 */
710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
711 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800712
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700713 /**
714 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 * <p>Output: An Intent representing the shortcut. The intent must contain three
717 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
718 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800719 * (value: ShortcutIconResource).</p>
720 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700721 * @see #EXTRA_SHORTCUT_INTENT
722 * @see #EXTRA_SHORTCUT_NAME
723 * @see #EXTRA_SHORTCUT_ICON
724 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
725 * @see android.content.Intent.ShortcutIconResource
726 */
727 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
728 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
729
730 /**
731 * The name of the extra used to define the Intent of a shortcut.
732 *
733 * @see #ACTION_CREATE_SHORTCUT
734 */
735 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
736 /**
737 * The name of the extra used to define the name of a shortcut.
738 *
739 * @see #ACTION_CREATE_SHORTCUT
740 */
741 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
742 /**
743 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
744 *
745 * @see #ACTION_CREATE_SHORTCUT
746 */
747 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
748 /**
749 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
750 *
751 * @see #ACTION_CREATE_SHORTCUT
752 * @see android.content.Intent.ShortcutIconResource
753 */
754 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
755 "android.intent.extra.shortcut.ICON_RESOURCE";
756
757 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800758 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 *
760 * @see Intent#ACTION_CREATE_SHORTCUT
761 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800762 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
763 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 */
765 public static class ShortcutIconResource implements Parcelable {
766 /**
767 * The package name of the application containing the icon.
768 */
769 public String packageName;
770
771 /**
772 * The resource name of the icon, including package, name and type.
773 */
774 public String resourceName;
775
776 /**
777 * Creates a new ShortcutIconResource for the specified context and resource
778 * identifier.
779 *
780 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700781 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700783 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700785 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700786 ShortcutIconResource icon = new ShortcutIconResource();
787 icon.packageName = context.getPackageName();
788 icon.resourceName = context.getResources().getResourceName(resourceId);
789 return icon;
790 }
791
792 /**
793 * Used to read a ShortcutIconResource from a Parcel.
794 */
795 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
796 new Parcelable.Creator<ShortcutIconResource>() {
797
798 public ShortcutIconResource createFromParcel(Parcel source) {
799 ShortcutIconResource icon = new ShortcutIconResource();
800 icon.packageName = source.readString();
801 icon.resourceName = source.readString();
802 return icon;
803 }
804
805 public ShortcutIconResource[] newArray(int size) {
806 return new ShortcutIconResource[size];
807 }
808 };
809
810 /**
811 * No special parcel contents.
812 */
813 public int describeContents() {
814 return 0;
815 }
816
817 public void writeToParcel(Parcel dest, int flags) {
818 dest.writeString(packageName);
819 dest.writeString(resourceName);
820 }
821
822 @Override
823 public String toString() {
824 return resourceName;
825 }
826 }
827
828 /**
829 * Activity Action: Display an activity chooser, allowing the user to pick
830 * what they want to before proceeding. This can be used as an alternative
831 * to the standard activity picker that is displayed by the system when
832 * you try to start an activity with multiple possible matches, with these
833 * differences in behavior:
834 * <ul>
835 * <li>You can specify the title that will appear in the activity chooser.
836 * <li>The user does not have the option to make one of the matching
837 * activities a preferred activity, and all possible activities will
838 * always be shown even if one of them is currently marked as the
839 * preferred activity.
840 * </ul>
841 * <p>
842 * This action should be used when the user will naturally expect to
843 * select an activity in order to proceed. An example if when not to use
844 * it is when the user clicks on a "mailto:" link. They would naturally
845 * expect to go directly to their mail app, so startActivity() should be
846 * called directly: it will
847 * either launch the current preferred app, or put up a dialog allowing the
848 * user to pick an app to use and optionally marking that as preferred.
849 * <p>
850 * In contrast, if the user is selecting a menu item to send a picture
851 * they are viewing to someone else, there are many different things they
852 * may want to do at this point: send it through e-mail, upload it to a
853 * web service, etc. In this case the CHOOSER action should be used, to
854 * always present to the user a list of the things they can do, with a
855 * nice title given by the caller such as "Send this photo with:".
856 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700857 * If you need to grant URI permissions through a chooser, you must specify
858 * the permissions to be granted on the ACTION_CHOOSER Intent
859 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
860 * {@link #setClipData} to specify the URIs to be granted as well as
861 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
862 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
863 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700864 * As a convenience, an Intent of this form can be created with the
865 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700866 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700867 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
869 * and can optionally have a {@link #EXTRA_TITLE} field containing the
870 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700871 * <p>
872 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700873 */
874 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
875 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
876
877 /**
878 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
879 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700880 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
881 * target intent, also optionally supplying a title. If the target
882 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
883 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
884 * set in the returned chooser intent, with its ClipData set appropriately:
885 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500886 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700887 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700888 * @param target The Intent that the user will be selecting an activity
889 * to perform.
890 * @param title Optional title that will be displayed in the chooser.
891 * @return Return a new Intent object that you can hand to
892 * {@link Context#startActivity(Intent) Context.startActivity()} and
893 * related methods.
894 */
895 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700896 return createChooser(target, title, null);
897 }
898
899 /**
900 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
901 *
902 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
903 * target intent, also optionally supplying a title. If the target
904 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
905 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
906 * set in the returned chooser intent, with its ClipData set appropriately:
907 * either a direct reflection of {@link #getClipData()} if that is non-null,
908 * or a new ClipData built from {@link #getData()}.</p>
909 *
910 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
911 * when the user makes a choice. This can be useful if the calling application wants
912 * to remember the last chosen target and surface it as a more prominent or one-touch
913 * affordance elsewhere in the UI for next time.</p>
914 *
915 * @param target The Intent that the user will be selecting an activity
916 * to perform.
917 * @param title Optional title that will be displayed in the chooser.
918 * @param sender Optional IntentSender to be called when a choice is made.
919 * @return Return a new Intent object that you can hand to
920 * {@link Context#startActivity(Intent) Context.startActivity()} and
921 * related methods.
922 */
923 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924 Intent intent = new Intent(ACTION_CHOOSER);
925 intent.putExtra(EXTRA_INTENT, target);
926 if (title != null) {
927 intent.putExtra(EXTRA_TITLE, title);
928 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929
Adam Powell0b3c1122014-10-09 12:50:14 -0700930 if (sender != null) {
931 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
932 }
933
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700934 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700935 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
936 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
937 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700938 if (permFlags != 0) {
939 ClipData targetClipData = target.getClipData();
940 if (targetClipData == null && target.getData() != null) {
941 ClipData.Item item = new ClipData.Item(target.getData());
942 String[] mimeTypes;
943 if (target.getType() != null) {
944 mimeTypes = new String[] { target.getType() };
945 } else {
946 mimeTypes = new String[] { };
947 }
948 targetClipData = new ClipData(null, mimeTypes, item);
949 }
950 if (targetClipData != null) {
951 intent.setClipData(targetClipData);
952 intent.addFlags(permFlags);
953 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700954 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700955
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700956 return intent;
957 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700958
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700959 /**
960 * Activity Action: Allow the user to select a particular kind of data and
961 * return it. This is different than {@link #ACTION_PICK} in that here we
962 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800963 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700964 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900965 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700966 * etc.
967 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900968 * 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 -0700969 * of data, such as a person contact, you set the MIME type to the kind of
970 * data you want and launch it with {@link Context#startActivity(Intent)}.
971 * The system will then launch the best application to select that kind
972 * of data for you.
973 * <p>
974 * You may also be interested in any of a set of types of content the user
975 * can pick. For example, an e-mail application that wants to allow the
976 * user to add an attachment to an e-mail message can use this action to
977 * bring up a list of all of the types of content the user can attach.
978 * <p>
979 * In this case, you should wrap the GET_CONTENT intent with a chooser
980 * (through {@link #createChooser}), which will give the proper interface
981 * for the user to pick how to send your data and allow you to specify
982 * a prompt indicating what they are doing. You will usually specify a
983 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
984 * broad range of content types the user can select from.
985 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900986 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700987 * only pick from data that can be represented as a stream. This is
988 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
989 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800990 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900991 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800992 * is locally available on the device. For example, if this extra is set
993 * to true then an image picker should not show any pictures that are available
994 * from a remote server but not already on the local device (thus requiring
995 * they be downloaded when opened).
996 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800997 * If the caller can handle multiple returned items (the user performing
998 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
999 * to indicate this.
1000 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001001 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1002 * that no URI is supplied in the intent, as there are no constraints on
1003 * where the returned data originally comes from. You may also include the
1004 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001005 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001006 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1007 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001008 * <p>
1009 * Output: The URI of the item that was picked. This must be a content:
1010 * URI so that any receiver can access it.
1011 */
1012 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1013 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1014 /**
1015 * Activity Action: Dial a number as specified by the data. This shows a
1016 * UI with the number being dialed, allowing the user to explicitly
1017 * initiate the call.
1018 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1019 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1020 * number.
1021 * <p>Output: nothing.
1022 */
1023 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1024 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1025 /**
1026 * Activity Action: Perform a call to someone specified by the data.
1027 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1028 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1029 * number.
1030 * <p>Output: nothing.
1031 *
1032 * <p>Note: there will be restrictions on which applications can initiate a
1033 * call; most applications should use the {@link #ACTION_DIAL}.
1034 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1035 * numbers. Applications can <strong>dial</strong> emergency numbers using
1036 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001037 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001038 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001039 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001040 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001041 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001042 */
1043 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1044 public static final String ACTION_CALL = "android.intent.action.CALL";
1045 /**
1046 * Activity Action: Perform a call to an emergency number specified by the
1047 * data.
1048 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1049 * tel: URI of an explicit phone number.
1050 * <p>Output: nothing.
1051 * @hide
1052 */
1053 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1054 /**
1055 * Activity action: Perform a call to any number (emergency or not)
1056 * specified by the data.
1057 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1058 * tel: URI of an explicit phone number.
1059 * <p>Output: nothing.
1060 * @hide
1061 */
1062 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1063 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001064 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1065 * sending this intent is a no-op.
1066 * <p>Input: No data should be specified. get*Extra may have an optional
1067 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1068 * send the activation result.
1069 * <p>Output: nothing.
1070 * @hide
1071 */
1072 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1073 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1074 "android.intent.action.SIM_ACTIVATION_REQUEST";
1075 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001076 * Activity Action: Send a message to someone specified by the data.
1077 * <p>Input: {@link #getData} is URI describing the target.
1078 * <p>Output: nothing.
1079 */
1080 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1081 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1082 /**
1083 * Activity Action: Deliver some data to someone else. Who the data is
1084 * being delivered to is not specified; it is up to the receiver of this
1085 * action to ask the user where the data should be sent.
1086 * <p>
1087 * When launching a SEND intent, you should usually wrap it in a chooser
1088 * (through {@link #createChooser}), which will give the proper interface
1089 * for the user to pick how to send your data and allow you to specify
1090 * a prompt indicating what they are doing.
1091 * <p>
1092 * Input: {@link #getType} is the MIME type of the data being sent.
1093 * get*Extra can have either a {@link #EXTRA_TEXT}
1094 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1095 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1096 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1097 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001098 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1099 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1100 * your text with HTML formatting.
1101 * <p>
1102 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1103 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1104 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1105 * content: URIs and other advanced features of {@link ClipData}. If
1106 * using this approach, you still must supply the same data through the
1107 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1108 * for compatibility with old applications. If you don't set a ClipData,
1109 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001110 * <p>
1111 * Optional standard extras, which may be interpreted by some recipients as
1112 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1113 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1114 * <p>
1115 * Output: nothing.
1116 */
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118 public static final String ACTION_SEND = "android.intent.action.SEND";
1119 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001120 * Activity Action: Deliver multiple data to someone else.
1121 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001122 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001123 * <p>
1124 * Input: {@link #getType} is the MIME type of the data being sent.
1125 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001126 * #EXTRA_STREAM} field, containing the data to be sent. If using
1127 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1128 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001129 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001130 * Multiple types are supported, and receivers should handle mixed types
1131 * whenever possible. The right way for the receiver to check them is to
1132 * use the content resolver on each URI. The intent sender should try to
1133 * put the most concrete mime type in the intent type, but it can fall
1134 * back to {@literal <type>/*} or {@literal *}/* as needed.
1135 * <p>
1136 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1137 * be image/jpg, but if you are sending image/jpg and image/png, then the
1138 * intent's type should be image/*.
1139 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001140 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1141 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1142 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1143 * content: URIs and other advanced features of {@link ClipData}. If
1144 * using this approach, you still must supply the same data through the
1145 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1146 * for compatibility with old applications. If you don't set a ClipData,
1147 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1148 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001149 * Optional standard extras, which may be interpreted by some recipients as
1150 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1151 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1152 * <p>
1153 * Output: nothing.
1154 */
1155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1156 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1157 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001158 * Activity Action: Handle an incoming phone call.
1159 * <p>Input: nothing.
1160 * <p>Output: nothing.
1161 */
1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1164 /**
1165 * Activity Action: Insert an empty item into the given container.
1166 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1167 * in which to place the data.
1168 * <p>Output: URI of the new data that was created.
1169 */
1170 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1171 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1172 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001173 * Activity Action: Create a new item in the given container, initializing it
1174 * from the current contents of the clipboard.
1175 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1176 * in which to place the data.
1177 * <p>Output: URI of the new data that was created.
1178 */
1179 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1180 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1181 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001182 * Activity Action: Delete the given data from its container.
1183 * <p>Input: {@link #getData} is URI of data to be deleted.
1184 * <p>Output: nothing.
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1188 /**
1189 * Activity Action: Run the data, whatever that means.
1190 * <p>Input: ? (Note: this is currently specific to the test harness.)
1191 * <p>Output: nothing.
1192 */
1193 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1194 public static final String ACTION_RUN = "android.intent.action.RUN";
1195 /**
1196 * Activity Action: Perform a data synchronization.
1197 * <p>Input: ?
1198 * <p>Output: ?
1199 */
1200 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1201 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1202 /**
1203 * Activity Action: Pick an activity given an intent, returning the class
1204 * selected.
1205 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1206 * used with {@link PackageManager#queryIntentActivities} to determine the
1207 * set of activities from which to pick.
1208 * <p>Output: Class name of the activity that was selected.
1209 */
1210 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1211 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1212 /**
1213 * Activity Action: Perform a search.
1214 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1215 * is the text to search for. If empty, simply
1216 * enter your search results Activity with the search UI activated.
1217 * <p>Output: nothing.
1218 */
1219 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1220 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1221 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001222 * Activity Action: Start the platform-defined tutorial
1223 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1224 * is the text to search for. If empty, simply
1225 * enter your search results Activity with the search UI activated.
1226 * <p>Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1230 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001231 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001232 * <p>
1233 * Input: {@link android.app.SearchManager#QUERY
1234 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1235 * a url starts with http or https, the site will be opened. If it is plain
1236 * text, Google search will be applied.
1237 * <p>
1238 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001239 */
1240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1241 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001242
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001243 /**
Jim Miller07994402012-05-02 14:22:27 -07001244 * Activity Action: Perform assist action.
1245 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001246 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1247 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001248 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1249 * information.
Jim Miller07994402012-05-02 14:22:27 -07001250 * Output: nothing.
1251 */
1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1253 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001254
1255 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001256 * Activity Action: Perform voice assist action.
1257 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001258 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1259 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001260 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001261 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001262 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1266
1267 /**
Adam Skory7140a252013-09-11 12:04:58 +01001268 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1269 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001270 */
1271 public static final String EXTRA_ASSIST_PACKAGE
1272 = "android.intent.extra.ASSIST_PACKAGE";
1273
1274 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001275 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1276 * application package at the time the assist was invoked.
1277 */
1278 public static final String EXTRA_ASSIST_UID
1279 = "android.intent.extra.ASSIST_UID";
1280
1281 /**
Adam Skory7140a252013-09-11 12:04:58 +01001282 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1283 * information supplied by the current foreground app at the time of the assist request.
1284 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001285 */
1286 public static final String EXTRA_ASSIST_CONTEXT
1287 = "android.intent.extra.ASSIST_CONTEXT";
1288
Jim Miller07994402012-05-02 14:22:27 -07001289 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001290 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1291 * keyboard as the primary input device for assistance.
1292 */
1293 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1294 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1295
1296 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001297 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1298 * that was used to invoke the assist.
1299 */
1300 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1301 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1302
1303 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001304 * Activity Action: List all available applications
1305 * <p>Input: Nothing.
1306 * <p>Output: nothing.
1307 */
1308 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1309 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1310 /**
1311 * Activity Action: Show settings for choosing wallpaper
1312 * <p>Input: Nothing.
1313 * <p>Output: Nothing.
1314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1317
1318 /**
1319 * Activity Action: Show activity for reporting a bug.
1320 * <p>Input: Nothing.
1321 * <p>Output: Nothing.
1322 */
1323 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1325
1326 /**
1327 * Activity Action: Main entry point for factory tests. Only used when
1328 * the device is booting in factory test node. The implementing package
1329 * must be installed in the system image.
1330 * <p>Input: nothing
1331 * <p>Output: nothing
1332 */
1333 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1334
1335 /**
1336 * Activity Action: The user pressed the "call" button to go to the dialer
1337 * or other appropriate UI for placing a call.
1338 * <p>Input: Nothing.
1339 * <p>Output: Nothing.
1340 */
1341 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1342 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1343
1344 /**
1345 * Activity Action: Start Voice Command.
1346 * <p>Input: Nothing.
1347 * <p>Output: Nothing.
1348 */
1349 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1350 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001351
1352 /**
1353 * Activity Action: Start action associated with long pressing on the
1354 * search key.
1355 * <p>Input: Nothing.
1356 * <p>Output: Nothing.
1357 */
1358 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1359 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001360
Jacek Surazski86b6c532009-05-13 14:38:28 +02001361 /**
1362 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1363 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001364 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001365 * <p>Input: No data is specified. The bug report is passed in using
1366 * an {@link #EXTRA_BUG_REPORT} field.
1367 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001368 *
1369 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001370 */
1371 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1372 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001373
1374 /**
1375 * Activity Action: Show power usage information to the user.
1376 * <p>Input: Nothing.
1377 * <p>Output: Nothing.
1378 */
1379 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1380 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001381
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001382 /**
1383 * Activity Action: Setup wizard to launch after a platform update. This
1384 * activity should have a string meta-data field associated with it,
1385 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1386 * the platform for setup. The activity will be launched only if
1387 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1388 * same value.
1389 * <p>Input: Nothing.
1390 * <p>Output: Nothing.
1391 * @hide
1392 */
1393 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1394 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001395
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001396 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001397 * Activity Action: Show settings for managing network data usage of a
1398 * specific application. Applications should define an activity that offers
1399 * options to control data usage.
1400 */
1401 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1402 public static final String ACTION_MANAGE_NETWORK_USAGE =
1403 "android.intent.action.MANAGE_NETWORK_USAGE";
1404
1405 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001406 * Activity Action: Launch application installer.
1407 * <p>
1408 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001409 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1410 * you can also use "package:<package-name>" to install an application for the
1411 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001412 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1413 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1414 * <p>
1415 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1416 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001417 * <p>
1418 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1419 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1420 * in order to launch the application installer.
1421 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001422 *
1423 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1424 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1425 * @see #EXTRA_RETURN_RESULT
1426 */
1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1428 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1429
1430 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001431 * Activity Action: Launch ephemeral installer.
1432 * <p>
1433 * Input: The data must be a http: URI that the ephemeral application is registered
1434 * to handle.
1435 * <p class="note">
1436 * This is a protected intent that can only be sent by the system.
1437 * </p>
1438 *
1439 * @hide
1440 */
1441 @SystemApi
1442 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1443 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1444 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1445
1446 /**
1447 * Service Action: Resolve ephemeral application.
1448 * <p>
1449 * The system will have a persistent connection to this service.
1450 * This is a protected intent that can only be sent by the system.
1451 * </p>
1452 *
1453 * @hide
1454 */
1455 @SystemApi
1456 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1457 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1458 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1459
1460 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001461 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1462 * package. Specifies the installer package name; this package will receive the
1463 * {@link #ACTION_APP_ERROR} intent.
1464 */
1465 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1466 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1467
1468 /**
1469 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1470 * package. Specifies that the application being installed should not be
1471 * treated as coming from an unknown source, but as coming from the app
1472 * invoking the Intent. For this to work you must start the installer with
1473 * startActivityForResult().
1474 */
1475 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1476 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1477
1478 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001479 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1480 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001481 * data field originated from.
1482 */
rich cannings706e8ba2012-08-20 13:20:14 -07001483 public static final String EXTRA_ORIGINATING_URI
1484 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001485
1486 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001487 * This extra can be used with any Intent used to launch an activity, supplying information
1488 * about who is launching that activity. This field contains a {@link android.net.Uri}
1489 * object, typically an http: or https: URI of the web site that the referral came from;
1490 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1491 * a native application that it came from.
1492 *
1493 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1494 * instead of directly retrieving the extra. It is also valid for applications to
1495 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1496 * a string, not a Uri; the field here, if supplied, will always take precedence,
1497 * however.</p>
1498 *
1499 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001500 */
1501 public static final String EXTRA_REFERRER
1502 = "android.intent.extra.REFERRER";
1503
1504 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001505 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1506 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1507 * not be created, in particular when Intent extras are supplied through the
1508 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1509 * schemes.
1510 *
1511 * @see #EXTRA_REFERRER
1512 */
1513 public static final String EXTRA_REFERRER_NAME
1514 = "android.intent.extra.REFERRER_NAME";
1515
1516 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001517 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1518 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1519 * @hide
1520 */
1521 public static final String EXTRA_ORIGINATING_UID
1522 = "android.intent.extra.ORIGINATING_UID";
1523
1524 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001525 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1526 * package. Tells the installer UI to skip the confirmation with the user
1527 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001528 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1529 * will no longer show an interstitial message about updating existing
1530 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001532 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001533 public static final String EXTRA_ALLOW_REPLACE
1534 = "android.intent.extra.ALLOW_REPLACE";
1535
1536 /**
1537 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1538 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1539 * return to the application the result code of the install/uninstall. The returned result
1540 * code will be {@link android.app.Activity#RESULT_OK} on success or
1541 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1542 */
1543 public static final String EXTRA_RETURN_RESULT
1544 = "android.intent.extra.RETURN_RESULT";
1545
1546 /**
1547 * Package manager install result code. @hide because result codes are not
1548 * yet ready to be exposed.
1549 */
1550 public static final String EXTRA_INSTALL_RESULT
1551 = "android.intent.extra.INSTALL_RESULT";
1552
1553 /**
1554 * Activity Action: Launch application uninstaller.
1555 * <p>
1556 * Input: The data must be a package: URI whose scheme specific part is
1557 * the package name of the current installed package to be uninstalled.
1558 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1559 * <p>
1560 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1561 * succeeded.
1562 */
1563 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1564 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1565
1566 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001567 * Specify whether the package should be uninstalled for all users.
1568 * @hide because these should not be part of normal application flow.
1569 */
1570 public static final String EXTRA_UNINSTALL_ALL_USERS
1571 = "android.intent.extra.UNINSTALL_ALL_USERS";
1572
1573 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001574 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1575 * describing the last run version of the platform that was setup.
1576 * @hide
1577 */
1578 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1579
Svet Ganov3695b8a2015-03-24 16:30:25 -07001580 /**
1581 * Activity action: Launch UI to manage the permissions of an app.
1582 * <p>
1583 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1584 * will be managed by the launched UI.
1585 * </p>
1586 * <p>
1587 * Output: Nothing.
1588 * </p>
1589 *
1590 * @see #EXTRA_PACKAGE_NAME
1591 *
1592 * @hide
1593 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001594 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1595 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1596 "android.intent.action.MANAGE_APP_PERMISSIONS";
1597
1598 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001599 * Activity action: Launch UI to manage permissions.
1600 * <p>
1601 * Input: Nothing.
1602 * </p>
1603 * <p>
1604 * Output: Nothing.
1605 * </p>
1606 *
1607 * @hide
1608 */
Svet Ganov321f0152015-05-16 22:51:50 -07001609 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1610 public static final String ACTION_MANAGE_PERMISSIONS =
1611 "android.intent.action.MANAGE_PERMISSIONS";
1612
1613 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001614 * Activity action: Launch UI to review permissions for an app.
1615 * The system uses this intent if permission review for apps not
1616 * supporting the new runtime permissions model is enabled. In
1617 * this mode a permission review is required before any of the
1618 * app components can run.
1619 * <p>
1620 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1621 * permissions will be reviewed (mandatory).
1622 * </p>
1623 * <p>
1624 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1625 * be fired after the permission review (optional).
1626 * </p>
1627 * <p>
1628 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1629 * be invoked after the permission review (optional).
1630 * </p>
1631 * <p>
1632 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1633 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1634 * </p>
1635 * <p>
1636 * Output: Nothing.
1637 * </p>
1638 *
1639 * @see #EXTRA_PACKAGE_NAME
1640 * @see #EXTRA_INTENT
1641 * @see #EXTRA_REMOTE_CALLBACK
1642 * @see #EXTRA_RESULT_NEEDED
1643 *
1644 * @hide
1645 */
1646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1647 public static final String ACTION_REVIEW_PERMISSIONS =
1648 "android.intent.action.REVIEW_PERMISSIONS";
1649
1650 /**
1651 * Intent extra: A callback for reporting remote result as a bundle.
1652 * <p>
1653 * Type: IRemoteCallback
1654 * </p>
1655 *
1656 * @hide
1657 */
1658 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1659
1660 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001661 * Intent extra: An app package name.
1662 * <p>
1663 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001664 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001665 *
1666 * @hide
1667 */
1668 @SystemApi
1669 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1670
1671 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001672 * Intent extra: An extra for specifying whether a result is needed.
1673 * <p>
1674 * Type: boolean
1675 * </p>
1676 *
1677 * @hide
1678 */
1679 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1680
1681 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001682 * Broadcast action that requests current permission granted information. It will respond
1683 * to the request by sending a broadcast with action defined by
1684 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001685 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1686 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1687 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001688 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001689 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1690 * number of permissions requested and the number of granted additional permissions
1691 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001692 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001693 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1694 * of localized permission group names that are granted in
1695 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001696 *
1697 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1698 * permissions and the total number of apps requesting runtime permissions will be the first
1699 * and second elements respectively of an int[] in the response as
1700 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1701 *
1702 * @hide
1703 */
1704 public static final String ACTION_GET_PERMISSIONS_COUNT
1705 = "android.intent.action.GET_PERMISSIONS_COUNT";
1706
1707 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001708 * Broadcast action that requests list of all apps that have runtime permissions. It will
1709 * respond to the request by sending a broadcast with action defined by
1710 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1711 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1712 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1713 * a null upon failure.
1714 *
1715 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1716 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1717 * will contain the list of app labels corresponding ot the apps in the first list.
1718 *
1719 * @hide
1720 */
1721 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1722 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1723
1724 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001725 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1726 * @hide
1727 */
1728 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1729 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1730
1731 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001732 * List of CharSequence of localized permission group labels.
1733 * @hide
1734 */
1735 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1736 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1737
1738 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001739 * String list of apps that have one or more runtime permissions.
1740 * @hide
1741 */
1742 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1743 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1744
1745 /**
1746 * String list of app labels for apps that have one or more runtime permissions.
1747 * @hide
1748 */
1749 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1750 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1751
1752 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001753 * Boolean list describing if the app is a system app for apps that have one or more runtime
1754 * permissions.
1755 * @hide
1756 */
1757 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1758 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1759
1760 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001761 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001762 * @hide
1763 */
1764 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1765 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1766
1767 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001768 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1769 * @hide
1770 */
1771 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1772 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1773
1774 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001775 * Activity action: Launch UI to manage which apps have a given permission.
1776 * <p>
1777 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1778 * to which will be managed by the launched UI.
1779 * </p>
1780 * <p>
1781 * Output: Nothing.
1782 * </p>
1783 *
1784 * @see #EXTRA_PERMISSION_NAME
1785 *
1786 * @hide
1787 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001788 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1789 public static final String ACTION_MANAGE_PERMISSION_APPS =
1790 "android.intent.action.MANAGE_PERMISSION_APPS";
1791
1792 /**
1793 * Intent extra: The name of a permission.
1794 * <p>
1795 * Type: String
1796 * </p>
1797 *
1798 * @hide
1799 */
1800 @SystemApi
1801 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1802
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001803 // ---------------------------------------------------------------------
1804 // ---------------------------------------------------------------------
1805 // Standard intent broadcast actions (see action variable).
1806
1807 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001808 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1809 * <p>
1810 * For historical reasons, the name of this broadcast action refers to the power
1811 * state of the screen but it is actually sent in response to changes in the
1812 * overall interactive state of the device.
1813 * </p><p>
1814 * This broadcast is sent when the device becomes non-interactive which may have
1815 * nothing to do with the screen turning off. To determine the
1816 * actual state of the screen, use {@link android.view.Display#getState}.
1817 * </p><p>
1818 * See {@link android.os.PowerManager#isInteractive} for details.
1819 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001820 * You <em>cannot</em> receive this through components declared in
1821 * manifests, only by explicitly registering for it with
1822 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1823 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001824 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001825 * <p class="note">This is a protected intent that can only be sent
1826 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001827 */
1828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1829 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001830
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001831 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001832 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1833 * <p>
1834 * For historical reasons, the name of this broadcast action refers to the power
1835 * state of the screen but it is actually sent in response to changes in the
1836 * overall interactive state of the device.
1837 * </p><p>
1838 * This broadcast is sent when the device becomes interactive which may have
1839 * nothing to do with the screen turning on. To determine the
1840 * actual state of the screen, use {@link android.view.Display#getState}.
1841 * </p><p>
1842 * See {@link android.os.PowerManager#isInteractive} for details.
1843 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001844 * You <em>cannot</em> receive this through components declared in
1845 * manifests, only by explicitly registering for it with
1846 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1847 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001848 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001849 * <p class="note">This is a protected intent that can only be sent
1850 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001851 */
1852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1853 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001854
1855 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001856 * Broadcast Action: Sent after the system stops dreaming.
1857 *
1858 * <p class="note">This is a protected intent that can only be sent by the system.
1859 * It is only sent to registered receivers.</p>
1860 */
1861 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1862 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1863
1864 /**
1865 * Broadcast Action: Sent after the system starts dreaming.
1866 *
1867 * <p class="note">This is a protected intent that can only be sent by the system.
1868 * It is only sent to registered receivers.</p>
1869 */
1870 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1871 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1872
1873 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001874 * 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 -07001875 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001876 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001877 * <p class="note">This is a protected intent that can only be sent
1878 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001879 */
1880 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001881 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001882
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001883 /**
1884 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001885 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001886 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001887 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1888 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001889 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001890 * <p class="note">This is a protected intent that can only be sent
1891 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001892 */
1893 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1894 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1895 /**
1896 * Broadcast Action: The time was set.
1897 */
1898 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1899 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1900 /**
1901 * Broadcast Action: The date has changed.
1902 */
1903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1904 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1905 /**
1906 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1907 * <ul>
1908 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1909 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001910 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001911 * <p class="note">This is a protected intent that can only be sent
1912 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001913 */
1914 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1915 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1916 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001917 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1918 * DNS entries should be tossed.
1919 * @hide
1920 */
1921 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1922 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001924 * Alarm Changed Action: This is broadcast when the AlarmClock
1925 * application's alarm is set or unset. It is used by the
1926 * AlarmClock application and the StatusBar service.
1927 * @hide
1928 */
1929 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1930 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001931
1932 /**
1933 * Broadcast Action: This is broadcast once, after the system has finished
1934 * booting and the user is in a "locked" state. A user is locked when their
1935 * credential-encrypted private app data storage is unavailable. Once the
1936 * user has entered their credentials (such as a lock pattern or PIN) for
1937 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1938 * sent.
1939 * <p>
1940 * You must hold the
1941 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1942 * order to receive this broadcast.
1943 * <p class="note">
1944 * This is a protected intent that can only be sent by the system.
1945 */
1946 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1947 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1948
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001949 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001950 * Broadcast Action: This is broadcast once, after the system has finished
1951 * booting. It can be used to perform application-specific initialization,
1952 * such as installing alarms. You must hold the
1953 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1954 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001955 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001956 * <p class="note">This is a protected intent that can only be sent
1957 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001958 */
1959 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1960 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001961
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001962 /**
1963 * Broadcast Action: This is broadcast when a user action should request a
1964 * temporary system dialog to dismiss. Some examples of temporary system
1965 * dialogs are the notification window-shade and the recent tasks dialog.
1966 */
1967 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1968 /**
1969 * Broadcast Action: Trigger the download and eventual installation
1970 * of a package.
1971 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001972 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001973 * <p class="note">This is a protected intent that can only be sent
1974 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001975 *
1976 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001977 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001978 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001979 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1980 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1981 /**
1982 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001983 * device. The data contains the name of the package. Note that the
1984 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001985 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001986 * <ul>
1987 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
1988 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
1989 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
1990 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001991 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001992 * <p class="note">This is a protected intent that can only be sent
1993 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
1997 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001998 * Broadcast Action: A new version of an application package has been
1999 * installed, replacing an existing version that was previously installed.
2000 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002001 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002002 * <ul>
2003 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2004 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002005 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002006 * <p class="note">This is a protected intent that can only be sent
2007 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2011 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002012 * Broadcast Action: A new version of your application has been installed
2013 * over an existing one. This is only sent to the application that was
2014 * replaced. It does not contain any additional data; to receive it, just
2015 * use an intent filter for this action.
2016 *
2017 * <p class="note">This is a protected intent that can only be sent
2018 * by the system.
2019 */
2020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2021 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2022 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002023 * Broadcast Action: An existing application package has been removed from
2024 * the device. The data contains the name of the package. The package
2025 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002026 * <ul>
2027 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2028 * to the package.
2029 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2030 * application -- data and code -- is being removed.
2031 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2032 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2033 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002034 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002035 * <p class="note">This is a protected intent that can only be sent
2036 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002037 */
2038 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2039 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2040 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002041 * Broadcast Action: An existing application package has been completely
2042 * removed from the device. The data contains the name of the package.
2043 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2044 * {@link #EXTRA_DATA_REMOVED} is true and
2045 * {@link #EXTRA_REPLACING} is false of that broadcast.
2046 *
2047 * <ul>
2048 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2049 * to the package.
2050 * </ul>
2051 *
2052 * <p class="note">This is a protected intent that can only be sent
2053 * by the system.
2054 */
2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2056 public static final String ACTION_PACKAGE_FULLY_REMOVED
2057 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2058 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002059 * Broadcast Action: An existing application package has been changed (e.g.
2060 * a component has been enabled or disabled). The data contains the name of
2061 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002062 * <ul>
2063 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002064 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002065 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002066 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2067 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002068 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002069 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002070 * <p class="note">This is a protected intent that can only be sent
2071 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2074 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2075 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002076 * @hide
2077 * Broadcast Action: Ask system services if there is any reason to
2078 * restart the given package. The data contains the name of the
2079 * package.
2080 * <ul>
2081 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2082 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2083 * </ul>
2084 *
2085 * <p class="note">This is a protected intent that can only be sent
2086 * by the system.
2087 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002088 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002089 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2090 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2091 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002092 * Broadcast Action: The user has restarted a package, and all of its
2093 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002094 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002095 * be removed. Note that the restarted package does <em>not</em>
2096 * receive this broadcast.
2097 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002098 * <ul>
2099 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2100 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002101 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002102 * <p class="note">This is a protected intent that can only be sent
2103 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002104 */
2105 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2106 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2107 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002108 * Broadcast Action: The user has cleared the data of a package. This should
2109 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002110 * its persistent data is erased and this broadcast sent.
2111 * Note that the cleared package does <em>not</em>
2112 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002113 * <ul>
2114 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2115 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002116 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002117 * <p class="note">This is a protected intent that can only be sent
2118 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002119 */
2120 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2121 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2122 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002123 * Broadcast Action: Packages have been suspended.
2124 * <p>Includes the following extras:
2125 * <ul>
2126 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2127 * </ul>
2128 *
2129 * <p class="note">This is a protected intent that can only be sent
2130 * by the system. It is only sent to registered receivers.
2131 */
2132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2133 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2134 /**
2135 * Broadcast Action: Packages have been unsuspended.
2136 * <p>Includes the following extras:
2137 * <ul>
2138 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2139 * </ul>
2140 *
2141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system. It is only sent to registered receivers.
2143 */
2144 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2145 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2146 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002147 * Broadcast Action: A user ID has been removed from the system. The user
2148 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002155
2156 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002157 * Broadcast Action: Sent to the installer package of an application
2158 * when that application is first launched (that is the first time it
2159 * is moved out of the stopped state). The data contains the name of the package.
2160 *
2161 * <p class="note">This is a protected intent that can only be sent
2162 * by the system.
2163 */
2164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2165 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2166
2167 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002168 * Broadcast Action: Sent to the system package verifier when a package
2169 * needs to be verified. The data contains the package URI.
2170 * <p class="note">
2171 * This is a protected intent that can only be sent by the system.
2172 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002173 */
2174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2175 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2176
2177 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002178 * Broadcast Action: Sent to the system package verifier when a package is
2179 * verified. The data contains the package URI.
2180 * <p class="note">
2181 * This is a protected intent that can only be sent by the system.
2182 */
2183 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2184 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2185
2186 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002187 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2188 * needs to be verified. The data contains the filter data hosts to be verified against.
2189 * <p class="note">
2190 * This is a protected intent that can only be sent by the system.
2191 * </p>
2192 *
2193 * @hide
2194 */
2195 @SystemApi
2196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2197 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2198
2199 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002200 * Broadcast Action: Resources for a set of packages (which were
2201 * previously unavailable) are currently
2202 * available since the media on which they exist is available.
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 * Note that the
2208 * packages in this list do <em>not</em> receive this broadcast.
2209 * The specified set of packages are now available on the system.
2210 * <p>Includes the following extras:
2211 * <ul>
2212 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2213 * whose resources(were previously unavailable) are currently available.
2214 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2215 * packages whose resources(were previously unavailable)
2216 * are currently available.
2217 * </ul>
2218 *
2219 * <p class="note">This is a protected intent that can only be sent
2220 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002221 */
2222 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002223 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2224 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002225
2226 /**
2227 * Broadcast Action: Resources for a set of packages are currently
2228 * unavailable since the media on which they exist is unavailable.
2229 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2230 * list of packages whose availability changed.
2231 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2232 * list of uids of packages whose availability changed.
2233 * The specified set of packages can no longer be
2234 * launched and are practically unavailable on the system.
2235 * <p>Inclues the following extras:
2236 * <ul>
2237 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2238 * whose resources are no longer available.
2239 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2240 * whose resources are no longer available.
2241 * </ul>
2242 *
2243 * <p class="note">This is a protected intent that can only be sent
2244 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002245 */
2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002247 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002248 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002249
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002250 /**
2251 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002252 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002253 * This should <em>only</em> be used to determine when the wallpaper
2254 * has changed to show the new wallpaper to the user. You should certainly
2255 * never, in response to this, change the wallpaper or other attributes of
2256 * it such as the suggested size. That would be crazy, right? You'd cause
2257 * all kinds of loops, especially if other apps are doing similar things,
2258 * right? Of course. So please don't do this.
2259 *
2260 * @deprecated Modern applications should use
2261 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2262 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2263 * shown behind their UI, rather than watching for this broadcast and
2264 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002265 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002266 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002267 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2268 /**
2269 * Broadcast Action: The current device {@link android.content.res.Configuration}
2270 * (orientation, locale, etc) has changed. When such a change happens, the
2271 * UIs (view hierarchy) will need to be rebuilt based on this new
2272 * information; for the most part, applications don't need to worry about
2273 * this, because the system will take care of stopping and restarting the
2274 * application to make sure it sees the new changes. Some system code that
2275 * can not be restarted will need to watch for this action and handle it
2276 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002277 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002278 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002279 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002280 * in manifests, only by explicitly registering for it with
2281 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2282 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002283 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002286 *
2287 * @see android.content.res.Configuration
2288 */
2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2290 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2291 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002292 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002293 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002294 * <p class="note">This is a protected intent that can only be sent
2295 * by the system.
2296 */
2297 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2298 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2299 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002300 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2301 * charging state, level, and other information about the battery.
2302 * See {@link android.os.BatteryManager} for documentation on the
2303 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002304 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002305 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002306 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002307 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002308 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002309 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2310 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2311 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2312 * broadcasts that are sent and can be received through manifest
2313 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002314 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002315 * <p class="note">This is a protected intent that can only be sent
2316 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002317 */
2318 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2319 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2320 /**
2321 * Broadcast Action: Indicates low battery condition on the device.
2322 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002323 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002324 * <p class="note">This is a protected intent that can only be sent
2325 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002326 */
2327 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2328 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2329 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002330 * Broadcast Action: Indicates the battery is now okay after being low.
2331 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2332 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002333 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002334 * <p class="note">This is a protected intent that can only be sent
2335 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002336 */
2337 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2338 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2339 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002340 * Broadcast Action: External power has been connected to the device.
2341 * This is intended for applications that wish to register specifically to this notification.
2342 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2343 * stay active to receive this notification. This action can be used to implement actions
2344 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002345 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002346 * <p class="note">This is a protected intent that can only be sent
2347 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002348 */
2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002350 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002351 /**
2352 * Broadcast Action: External power has been removed from the device.
2353 * This is intended for applications that wish to register specifically to this notification.
2354 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2355 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002356 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002357 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002358 * <p class="note">This is a protected intent that can only be sent
2359 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002360 */
2361 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002362 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002363 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002364 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002365 * Broadcast Action: Device is shutting down.
2366 * This is broadcast when the device is being shut down (completely turned
2367 * off, not sleeping). Once the broadcast is complete, the final shutdown
2368 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002369 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002370 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002371 * <p class="note">This is a protected intent that can only be sent
2372 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002373 * <p>May include the following extras:
2374 * <ul>
2375 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2376 * shutdown is only for userspace processes. If not set, assumed to be false.
2377 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002380 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002381 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002382 * Activity Action: Start this activity to request system shutdown.
2383 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002384 * to request confirmation from the user before shutting down. The optional boolean
2385 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2386 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002387 *
2388 * <p class="note">This is a protected intent that can only be sent
2389 * by the system.
2390 *
2391 * {@hide}
2392 */
2393 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2394 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002395 * Broadcast Action: A sticky broadcast that indicates low memory
2396 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002397 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002398 * <p class="note">This is a protected intent that can only be sent
2399 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2402 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2403 /**
2404 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002405 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002406 * <p class="note">This is a protected intent that can only be sent
2407 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002408 */
2409 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2410 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2411 /**
Jake Hambybb371632010-08-23 18:16:48 -07002412 * Broadcast Action: A sticky broadcast that indicates a memory full
2413 * condition on the device. This is intended for activities that want
2414 * to be able to fill the data partition completely, leaving only
2415 * enough free space to prevent system-wide SQLite failures.
2416 *
2417 * <p class="note">This is a protected intent that can only be sent
2418 * by the system.
2419 *
2420 * {@hide}
2421 */
2422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2423 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2424 /**
2425 * Broadcast Action: Indicates memory full condition on the device
2426 * no longer exists.
2427 *
2428 * <p class="note">This is a protected intent that can only be sent
2429 * by the system.
2430 *
2431 * {@hide}
2432 */
2433 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2434 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2435 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2437 * and package management should be started.
2438 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2439 * notification.
2440 */
2441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2442 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2443 /**
2444 * Broadcast Action: The device has entered USB Mass Storage mode.
2445 * This is used mainly for the USB Settings panel.
2446 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2447 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002448 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002449 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002450 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002451 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2452
2453 /**
2454 * Broadcast Action: The device has exited USB Mass Storage mode.
2455 * This is used mainly for the USB Settings panel.
2456 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2457 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002458 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002459 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002460 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002461 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2462
2463 /**
2464 * Broadcast Action: External media has been removed.
2465 * The path to the mount point for the removed media is contained in the Intent.mData field.
2466 */
2467 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2468 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2469
2470 /**
2471 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002472 * 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 -07002473 */
2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2475 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2476
2477 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002478 * Broadcast Action: External media is present, and being disk-checked
2479 * 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 -08002480 */
2481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2482 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2483
2484 /**
2485 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2486 * 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 -08002487 */
2488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2489 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2490
2491 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002492 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002493 * 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 -07002494 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2495 * media was mounted read only.
2496 */
2497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2498 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2499
2500 /**
2501 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002502 * 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 -07002503 */
2504 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2505 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2506
2507 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002508 * Broadcast Action: External media is no longer being shared via USB mass storage.
2509 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2510 *
2511 * @hide
2512 */
2513 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2514
2515 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002516 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2517 * The path to the mount point for the removed media is contained in the Intent.mData field.
2518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2520 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2521
2522 /**
2523 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002524 * 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 -07002525 */
2526 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2527 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2528
2529 /**
2530 * Broadcast Action: User has expressed the desire to remove the external storage media.
2531 * Applications should close all files they have open within the mount point when they receive this intent.
2532 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2536
2537 /**
2538 * Broadcast Action: The media scanner has started scanning a directory.
2539 * The path to the directory being scanned is contained in the Intent.mData field.
2540 */
2541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2542 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2543
2544 /**
2545 * Broadcast Action: The media scanner has finished scanning a directory.
2546 * The path to the scanned directory is contained in the Intent.mData field.
2547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2549 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2550
2551 /**
2552 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2553 * The path to the file is contained in the Intent.mData field.
2554 */
2555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2556 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2557
2558 /**
2559 * Broadcast Action: The "Media Button" was pressed. Includes a single
2560 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2561 * caused the broadcast.
2562 */
2563 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2564 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2565
Jaewan Kim52632e22016-01-14 18:01:52 +09002566 /**
2567 * Broadcast Action: The "Picture-in-picture (PIP) Button" was pressed.
2568 * Includes a single extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2569 * caused the broadcast.
2570 * @hide
2571 */
2572 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2573 public static final String ACTION_PICTURE_IN_PICTURE_BUTTON =
2574 "android.intent.action.PICTURE_IN_PICTURE_BUTTON";
2575
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002576 /**
2577 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2578 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2579 * caused the broadcast.
2580 */
2581 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2582 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2583
2584 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2585 // location; they are not general-purpose actions.
2586
2587 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002588 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 */
2590 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2591 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2592 "android.intent.action.GTALK_CONNECTED";
2593
2594 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002595 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002596 */
2597 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2598 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2599 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002600
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002601 /**
2602 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002603 */
2604 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2605 public static final String ACTION_INPUT_METHOD_CHANGED =
2606 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002607
2608 /**
2609 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2610 * more radios have been turned off or on. The intent will have the following extra value:</p>
2611 * <ul>
2612 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2613 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2614 * turned off</li>
2615 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002616 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002617 * <p class="note">This is a protected intent that can only be sent
2618 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2622
2623 /**
2624 * Broadcast Action: Some content providers have parts of their namespace
2625 * where they publish new events or items that the user may be especially
2626 * interested in. For these things, they may broadcast this action when the
2627 * set of interesting items change.
2628 *
2629 * For example, GmailProvider sends this notification when the set of unread
2630 * mail in the inbox changes.
2631 *
2632 * <p>The data of the intent identifies which part of which provider
2633 * changed. When queried through the content resolver, the data URI will
2634 * return the data set in question.
2635 *
2636 * <p>The intent will have the following extra values:
2637 * <ul>
2638 * <li><em>count</em> - The number of items in the data set. This is the
2639 * same as the number of items in the cursor returned by querying the
2640 * data URI. </li>
2641 * </ul>
2642 *
2643 * This intent will be sent at boot (if the count is non-zero) and when the
2644 * data set changes. It is possible for the data set to change without the
2645 * count changing (for example, if a new unread message arrives in the same
2646 * sync operation in which a message is archived). The phone should still
2647 * ring/vibrate/etc as normal in this case.
2648 */
2649 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2650 public static final String ACTION_PROVIDER_CHANGED =
2651 "android.intent.action.PROVIDER_CHANGED";
2652
2653 /**
2654 * Broadcast Action: Wired Headset plugged in or unplugged.
2655 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002656 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2657 * and documentation.
2658 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002659 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002660 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002663 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002664
2665 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002666 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2667 * <ul>
2668 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2669 * </ul>
2670 *
2671 * <p class="note">This is a protected intent that can only be sent
2672 * by the system.
2673 *
2674 * @hide
2675 */
2676 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2677 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2678 = "android.intent.action.ADVANCED_SETTINGS";
2679
2680 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002681 * Broadcast Action: Sent after application restrictions are changed.
2682 *
2683 * <p class="note">This is a protected intent that can only be sent
2684 * by the system.</p>
2685 */
2686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2687 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2688 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2689
2690 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002691 * Broadcast Action: An outgoing call is about to be placed.
2692 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002693 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002694 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002695 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002696 * the phone number originally intended to be dialed.</li>
2697 * </ul>
2698 * <p>Once the broadcast is finished, the resultData is used as the actual
2699 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002700 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002701 * outgoing call in turn: for example, a parental control application
2702 * might verify that the user is authorized to place the call at that
2703 * time, then a number-rewriting application might add an area code if
2704 * one was not specified.</p>
2705 * <p>For consistency, any receiver whose purpose is to prohibit phone
2706 * calls should have a priority of 0, to ensure it will see the final
2707 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002708 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002709 * should have a positive priority.
2710 * Negative priorities are reserved for the system for this broadcast;
2711 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002712 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2713 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002714 * <p>Emergency calls cannot be intercepted using this mechanism, and
2715 * other calls cannot be modified to call emergency numbers using this
2716 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002717 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2718 * call to use their own service instead. Those apps should first prevent
2719 * the call from being placed by setting resultData to <code>null</code>
2720 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002721 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2723 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002724 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002725 * <p class="note">This is a protected intent that can only be sent
2726 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727 */
2728 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2729 public static final String ACTION_NEW_OUTGOING_CALL =
2730 "android.intent.action.NEW_OUTGOING_CALL";
2731
2732 /**
2733 * Broadcast Action: Have the device reboot. This is only for use by
2734 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002735 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002736 * <p class="note">This is a protected intent that can only be sent
2737 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002738 */
2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740 public static final String ACTION_REBOOT =
2741 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002742
Wei Huang97ecc9c2009-05-11 17:44:20 -07002743 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002744 * Broadcast Action: A sticky broadcast for changes in the physical
2745 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002746 *
2747 * <p>The intent will have the following extra values:
2748 * <ul>
2749 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002750 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002751 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002752 * <p>This is intended for monitoring the current physical dock state.
2753 * See {@link android.app.UiModeManager} for the normal API dealing with
2754 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002755 */
2756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2757 public static final String ACTION_DOCK_EVENT =
2758 "android.intent.action.DOCK_EVENT";
2759
2760 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002761 * Broadcast Action: A broadcast when idle maintenance can be started.
2762 * This means that the user is not interacting with the device and is
2763 * not expected to do so soon. Typical use of the idle maintenance is
2764 * to perform somehow expensive tasks that can be postponed at a moment
2765 * when they will not degrade user experience.
2766 * <p>
2767 * <p class="note">In order to keep the device responsive in case of an
2768 * unexpected user interaction, implementations of a maintenance task
2769 * should be interruptible. In such a scenario a broadcast with action
2770 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2771 * should not do the maintenance work in
2772 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2773 * maintenance service by {@link Context#startService(Intent)}. Also
2774 * you should hold a wake lock while your maintenance service is running
2775 * to prevent the device going to sleep.
2776 * </p>
2777 * <p>
2778 * <p class="note">This is a protected intent that can only be sent by
2779 * the system.
2780 * </p>
2781 *
2782 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002783 *
2784 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002785 */
2786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2787 public static final String ACTION_IDLE_MAINTENANCE_START =
2788 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2789
2790 /**
2791 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2792 * This means that the user was not interacting with the device as a result
2793 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2794 * was sent and now the user started interacting with the device. Typical
2795 * use of the idle maintenance is to perform somehow expensive tasks that
2796 * can be postponed at a moment when they will not degrade user experience.
2797 * <p>
2798 * <p class="note">In order to keep the device responsive in case of an
2799 * unexpected user interaction, implementations of a maintenance task
2800 * should be interruptible. Hence, on receiving a broadcast with this
2801 * action, the maintenance task should be interrupted as soon as possible.
2802 * In other words, you should not do the maintenance work in
2803 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2804 * maintenance service that was started on receiving of
2805 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2806 * lock you acquired when your maintenance service started.
2807 * </p>
2808 * <p class="note">This is a protected intent that can only be sent
2809 * by the system.
2810 *
2811 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002812 *
2813 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_IDLE_MAINTENANCE_END =
2817 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2818
2819 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002820 * Broadcast Action: a remote intent is to be broadcasted.
2821 *
2822 * A remote intent is used for remote RPC between devices. The remote intent
2823 * is serialized and sent from one device to another device. The receiving
2824 * device parses the remote intent and broadcasts it. Note that anyone can
2825 * broadcast a remote intent. However, if the intent receiver of the remote intent
2826 * does not trust intent broadcasts from arbitrary intent senders, it should require
2827 * the sender to hold certain permissions so only trusted sender's broadcast will be
2828 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002829 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002830 */
2831 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002832 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002833
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002834 /**
2835 * Broadcast Action: hook for permforming cleanup after a system update.
2836 *
2837 * The broadcast is sent when the system is booting, before the
2838 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2839 * image. A receiver for this should do its work and then disable itself
2840 * so that it does not get run again at the next boot.
2841 * @hide
2842 */
2843 public static final String ACTION_PRE_BOOT_COMPLETED =
2844 "android.intent.action.PRE_BOOT_COMPLETED";
2845
Amith Yamasani13593602012-03-22 16:16:17 -07002846 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002847 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002848 * on restricted users. The broadcast intent contains an extra
2849 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2850 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2851 * String[] depending on the restriction type.<p/>
2852 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002853 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2854 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2855 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002856 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2857 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002858 * @see RestrictionEntry
2859 */
2860 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2861 "android.intent.action.GET_RESTRICTION_ENTRIES";
2862
2863 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002864 * Sent the first time a user is starting, to allow system apps to
2865 * perform one time initialization. (This will not be seen by third
2866 * party applications because a newly initialized user does not have any
2867 * third party applications installed for it.) This is sent early in
2868 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002869 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2870 * broadcast, since it is part of a visible user interaction; be as quick
2871 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002872 */
2873 public static final String ACTION_USER_INITIALIZE =
2874 "android.intent.action.USER_INITIALIZE";
2875
2876 /**
2877 * Sent when a user switch is happening, causing the process's user to be
2878 * brought to the foreground. This is only sent to receivers registered
2879 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2880 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002881 * foreground. This is sent as a foreground
2882 * broadcast, since it is part of a visible user interaction; be as quick
2883 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002884 */
2885 public static final String ACTION_USER_FOREGROUND =
2886 "android.intent.action.USER_FOREGROUND";
2887
2888 /**
2889 * Sent when a user switch is happening, causing the process's user to be
2890 * sent to the background. This is only sent to receivers registered
2891 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2892 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002893 * background. This is sent as a foreground
2894 * broadcast, since it is part of a visible user interaction; be as quick
2895 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002896 */
2897 public static final String ACTION_USER_BACKGROUND =
2898 "android.intent.action.USER_BACKGROUND";
2899
2900 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002901 * Broadcast sent to the system when a user is added. Carries an extra
2902 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2903 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002904 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002905 * @hide
2906 */
2907 public static final String ACTION_USER_ADDED =
2908 "android.intent.action.USER_ADDED";
2909
2910 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002911 * Broadcast sent by the system when a user is started. Carries an extra
2912 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002913 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002914 * that has been started. This is sent as a foreground
2915 * broadcast, since it is part of a visible user interaction; be as quick
2916 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002917 * @hide
2918 */
2919 public static final String ACTION_USER_STARTED =
2920 "android.intent.action.USER_STARTED";
2921
2922 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002923 * Broadcast sent when a user is in the process of starting. Carries an extra
2924 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2925 * sent to registered receivers, not manifest receivers. It is sent to all
2926 * users (including the one that is being started). You must hold
2927 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2928 * this broadcast. This is sent as a background broadcast, since
2929 * its result is not part of the primary UX flow; to safely keep track of
2930 * started/stopped state of a user you can use this in conjunction with
2931 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2932 * other user state broadcasts since those are foreground broadcasts so can
2933 * execute in a different order.
2934 * @hide
2935 */
2936 public static final String ACTION_USER_STARTING =
2937 "android.intent.action.USER_STARTING";
2938
2939 /**
2940 * Broadcast sent when a user is going to be stopped. Carries an extra
2941 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2942 * sent to registered receivers, not manifest receivers. It is sent to all
2943 * users (including the one that is being stopped). You must hold
2944 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2945 * this broadcast. The user will not stop until all receivers have
2946 * handled the broadcast. This is sent as a background broadcast, since
2947 * its result is not part of the primary UX flow; to safely keep track of
2948 * started/stopped state of a user you can use this in conjunction with
2949 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2950 * other user state broadcasts since those are foreground broadcasts so can
2951 * execute in a different order.
2952 * @hide
2953 */
2954 public static final String ACTION_USER_STOPPING =
2955 "android.intent.action.USER_STOPPING";
2956
2957 /**
2958 * Broadcast sent to the system when a user is stopped. Carries an extra
2959 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2960 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2961 * specific package. This is only sent to registered receivers, not manifest
2962 * receivers. It is sent to all running users <em>except</em> the one that
2963 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002964 * @hide
2965 */
2966 public static final String ACTION_USER_STOPPED =
2967 "android.intent.action.USER_STOPPED";
2968
2969 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002970 * 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 -07002971 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002972 * one that has been removed. The user will not be completely removed until all receivers have
2973 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002974 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002975 * @hide
2976 */
2977 public static final String ACTION_USER_REMOVED =
2978 "android.intent.action.USER_REMOVED";
2979
2980 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002981 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002982 * the userHandle of the user to become the current one. This is only sent to
2983 * registered receivers, not manifest receivers. It is sent to all running users.
2984 * You must hold
2985 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002986 * @hide
2987 */
2988 public static final String ACTION_USER_SWITCHED =
2989 "android.intent.action.USER_SWITCHED";
2990
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002991 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002992 * Broadcast Action: Sent when the credential-encrypted private storage has
2993 * become unlocked for the target user. This is only sent to registered
2994 * receivers, not manifest receivers.
2995 */
2996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2997 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
2998
2999 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003000 * Broadcast sent to the system when a user's information changes. Carries an extra
3001 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003002 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003003 * @hide
3004 */
3005 public static final String ACTION_USER_INFO_CHANGED =
3006 "android.intent.action.USER_INFO_CHANGED";
3007
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003008 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003009 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3010 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003011 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3012 * that need to display merged content across both primary and managed profiles need to
3013 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003014 * not manifest receivers.
3015 */
3016 public static final String ACTION_MANAGED_PROFILE_ADDED =
3017 "android.intent.action.MANAGED_PROFILE_ADDED";
3018
3019 /**
3020 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003021 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3022 * Only applications (for example Launchers) that need to display merged content across both
3023 * primary and managed profiles need to worry about this broadcast. This is only sent to
3024 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003025 */
3026 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3027 "android.intent.action.MANAGED_PROFILE_REMOVED";
3028
3029 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003030 * Broadcast sent to the primary user when an associated managed profile's availability has
3031 * changed. This includes when the user toggles the profile's quiet mode, or when the profile
3032 * owner suspends the profile. Carries an extra {@link #EXTRA_USER} that specifies the
3033 * UserHandle of the profile. When quiet mode is changed, this broadcast will carry a boolean
3034 * extra {@link #EXTRA_QUIET_MODE} indicating the new state of quiet mode. This is only sent to
3035 * registered receivers, not manifest receivers.
3036 */
3037 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3038 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3039
3040 /**
3041 * Broadcast sent to the managed profile when its availability has changed. This includes when
3042 * the user toggles the profile's quiet mode, or when the profile owner suspends the profile.
3043 * When quiet mode is changed, this broadcast will carry a boolean extra
3044 * {@link #EXTRA_QUIET_MODE} indicating the new state of quiet mode. This is only sent to
3045 * registered receivers, not manifest receivers. See also
3046 * {@link #ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED}
3047 */
3048 public static final String ACTION_AVAILABILITY_CHANGED =
3049 "android.intent.action.AVAILABILITY_CHANGED";
3050
3051 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003052 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3053 */
3054 public static final String ACTION_QUICK_CLOCK =
3055 "android.intent.action.QUICK_CLOCK";
3056
Michael Wright0087a142013-02-05 16:29:39 -08003057 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003058 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003059 * @hide
3060 */
3061 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3062 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3063
Justin Kohd378ad72013-04-01 12:18:26 -07003064 /**
3065 * Broadcast Action: A global button was pressed. Includes a single
3066 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3067 * caused the broadcast.
3068 * @hide
3069 */
3070 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3071
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003072 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003073 * Broadcast Action: Sent when media resource is granted.
3074 * <p>
3075 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3076 * granted.
3077 * </p>
3078 * <p class="note">
3079 * This is a protected intent that can only be sent by the system.
3080 * </p>
3081 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003082 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003083 * </p>
3084 *
3085 * @hide
3086 */
3087 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3088 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3089
3090 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003091 * Activity Action: Allow the user to select and return one or more existing
3092 * documents. When invoked, the system will display the various
3093 * {@link DocumentsProvider} instances installed on the device, letting the
3094 * user interactively navigate through them. These documents include local
3095 * media, such as photos and video, and documents provided by installed
3096 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003097 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003098 * Each document is represented as a {@code content://} URI backed by a
3099 * {@link DocumentsProvider}, which can be opened as a stream with
3100 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3101 * {@link android.provider.DocumentsContract.Document} metadata.
3102 * <p>
3103 * All selected documents are returned to the calling application with
3104 * persistable read and write permission grants. If you want to maintain
3105 * access to the documents across device reboots, you need to explicitly
3106 * take the persistable permissions using
3107 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3108 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003109 * Callers must indicate the acceptable document MIME types through
3110 * {@link #setType(String)}. For example, to select photos, use
3111 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3112 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3113 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003114 * <p>
3115 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003116 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3117 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003118 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003119 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3120 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003121 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003122 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003123 * Output: The URI of the item that was picked, returned in
3124 * {@link #getData()}. This must be a {@code content://} URI so that any
3125 * receiver can access it. If multiple documents were selected, they are
3126 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003127 *
3128 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003129 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003130 * @see #ACTION_CREATE_DOCUMENT
3131 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003132 */
3133 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3134 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3135
3136 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003137 * Activity Action: Allow the user to create a new document. When invoked,
3138 * the system will display the various {@link DocumentsProvider} instances
3139 * installed on the device, letting the user navigate through them. The
3140 * returned document may be a newly created document with no content, or it
3141 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003142 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003143 * Each document is represented as a {@code content://} URI backed by a
3144 * {@link DocumentsProvider}, which can be opened as a stream with
3145 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3146 * {@link android.provider.DocumentsContract.Document} metadata.
3147 * <p>
3148 * Callers must indicate the concrete MIME type of the document being
3149 * created by setting {@link #setType(String)}. This MIME type cannot be
3150 * changed after the document is created.
3151 * <p>
3152 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3153 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003154 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003155 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3156 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003157 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003158 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003159 * Output: The URI of the item that was created. This must be a
3160 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003161 *
3162 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003163 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003164 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003165 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003166 */
3167 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3168 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3169
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003170 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003171 * Activity Action: Allow the user to pick a directory subtree. When
3172 * invoked, the system will display the various {@link DocumentsProvider}
3173 * instances installed on the device, letting the user navigate through
3174 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003175 * <p>
3176 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003177 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3178 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3179 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003180 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003181 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003182 *
3183 * @see DocumentsContract
3184 */
3185 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003186 public static final String
3187 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003188
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003189 /** {@hide} */
3190 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3191
Christopher Tate6597e342015-02-17 12:15:25 -08003192 /**
3193 * Broadcast action: report that a settings element is being restored from backup. The intent
3194 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3195 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3196 * is the value of that settings entry prior to the restore operation. All of these values are
3197 * represented as strings.
3198 *
3199 * <p>This broadcast is sent only for settings provider entries known to require special handling
3200 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3201 * the provider's backup agent implementation.
3202 *
3203 * @see #EXTRA_SETTING_NAME
3204 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3205 * @see #EXTRA_SETTING_NEW_VALUE
3206 * {@hide}
3207 */
3208 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3209
3210 /** {@hide} */
3211 public static final String EXTRA_SETTING_NAME = "setting_name";
3212 /** {@hide} */
3213 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3214 /** {@hide} */
3215 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3216
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003217 /**
3218 * Activity Action: Process a piece of text.
3219 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3220 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3221 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3222 */
3223 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3224 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3225 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003226 * The name of the extra used to define the text to be processed, as a
3227 * CharSequence. Note that this may be a styled CharSequence, so you must use
3228 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003229 */
3230 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3231 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003232 * 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 +00003233 */
3234 public static final String EXTRA_PROCESS_TEXT_READONLY =
3235 "android.intent.extra.PROCESS_TEXT_READONLY";
3236
Bryce Leebc58f592015-09-25 16:43:01 -07003237 /**
3238 * Broadcast action: reports when a new thermal event has been reached. When the device
3239 * is reaching its maximum temperatue, the thermal level reported
3240 * {@hide}
3241 */
3242 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3243 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3244
3245 /** {@hide} */
3246 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3247
3248 /**
3249 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003250 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003251 * {@hide}
3252 */
3253 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3254
3255 /**
3256 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003257 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003258 * {@hide}
3259 */
3260 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3261
3262 /**
3263 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003264 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003265 * {@hide}
3266 */
3267 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3268
3269
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003270 // ---------------------------------------------------------------------
3271 // ---------------------------------------------------------------------
3272 // Standard intent categories (see addCategory()).
3273
3274 /**
3275 * Set if the activity should be an option for the default action
3276 * (center press) to perform on a piece of data. Setting this will
3277 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003278 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003279 * Intent when initiating an action -- it is for use in intent filters
3280 * specified in packages.
3281 */
3282 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3283 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3284 /**
3285 * Activities that can be safely invoked from a browser must support this
3286 * category. For example, if the user is viewing a web page or an e-mail
3287 * and clicks on a link in the text, the Intent generated execute that
3288 * link will require the BROWSABLE category, so that only activities
3289 * supporting this category will be considered as possible actions. By
3290 * supporting this category, you are promising that there is nothing
3291 * damaging (without user intervention) that can happen by invoking any
3292 * matching Intent.
3293 */
3294 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3295 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3296 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003297 * Categories for activities that can participate in voice interaction.
3298 * An activity that supports this category must be prepared to run with
3299 * no UI shown at all (though in some case it may have a UI shown), and
3300 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3301 */
3302 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3303 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003305 * Set if the activity should be considered as an alternative action to
3306 * the data the user is currently viewing. See also
3307 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3308 * applies to the selection in a list of items.
3309 *
3310 * <p>Supporting this category means that you would like your activity to be
3311 * displayed in the set of alternative things the user can do, usually as
3312 * part of the current activity's options menu. You will usually want to
3313 * include a specific label in the &lt;intent-filter&gt; of this action
3314 * describing to the user what it does.
3315 *
3316 * <p>The action of IntentFilter with this category is important in that it
3317 * describes the specific action the target will perform. This generally
3318 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3319 * a specific name such as "com.android.camera.action.CROP. Only one
3320 * alternative of any particular action will be shown to the user, so using
3321 * a specific action like this makes sure that your alternative will be
3322 * displayed while also allowing other applications to provide their own
3323 * overrides of that particular action.
3324 */
3325 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3326 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3327 /**
3328 * Set if the activity should be considered as an alternative selection
3329 * action to the data the user has currently selected. This is like
3330 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3331 * of items from which the user can select, giving them alternatives to the
3332 * default action that will be performed on it.
3333 */
3334 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3335 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3336 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003337 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003338 */
3339 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3340 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3341 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003342 * Should be displayed in the top-level launcher.
3343 */
3344 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3345 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3346 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003347 * Indicates an activity optimized for Leanback mode, and that should
3348 * be displayed in the Leanback launcher.
3349 */
3350 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3351 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3352 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003353 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3354 * @hide
3355 */
3356 @SystemApi
3357 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3358 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003359 * Provides information about the package it is in; typically used if
3360 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3361 * a front-door to the user without having to be shown in the all apps list.
3362 */
3363 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3364 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3365 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003366 * This is the home activity, that is the first activity that is displayed
3367 * when the device boots.
3368 */
3369 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3370 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3371 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003372 * This is the home activity that is displayed when the device is finished setting up and ready
3373 * for use.
3374 * @hide
3375 */
3376 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3377 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3378 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003379 * This is the setup wizard activity, that is the first activity that is displayed
3380 * when the user sets up the device for the first time.
3381 * @hide
3382 */
3383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3384 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3385 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003386 * This activity is a preference panel.
3387 */
3388 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3389 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3390 /**
3391 * This activity is a development preference panel.
3392 */
3393 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3394 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3395 /**
3396 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003397 */
3398 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3399 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3400 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003401 * This activity allows the user to browse and download new applications.
3402 */
3403 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3404 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3405 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003406 * This activity may be exercised by the monkey or other automated test tools.
3407 */
3408 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3409 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3410 /**
3411 * To be used as a test (not part of the normal user experience).
3412 */
3413 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3414 /**
3415 * To be used as a unit test (run through the Test Harness).
3416 */
3417 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3418 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003419 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003420 * experience).
3421 */
3422 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003423
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003424 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003425 * Used to indicate that an intent only wants URIs that can be opened with
3426 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3427 * must support at least the columns defined in {@link OpenableColumns} when
3428 * queried.
3429 *
3430 * @see #ACTION_GET_CONTENT
3431 * @see #ACTION_OPEN_DOCUMENT
3432 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003433 */
3434 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3435 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3436
3437 /**
3438 * To be used as code under test for framework instrumentation tests.
3439 */
3440 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3441 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003442 /**
3443 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003444 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3445 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003446 */
3447 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3448 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3449 /**
3450 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003451 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3452 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003453 */
3454 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3455 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003456 /**
3457 * An activity to run when device is inserted into a analog (low end) dock.
3458 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3459 * information, see {@link android.app.UiModeManager}.
3460 */
3461 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3462 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3463
3464 /**
3465 * An activity to run when device is inserted into a digital (high end) dock.
3466 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3467 * information, see {@link android.app.UiModeManager}.
3468 */
3469 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3470 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003471
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003472 /**
3473 * Used to indicate that the activity can be used in a car environment.
3474 */
3475 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3476 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3477
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003478 // ---------------------------------------------------------------------
3479 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003480 // Application launch intent categories (see addCategory()).
3481
3482 /**
3483 * Used with {@link #ACTION_MAIN} to launch the browser application.
3484 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003485 * <p>NOTE: This should not be used as the primary key of an Intent,
3486 * since it will not result in the app launching with the correct
3487 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003488 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003489 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003490 */
3491 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3492 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3493
3494 /**
3495 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3496 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003497 * <p>NOTE: This should not be used as the primary key of an Intent,
3498 * since it will not result in the app launching with the correct
3499 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003500 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003501 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003502 */
3503 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3504 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3505
3506 /**
3507 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3508 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003509 * <p>NOTE: This should not be used as the primary key of an Intent,
3510 * since it will not result in the app launching with the correct
3511 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003512 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003513 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003514 */
3515 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3516 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3517
3518 /**
3519 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3520 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003521 * <p>NOTE: This should not be used as the primary key of an Intent,
3522 * since it will not result in the app launching with the correct
3523 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003524 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003525 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003526 */
3527 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3528 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3529
3530 /**
3531 * Used with {@link #ACTION_MAIN} to launch the email application.
3532 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003533 * <p>NOTE: This should not be used as the primary key of an Intent,
3534 * since it will not result in the app launching with the correct
3535 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003536 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003537 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003538 */
3539 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3540 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3541
3542 /**
3543 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3544 * The activity should be able to view and manipulate image and video files
3545 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003546 * <p>NOTE: This should not be used as the primary key of an Intent,
3547 * since it will not result in the app launching with the correct
3548 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003549 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003550 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003551 */
3552 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3553 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3554
3555 /**
3556 * Used with {@link #ACTION_MAIN} to launch the maps application.
3557 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003558 * <p>NOTE: This should not be used as the primary key of an Intent,
3559 * since it will not result in the app launching with the correct
3560 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003561 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003562 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003563 */
3564 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3565 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3566
3567 /**
3568 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3569 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003570 * <p>NOTE: This should not be used as the primary key of an Intent,
3571 * since it will not result in the app launching with the correct
3572 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003573 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003574 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003575 */
3576 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3577 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3578
3579 /**
3580 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003581 * The activity should be able to play, browse, or manipulate music files
3582 * stored on the device.
3583 * <p>NOTE: This should not be used as the primary key of an Intent,
3584 * since it will not result in the app launching with the correct
3585 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003586 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003587 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003588 */
3589 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3590 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3591
3592 // ---------------------------------------------------------------------
3593 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003594 // Standard extra data keys.
3595
3596 /**
3597 * The initial data to place in a newly created record. Use with
3598 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3599 * fields as would be given to the underlying ContentProvider.insert()
3600 * call.
3601 */
3602 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3603
3604 /**
3605 * A constant CharSequence that is associated with the Intent, used with
3606 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3607 * this may be a styled CharSequence, so you must use
3608 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3609 * retrieve it.
3610 */
3611 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3612
3613 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003614 * A constant String that is associated with the Intent, used with
3615 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3616 * as HTML formatted text. Note that you <em>must</em> also supply
3617 * {@link #EXTRA_TEXT}.
3618 */
3619 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3620
3621 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003622 * A content: URI holding a stream of data associated with the Intent,
3623 * used with {@link #ACTION_SEND} to supply the data being sent.
3624 */
3625 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3626
3627 /**
3628 * A String[] holding e-mail addresses that should be delivered to.
3629 */
3630 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3631
3632 /**
3633 * A String[] holding e-mail addresses that should be carbon copied.
3634 */
3635 public static final String EXTRA_CC = "android.intent.extra.CC";
3636
3637 /**
3638 * A String[] holding e-mail addresses that should be blind carbon copied.
3639 */
3640 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3641
3642 /**
3643 * A constant string holding the desired subject line of a message.
3644 */
3645 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3646
3647 /**
3648 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003649 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003650 */
3651 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3652
3653 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003654 * An int representing the user id to be used.
3655 *
3656 * @hide
3657 */
3658 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3659
3660 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003661 * An int representing the task id to be retrieved. This is used when a launch from recents is
3662 * intercepted by another action such as credentials confirmation to remember which task should
3663 * be resumed when complete.
3664 *
3665 * @hide
3666 */
3667 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3668
3669 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003670 * An Intent[] describing additional, alternate choices you would like shown with
3671 * {@link #ACTION_CHOOSER}.
3672 *
3673 * <p>An app may be capable of providing several different payload types to complete a
3674 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3675 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3676 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3677 * photo data or a hosted link where the photos can be viewed.</p>
3678 *
3679 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3680 * first/primary/preferred intent in the set. Additional intents specified in
3681 * this extra are ordered; by default intents that appear earlier in the array will be
3682 * preferred over intents that appear later in the array as matches for the same
3683 * target component. To alter this preference, a calling app may also supply
3684 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3685 */
3686 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3687
3688 /**
3689 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3690 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3691 *
3692 * <p>An app preparing an action for another app to complete may wish to allow the user to
3693 * disambiguate between several options for completing the action based on the chosen target
3694 * or otherwise refine the action before it is invoked.
3695 * </p>
3696 *
3697 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3698 * <ul>
3699 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3700 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3701 * chosen target beyond the first</li>
3702 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3703 * should fill in and send once the disambiguation is complete</li>
3704 * </ul>
3705 */
3706 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3707 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3708
3709 /**
3710 * A {@link ResultReceiver} used to return data back to the sender.
3711 *
3712 * <p>Used to complete an app-specific
3713 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3714 *
3715 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3716 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3717 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3718 * when the user selects a target component from the chooser. It is up to the recipient
3719 * to send a result to this ResultReceiver to signal that disambiguation is complete
3720 * and that the chooser should invoke the user's choice.</p>
3721 *
3722 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3723 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3724 * to match and fill in the final Intent or ChooserTarget before starting it.
3725 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3726 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3727 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3728 *
3729 * <p>The result code passed to the ResultReceiver should be
3730 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3731 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3732 * the chooser should finish without starting a target.</p>
3733 */
3734 public static final String EXTRA_RESULT_RECEIVER
3735 = "android.intent.extra.RESULT_RECEIVER";
3736
3737 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003738 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003739 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003740 */
3741 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3742
3743 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003744 * A Parcelable[] of {@link Intent} or
3745 * {@link android.content.pm.LabeledIntent} objects as set with
3746 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3747 * a the front of the list of choices, when shown to the user with a
3748 * {@link #ACTION_CHOOSER}.
3749 */
3750 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3751
3752 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003753 * A {@link IntentSender} to start after ephemeral installation success.
3754 * @hide
3755 */
3756 @SystemApi
3757 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3758
3759 /**
3760 * A {@link IntentSender} to start after ephemeral installation failure.
3761 * @hide
3762 */
3763 @SystemApi
3764 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3765
3766 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003767 * A Bundle forming a mapping of potential target package names to different extras Bundles
3768 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3769 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3770 * be currently installed on the device.
3771 *
3772 * <p>An application may choose to provide alternate extras for the case where a user
3773 * selects an activity from a predetermined set of target packages. If the activity
3774 * the user selects from the chooser belongs to a package with its package name as
3775 * a key in this bundle, the corresponding extras for that package will be merged with
3776 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3777 * extra has the same key as an extra already present in the intent it will overwrite
3778 * the extra from the intent.</p>
3779 *
3780 * <p><em>Examples:</em>
3781 * <ul>
3782 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3783 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3784 * parameters for that target.</li>
3785 * <li>An application may offer additional metadata for known targets of a given intent
3786 * to pass along information only relevant to that target such as account or content
3787 * identifiers already known to that application.</li>
3788 * </ul></p>
3789 */
3790 public static final String EXTRA_REPLACEMENT_EXTRAS =
3791 "android.intent.extra.REPLACEMENT_EXTRAS";
3792
3793 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003794 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3795 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3796 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3797 * {@link ComponentName} of the chosen component.
3798 *
3799 * <p>In some situations this callback may never come, for example if the user abandons
3800 * the chooser, switches to another task or any number of other reasons. Apps should not
3801 * be written assuming that this callback will always occur.</p>
3802 */
3803 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3804 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3805
3806 /**
3807 * The {@link ComponentName} chosen by the user to complete an action.
3808 *
3809 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3810 */
3811 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3812
3813 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003814 * A {@link android.view.KeyEvent} object containing the event that
3815 * triggered the creation of the Intent it is in.
3816 */
3817 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3818
3819 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003820 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3821 * before shutting down.
3822 *
3823 * {@hide}
3824 */
3825 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3826
3827 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003828 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3829 * requested by the user.
3830 *
3831 * {@hide}
3832 */
3833 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3834 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3835
3836 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003837 * 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 -07003838 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3839 * of restarting the application.
3840 */
3841 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3842
3843 /**
3844 * A String holding the phone number originally entered in
3845 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3846 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3847 */
3848 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003849
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003850 /**
3851 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3852 * intents to supply the uid the package had been assigned. Also an optional
3853 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3854 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3855 * purpose.
3856 */
3857 public static final String EXTRA_UID = "android.intent.extra.UID";
3858
3859 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003860 * @hide String array of package names.
3861 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003862 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003863 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3864
3865 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003866 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3867 * intents to indicate whether this represents a full uninstall (removing
3868 * both the code and its data) or a partial uninstall (leaving its data,
3869 * implying that this is an update).
3870 */
3871 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003872
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003873 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003874 * @hide
3875 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3876 * intents to indicate that at this point the package has been removed for
3877 * all users on the device.
3878 */
3879 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3880 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3881
3882 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003883 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3884 * intents to indicate that this is a replacement of the package, so this
3885 * broadcast will immediately be followed by an add broadcast for a
3886 * different version of the same package.
3887 */
3888 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003889
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003890 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003891 * Used as an int extra field in {@link android.app.AlarmManager} intents
3892 * to tell the application being invoked how many pending alarms are being
3893 * delievered with the intent. For one-shot alarms this will always be 1.
3894 * For recurring alarms, this might be greater than 1 if the device was
3895 * asleep or powered off at the time an earlier alarm would have been
3896 * delivered.
3897 */
3898 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003899
Jacek Surazski86b6c532009-05-13 14:38:28 +02003900 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003901 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3902 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003903 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3904 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003905 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3906 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3907 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003908 */
3909 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3910
3911 /**
3912 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3913 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003914 */
3915 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3916
3917 /**
3918 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3919 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003920 */
3921 public static final int EXTRA_DOCK_STATE_DESK = 1;
3922
3923 /**
3924 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3925 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003926 */
3927 public static final int EXTRA_DOCK_STATE_CAR = 2;
3928
3929 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003930 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3931 * to represent that the phone is in a analog (low end) dock.
3932 */
3933 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3934
3935 /**
3936 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3937 * to represent that the phone is in a digital (high end) dock.
3938 */
3939 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3940
3941 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003942 * Boolean that can be supplied as meta-data with a dock activity, to
3943 * indicate that the dock should take over the home key when it is active.
3944 */
3945 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003946
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003947 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003948 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3949 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003950 */
3951 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3952
3953 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003954 * Used in the extra field in the remote intent. It's astring token passed with the
3955 * remote intent.
3956 */
3957 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3958 "android.intent.extra.remote_intent_token";
3959
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003960 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003961 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003962 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003963 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003964 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003965 "android.intent.extra.changed_component_name";
3966
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003967 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003968 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003969 * and contains a string array of all of the components that have changed. If
3970 * the state of the overall package has changed, then it will contain an entry
3971 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003972 */
3973 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3974 "android.intent.extra.changed_component_name_list";
3975
3976 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003977 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003978 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00003979 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
3980 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
3981 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003982 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003983 */
3984 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3985 "android.intent.extra.changed_package_list";
3986
3987 /**
3988 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003989 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
3990 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003991 * and contains an integer array of uids of all of the components
3992 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003993 */
3994 public static final String EXTRA_CHANGED_UID_LIST =
3995 "android.intent.extra.changed_uid_list";
3996
3997 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003998 * @hide
3999 * Magic extra system code can use when binding, to give a label for
4000 * who it is that has bound to a service. This is an integer giving
4001 * a framework string resource that can be displayed to the user.
4002 */
4003 public static final String EXTRA_CLIENT_LABEL =
4004 "android.intent.extra.client_label";
4005
4006 /**
4007 * @hide
4008 * Magic extra system code can use when binding, to give a PendingIntent object
4009 * that can be launched for the user to disable the system's use of this
4010 * service.
4011 */
4012 public static final String EXTRA_CLIENT_INTENT =
4013 "android.intent.extra.client_intent";
4014
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004015 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004016 * Extra used to indicate that an intent should only return data that is on
4017 * the local device. This is a boolean extra; the default is false. If true,
4018 * an implementation should only allow the user to select data that is
4019 * already on the device, not requiring it be downloaded from a remote
4020 * service when opened.
4021 *
4022 * @see #ACTION_GET_CONTENT
4023 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004024 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004025 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004026 */
4027 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004028 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004029
Amith Yamasani13593602012-03-22 16:16:17 -07004030 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004031 * Extra used to indicate that an intent can allow the user to select and
4032 * return multiple items. This is a boolean extra; the default is false. If
4033 * true, an implementation is allowed to present the user with a UI where
4034 * they can pick multiple items that are all returned to the caller. When
4035 * this happens, they should be returned as the {@link #getClipData()} part
4036 * of the result Intent.
4037 *
4038 * @see #ACTION_GET_CONTENT
4039 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004040 */
4041 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004042 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004043
4044 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004045 * The integer userHandle carried with broadcast intents related to addition, removal and
4046 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4047 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4048 *
Amith Yamasani13593602012-03-22 16:16:17 -07004049 * @hide
4050 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004051 public static final String EXTRA_USER_HANDLE =
4052 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004053
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004054 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004055 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4056 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4057 */
4058 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004059 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004060
4061 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004062 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004063 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4064 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004065 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004066 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4067
4068 /**
4069 * Extra sent in the intent to the BroadcastReceiver that handles
4070 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4071 * the restrictions as key/value pairs.
4072 */
4073 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4074 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004075
Amith Yamasani86118ba2013-03-28 14:33:16 -07004076 /**
4077 * Extra used in the response from a BroadcastReceiver that handles
4078 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4079 */
4080 public static final String EXTRA_RESTRICTIONS_INTENT =
4081 "android.intent.extra.restrictions_intent";
4082
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004083 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004084 * Extra used to communicate a set of acceptable MIME types. The type of the
4085 * extra is {@code String[]}. Values may be a combination of concrete MIME
4086 * types (such as "image/png") and/or partial MIME types (such as
4087 * "audio/*").
4088 *
4089 * @see #ACTION_GET_CONTENT
4090 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004091 */
4092 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4093
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004094 /**
4095 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4096 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004097 * When this is true, hardware devices can use this information to determine that
4098 * they shouldn't do a complete shutdown of their device since this is not a
4099 * complete shutdown down to the kernel, but only user space restarting.
4100 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004101 */
4102 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4103 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4104
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004105 /**
4106 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4107 * user has set their time format preferences to the 24 hour format.
4108 *
4109 * @hide for internal use only.
4110 */
4111 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4112 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4113
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004114 /** {@hide} */
4115 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4116
Rubin Xue8490f12015-06-25 12:17:48 +01004117 /** {@hide} */
4118 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4119
Santos Cordon15a13782015-03-31 18:32:31 -07004120 /**
4121 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4122 * activation request.
4123 * TODO: Add information about the structure and response data used with the pending intent.
4124 * @hide
4125 */
4126 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4127 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4128
Steve McKay6eaf38632015-08-04 10:11:01 -07004129 /** {@hide} */
4130 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4131
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004132 /**
4133 * Optional boolean extra indicating whether quiet mode has been switched on or off.
4134 */
4135 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004136
4137 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004138 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004139 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004140 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4141 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004142 *
4143 * @hide
4144 */
4145 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4146 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4147
4148 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004149 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004150 * to represent that a video codec is allowed to use.
4151 *
4152 * @hide
4153 */
4154 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4155
4156 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004157 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004158 * to represent that a audio codec is allowed to use.
4159 *
4160 * @hide
4161 */
4162 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4163
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004164 // ---------------------------------------------------------------------
4165 // ---------------------------------------------------------------------
4166 // Intent flags (see mFlags variable).
4167
Tor Norbyed9273d62013-05-30 15:59:53 -07004168 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004169 @IntDef(flag = true, value = {
4170 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4171 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004172 @Retention(RetentionPolicy.SOURCE)
4173 public @interface GrantUriMode {}
4174
Jeff Sharkey846318a2014-04-04 12:12:41 -07004175 /** @hide */
4176 @IntDef(flag = true, value = {
4177 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4178 @Retention(RetentionPolicy.SOURCE)
4179 public @interface AccessUriMode {}
4180
4181 /**
4182 * Test if given mode flags specify an access mode, which must be at least
4183 * read and/or write.
4184 *
4185 * @hide
4186 */
4187 public static boolean isAccessUriMode(int modeFlags) {
4188 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4189 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4190 }
4191
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004192 /**
4193 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004194 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004195 * specified in its ClipData. When applying to an Intent's ClipData,
4196 * all URIs as well as recursive traversals through data or other ClipData
4197 * in Intent items will be granted; only the grant flags of the top-level
4198 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004199 */
4200 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4201 /**
4202 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004203 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004204 * specified in its ClipData. When applying to an Intent's ClipData,
4205 * all URIs as well as recursive traversals through data or other ClipData
4206 * in Intent items will be granted; only the grant flags of the top-level
4207 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004208 */
4209 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4210 /**
4211 * Can be set by the caller to indicate that this Intent is coming from
4212 * a background operation, not from direct user interaction.
4213 */
4214 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4215 /**
4216 * A flag you can enable for debugging: when set, log messages will be
4217 * printed during the resolution of this intent to show you what has
4218 * been found to create the final resolved list.
4219 */
4220 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004221 /**
4222 * If set, this intent will not match any components in packages that
4223 * are currently stopped. If this is not set, then the default behavior
4224 * is to include such applications in the result.
4225 */
4226 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4227 /**
4228 * If set, this intent will always match any components in packages that
4229 * are currently stopped. This is the default behavior when
4230 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4231 * flags are set, this one wins (it allows overriding of exclude for
4232 * places where the framework may automatically set the exclude flag).
4233 */
4234 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004235
4236 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004237 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004238 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004239 * persisted across device reboots until explicitly revoked with
4240 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4241 * grant for possible persisting; the receiving application must call
4242 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4243 * actually persist.
4244 *
4245 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4246 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4247 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004248 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004249 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004250 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004251
4252 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004253 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4254 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4255 * applies to any URI that is a prefix match against the original granted
4256 * URI. (Without this flag, the URI must match exactly for access to be
4257 * granted.) Another URI is considered a prefix match only when scheme,
4258 * authority, and all path segments defined by the prefix are an exact
4259 * match.
4260 */
4261 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4262
4263 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004264 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004265 * homework and verified that they correctly handle packages and components
4266 * that come and go over time. In particular:
4267 * <ul>
4268 * <li>Apps installed on external storage, which will appear to be
4269 * uninstalled while the the device is ejected.
4270 * <li>Apps with encryption unaware components, which will appear to not
4271 * exist while the device is locked.
4272 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004273 *
4274 * @hide
4275 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004276 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004277
4278 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004279 * If set, the new activity is not kept in the history stack. As soon as
4280 * the user navigates away from it, the activity is finished. This may also
4281 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4282 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004283 *
4284 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4285 * is never invoked when the current activity starts a new activity which
4286 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004287 */
4288 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4289 /**
4290 * If set, the activity will not be launched if it is already running
4291 * at the top of the history stack.
4292 */
4293 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4294 /**
4295 * If set, this activity will become the start of a new task on this
4296 * history stack. A task (from the activity that started it to the
4297 * next task activity) defines an atomic group of activities that the
4298 * user can move to. Tasks can be moved to the foreground and background;
4299 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004300 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004301 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4302 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004303 *
4304 * <p>This flag is generally used by activities that want
4305 * to present a "launcher" style behavior: they give the user a list of
4306 * separate things that can be done, which otherwise run completely
4307 * independently of the activity launching them.
4308 *
4309 * <p>When using this flag, if a task is already running for the activity
4310 * you are now starting, then a new activity will not be started; instead,
4311 * the current task will simply be brought to the front of the screen with
4312 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4313 * to disable this behavior.
4314 *
4315 * <p>This flag can not be used when the caller is requesting a result from
4316 * the activity being launched.
4317 */
4318 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4319 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004320 * This flag is used to create a new task and launch an activity into it.
4321 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4322 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4323 * search through existing tasks for ones matching this Intent. Only if no such
4324 * task is found would a new task be created. When paired with
4325 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4326 * the search for a matching task and unconditionally start a new task.
4327 *
4328 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4329 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004330 * top-level application launcher.</strong> Used in conjunction with
4331 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4332 * behavior of bringing an existing task to the foreground. When set,
4333 * a new task is <em>always</em> started to host the Activity for the
4334 * Intent, regardless of whether there is already an existing task running
4335 * the same thing.
4336 *
4337 * <p><strong>Because the default system does not include graphical task management,
4338 * you should not use this flag unless you provide some way for a user to
4339 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004340 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004341 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4342 * creating new document tasks.
4343 *
4344 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004345 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004346 *
Scott Main7aee61f2011-02-08 11:25:01 -08004347 * <p>See
4348 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4349 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004350 *
4351 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4352 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004353 */
4354 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4355 /**
4356 * If set, and the activity being launched is already running in the
4357 * current task, then instead of launching a new instance of that activity,
4358 * all of the other activities on top of it will be closed and this Intent
4359 * will be delivered to the (now on top) old activity as a new Intent.
4360 *
4361 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4362 * If D calls startActivity() with an Intent that resolves to the component
4363 * of activity B, then C and D will be finished and B receive the given
4364 * Intent, resulting in the stack now being: A, B.
4365 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004366 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004367 * either receive the new intent you are starting here in its
4368 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004369 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004370 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4371 * the same intent, then it will be finished and re-created; for all other
4372 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4373 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004374 *
4375 * <p>This launch mode can also be used to good effect in conjunction with
4376 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4377 * of a task, it will bring any currently running instance of that task
4378 * to the foreground, and then clear it to its root state. This is
4379 * especially useful, for example, when launching an activity from the
4380 * notification manager.
4381 *
Scott Main7aee61f2011-02-08 11:25:01 -08004382 * <p>See
4383 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4384 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004385 */
4386 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4387 /**
4388 * If set and this intent is being used to launch a new activity from an
4389 * existing one, then the reply target of the existing activity will be
4390 * transfered to the new activity. This way the new activity can call
4391 * {@link android.app.Activity#setResult} and have that result sent back to
4392 * the reply target of the original activity.
4393 */
4394 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4395 /**
4396 * If set and this intent is being used to launch a new activity from an
4397 * existing one, the current activity will not be counted as the top
4398 * activity for deciding whether the new intent should be delivered to
4399 * the top instead of starting a new one. The previous activity will
4400 * be used as the top, with the assumption being that the current activity
4401 * will finish itself immediately.
4402 */
4403 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4404 /**
4405 * If set, the new activity is not kept in the list of recently launched
4406 * activities.
4407 */
4408 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4409 /**
4410 * This flag is not normally set by application code, but set for you by
4411 * the system as described in the
4412 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4413 * launchMode} documentation for the singleTask mode.
4414 */
4415 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4416 /**
4417 * If set, and this activity is either being started in a new task or
4418 * bringing to the top an existing task, then it will be launched as
4419 * the front door of the task. This will result in the application of
4420 * any affinities needed to have that task in the proper state (either
4421 * moving activities to or from it), or simply resetting that task to
4422 * its initial state if needed.
4423 */
4424 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4425 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004426 * This flag is not normally set by application code, but set for you by
4427 * the system if this activity is being launched from history
4428 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004429 */
4430 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004431 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004432 * @deprecated As of API 21 this performs identically to
4433 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004434 */
4435 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004436 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004437 * This flag is used to open a document into a new task rooted at the activity launched
4438 * by this Intent. Through the use of this flag, or its equivalent attribute,
4439 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004440 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004441 *
Craig Mautner026596b2014-05-21 15:35:44 -07004442 * <p>The use of the activity attribute form of this,
4443 * {@link android.R.attr#documentLaunchMode}, is
4444 * preferred over the Intent flag described here. The attribute form allows the
4445 * Activity to specify multiple document behavior for all launchers of the Activity
4446 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004447 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004448 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4449 * it is kept after the activity is finished is different than the use of
4450 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4451 * this flag is being used to create a new recents entry, then by default that entry
4452 * will be removed once the activity is finished. You can modify this behavior with
4453 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4454 *
Craig Mautner026596b2014-05-21 15:35:44 -07004455 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4456 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4457 * equivalent of the Activity manifest specifying {@link
4458 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4459 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4460 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004461 *
Craig Mautner026596b2014-05-21 15:35:44 -07004462 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004463 *
Craig Mautner026596b2014-05-21 15:35:44 -07004464 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004465 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4466 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004467 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004468 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004469 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004470 * callback from occurring on the current frontmost activity before it is
4471 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004472 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004473 * <p>Typically, an activity can rely on that callback to indicate that an
4474 * explicit user action has caused their activity to be moved out of the
4475 * foreground. The callback marks an appropriate point in the activity's
4476 * lifecycle for it to dismiss any notifications that it intends to display
4477 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004478 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004479 * <p>If an activity is ever started via any non-user-driven events such as
4480 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4481 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004482 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004483 */
4484 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004485 /**
4486 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4487 * this flag will cause the launched activity to be brought to the front of its
4488 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004489 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004490 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4491 * If D calls startActivity() with an Intent that resolves to the component
4492 * of activity B, then B will be brought to the front of the history stack,
4493 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004494 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004495 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004496 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004497 */
4498 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004499 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004500 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4501 * this flag will prevent the system from applying an activity transition
4502 * animation to go to the next activity state. This doesn't mean an
4503 * animation will never run -- if another activity change happens that doesn't
4504 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004505 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004506 * when you are going to do a series of activity operations but the
4507 * animation seen by the user shouldn't be driven by the first activity
4508 * change but rather a later one.
4509 */
4510 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4511 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004512 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4513 * this flag will cause any existing task that would be associated with the
4514 * activity to be cleared before the activity is started. That is, the activity
4515 * becomes the new root of an otherwise empty task, and any old activities
4516 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4517 */
4518 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4519 /**
4520 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4521 * this flag will cause a newly launching task to be placed on top of the current
4522 * home activity task (if there is one). That is, pressing back from the task
4523 * will always return the user to home even if that was not the last activity they
4524 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4525 */
4526 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4527 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004528 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4529 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004530 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004531 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004532 * this flag. When set and the task's activity is finished, the recents
4533 * entry will remain in the interface for the user to re-launch it, like a
4534 * recents entry for a top-level application.
4535 * <p>
4536 * The receiving activity can override this request with
4537 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4538 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004539 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004540 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004541 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004542
4543 /**
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004544 * This flag is only used in the multi-window mode. The new activity will be displayed on
4545 * the other side than the one that is launching it. This can only be used in conjunction with
4546 * {@link #FLAG_ACTIVITY_NEW_TASK}.
4547 */
4548 public static final int FLAG_ACTIVITY_LAUNCH_TO_SIDE = 0x00001000;
4549
4550 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004551 * If set, when sending a broadcast only registered receivers will be
4552 * called -- no BroadcastReceiver components will be launched.
4553 */
4554 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004555 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004556 * If set, when sending a broadcast the new broadcast will replace
4557 * any existing pending broadcast that matches it. Matching is defined
4558 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4559 * true for the intents of the two broadcasts. When a match is found,
4560 * the new broadcast (and receivers associated with it) will replace the
4561 * existing one in the pending broadcast list, remaining at the same
4562 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004563 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004564 * <p>This flag is most typically used with sticky broadcasts, which
4565 * only care about delivering the most recent values of the broadcast
4566 * to their receivers.
4567 */
4568 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4569 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004570 * If set, when sending a broadcast the recipient is allowed to run at
4571 * foreground priority, with a shorter timeout interval. During normal
4572 * broadcasts the receivers are not automatically hoisted out of the
4573 * background priority class.
4574 */
4575 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4576 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004577 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4578 * They can still propagate results through to later receivers, but they can not prevent
4579 * later receivers from seeing the broadcast.
4580 */
4581 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4582 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004583 * If set, when sending a broadcast <i>before boot has completed</i> only
4584 * registered receivers will be called -- no BroadcastReceiver components
4585 * will be launched. Sticky intent state will be recorded properly even
4586 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4587 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004588 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004589 * <p>This flag is only for use by system sevices as a convenience to
4590 * avoid having to implement a more complex mechanism around detection
4591 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004592 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004593 * @hide
4594 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004595 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004596 /**
4597 * Set when this broadcast is for a boot upgrade, a special mode that
4598 * allows the broadcast to be sent before the system is ready and launches
4599 * the app process with no providers running in it.
4600 * @hide
4601 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004602 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004603 /**
4604 * If set, the broadcast will always go to manifest receivers in background (cached
4605 * or not running) apps, regardless of whether that would be done by default. By
4606 * default they will only receive broadcasts if the broadcast has specified an
4607 * explicit component or package name.
4608 * @hide
4609 */
4610 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4611 /**
4612 * If set, the broadcast will never go to manifest receivers in background (cached
4613 * or not running) apps, regardless of whether that would be done by default. By
4614 * default they will receive broadcasts if the broadcast has specified an
4615 * explicit component or package name.
4616 * @hide
4617 */
4618 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004619
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004620 /**
4621 * @hide Flags that can't be changed with PendingIntent.
4622 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004623 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4624 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4625 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004627 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004628 // ---------------------------------------------------------------------
4629 // toUri() and parseUri() options.
4630
4631 /**
4632 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4633 * always has the "intent:" scheme. This syntax can be used when you want
4634 * to later disambiguate between URIs that are intended to describe an
4635 * Intent vs. all others that should be treated as raw URIs. When used
4636 * with {@link #parseUri}, any other scheme will result in a generic
4637 * VIEW action for that raw URI.
4638 */
4639 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004640
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004641 /**
4642 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4643 * always has the "android-app:" scheme. This is a variation of
4644 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4645 * http/https URI being delivered to a specific package name. The format
4646 * is:
4647 *
4648 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004649 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004650 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004651 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4652 * you must also include a scheme; including a path also requires both a host and a scheme.
4653 * The final #Intent; fragment can be used without a scheme, host, or path.
4654 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004655 * used with intents that have a {@link #setSelector}, since the base intent
4656 * will always have an explicit package name.</p>
4657 *
4658 * <p>Some examples of how this scheme maps to Intent objects:</p>
4659 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4660 * <colgroup align="left" />
4661 * <colgroup align="left" />
4662 * <thead>
4663 * <tr><th>URI</th> <th>Intent</th></tr>
4664 * </thead>
4665 *
4666 * <tbody>
4667 * <tr><td><code>android-app://com.example.app</code></td>
4668 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4669 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4670 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4671 * </table></td>
4672 * </tr>
4673 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4674 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4675 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4676 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4677 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4678 * </table></td>
4679 * </tr>
4680 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4681 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4682 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4683 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4684 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4685 * </table></td>
4686 * </tr>
4687 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4688 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4689 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4690 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4691 * </table></td>
4692 * </tr>
4693 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4694 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4695 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4696 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4697 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4698 * </table></td>
4699 * </tr>
4700 * <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>
4701 * <td><table border="" style="margin:0" >
4702 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4703 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4704 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4705 * </table></td>
4706 * </tr>
4707 * </tbody>
4708 * </table>
4709 */
4710 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4711
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004712 /**
4713 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4714 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4715 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4716 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4717 * generated Intent can not cause unexpected data access to happen.
4718 *
4719 * <p>If you do not trust the source of the URI being parsed, you should still do further
4720 * processing to protect yourself from it. In particular, when using it to start an
4721 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4722 * that can handle it.</p>
4723 */
4724 public static final int URI_ALLOW_UNSAFE = 1<<2;
4725
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004726 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004727
4728 private String mAction;
4729 private Uri mData;
4730 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004731 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004732 private ComponentName mComponent;
4733 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004734 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004735 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004736 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004737 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004738 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004739 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004740
4741 // ---------------------------------------------------------------------
4742
4743 /**
4744 * Create an empty intent.
4745 */
4746 public Intent() {
4747 }
4748
4749 /**
4750 * Copy constructor.
4751 */
4752 public Intent(Intent o) {
4753 this.mAction = o.mAction;
4754 this.mData = o.mData;
4755 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004756 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004757 this.mComponent = o.mComponent;
4758 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004759 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004760 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004761 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004762 }
4763 if (o.mExtras != null) {
4764 this.mExtras = new Bundle(o.mExtras);
4765 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004766 if (o.mSourceBounds != null) {
4767 this.mSourceBounds = new Rect(o.mSourceBounds);
4768 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004769 if (o.mSelector != null) {
4770 this.mSelector = new Intent(o.mSelector);
4771 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004772 if (o.mClipData != null) {
4773 this.mClipData = new ClipData(o.mClipData);
4774 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004775 }
4776
4777 @Override
4778 public Object clone() {
4779 return new Intent(this);
4780 }
4781
4782 private Intent(Intent o, boolean all) {
4783 this.mAction = o.mAction;
4784 this.mData = o.mData;
4785 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004786 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004787 this.mComponent = o.mComponent;
4788 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004789 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004790 }
4791 }
4792
4793 /**
4794 * Make a clone of only the parts of the Intent that are relevant for
4795 * filter matching: the action, data, type, component, and categories.
4796 */
4797 public Intent cloneFilter() {
4798 return new Intent(this, false);
4799 }
4800
4801 /**
4802 * Create an intent with a given action. All other fields (data, type,
4803 * class) are null. Note that the action <em>must</em> be in a
4804 * namespace because Intents are used globally in the system -- for
4805 * example the system VIEW action is android.intent.action.VIEW; an
4806 * application's custom action would be something like
4807 * com.google.app.myapp.CUSTOM_ACTION.
4808 *
4809 * @param action The Intent action, such as ACTION_VIEW.
4810 */
4811 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004812 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004813 }
4814
4815 /**
4816 * Create an intent with a given action and for a given data url. Note
4817 * that the action <em>must</em> be in a namespace because Intents are
4818 * used globally in the system -- for example the system VIEW action is
4819 * android.intent.action.VIEW; an application's custom action would be
4820 * something like com.google.app.myapp.CUSTOM_ACTION.
4821 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004822 * <p><em>Note: scheme and host name matching in the Android framework is
4823 * case-sensitive, unlike the formal RFC. As a result,
4824 * you should always ensure that you write your Uri with these elements
4825 * using lower case letters, and normalize any Uris you receive from
4826 * outside of Android to ensure the scheme and host is lower case.</em></p>
4827 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004828 * @param action The Intent action, such as ACTION_VIEW.
4829 * @param uri The Intent data URI.
4830 */
4831 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004832 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004833 mData = uri;
4834 }
4835
4836 /**
4837 * Create an intent for a specific component. All other fields (action, data,
4838 * type, class) are null, though they can be modified later with explicit
4839 * calls. This provides a convenient way to create an intent that is
4840 * intended to execute a hard-coded class name, rather than relying on the
4841 * system to find an appropriate class for you; see {@link #setComponent}
4842 * for more information on the repercussions of this.
4843 *
4844 * @param packageContext A Context of the application package implementing
4845 * this class.
4846 * @param cls The component class that is to be used for the intent.
4847 *
4848 * @see #setClass
4849 * @see #setComponent
4850 * @see #Intent(String, android.net.Uri , Context, Class)
4851 */
4852 public Intent(Context packageContext, Class<?> cls) {
4853 mComponent = new ComponentName(packageContext, cls);
4854 }
4855
4856 /**
4857 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004858 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004859 * construct the Intent and then calling {@link #setClass} to set its
4860 * class.
4861 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004862 * <p><em>Note: scheme and host name matching in the Android framework is
4863 * case-sensitive, unlike the formal RFC. As a result,
4864 * you should always ensure that you write your Uri with these elements
4865 * using lower case letters, and normalize any Uris you receive from
4866 * outside of Android to ensure the scheme and host is lower case.</em></p>
4867 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004868 * @param action The Intent action, such as ACTION_VIEW.
4869 * @param uri The Intent data URI.
4870 * @param packageContext A Context of the application package implementing
4871 * this class.
4872 * @param cls The component class that is to be used for the intent.
4873 *
4874 * @see #Intent(String, android.net.Uri)
4875 * @see #Intent(Context, Class)
4876 * @see #setClass
4877 * @see #setComponent
4878 */
4879 public Intent(String action, Uri uri,
4880 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004881 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004882 mData = uri;
4883 mComponent = new ComponentName(packageContext, cls);
4884 }
4885
4886 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004887 * Create an intent to launch the main (root) activity of a task. This
4888 * is the Intent that is started when the application's is launched from
4889 * Home. For anything else that wants to launch an application in the
4890 * same way, it is important that they use an Intent structured the same
4891 * way, and can use this function to ensure this is the case.
4892 *
4893 * <p>The returned Intent has the given Activity component as its explicit
4894 * component, {@link #ACTION_MAIN} as its action, and includes the
4895 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4896 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4897 * to do that through {@link #addFlags(int)} on the returned Intent.
4898 *
4899 * @param mainActivity The main activity component that this Intent will
4900 * launch.
4901 * @return Returns a newly created Intent that can be used to launch the
4902 * activity as a main application entry.
4903 *
4904 * @see #setClass
4905 * @see #setComponent
4906 */
4907 public static Intent makeMainActivity(ComponentName mainActivity) {
4908 Intent intent = new Intent(ACTION_MAIN);
4909 intent.setComponent(mainActivity);
4910 intent.addCategory(CATEGORY_LAUNCHER);
4911 return intent;
4912 }
4913
4914 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004915 * Make an Intent for the main activity of an application, without
4916 * specifying a specific activity to run but giving a selector to find
4917 * the activity. This results in a final Intent that is structured
4918 * the same as when the application is launched from
4919 * Home. For anything else that wants to launch an application in the
4920 * same way, it is important that they use an Intent structured the same
4921 * way, and can use this function to ensure this is the case.
4922 *
4923 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4924 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4925 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4926 * to do that through {@link #addFlags(int)} on the returned Intent.
4927 *
4928 * @param selectorAction The action name of the Intent's selector.
4929 * @param selectorCategory The name of a category to add to the Intent's
4930 * selector.
4931 * @return Returns a newly created Intent that can be used to launch the
4932 * activity as a main application entry.
4933 *
4934 * @see #setSelector(Intent)
4935 */
4936 public static Intent makeMainSelectorActivity(String selectorAction,
4937 String selectorCategory) {
4938 Intent intent = new Intent(ACTION_MAIN);
4939 intent.addCategory(CATEGORY_LAUNCHER);
4940 Intent selector = new Intent();
4941 selector.setAction(selectorAction);
4942 selector.addCategory(selectorCategory);
4943 intent.setSelector(selector);
4944 return intent;
4945 }
4946
4947 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004948 * Make an Intent that can be used to re-launch an application's task
4949 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4950 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4951 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4952 *
4953 * @param mainActivity The activity component that is the root of the
4954 * task; this is the activity that has been published in the application's
4955 * manifest as the main launcher icon.
4956 *
4957 * @return Returns a newly created Intent that can be used to relaunch the
4958 * activity's task in its root state.
4959 */
4960 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4961 Intent intent = makeMainActivity(mainActivity);
4962 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4963 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4964 return intent;
4965 }
4966
4967 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004968 * Call {@link #parseUri} with 0 flags.
4969 * @deprecated Use {@link #parseUri} instead.
4970 */
4971 @Deprecated
4972 public static Intent getIntent(String uri) throws URISyntaxException {
4973 return parseUri(uri, 0);
4974 }
Tom Taylord4a47292009-12-21 13:59:18 -08004975
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004976 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004977 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004978 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004979 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004980 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004981 *
4982 * <p>The URI given here must not be relative -- that is, it must include
4983 * the scheme and full path.
4984 *
4985 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004986 * @param flags Additional processing flags. Either 0,
4987 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004988 *
4989 * @return Intent The newly created Intent object.
4990 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004991 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
4992 * it bad (as parsed by the Uri class) or the Intent data within the
4993 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08004994 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004995 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004996 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004997 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004998 int i = 0;
4999 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005000 final boolean androidApp = uri.startsWith("android-app:");
5001
5002 // Validate intent scheme if requested.
5003 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5004 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005005 Intent intent = new Intent(ACTION_VIEW);
5006 try {
5007 intent.setData(Uri.parse(uri));
5008 } catch (IllegalArgumentException e) {
5009 throw new URISyntaxException(uri, e.getMessage());
5010 }
5011 return intent;
5012 }
5013 }
Tom Taylord4a47292009-12-21 13:59:18 -08005014
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005015 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005016 // simple case
5017 if (i == -1) {
5018 if (!androidApp) {
5019 return new Intent(ACTION_VIEW, Uri.parse(uri));
5020 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005021
5022 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005023 } else if (!uri.startsWith("#Intent;", i)) {
5024 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005025 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005026 } else {
5027 i = -1;
5028 }
5029 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005030
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005031 // new format
5032 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005033 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005034 boolean explicitAction = false;
5035 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005036
5037 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005038 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005039 String data;
5040 if (i >= 0) {
5041 data = uri.substring(0, i);
5042 i += 8; // length of "#Intent;"
5043 } else {
5044 data = uri;
5045 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005046
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005047 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005048 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005049 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005050 if (eq < 0) eq = i-1;
5051 int semi = uri.indexOf(';', i);
5052 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005053
5054 // action
5055 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005056 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005057 if (!inSelector) {
5058 explicitAction = true;
5059 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005060 }
5061
5062 // categories
5063 else if (uri.startsWith("category=", i)) {
5064 intent.addCategory(value);
5065 }
5066
5067 // type
5068 else if (uri.startsWith("type=", i)) {
5069 intent.mType = value;
5070 }
5071
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005072 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005073 else if (uri.startsWith("launchFlags=", i)) {
5074 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005075 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5076 intent.mFlags &= ~IMMUTABLE_FLAGS;
5077 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005078 }
5079
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005080 // package
5081 else if (uri.startsWith("package=", i)) {
5082 intent.mPackage = value;
5083 }
5084
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005085 // component
5086 else if (uri.startsWith("component=", i)) {
5087 intent.mComponent = ComponentName.unflattenFromString(value);
5088 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005089
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005090 // scheme
5091 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005092 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005093 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005094 } else {
5095 scheme = value;
5096 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005097 }
5098
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005099 // source bounds
5100 else if (uri.startsWith("sourceBounds=", i)) {
5101 intent.mSourceBounds = Rect.unflattenFromString(value);
5102 }
5103
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005104 // selector
5105 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5106 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005107 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005108 }
5109
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005110 // extra
5111 else {
5112 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005113 // create Bundle if it doesn't already exist
5114 if (intent.mExtras == null) intent.mExtras = new Bundle();
5115 Bundle b = intent.mExtras;
5116 // add EXTRA
5117 if (uri.startsWith("S.", i)) b.putString(key, value);
5118 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5119 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5120 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5121 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5122 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5123 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5124 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5125 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5126 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5127 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005128
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005129 // move to the next item
5130 i = semi + 1;
5131 }
5132
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005133 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005134 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005135 if (baseIntent.mPackage == null) {
5136 baseIntent.setSelector(intent);
5137 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005138 intent = baseIntent;
5139 }
5140
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005141 if (data != null) {
5142 if (data.startsWith("intent:")) {
5143 data = data.substring(7);
5144 if (scheme != null) {
5145 data = scheme + ':' + data;
5146 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005147 } else if (data.startsWith("android-app:")) {
5148 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5149 // Correctly formed android-app, first part is package name.
5150 int end = data.indexOf('/', 14);
5151 if (end < 0) {
5152 // All we have is a package name.
5153 intent.mPackage = data.substring(14);
5154 if (!explicitAction) {
5155 intent.setAction(ACTION_MAIN);
5156 }
5157 data = "";
5158 } else {
5159 // Target the Intent at the given package name always.
5160 String authority = null;
5161 intent.mPackage = data.substring(14, end);
5162 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005163 if ((end+1) < data.length()) {
5164 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5165 // Found a scheme, remember it.
5166 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005167 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005168 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5169 // Found a authority, remember it.
5170 authority = data.substring(end+1, newEnd);
5171 end = newEnd;
5172 }
5173 } else {
5174 // All we have is a scheme.
5175 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005176 }
5177 }
5178 if (scheme == null) {
5179 // If there was no scheme, then this just targets the package.
5180 if (!explicitAction) {
5181 intent.setAction(ACTION_MAIN);
5182 }
5183 data = "";
5184 } else if (authority == null) {
5185 data = scheme + ":";
5186 } else {
5187 data = scheme + "://" + authority + data.substring(end);
5188 }
5189 }
5190 } else {
5191 data = "";
5192 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005193 }
Tom Taylord4a47292009-12-21 13:59:18 -08005194
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005195 if (data.length() > 0) {
5196 try {
5197 intent.mData = Uri.parse(data);
5198 } catch (IllegalArgumentException e) {
5199 throw new URISyntaxException(uri, e.getMessage());
5200 }
5201 }
5202 }
Tom Taylord4a47292009-12-21 13:59:18 -08005203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005204 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005205
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005206 } catch (IndexOutOfBoundsException e) {
5207 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5208 }
5209 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005210
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005211 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005212 return getIntentOld(uri, 0);
5213 }
5214
5215 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005216 Intent intent;
5217
5218 int i = uri.lastIndexOf('#');
5219 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005220 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005221 final int intentFragmentStart = i;
5222 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005223
5224 i++;
5225
5226 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005227 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005228 i += 7;
5229 int j = uri.indexOf(')', i);
5230 action = uri.substring(i, j);
5231 i = j + 1;
5232 }
5233
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005234 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005235
5236 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005237 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005238 i += 11;
5239 int j = uri.indexOf(')', i);
5240 while (i < j) {
5241 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005242 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005243 if (i < sep) {
5244 intent.addCategory(uri.substring(i, sep));
5245 }
5246 i = sep + 1;
5247 }
5248 i = j + 1;
5249 }
5250
5251 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005252 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005253 i += 5;
5254 int j = uri.indexOf(')', i);
5255 intent.mType = uri.substring(i, j);
5256 i = j + 1;
5257 }
5258
5259 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005260 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005261 i += 12;
5262 int j = uri.indexOf(')', i);
5263 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005264 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5265 intent.mFlags &= ~IMMUTABLE_FLAGS;
5266 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005267 i = j + 1;
5268 }
5269
5270 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005271 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005272 i += 10;
5273 int j = uri.indexOf(')', i);
5274 int sep = uri.indexOf('!', i);
5275 if (sep >= 0 && sep < j) {
5276 String pkg = uri.substring(i, sep);
5277 String cls = uri.substring(sep + 1, j);
5278 intent.mComponent = new ComponentName(pkg, cls);
5279 }
5280 i = j + 1;
5281 }
5282
5283 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005284 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005285 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005286
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005287 final int closeParen = uri.indexOf(')', i);
5288 if (closeParen == -1) throw new URISyntaxException(uri,
5289 "EXTRA missing trailing ')'", i);
5290
5291 while (i < closeParen) {
5292 // fetch the key value
5293 int j = uri.indexOf('=', i);
5294 if (j <= i + 1 || i >= closeParen) {
5295 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5296 }
5297 char type = uri.charAt(i);
5298 i++;
5299 String key = uri.substring(i, j);
5300 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005301
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005302 // get type-value
5303 j = uri.indexOf('!', i);
5304 if (j == -1 || j >= closeParen) j = closeParen;
5305 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5306 String value = uri.substring(i, j);
5307 i = j;
5308
5309 // create Bundle if it doesn't already exist
5310 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005311
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005312 // add item to bundle
5313 try {
5314 switch (type) {
5315 case 'S':
5316 intent.mExtras.putString(key, Uri.decode(value));
5317 break;
5318 case 'B':
5319 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5320 break;
5321 case 'b':
5322 intent.mExtras.putByte(key, Byte.parseByte(value));
5323 break;
5324 case 'c':
5325 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5326 break;
5327 case 'd':
5328 intent.mExtras.putDouble(key, Double.parseDouble(value));
5329 break;
5330 case 'f':
5331 intent.mExtras.putFloat(key, Float.parseFloat(value));
5332 break;
5333 case 'i':
5334 intent.mExtras.putInt(key, Integer.parseInt(value));
5335 break;
5336 case 'l':
5337 intent.mExtras.putLong(key, Long.parseLong(value));
5338 break;
5339 case 's':
5340 intent.mExtras.putShort(key, Short.parseShort(value));
5341 break;
5342 default:
5343 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5344 }
5345 } catch (NumberFormatException e) {
5346 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5347 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005348
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005349 char ch = uri.charAt(i);
5350 if (ch == ')') break;
5351 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5352 i++;
5353 }
5354 }
5355
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005356 if (isIntentFragment) {
5357 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5358 } else {
5359 intent.mData = Uri.parse(uri);
5360 }
Tom Taylord4a47292009-12-21 13:59:18 -08005361
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005362 if (intent.mAction == null) {
5363 // By default, if no action is specified, then use VIEW.
5364 intent.mAction = ACTION_VIEW;
5365 }
5366
5367 } else {
5368 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5369 }
5370
5371 return intent;
5372 }
5373
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005374 /** @hide */
5375 public interface CommandOptionHandler {
5376 boolean handleOption(String opt, ShellCommand cmd);
5377 }
5378
5379 /** @hide */
5380 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5381 throws URISyntaxException {
5382 Intent intent = new Intent();
5383 Intent baseIntent = intent;
5384 boolean hasIntentInfo = false;
5385
5386 Uri data = null;
5387 String type = null;
5388
5389 String opt;
5390 while ((opt=cmd.getNextOption()) != null) {
5391 switch (opt) {
5392 case "-a":
5393 intent.setAction(cmd.getNextArgRequired());
5394 if (intent == baseIntent) {
5395 hasIntentInfo = true;
5396 }
5397 break;
5398 case "-d":
5399 data = Uri.parse(cmd.getNextArgRequired());
5400 if (intent == baseIntent) {
5401 hasIntentInfo = true;
5402 }
5403 break;
5404 case "-t":
5405 type = cmd.getNextArgRequired();
5406 if (intent == baseIntent) {
5407 hasIntentInfo = true;
5408 }
5409 break;
5410 case "-c":
5411 intent.addCategory(cmd.getNextArgRequired());
5412 if (intent == baseIntent) {
5413 hasIntentInfo = true;
5414 }
5415 break;
5416 case "-e":
5417 case "--es": {
5418 String key = cmd.getNextArgRequired();
5419 String value = cmd.getNextArgRequired();
5420 intent.putExtra(key, value);
5421 }
5422 break;
5423 case "--esn": {
5424 String key = cmd.getNextArgRequired();
5425 intent.putExtra(key, (String) null);
5426 }
5427 break;
5428 case "--ei": {
5429 String key = cmd.getNextArgRequired();
5430 String value = cmd.getNextArgRequired();
5431 intent.putExtra(key, Integer.decode(value));
5432 }
5433 break;
5434 case "--eu": {
5435 String key = cmd.getNextArgRequired();
5436 String value = cmd.getNextArgRequired();
5437 intent.putExtra(key, Uri.parse(value));
5438 }
5439 break;
5440 case "--ecn": {
5441 String key = cmd.getNextArgRequired();
5442 String value = cmd.getNextArgRequired();
5443 ComponentName cn = ComponentName.unflattenFromString(value);
5444 if (cn == null)
5445 throw new IllegalArgumentException("Bad component name: " + value);
5446 intent.putExtra(key, cn);
5447 }
5448 break;
5449 case "--eia": {
5450 String key = cmd.getNextArgRequired();
5451 String value = cmd.getNextArgRequired();
5452 String[] strings = value.split(",");
5453 int[] list = new int[strings.length];
5454 for (int i = 0; i < strings.length; i++) {
5455 list[i] = Integer.decode(strings[i]);
5456 }
5457 intent.putExtra(key, list);
5458 }
5459 break;
5460 case "--eial": {
5461 String key = cmd.getNextArgRequired();
5462 String value = cmd.getNextArgRequired();
5463 String[] strings = value.split(",");
5464 ArrayList<Integer> list = new ArrayList<>(strings.length);
5465 for (int i = 0; i < strings.length; i++) {
5466 list.add(Integer.decode(strings[i]));
5467 }
5468 intent.putExtra(key, list);
5469 }
5470 break;
5471 case "--el": {
5472 String key = cmd.getNextArgRequired();
5473 String value = cmd.getNextArgRequired();
5474 intent.putExtra(key, Long.valueOf(value));
5475 }
5476 break;
5477 case "--ela": {
5478 String key = cmd.getNextArgRequired();
5479 String value = cmd.getNextArgRequired();
5480 String[] strings = value.split(",");
5481 long[] list = new long[strings.length];
5482 for (int i = 0; i < strings.length; i++) {
5483 list[i] = Long.valueOf(strings[i]);
5484 }
5485 intent.putExtra(key, list);
5486 hasIntentInfo = true;
5487 }
5488 break;
5489 case "--elal": {
5490 String key = cmd.getNextArgRequired();
5491 String value = cmd.getNextArgRequired();
5492 String[] strings = value.split(",");
5493 ArrayList<Long> list = new ArrayList<>(strings.length);
5494 for (int i = 0; i < strings.length; i++) {
5495 list.add(Long.valueOf(strings[i]));
5496 }
5497 intent.putExtra(key, list);
5498 hasIntentInfo = true;
5499 }
5500 break;
5501 case "--ef": {
5502 String key = cmd.getNextArgRequired();
5503 String value = cmd.getNextArgRequired();
5504 intent.putExtra(key, Float.valueOf(value));
5505 hasIntentInfo = true;
5506 }
5507 break;
5508 case "--efa": {
5509 String key = cmd.getNextArgRequired();
5510 String value = cmd.getNextArgRequired();
5511 String[] strings = value.split(",");
5512 float[] list = new float[strings.length];
5513 for (int i = 0; i < strings.length; i++) {
5514 list[i] = Float.valueOf(strings[i]);
5515 }
5516 intent.putExtra(key, list);
5517 hasIntentInfo = true;
5518 }
5519 break;
5520 case "--efal": {
5521 String key = cmd.getNextArgRequired();
5522 String value = cmd.getNextArgRequired();
5523 String[] strings = value.split(",");
5524 ArrayList<Float> list = new ArrayList<>(strings.length);
5525 for (int i = 0; i < strings.length; i++) {
5526 list.add(Float.valueOf(strings[i]));
5527 }
5528 intent.putExtra(key, list);
5529 hasIntentInfo = true;
5530 }
5531 break;
5532 case "--esa": {
5533 String key = cmd.getNextArgRequired();
5534 String value = cmd.getNextArgRequired();
5535 // Split on commas unless they are preceeded by an escape.
5536 // The escape character must be escaped for the string and
5537 // again for the regex, thus four escape characters become one.
5538 String[] strings = value.split("(?<!\\\\),");
5539 intent.putExtra(key, strings);
5540 hasIntentInfo = true;
5541 }
5542 break;
5543 case "--esal": {
5544 String key = cmd.getNextArgRequired();
5545 String value = cmd.getNextArgRequired();
5546 // Split on commas unless they are preceeded by an escape.
5547 // The escape character must be escaped for the string and
5548 // again for the regex, thus four escape characters become one.
5549 String[] strings = value.split("(?<!\\\\),");
5550 ArrayList<String> list = new ArrayList<>(strings.length);
5551 for (int i = 0; i < strings.length; i++) {
5552 list.add(strings[i]);
5553 }
5554 intent.putExtra(key, list);
5555 hasIntentInfo = true;
5556 }
5557 break;
5558 case "--ez": {
5559 String key = cmd.getNextArgRequired();
5560 String value = cmd.getNextArgRequired().toLowerCase();
5561 // Boolean.valueOf() results in false for anything that is not "true", which is
5562 // error-prone in shell commands
5563 boolean arg;
5564 if ("true".equals(value) || "t".equals(value)) {
5565 arg = true;
5566 } else if ("false".equals(value) || "f".equals(value)) {
5567 arg = false;
5568 } else {
5569 try {
5570 arg = Integer.decode(value) != 0;
5571 } catch (NumberFormatException ex) {
5572 throw new IllegalArgumentException("Invalid boolean value: " + value);
5573 }
5574 }
5575
5576 intent.putExtra(key, arg);
5577 }
5578 break;
5579 case "-n": {
5580 String str = cmd.getNextArgRequired();
5581 ComponentName cn = ComponentName.unflattenFromString(str);
5582 if (cn == null)
5583 throw new IllegalArgumentException("Bad component name: " + str);
5584 intent.setComponent(cn);
5585 if (intent == baseIntent) {
5586 hasIntentInfo = true;
5587 }
5588 }
5589 break;
5590 case "-p": {
5591 String str = cmd.getNextArgRequired();
5592 intent.setPackage(str);
5593 if (intent == baseIntent) {
5594 hasIntentInfo = true;
5595 }
5596 }
5597 break;
5598 case "-f":
5599 String str = cmd.getNextArgRequired();
5600 intent.setFlags(Integer.decode(str).intValue());
5601 break;
5602 case "--grant-read-uri-permission":
5603 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5604 break;
5605 case "--grant-write-uri-permission":
5606 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5607 break;
5608 case "--grant-persistable-uri-permission":
5609 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5610 break;
5611 case "--grant-prefix-uri-permission":
5612 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5613 break;
5614 case "--exclude-stopped-packages":
5615 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5616 break;
5617 case "--include-stopped-packages":
5618 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5619 break;
5620 case "--debug-log-resolution":
5621 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5622 break;
5623 case "--activity-brought-to-front":
5624 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5625 break;
5626 case "--activity-clear-top":
5627 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5628 break;
5629 case "--activity-clear-when-task-reset":
5630 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5631 break;
5632 case "--activity-exclude-from-recents":
5633 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5634 break;
5635 case "--activity-launched-from-history":
5636 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5637 break;
5638 case "--activity-multiple-task":
5639 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5640 break;
5641 case "--activity-no-animation":
5642 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5643 break;
5644 case "--activity-no-history":
5645 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5646 break;
5647 case "--activity-no-user-action":
5648 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5649 break;
5650 case "--activity-previous-is-top":
5651 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5652 break;
5653 case "--activity-reorder-to-front":
5654 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5655 break;
5656 case "--activity-reset-task-if-needed":
5657 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5658 break;
5659 case "--activity-single-top":
5660 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5661 break;
5662 case "--activity-clear-task":
5663 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5664 break;
5665 case "--activity-task-on-home":
5666 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5667 break;
5668 case "--receiver-registered-only":
5669 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5670 break;
5671 case "--receiver-replace-pending":
5672 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5673 break;
5674 case "--selector":
5675 intent.setDataAndType(data, type);
5676 intent = new Intent();
5677 break;
5678 default:
5679 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5680 // Okay, caller handled this option.
5681 } else {
5682 throw new IllegalArgumentException("Unknown option: " + opt);
5683 }
5684 break;
5685 }
5686 }
5687 intent.setDataAndType(data, type);
5688
5689 final boolean hasSelector = intent != baseIntent;
5690 if (hasSelector) {
5691 // A selector was specified; fix up.
5692 baseIntent.setSelector(intent);
5693 intent = baseIntent;
5694 }
5695
5696 String arg = cmd.getNextArg();
5697 baseIntent = null;
5698 if (arg == null) {
5699 if (hasSelector) {
5700 // If a selector has been specified, and no arguments
5701 // have been supplied for the main Intent, then we can
5702 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5703 // need to have a component name specified yet, the
5704 // selector will take care of that.
5705 baseIntent = new Intent(Intent.ACTION_MAIN);
5706 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5707 }
5708 } else if (arg.indexOf(':') >= 0) {
5709 // The argument is a URI. Fully parse it, and use that result
5710 // to fill in any data not specified so far.
5711 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5712 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5713 } else if (arg.indexOf('/') >= 0) {
5714 // The argument is a component name. Build an Intent to launch
5715 // it.
5716 baseIntent = new Intent(Intent.ACTION_MAIN);
5717 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5718 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5719 } else {
5720 // Assume the argument is a package name.
5721 baseIntent = new Intent(Intent.ACTION_MAIN);
5722 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5723 baseIntent.setPackage(arg);
5724 }
5725 if (baseIntent != null) {
5726 Bundle extras = intent.getExtras();
5727 intent.replaceExtras((Bundle)null);
5728 Bundle uriExtras = baseIntent.getExtras();
5729 baseIntent.replaceExtras((Bundle)null);
5730 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5731 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5732 for (String c : cats) {
5733 baseIntent.removeCategory(c);
5734 }
5735 }
5736 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5737 if (extras == null) {
5738 extras = uriExtras;
5739 } else if (uriExtras != null) {
5740 uriExtras.putAll(extras);
5741 extras = uriExtras;
5742 }
5743 intent.replaceExtras(extras);
5744 hasIntentInfo = true;
5745 }
5746
5747 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5748 return intent;
5749 }
5750
5751 /** @hide */
5752 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5753 final String[] lines = new String[] {
5754 "<INTENT> specifications include these flags and arguments:",
5755 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5756 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5757 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5758 " [--esn <EXTRA_KEY> ...]",
5759 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5760 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5761 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5762 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5763 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5764 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5765 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5766 " (mutiple extras passed as Integer[])",
5767 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5768 " (mutiple extras passed as List<Integer>)",
5769 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5770 " (mutiple extras passed as Long[])",
5771 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5772 " (mutiple extras passed as List<Long>)",
5773 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5774 " (mutiple extras passed as Float[])",
5775 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5776 " (mutiple extras passed as List<Float>)",
5777 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5778 " (mutiple extras passed as String[]; to embed a comma into a string,",
5779 " escape it using \"\\,\")",
5780 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5781 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5782 " escape it using \"\\,\")",
5783 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5784 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5785 " [--debug-log-resolution] [--exclude-stopped-packages]",
5786 " [--include-stopped-packages]",
5787 " [--activity-brought-to-front] [--activity-clear-top]",
5788 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5789 " [--activity-launched-from-history] [--activity-multiple-task]",
5790 " [--activity-no-animation] [--activity-no-history]",
5791 " [--activity-no-user-action] [--activity-previous-is-top]",
5792 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5793 " [--activity-single-top] [--activity-clear-task]",
5794 " [--activity-task-on-home]",
5795 " [--receiver-registered-only] [--receiver-replace-pending]",
5796 " [--selector]",
5797 " [<URI> | <PACKAGE> | <COMPONENT>]"
5798 };
5799 for (String line : lines) {
5800 pw.print(prefix);
5801 pw.println(line);
5802 }
5803 }
5804
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005805 /**
5806 * Retrieve the general action to be performed, such as
5807 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5808 * the information in the intent should be interpreted -- most importantly,
5809 * what to do with the data returned by {@link #getData}.
5810 *
5811 * @return The action of this intent or null if none is specified.
5812 *
5813 * @see #setAction
5814 */
5815 public String getAction() {
5816 return mAction;
5817 }
5818
5819 /**
5820 * Retrieve data this intent is operating on. This URI specifies the name
5821 * of the data; often it uses the content: scheme, specifying data in a
5822 * content provider. Other schemes may be handled by specific activities,
5823 * such as http: by the web browser.
5824 *
5825 * @return The URI of the data this intent is targeting or null.
5826 *
5827 * @see #getScheme
5828 * @see #setData
5829 */
5830 public Uri getData() {
5831 return mData;
5832 }
5833
5834 /**
5835 * The same as {@link #getData()}, but returns the URI as an encoded
5836 * String.
5837 */
5838 public String getDataString() {
5839 return mData != null ? mData.toString() : null;
5840 }
5841
5842 /**
5843 * Return the scheme portion of the intent's data. If the data is null or
5844 * does not include a scheme, null is returned. Otherwise, the scheme
5845 * prefix without the final ':' is returned, i.e. "http".
5846 *
5847 * <p>This is the same as calling getData().getScheme() (and checking for
5848 * null data).
5849 *
5850 * @return The scheme of this intent.
5851 *
5852 * @see #getData
5853 */
5854 public String getScheme() {
5855 return mData != null ? mData.getScheme() : null;
5856 }
5857
5858 /**
5859 * Retrieve any explicit MIME type included in the intent. This is usually
5860 * null, as the type is determined by the intent data.
5861 *
5862 * @return If a type was manually set, it is returned; else null is
5863 * returned.
5864 *
5865 * @see #resolveType(ContentResolver)
5866 * @see #setType
5867 */
5868 public String getType() {
5869 return mType;
5870 }
5871
5872 /**
5873 * Return the MIME data type of this intent. If the type field is
5874 * explicitly set, that is simply returned. Otherwise, if the data is set,
5875 * the type of that data is returned. If neither fields are set, a null is
5876 * returned.
5877 *
5878 * @return The MIME type of this intent.
5879 *
5880 * @see #getType
5881 * @see #resolveType(ContentResolver)
5882 */
5883 public String resolveType(Context context) {
5884 return resolveType(context.getContentResolver());
5885 }
5886
5887 /**
5888 * Return the MIME data type of this intent. If the type field is
5889 * explicitly set, that is simply returned. Otherwise, if the data is set,
5890 * the type of that data is returned. If neither fields are set, a null is
5891 * returned.
5892 *
5893 * @param resolver A ContentResolver that can be used to determine the MIME
5894 * type of the intent's data.
5895 *
5896 * @return The MIME type of this intent.
5897 *
5898 * @see #getType
5899 * @see #resolveType(Context)
5900 */
5901 public String resolveType(ContentResolver resolver) {
5902 if (mType != null) {
5903 return mType;
5904 }
5905 if (mData != null) {
5906 if ("content".equals(mData.getScheme())) {
5907 return resolver.getType(mData);
5908 }
5909 }
5910 return null;
5911 }
5912
5913 /**
5914 * Return the MIME data type of this intent, only if it will be needed for
5915 * intent resolution. This is not generally useful for application code;
5916 * it is used by the frameworks for communicating with back-end system
5917 * services.
5918 *
5919 * @param resolver A ContentResolver that can be used to determine the MIME
5920 * type of the intent's data.
5921 *
5922 * @return The MIME type of this intent, or null if it is unknown or not
5923 * needed.
5924 */
5925 public String resolveTypeIfNeeded(ContentResolver resolver) {
5926 if (mComponent != null) {
5927 return mType;
5928 }
5929 return resolveType(resolver);
5930 }
5931
5932 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005933 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005934 *
5935 * @param category The category to check.
5936 *
5937 * @return boolean True if the intent contains the category, else false.
5938 *
5939 * @see #getCategories
5940 * @see #addCategory
5941 */
5942 public boolean hasCategory(String category) {
5943 return mCategories != null && mCategories.contains(category);
5944 }
5945
5946 /**
5947 * Return the set of all categories in the intent. If there are no categories,
5948 * returns NULL.
5949 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005950 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005951 *
5952 * @see #hasCategory
5953 * @see #addCategory
5954 */
5955 public Set<String> getCategories() {
5956 return mCategories;
5957 }
5958
5959 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005960 * Return the specific selector associated with this Intent. If there is
5961 * none, returns null. See {@link #setSelector} for more information.
5962 *
5963 * @see #setSelector
5964 */
5965 public Intent getSelector() {
5966 return mSelector;
5967 }
5968
5969 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005970 * Return the {@link ClipData} associated with this Intent. If there is
5971 * none, returns null. See {@link #setClipData} for more information.
5972 *
John Spurlock125d1332013-11-25 11:58:37 -05005973 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005974 */
5975 public ClipData getClipData() {
5976 return mClipData;
5977 }
5978
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005979 /** @hide */
5980 public int getContentUserHint() {
5981 return mContentUserHint;
5982 }
5983
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005984 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005985 * Sets the ClassLoader that will be used when unmarshalling
5986 * any Parcelable values from the extras of this Intent.
5987 *
5988 * @param loader a ClassLoader, or null to use the default loader
5989 * at the time of unmarshalling.
5990 */
5991 public void setExtrasClassLoader(ClassLoader loader) {
5992 if (mExtras != null) {
5993 mExtras.setClassLoader(loader);
5994 }
5995 }
5996
5997 /**
5998 * Returns true if an extra value is associated with the given name.
5999 * @param name the extra's name
6000 * @return true if the given extra is present.
6001 */
6002 public boolean hasExtra(String name) {
6003 return mExtras != null && mExtras.containsKey(name);
6004 }
6005
6006 /**
6007 * Returns true if the Intent's extras contain a parcelled file descriptor.
6008 * @return true if the Intent contains a parcelled file descriptor.
6009 */
6010 public boolean hasFileDescriptors() {
6011 return mExtras != null && mExtras.hasFileDescriptors();
6012 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006013
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006014 /** @hide */
6015 public void setAllowFds(boolean allowFds) {
6016 if (mExtras != null) {
6017 mExtras.setAllowFds(allowFds);
6018 }
6019 }
6020
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006021 /**
6022 * Retrieve extended data from the intent.
6023 *
6024 * @param name The name of the desired item.
6025 *
6026 * @return the value of an item that previously added with putExtra()
6027 * or null if none was found.
6028 *
6029 * @deprecated
6030 * @hide
6031 */
6032 @Deprecated
6033 public Object getExtra(String name) {
6034 return getExtra(name, null);
6035 }
6036
6037 /**
6038 * Retrieve extended data from the intent.
6039 *
6040 * @param name The name of the desired item.
6041 * @param defaultValue the value to be returned if no value of the desired
6042 * type is stored with the given name.
6043 *
6044 * @return the value of an item that previously added with putExtra()
6045 * or the default value if none was found.
6046 *
6047 * @see #putExtra(String, boolean)
6048 */
6049 public boolean getBooleanExtra(String name, boolean defaultValue) {
6050 return mExtras == null ? defaultValue :
6051 mExtras.getBoolean(name, defaultValue);
6052 }
6053
6054 /**
6055 * Retrieve extended data from the intent.
6056 *
6057 * @param name The name of the desired item.
6058 * @param defaultValue the value to be returned if no value of the desired
6059 * type is stored with the given name.
6060 *
6061 * @return the value of an item that previously added with putExtra()
6062 * or the default value if none was found.
6063 *
6064 * @see #putExtra(String, byte)
6065 */
6066 public byte getByteExtra(String name, byte defaultValue) {
6067 return mExtras == null ? defaultValue :
6068 mExtras.getByte(name, defaultValue);
6069 }
6070
6071 /**
6072 * Retrieve extended data from the intent.
6073 *
6074 * @param name The name of the desired item.
6075 * @param defaultValue the value to be returned if no value of the desired
6076 * type is stored with the given name.
6077 *
6078 * @return the value of an item that previously added with putExtra()
6079 * or the default value if none was found.
6080 *
6081 * @see #putExtra(String, short)
6082 */
6083 public short getShortExtra(String name, short defaultValue) {
6084 return mExtras == null ? defaultValue :
6085 mExtras.getShort(name, defaultValue);
6086 }
6087
6088 /**
6089 * Retrieve extended data from the intent.
6090 *
6091 * @param name The name of the desired item.
6092 * @param defaultValue the value to be returned if no value of the desired
6093 * type is stored with the given name.
6094 *
6095 * @return the value of an item that previously added with putExtra()
6096 * or the default value if none was found.
6097 *
6098 * @see #putExtra(String, char)
6099 */
6100 public char getCharExtra(String name, char defaultValue) {
6101 return mExtras == null ? defaultValue :
6102 mExtras.getChar(name, defaultValue);
6103 }
6104
6105 /**
6106 * Retrieve extended data from the intent.
6107 *
6108 * @param name The name of the desired item.
6109 * @param defaultValue the value to be returned if no value of the desired
6110 * type is stored with the given name.
6111 *
6112 * @return the value of an item that previously added with putExtra()
6113 * or the default value if none was found.
6114 *
6115 * @see #putExtra(String, int)
6116 */
6117 public int getIntExtra(String name, int defaultValue) {
6118 return mExtras == null ? defaultValue :
6119 mExtras.getInt(name, defaultValue);
6120 }
6121
6122 /**
6123 * Retrieve extended data from the intent.
6124 *
6125 * @param name The name of the desired item.
6126 * @param defaultValue the value to be returned if no value of the desired
6127 * type is stored with the given name.
6128 *
6129 * @return the value of an item that previously added with putExtra()
6130 * or the default value if none was found.
6131 *
6132 * @see #putExtra(String, long)
6133 */
6134 public long getLongExtra(String name, long defaultValue) {
6135 return mExtras == null ? defaultValue :
6136 mExtras.getLong(name, defaultValue);
6137 }
6138
6139 /**
6140 * Retrieve extended data from the intent.
6141 *
6142 * @param name The name of the desired item.
6143 * @param defaultValue the value to be returned if no value of the desired
6144 * type is stored with the given name.
6145 *
6146 * @return the value of an item that previously added with putExtra(),
6147 * or the default value if no such item is present
6148 *
6149 * @see #putExtra(String, float)
6150 */
6151 public float getFloatExtra(String name, float defaultValue) {
6152 return mExtras == null ? defaultValue :
6153 mExtras.getFloat(name, defaultValue);
6154 }
6155
6156 /**
6157 * Retrieve extended data from the intent.
6158 *
6159 * @param name The name of the desired item.
6160 * @param defaultValue the value to be returned if no value of the desired
6161 * type is stored with the given name.
6162 *
6163 * @return the value of an item that previously added with putExtra()
6164 * or the default value if none was found.
6165 *
6166 * @see #putExtra(String, double)
6167 */
6168 public double getDoubleExtra(String name, double defaultValue) {
6169 return mExtras == null ? defaultValue :
6170 mExtras.getDouble(name, defaultValue);
6171 }
6172
6173 /**
6174 * Retrieve extended data from the intent.
6175 *
6176 * @param name The name of the desired item.
6177 *
6178 * @return the value of an item that previously added with putExtra()
6179 * or null if no String value was found.
6180 *
6181 * @see #putExtra(String, String)
6182 */
6183 public String getStringExtra(String name) {
6184 return mExtras == null ? null : mExtras.getString(name);
6185 }
6186
6187 /**
6188 * Retrieve extended data from the intent.
6189 *
6190 * @param name The name of the desired item.
6191 *
6192 * @return the value of an item that previously added with putExtra()
6193 * or null if no CharSequence value was found.
6194 *
6195 * @see #putExtra(String, CharSequence)
6196 */
6197 public CharSequence getCharSequenceExtra(String name) {
6198 return mExtras == null ? null : mExtras.getCharSequence(name);
6199 }
6200
6201 /**
6202 * Retrieve extended data from the intent.
6203 *
6204 * @param name The name of the desired item.
6205 *
6206 * @return the value of an item that previously added with putExtra()
6207 * or null if no Parcelable value was found.
6208 *
6209 * @see #putExtra(String, Parcelable)
6210 */
6211 public <T extends Parcelable> T getParcelableExtra(String name) {
6212 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6213 }
6214
6215 /**
6216 * Retrieve extended data from the intent.
6217 *
6218 * @param name The name of the desired item.
6219 *
6220 * @return the value of an item that previously added with putExtra()
6221 * or null if no Parcelable[] value was found.
6222 *
6223 * @see #putExtra(String, Parcelable[])
6224 */
6225 public Parcelable[] getParcelableArrayExtra(String name) {
6226 return mExtras == null ? null : mExtras.getParcelableArray(name);
6227 }
6228
6229 /**
6230 * Retrieve extended data from the intent.
6231 *
6232 * @param name The name of the desired item.
6233 *
6234 * @return the value of an item that previously added with putExtra()
6235 * or null if no ArrayList<Parcelable> value was found.
6236 *
6237 * @see #putParcelableArrayListExtra(String, ArrayList)
6238 */
6239 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6240 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6241 }
6242
6243 /**
6244 * Retrieve extended data from the intent.
6245 *
6246 * @param name The name of the desired item.
6247 *
6248 * @return the value of an item that previously added with putExtra()
6249 * or null if no Serializable value was found.
6250 *
6251 * @see #putExtra(String, Serializable)
6252 */
6253 public Serializable getSerializableExtra(String name) {
6254 return mExtras == null ? null : mExtras.getSerializable(name);
6255 }
6256
6257 /**
6258 * Retrieve extended data from the intent.
6259 *
6260 * @param name The name of the desired item.
6261 *
6262 * @return the value of an item that previously added with putExtra()
6263 * or null if no ArrayList<Integer> value was found.
6264 *
6265 * @see #putIntegerArrayListExtra(String, ArrayList)
6266 */
6267 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6268 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6269 }
6270
6271 /**
6272 * Retrieve extended data from the intent.
6273 *
6274 * @param name The name of the desired item.
6275 *
6276 * @return the value of an item that previously added with putExtra()
6277 * or null if no ArrayList<String> value was found.
6278 *
6279 * @see #putStringArrayListExtra(String, ArrayList)
6280 */
6281 public ArrayList<String> getStringArrayListExtra(String name) {
6282 return mExtras == null ? null : mExtras.getStringArrayList(name);
6283 }
6284
6285 /**
6286 * Retrieve extended data from the intent.
6287 *
6288 * @param name The name of the desired item.
6289 *
6290 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006291 * or null if no ArrayList<CharSequence> value was found.
6292 *
6293 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6294 */
6295 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6296 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6297 }
6298
6299 /**
6300 * Retrieve extended data from the intent.
6301 *
6302 * @param name The name of the desired item.
6303 *
6304 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006305 * or null if no boolean array value was found.
6306 *
6307 * @see #putExtra(String, boolean[])
6308 */
6309 public boolean[] getBooleanArrayExtra(String name) {
6310 return mExtras == null ? null : mExtras.getBooleanArray(name);
6311 }
6312
6313 /**
6314 * Retrieve extended data from the intent.
6315 *
6316 * @param name The name of the desired item.
6317 *
6318 * @return the value of an item that previously added with putExtra()
6319 * or null if no byte array value was found.
6320 *
6321 * @see #putExtra(String, byte[])
6322 */
6323 public byte[] getByteArrayExtra(String name) {
6324 return mExtras == null ? null : mExtras.getByteArray(name);
6325 }
6326
6327 /**
6328 * Retrieve extended data from the intent.
6329 *
6330 * @param name The name of the desired item.
6331 *
6332 * @return the value of an item that previously added with putExtra()
6333 * or null if no short array value was found.
6334 *
6335 * @see #putExtra(String, short[])
6336 */
6337 public short[] getShortArrayExtra(String name) {
6338 return mExtras == null ? null : mExtras.getShortArray(name);
6339 }
6340
6341 /**
6342 * Retrieve extended data from the intent.
6343 *
6344 * @param name The name of the desired item.
6345 *
6346 * @return the value of an item that previously added with putExtra()
6347 * or null if no char array value was found.
6348 *
6349 * @see #putExtra(String, char[])
6350 */
6351 public char[] getCharArrayExtra(String name) {
6352 return mExtras == null ? null : mExtras.getCharArray(name);
6353 }
6354
6355 /**
6356 * Retrieve extended data from the intent.
6357 *
6358 * @param name The name of the desired item.
6359 *
6360 * @return the value of an item that previously added with putExtra()
6361 * or null if no int array value was found.
6362 *
6363 * @see #putExtra(String, int[])
6364 */
6365 public int[] getIntArrayExtra(String name) {
6366 return mExtras == null ? null : mExtras.getIntArray(name);
6367 }
6368
6369 /**
6370 * Retrieve extended data from the intent.
6371 *
6372 * @param name The name of the desired item.
6373 *
6374 * @return the value of an item that previously added with putExtra()
6375 * or null if no long array value was found.
6376 *
6377 * @see #putExtra(String, long[])
6378 */
6379 public long[] getLongArrayExtra(String name) {
6380 return mExtras == null ? null : mExtras.getLongArray(name);
6381 }
6382
6383 /**
6384 * Retrieve extended data from the intent.
6385 *
6386 * @param name The name of the desired item.
6387 *
6388 * @return the value of an item that previously added with putExtra()
6389 * or null if no float array value was found.
6390 *
6391 * @see #putExtra(String, float[])
6392 */
6393 public float[] getFloatArrayExtra(String name) {
6394 return mExtras == null ? null : mExtras.getFloatArray(name);
6395 }
6396
6397 /**
6398 * Retrieve extended data from the intent.
6399 *
6400 * @param name The name of the desired item.
6401 *
6402 * @return the value of an item that previously added with putExtra()
6403 * or null if no double array value was found.
6404 *
6405 * @see #putExtra(String, double[])
6406 */
6407 public double[] getDoubleArrayExtra(String name) {
6408 return mExtras == null ? null : mExtras.getDoubleArray(name);
6409 }
6410
6411 /**
6412 * Retrieve extended data from the intent.
6413 *
6414 * @param name The name of the desired item.
6415 *
6416 * @return the value of an item that previously added with putExtra()
6417 * or null if no String array value was found.
6418 *
6419 * @see #putExtra(String, String[])
6420 */
6421 public String[] getStringArrayExtra(String name) {
6422 return mExtras == null ? null : mExtras.getStringArray(name);
6423 }
6424
6425 /**
6426 * Retrieve extended data from the intent.
6427 *
6428 * @param name The name of the desired item.
6429 *
6430 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006431 * or null if no CharSequence array value was found.
6432 *
6433 * @see #putExtra(String, CharSequence[])
6434 */
6435 public CharSequence[] getCharSequenceArrayExtra(String name) {
6436 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6437 }
6438
6439 /**
6440 * Retrieve extended data from the intent.
6441 *
6442 * @param name The name of the desired item.
6443 *
6444 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006445 * or null if no Bundle value was found.
6446 *
6447 * @see #putExtra(String, Bundle)
6448 */
6449 public Bundle getBundleExtra(String name) {
6450 return mExtras == null ? null : mExtras.getBundle(name);
6451 }
6452
6453 /**
6454 * Retrieve extended data from the intent.
6455 *
6456 * @param name The name of the desired item.
6457 *
6458 * @return the value of an item that previously added with putExtra()
6459 * or null if no IBinder value was found.
6460 *
6461 * @see #putExtra(String, IBinder)
6462 *
6463 * @deprecated
6464 * @hide
6465 */
6466 @Deprecated
6467 public IBinder getIBinderExtra(String name) {
6468 return mExtras == null ? null : mExtras.getIBinder(name);
6469 }
6470
6471 /**
6472 * Retrieve extended data from the intent.
6473 *
6474 * @param name The name of the desired item.
6475 * @param defaultValue The default value to return in case no item is
6476 * associated with the key 'name'
6477 *
6478 * @return the value of an item that previously added with putExtra()
6479 * or defaultValue if none was found.
6480 *
6481 * @see #putExtra
6482 *
6483 * @deprecated
6484 * @hide
6485 */
6486 @Deprecated
6487 public Object getExtra(String name, Object defaultValue) {
6488 Object result = defaultValue;
6489 if (mExtras != null) {
6490 Object result2 = mExtras.get(name);
6491 if (result2 != null) {
6492 result = result2;
6493 }
6494 }
6495
6496 return result;
6497 }
6498
6499 /**
6500 * Retrieves a map of extended data from the intent.
6501 *
6502 * @return the map of all extras previously added with putExtra(),
6503 * or null if none have been added.
6504 */
6505 public Bundle getExtras() {
6506 return (mExtras != null)
6507 ? new Bundle(mExtras)
6508 : null;
6509 }
6510
6511 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006512 * Filter extras to only basic types.
6513 * @hide
6514 */
6515 public void removeUnsafeExtras() {
6516 if (mExtras != null) {
6517 mExtras.filterValues();
6518 }
6519 }
6520
6521 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006522 * Retrieve any special flags associated with this intent. You will
6523 * normally just set them with {@link #setFlags} and let the system
6524 * take the appropriate action with them.
6525 *
6526 * @return int The currently set flags.
6527 *
6528 * @see #setFlags
6529 */
6530 public int getFlags() {
6531 return mFlags;
6532 }
6533
Dianne Hackborne7f97212011-02-24 14:40:20 -08006534 /** @hide */
6535 public boolean isExcludingStopped() {
6536 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6537 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6538 }
6539
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006540 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006541 * Retrieve the application package name this Intent is limited to. When
6542 * resolving an Intent, if non-null this limits the resolution to only
6543 * components in the given application package.
6544 *
6545 * @return The name of the application package for the Intent.
6546 *
6547 * @see #resolveActivity
6548 * @see #setPackage
6549 */
6550 public String getPackage() {
6551 return mPackage;
6552 }
6553
6554 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006555 * Retrieve the concrete component associated with the intent. When receiving
6556 * an intent, this is the component that was found to best handle it (that is,
6557 * yourself) and will always be non-null; in all other cases it will be
6558 * null unless explicitly set.
6559 *
6560 * @return The name of the application component to handle the intent.
6561 *
6562 * @see #resolveActivity
6563 * @see #setComponent
6564 */
6565 public ComponentName getComponent() {
6566 return mComponent;
6567 }
6568
6569 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006570 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6571 * used as a hint to the receiver for animations and the like. Null means that there
6572 * is no source bounds.
6573 */
6574 public Rect getSourceBounds() {
6575 return mSourceBounds;
6576 }
6577
6578 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006579 * Return the Activity component that should be used to handle this intent.
6580 * The appropriate component is determined based on the information in the
6581 * intent, evaluated as follows:
6582 *
6583 * <p>If {@link #getComponent} returns an explicit class, that is returned
6584 * without any further consideration.
6585 *
6586 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6587 * category to be considered.
6588 *
6589 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6590 * action.
6591 *
6592 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6593 * this type.
6594 *
6595 * <p>If {@link #addCategory} has added any categories, the activity must
6596 * handle ALL of the categories specified.
6597 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006598 * <p>If {@link #getPackage} is non-NULL, only activity components in
6599 * that application package will be considered.
6600 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006601 * <p>If there are no activities that satisfy all of these conditions, a
6602 * null string is returned.
6603 *
6604 * <p>If multiple activities are found to satisfy the intent, the one with
6605 * the highest priority will be used. If there are multiple activities
6606 * with the same priority, the system will either pick the best activity
6607 * based on user preference, or resolve to a system class that will allow
6608 * the user to pick an activity and forward from there.
6609 *
6610 * <p>This method is implemented simply by calling
6611 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6612 * true.</p>
6613 * <p> This API is called for you as part of starting an activity from an
6614 * intent. You do not normally need to call it yourself.</p>
6615 *
6616 * @param pm The package manager with which to resolve the Intent.
6617 *
6618 * @return Name of the component implementing an activity that can
6619 * display the intent.
6620 *
6621 * @see #setComponent
6622 * @see #getComponent
6623 * @see #resolveActivityInfo
6624 */
6625 public ComponentName resolveActivity(PackageManager pm) {
6626 if (mComponent != null) {
6627 return mComponent;
6628 }
6629
6630 ResolveInfo info = pm.resolveActivity(
6631 this, PackageManager.MATCH_DEFAULT_ONLY);
6632 if (info != null) {
6633 return new ComponentName(
6634 info.activityInfo.applicationInfo.packageName,
6635 info.activityInfo.name);
6636 }
6637
6638 return null;
6639 }
6640
6641 /**
6642 * Resolve the Intent into an {@link ActivityInfo}
6643 * describing the activity that should execute the intent. Resolution
6644 * follows the same rules as described for {@link #resolveActivity}, but
6645 * you get back the completely information about the resolved activity
6646 * instead of just its class name.
6647 *
6648 * @param pm The package manager with which to resolve the Intent.
6649 * @param flags Addition information to retrieve as per
6650 * {@link PackageManager#getActivityInfo(ComponentName, int)
6651 * PackageManager.getActivityInfo()}.
6652 *
6653 * @return PackageManager.ActivityInfo
6654 *
6655 * @see #resolveActivity
6656 */
6657 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6658 ActivityInfo ai = null;
6659 if (mComponent != null) {
6660 try {
6661 ai = pm.getActivityInfo(mComponent, flags);
6662 } catch (PackageManager.NameNotFoundException e) {
6663 // ignore
6664 }
6665 } else {
6666 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006667 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006668 if (info != null) {
6669 ai = info.activityInfo;
6670 }
6671 }
6672
6673 return ai;
6674 }
6675
6676 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006677 * Special function for use by the system to resolve service
6678 * intents to system apps. Throws an exception if there are
6679 * multiple potential matches to the Intent. Returns null if
6680 * there are no matches.
6681 * @hide
6682 */
6683 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6684 if (mComponent != null) {
6685 return mComponent;
6686 }
6687
6688 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6689 if (results == null) {
6690 return null;
6691 }
6692 ComponentName comp = null;
6693 for (int i=0; i<results.size(); i++) {
6694 ResolveInfo ri = results.get(i);
6695 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6696 continue;
6697 }
6698 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6699 ri.serviceInfo.name);
6700 if (comp != null) {
6701 throw new IllegalStateException("Multiple system services handle " + this
6702 + ": " + comp + ", " + foundComp);
6703 }
6704 comp = foundComp;
6705 }
6706 return comp;
6707 }
6708
6709 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006710 * Set the general action to be performed.
6711 *
6712 * @param action An action name, such as ACTION_VIEW. Application-specific
6713 * actions should be prefixed with the vendor's package name.
6714 *
6715 * @return Returns the same Intent object, for chaining multiple calls
6716 * into a single statement.
6717 *
6718 * @see #getAction
6719 */
6720 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006721 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006722 return this;
6723 }
6724
6725 /**
6726 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006727 * clears any type that was previously set by {@link #setType} or
6728 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006729 *
Nick Pellyccae4122012-01-09 14:12:58 -08006730 * <p><em>Note: scheme matching in the Android framework is
6731 * case-sensitive, unlike the formal RFC. As a result,
6732 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006733 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006734 * {@link #setDataAndNormalize}
6735 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006736 *
Nick Pellyccae4122012-01-09 14:12:58 -08006737 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006738 *
6739 * @return Returns the same Intent object, for chaining multiple calls
6740 * into a single statement.
6741 *
6742 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006743 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006744 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006745 */
6746 public Intent setData(Uri data) {
6747 mData = data;
6748 mType = null;
6749 return this;
6750 }
6751
6752 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006753 * Normalize and set the data this intent is operating on.
6754 *
6755 * <p>This method automatically clears any type that was
6756 * previously set (for example, by {@link #setType}).
6757 *
6758 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006759 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006760 * so really this is just a convenience method for
6761 * <pre>
6762 * setData(data.normalize())
6763 * </pre>
6764 *
6765 * @param data The Uri of the data this intent is now targeting.
6766 *
6767 * @return Returns the same Intent object, for chaining multiple calls
6768 * into a single statement.
6769 *
6770 * @see #getData
6771 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006772 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006773 */
6774 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006775 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006776 }
6777
6778 /**
6779 * Set an explicit MIME data type.
6780 *
6781 * <p>This is used to create intents that only specify a type and not data,
6782 * for example to indicate the type of data to return.
6783 *
6784 * <p>This method automatically clears any data that was
6785 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006786 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006787 * <p><em>Note: MIME type matching in the Android framework is
6788 * case-sensitive, unlike formal RFC MIME types. As a result,
6789 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006790 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6791 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006792 *
6793 * @param type The MIME type of the data being handled by this intent.
6794 *
6795 * @return Returns the same Intent object, for chaining multiple calls
6796 * into a single statement.
6797 *
6798 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006799 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006800 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006801 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006802 */
6803 public Intent setType(String type) {
6804 mData = null;
6805 mType = type;
6806 return this;
6807 }
6808
6809 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006810 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006811 *
Nick Pellyccae4122012-01-09 14:12:58 -08006812 * <p>This is used to create intents that only specify a type and not data,
6813 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006814 *
Nick Pellyccae4122012-01-09 14:12:58 -08006815 * <p>This method automatically clears any data that was
6816 * previously set (for example by {@link #setData}).
6817 *
6818 * <p>The MIME type is normalized using
6819 * {@link #normalizeMimeType} before it is set,
6820 * so really this is just a convenience method for
6821 * <pre>
6822 * setType(Intent.normalizeMimeType(type))
6823 * </pre>
6824 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006825 * @param type The MIME type of the data being handled by this intent.
6826 *
6827 * @return Returns the same Intent object, for chaining multiple calls
6828 * into a single statement.
6829 *
Nick Pellyccae4122012-01-09 14:12:58 -08006830 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006831 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006832 * @see #normalizeMimeType
6833 */
6834 public Intent setTypeAndNormalize(String type) {
6835 return setType(normalizeMimeType(type));
6836 }
6837
6838 /**
6839 * (Usually optional) Set the data for the intent along with an explicit
6840 * MIME data type. This method should very rarely be used -- it allows you
6841 * to override the MIME type that would ordinarily be inferred from the
6842 * data with your own type given here.
6843 *
6844 * <p><em>Note: MIME type and Uri scheme matching in the
6845 * Android framework is case-sensitive, unlike the formal RFC definitions.
6846 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006847 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006848 * {@link #setDataAndTypeAndNormalize}
6849 * to ensure that they are converted to lower case.</em>
6850 *
6851 * @param data The Uri of the data this intent is now targeting.
6852 * @param type The MIME type of the data being handled by this intent.
6853 *
6854 * @return Returns the same Intent object, for chaining multiple calls
6855 * into a single statement.
6856 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006857 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006858 * @see #setData
6859 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006860 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006861 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006862 */
6863 public Intent setDataAndType(Uri data, String type) {
6864 mData = data;
6865 mType = type;
6866 return this;
6867 }
6868
6869 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006870 * (Usually optional) Normalize and set both the data Uri and an explicit
6871 * MIME data type. This method should very rarely be used -- it allows you
6872 * to override the MIME type that would ordinarily be inferred from the
6873 * data with your own type given here.
6874 *
6875 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006876 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006877 * before they are set, so really this is just a convenience method for
6878 * <pre>
6879 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6880 * </pre>
6881 *
6882 * @param data The Uri of the data this intent is now targeting.
6883 * @param type The MIME type of the data being handled by this intent.
6884 *
6885 * @return Returns the same Intent object, for chaining multiple calls
6886 * into a single statement.
6887 *
6888 * @see #setType
6889 * @see #setData
6890 * @see #setDataAndType
6891 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006892 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006893 */
6894 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006895 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006896 }
6897
6898 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006899 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006900 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006901 * activities that provide <em>all</em> of the requested categories will be
6902 * used.
6903 *
6904 * @param category The desired category. This can be either one of the
6905 * predefined Intent categories, or a custom category in your own
6906 * namespace.
6907 *
6908 * @return Returns the same Intent object, for chaining multiple calls
6909 * into a single statement.
6910 *
6911 * @see #hasCategory
6912 * @see #removeCategory
6913 */
6914 public Intent addCategory(String category) {
6915 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006916 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006917 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006918 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006919 return this;
6920 }
6921
6922 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006923 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 *
6925 * @param category The category to remove.
6926 *
6927 * @see #addCategory
6928 */
6929 public void removeCategory(String category) {
6930 if (mCategories != null) {
6931 mCategories.remove(category);
6932 if (mCategories.size() == 0) {
6933 mCategories = null;
6934 }
6935 }
6936 }
6937
6938 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006939 * Set a selector for this Intent. This is a modification to the kinds of
6940 * things the Intent will match. If the selector is set, it will be used
6941 * when trying to find entities that can handle the Intent, instead of the
6942 * main contents of the Intent. This allows you build an Intent containing
6943 * a generic protocol while targeting it more specifically.
6944 *
6945 * <p>An example of where this may be used is with things like
6946 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6947 * Intent that will launch the Browser application. However, the correct
6948 * main entry point of an application is actually {@link #ACTION_MAIN}
6949 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6950 * used to specify the actual Activity to launch. If you launch the browser
6951 * with something different, undesired behavior may happen if the user has
6952 * previously or later launches it the normal way, since they do not match.
6953 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6954 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6955 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6956 *
6957 * <p>Setting a selector does not impact the behavior of
6958 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6959 * desired behavior of a selector -- it does not impact the base meaning
6960 * of the Intent, just what kinds of things will be matched against it
6961 * when determining who can handle it.</p>
6962 *
6963 * <p>You can not use both a selector and {@link #setPackage(String)} on
6964 * the same base Intent.</p>
6965 *
6966 * @param selector The desired selector Intent; set to null to not use
6967 * a special selector.
6968 */
6969 public void setSelector(Intent selector) {
6970 if (selector == this) {
6971 throw new IllegalArgumentException(
6972 "Intent being set as a selector of itself");
6973 }
6974 if (selector != null && mPackage != null) {
6975 throw new IllegalArgumentException(
6976 "Can't set selector when package name is already set");
6977 }
6978 mSelector = selector;
6979 }
6980
6981 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006982 * Set a {@link ClipData} associated with this Intent. This replaces any
6983 * previously set ClipData.
6984 *
6985 * <p>The ClipData in an intent is not used for Intent matching or other
6986 * such operations. Semantically it is like extras, used to transmit
6987 * additional data with the Intent. The main feature of using this over
6988 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
6989 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
6990 * items included in the clip data. This is useful, in particular, if
6991 * you want to transmit an Intent containing multiple <code>content:</code>
6992 * URIs for which the recipient may not have global permission to access the
6993 * content provider.
6994 *
6995 * <p>If the ClipData contains items that are themselves Intents, any
6996 * grant flags in those Intents will be ignored. Only the top-level flags
6997 * of the main Intent are respected, and will be applied to all Uri or
6998 * Intent items in the clip (or sub-items of the clip).
6999 *
7000 * <p>The MIME type, label, and icon in the ClipData object are not
7001 * directly used by Intent. Applications should generally rely on the
7002 * MIME type of the Intent itself, not what it may find in the ClipData.
7003 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007004 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007005 *
7006 * @param clip The new clip to set. May be null to clear the current clip.
7007 */
7008 public void setClipData(ClipData clip) {
7009 mClipData = clip;
7010 }
7011
7012 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007013 * This is NOT a secure mechanism to identify the user who sent the intent.
7014 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7015 * who sent the intent.
7016 * @hide
7017 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007018 public void prepareToLeaveUser(int userId) {
7019 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7020 // We want mContentUserHint to refer to the original user, so don't do anything.
7021 if (mContentUserHint == UserHandle.USER_CURRENT) {
7022 mContentUserHint = userId;
7023 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007024 }
7025
7026 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007027 * Add extended data to the intent. The name must include a package
7028 * prefix, for example the app com.android.contacts would use names
7029 * like "com.android.contacts.ShowAll".
7030 *
7031 * @param name The name of the extra data, with package prefix.
7032 * @param value The boolean data value.
7033 *
7034 * @return Returns the same Intent object, for chaining multiple calls
7035 * into a single statement.
7036 *
7037 * @see #putExtras
7038 * @see #removeExtra
7039 * @see #getBooleanExtra(String, boolean)
7040 */
7041 public Intent putExtra(String name, boolean value) {
7042 if (mExtras == null) {
7043 mExtras = new Bundle();
7044 }
7045 mExtras.putBoolean(name, value);
7046 return this;
7047 }
7048
7049 /**
7050 * Add extended data to the intent. The name must include a package
7051 * prefix, for example the app com.android.contacts would use names
7052 * like "com.android.contacts.ShowAll".
7053 *
7054 * @param name The name of the extra data, with package prefix.
7055 * @param value The byte data value.
7056 *
7057 * @return Returns the same Intent object, for chaining multiple calls
7058 * into a single statement.
7059 *
7060 * @see #putExtras
7061 * @see #removeExtra
7062 * @see #getByteExtra(String, byte)
7063 */
7064 public Intent putExtra(String name, byte value) {
7065 if (mExtras == null) {
7066 mExtras = new Bundle();
7067 }
7068 mExtras.putByte(name, value);
7069 return this;
7070 }
7071
7072 /**
7073 * Add extended data to the intent. The name must include a package
7074 * prefix, for example the app com.android.contacts would use names
7075 * like "com.android.contacts.ShowAll".
7076 *
7077 * @param name The name of the extra data, with package prefix.
7078 * @param value The char data value.
7079 *
7080 * @return Returns the same Intent object, for chaining multiple calls
7081 * into a single statement.
7082 *
7083 * @see #putExtras
7084 * @see #removeExtra
7085 * @see #getCharExtra(String, char)
7086 */
7087 public Intent putExtra(String name, char value) {
7088 if (mExtras == null) {
7089 mExtras = new Bundle();
7090 }
7091 mExtras.putChar(name, value);
7092 return this;
7093 }
7094
7095 /**
7096 * Add extended data to the intent. The name must include a package
7097 * prefix, for example the app com.android.contacts would use names
7098 * like "com.android.contacts.ShowAll".
7099 *
7100 * @param name The name of the extra data, with package prefix.
7101 * @param value The short data value.
7102 *
7103 * @return Returns the same Intent object, for chaining multiple calls
7104 * into a single statement.
7105 *
7106 * @see #putExtras
7107 * @see #removeExtra
7108 * @see #getShortExtra(String, short)
7109 */
7110 public Intent putExtra(String name, short value) {
7111 if (mExtras == null) {
7112 mExtras = new Bundle();
7113 }
7114 mExtras.putShort(name, value);
7115 return this;
7116 }
7117
7118 /**
7119 * Add extended data to the intent. The name must include a package
7120 * prefix, for example the app com.android.contacts would use names
7121 * like "com.android.contacts.ShowAll".
7122 *
7123 * @param name The name of the extra data, with package prefix.
7124 * @param value The integer data value.
7125 *
7126 * @return Returns the same Intent object, for chaining multiple calls
7127 * into a single statement.
7128 *
7129 * @see #putExtras
7130 * @see #removeExtra
7131 * @see #getIntExtra(String, int)
7132 */
7133 public Intent putExtra(String name, int value) {
7134 if (mExtras == null) {
7135 mExtras = new Bundle();
7136 }
7137 mExtras.putInt(name, value);
7138 return this;
7139 }
7140
7141 /**
7142 * Add extended data to the intent. The name must include a package
7143 * prefix, for example the app com.android.contacts would use names
7144 * like "com.android.contacts.ShowAll".
7145 *
7146 * @param name The name of the extra data, with package prefix.
7147 * @param value The long data value.
7148 *
7149 * @return Returns the same Intent object, for chaining multiple calls
7150 * into a single statement.
7151 *
7152 * @see #putExtras
7153 * @see #removeExtra
7154 * @see #getLongExtra(String, long)
7155 */
7156 public Intent putExtra(String name, long value) {
7157 if (mExtras == null) {
7158 mExtras = new Bundle();
7159 }
7160 mExtras.putLong(name, value);
7161 return this;
7162 }
7163
7164 /**
7165 * Add extended data to the intent. The name must include a package
7166 * prefix, for example the app com.android.contacts would use names
7167 * like "com.android.contacts.ShowAll".
7168 *
7169 * @param name The name of the extra data, with package prefix.
7170 * @param value The float data value.
7171 *
7172 * @return Returns the same Intent object, for chaining multiple calls
7173 * into a single statement.
7174 *
7175 * @see #putExtras
7176 * @see #removeExtra
7177 * @see #getFloatExtra(String, float)
7178 */
7179 public Intent putExtra(String name, float value) {
7180 if (mExtras == null) {
7181 mExtras = new Bundle();
7182 }
7183 mExtras.putFloat(name, value);
7184 return this;
7185 }
7186
7187 /**
7188 * Add extended data to the intent. The name must include a package
7189 * prefix, for example the app com.android.contacts would use names
7190 * like "com.android.contacts.ShowAll".
7191 *
7192 * @param name The name of the extra data, with package prefix.
7193 * @param value The double data value.
7194 *
7195 * @return Returns the same Intent object, for chaining multiple calls
7196 * into a single statement.
7197 *
7198 * @see #putExtras
7199 * @see #removeExtra
7200 * @see #getDoubleExtra(String, double)
7201 */
7202 public Intent putExtra(String name, double value) {
7203 if (mExtras == null) {
7204 mExtras = new Bundle();
7205 }
7206 mExtras.putDouble(name, value);
7207 return this;
7208 }
7209
7210 /**
7211 * Add extended data to the intent. The name must include a package
7212 * prefix, for example the app com.android.contacts would use names
7213 * like "com.android.contacts.ShowAll".
7214 *
7215 * @param name The name of the extra data, with package prefix.
7216 * @param value The String data value.
7217 *
7218 * @return Returns the same Intent object, for chaining multiple calls
7219 * into a single statement.
7220 *
7221 * @see #putExtras
7222 * @see #removeExtra
7223 * @see #getStringExtra(String)
7224 */
7225 public Intent putExtra(String name, String value) {
7226 if (mExtras == null) {
7227 mExtras = new Bundle();
7228 }
7229 mExtras.putString(name, value);
7230 return this;
7231 }
7232
7233 /**
7234 * Add extended data to the intent. The name must include a package
7235 * prefix, for example the app com.android.contacts would use names
7236 * like "com.android.contacts.ShowAll".
7237 *
7238 * @param name The name of the extra data, with package prefix.
7239 * @param value The CharSequence data value.
7240 *
7241 * @return Returns the same Intent object, for chaining multiple calls
7242 * into a single statement.
7243 *
7244 * @see #putExtras
7245 * @see #removeExtra
7246 * @see #getCharSequenceExtra(String)
7247 */
7248 public Intent putExtra(String name, CharSequence value) {
7249 if (mExtras == null) {
7250 mExtras = new Bundle();
7251 }
7252 mExtras.putCharSequence(name, value);
7253 return this;
7254 }
7255
7256 /**
7257 * Add extended data to the intent. The name must include a package
7258 * prefix, for example the app com.android.contacts would use names
7259 * like "com.android.contacts.ShowAll".
7260 *
7261 * @param name The name of the extra data, with package prefix.
7262 * @param value The Parcelable data value.
7263 *
7264 * @return Returns the same Intent object, for chaining multiple calls
7265 * into a single statement.
7266 *
7267 * @see #putExtras
7268 * @see #removeExtra
7269 * @see #getParcelableExtra(String)
7270 */
7271 public Intent putExtra(String name, Parcelable value) {
7272 if (mExtras == null) {
7273 mExtras = new Bundle();
7274 }
7275 mExtras.putParcelable(name, value);
7276 return this;
7277 }
7278
7279 /**
7280 * Add extended data to the intent. The name must include a package
7281 * prefix, for example the app com.android.contacts would use names
7282 * like "com.android.contacts.ShowAll".
7283 *
7284 * @param name The name of the extra data, with package prefix.
7285 * @param value The Parcelable[] data value.
7286 *
7287 * @return Returns the same Intent object, for chaining multiple calls
7288 * into a single statement.
7289 *
7290 * @see #putExtras
7291 * @see #removeExtra
7292 * @see #getParcelableArrayExtra(String)
7293 */
7294 public Intent putExtra(String name, Parcelable[] value) {
7295 if (mExtras == null) {
7296 mExtras = new Bundle();
7297 }
7298 mExtras.putParcelableArray(name, value);
7299 return this;
7300 }
7301
7302 /**
7303 * Add extended data to the intent. The name must include a package
7304 * prefix, for example the app com.android.contacts would use names
7305 * like "com.android.contacts.ShowAll".
7306 *
7307 * @param name The name of the extra data, with package prefix.
7308 * @param value The ArrayList<Parcelable> data value.
7309 *
7310 * @return Returns the same Intent object, for chaining multiple calls
7311 * into a single statement.
7312 *
7313 * @see #putExtras
7314 * @see #removeExtra
7315 * @see #getParcelableArrayListExtra(String)
7316 */
7317 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7318 if (mExtras == null) {
7319 mExtras = new Bundle();
7320 }
7321 mExtras.putParcelableArrayList(name, value);
7322 return this;
7323 }
7324
7325 /**
7326 * Add extended data to the intent. The name must include a package
7327 * prefix, for example the app com.android.contacts would use names
7328 * like "com.android.contacts.ShowAll".
7329 *
7330 * @param name The name of the extra data, with package prefix.
7331 * @param value The ArrayList<Integer> data value.
7332 *
7333 * @return Returns the same Intent object, for chaining multiple calls
7334 * into a single statement.
7335 *
7336 * @see #putExtras
7337 * @see #removeExtra
7338 * @see #getIntegerArrayListExtra(String)
7339 */
7340 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7341 if (mExtras == null) {
7342 mExtras = new Bundle();
7343 }
7344 mExtras.putIntegerArrayList(name, value);
7345 return this;
7346 }
7347
7348 /**
7349 * Add extended data to the intent. The name must include a package
7350 * prefix, for example the app com.android.contacts would use names
7351 * like "com.android.contacts.ShowAll".
7352 *
7353 * @param name The name of the extra data, with package prefix.
7354 * @param value The ArrayList<String> data value.
7355 *
7356 * @return Returns the same Intent object, for chaining multiple calls
7357 * into a single statement.
7358 *
7359 * @see #putExtras
7360 * @see #removeExtra
7361 * @see #getStringArrayListExtra(String)
7362 */
7363 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7364 if (mExtras == null) {
7365 mExtras = new Bundle();
7366 }
7367 mExtras.putStringArrayList(name, value);
7368 return this;
7369 }
7370
7371 /**
7372 * Add extended data to the intent. The name must include a package
7373 * prefix, for example the app com.android.contacts would use names
7374 * like "com.android.contacts.ShowAll".
7375 *
7376 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007377 * @param value The ArrayList<CharSequence> data value.
7378 *
7379 * @return Returns the same Intent object, for chaining multiple calls
7380 * into a single statement.
7381 *
7382 * @see #putExtras
7383 * @see #removeExtra
7384 * @see #getCharSequenceArrayListExtra(String)
7385 */
7386 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7387 if (mExtras == null) {
7388 mExtras = new Bundle();
7389 }
7390 mExtras.putCharSequenceArrayList(name, value);
7391 return this;
7392 }
7393
7394 /**
7395 * Add extended data to the intent. The name must include a package
7396 * prefix, for example the app com.android.contacts would use names
7397 * like "com.android.contacts.ShowAll".
7398 *
7399 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007400 * @param value The Serializable data value.
7401 *
7402 * @return Returns the same Intent object, for chaining multiple calls
7403 * into a single statement.
7404 *
7405 * @see #putExtras
7406 * @see #removeExtra
7407 * @see #getSerializableExtra(String)
7408 */
7409 public Intent putExtra(String name, Serializable value) {
7410 if (mExtras == null) {
7411 mExtras = new Bundle();
7412 }
7413 mExtras.putSerializable(name, value);
7414 return this;
7415 }
7416
7417 /**
7418 * Add extended data to the intent. The name must include a package
7419 * prefix, for example the app com.android.contacts would use names
7420 * like "com.android.contacts.ShowAll".
7421 *
7422 * @param name The name of the extra data, with package prefix.
7423 * @param value The boolean array data value.
7424 *
7425 * @return Returns the same Intent object, for chaining multiple calls
7426 * into a single statement.
7427 *
7428 * @see #putExtras
7429 * @see #removeExtra
7430 * @see #getBooleanArrayExtra(String)
7431 */
7432 public Intent putExtra(String name, boolean[] value) {
7433 if (mExtras == null) {
7434 mExtras = new Bundle();
7435 }
7436 mExtras.putBooleanArray(name, value);
7437 return this;
7438 }
7439
7440 /**
7441 * Add extended data to the intent. The name must include a package
7442 * prefix, for example the app com.android.contacts would use names
7443 * like "com.android.contacts.ShowAll".
7444 *
7445 * @param name The name of the extra data, with package prefix.
7446 * @param value The byte array data value.
7447 *
7448 * @return Returns the same Intent object, for chaining multiple calls
7449 * into a single statement.
7450 *
7451 * @see #putExtras
7452 * @see #removeExtra
7453 * @see #getByteArrayExtra(String)
7454 */
7455 public Intent putExtra(String name, byte[] value) {
7456 if (mExtras == null) {
7457 mExtras = new Bundle();
7458 }
7459 mExtras.putByteArray(name, value);
7460 return this;
7461 }
7462
7463 /**
7464 * Add extended data to the intent. The name must include a package
7465 * prefix, for example the app com.android.contacts would use names
7466 * like "com.android.contacts.ShowAll".
7467 *
7468 * @param name The name of the extra data, with package prefix.
7469 * @param value The short array data value.
7470 *
7471 * @return Returns the same Intent object, for chaining multiple calls
7472 * into a single statement.
7473 *
7474 * @see #putExtras
7475 * @see #removeExtra
7476 * @see #getShortArrayExtra(String)
7477 */
7478 public Intent putExtra(String name, short[] value) {
7479 if (mExtras == null) {
7480 mExtras = new Bundle();
7481 }
7482 mExtras.putShortArray(name, value);
7483 return this;
7484 }
7485
7486 /**
7487 * Add extended data to the intent. The name must include a package
7488 * prefix, for example the app com.android.contacts would use names
7489 * like "com.android.contacts.ShowAll".
7490 *
7491 * @param name The name of the extra data, with package prefix.
7492 * @param value The char array data value.
7493 *
7494 * @return Returns the same Intent object, for chaining multiple calls
7495 * into a single statement.
7496 *
7497 * @see #putExtras
7498 * @see #removeExtra
7499 * @see #getCharArrayExtra(String)
7500 */
7501 public Intent putExtra(String name, char[] value) {
7502 if (mExtras == null) {
7503 mExtras = new Bundle();
7504 }
7505 mExtras.putCharArray(name, value);
7506 return this;
7507 }
7508
7509 /**
7510 * Add extended data to the intent. The name must include a package
7511 * prefix, for example the app com.android.contacts would use names
7512 * like "com.android.contacts.ShowAll".
7513 *
7514 * @param name The name of the extra data, with package prefix.
7515 * @param value The int array data value.
7516 *
7517 * @return Returns the same Intent object, for chaining multiple calls
7518 * into a single statement.
7519 *
7520 * @see #putExtras
7521 * @see #removeExtra
7522 * @see #getIntArrayExtra(String)
7523 */
7524 public Intent putExtra(String name, int[] value) {
7525 if (mExtras == null) {
7526 mExtras = new Bundle();
7527 }
7528 mExtras.putIntArray(name, value);
7529 return this;
7530 }
7531
7532 /**
7533 * Add extended data to the intent. The name must include a package
7534 * prefix, for example the app com.android.contacts would use names
7535 * like "com.android.contacts.ShowAll".
7536 *
7537 * @param name The name of the extra data, with package prefix.
7538 * @param value The byte array data value.
7539 *
7540 * @return Returns the same Intent object, for chaining multiple calls
7541 * into a single statement.
7542 *
7543 * @see #putExtras
7544 * @see #removeExtra
7545 * @see #getLongArrayExtra(String)
7546 */
7547 public Intent putExtra(String name, long[] value) {
7548 if (mExtras == null) {
7549 mExtras = new Bundle();
7550 }
7551 mExtras.putLongArray(name, value);
7552 return this;
7553 }
7554
7555 /**
7556 * Add extended data to the intent. The name must include a package
7557 * prefix, for example the app com.android.contacts would use names
7558 * like "com.android.contacts.ShowAll".
7559 *
7560 * @param name The name of the extra data, with package prefix.
7561 * @param value The float array data value.
7562 *
7563 * @return Returns the same Intent object, for chaining multiple calls
7564 * into a single statement.
7565 *
7566 * @see #putExtras
7567 * @see #removeExtra
7568 * @see #getFloatArrayExtra(String)
7569 */
7570 public Intent putExtra(String name, float[] value) {
7571 if (mExtras == null) {
7572 mExtras = new Bundle();
7573 }
7574 mExtras.putFloatArray(name, value);
7575 return this;
7576 }
7577
7578 /**
7579 * Add extended data to the intent. The name must include a package
7580 * prefix, for example the app com.android.contacts would use names
7581 * like "com.android.contacts.ShowAll".
7582 *
7583 * @param name The name of the extra data, with package prefix.
7584 * @param value The double array data value.
7585 *
7586 * @return Returns the same Intent object, for chaining multiple calls
7587 * into a single statement.
7588 *
7589 * @see #putExtras
7590 * @see #removeExtra
7591 * @see #getDoubleArrayExtra(String)
7592 */
7593 public Intent putExtra(String name, double[] value) {
7594 if (mExtras == null) {
7595 mExtras = new Bundle();
7596 }
7597 mExtras.putDoubleArray(name, value);
7598 return this;
7599 }
7600
7601 /**
7602 * Add extended data to the intent. The name must include a package
7603 * prefix, for example the app com.android.contacts would use names
7604 * like "com.android.contacts.ShowAll".
7605 *
7606 * @param name The name of the extra data, with package prefix.
7607 * @param value The String array data value.
7608 *
7609 * @return Returns the same Intent object, for chaining multiple calls
7610 * into a single statement.
7611 *
7612 * @see #putExtras
7613 * @see #removeExtra
7614 * @see #getStringArrayExtra(String)
7615 */
7616 public Intent putExtra(String name, String[] value) {
7617 if (mExtras == null) {
7618 mExtras = new Bundle();
7619 }
7620 mExtras.putStringArray(name, value);
7621 return this;
7622 }
7623
7624 /**
7625 * Add extended data to the intent. The name must include a package
7626 * prefix, for example the app com.android.contacts would use names
7627 * like "com.android.contacts.ShowAll".
7628 *
7629 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007630 * @param value The CharSequence array data value.
7631 *
7632 * @return Returns the same Intent object, for chaining multiple calls
7633 * into a single statement.
7634 *
7635 * @see #putExtras
7636 * @see #removeExtra
7637 * @see #getCharSequenceArrayExtra(String)
7638 */
7639 public Intent putExtra(String name, CharSequence[] value) {
7640 if (mExtras == null) {
7641 mExtras = new Bundle();
7642 }
7643 mExtras.putCharSequenceArray(name, value);
7644 return this;
7645 }
7646
7647 /**
7648 * Add extended data to the intent. The name must include a package
7649 * prefix, for example the app com.android.contacts would use names
7650 * like "com.android.contacts.ShowAll".
7651 *
7652 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007653 * @param value The Bundle data value.
7654 *
7655 * @return Returns the same Intent object, for chaining multiple calls
7656 * into a single statement.
7657 *
7658 * @see #putExtras
7659 * @see #removeExtra
7660 * @see #getBundleExtra(String)
7661 */
7662 public Intent putExtra(String name, Bundle value) {
7663 if (mExtras == null) {
7664 mExtras = new Bundle();
7665 }
7666 mExtras.putBundle(name, value);
7667 return this;
7668 }
7669
7670 /**
7671 * Add extended data to the intent. The name must include a package
7672 * prefix, for example the app com.android.contacts would use names
7673 * like "com.android.contacts.ShowAll".
7674 *
7675 * @param name The name of the extra data, with package prefix.
7676 * @param value The IBinder data value.
7677 *
7678 * @return Returns the same Intent object, for chaining multiple calls
7679 * into a single statement.
7680 *
7681 * @see #putExtras
7682 * @see #removeExtra
7683 * @see #getIBinderExtra(String)
7684 *
7685 * @deprecated
7686 * @hide
7687 */
7688 @Deprecated
7689 public Intent putExtra(String name, IBinder value) {
7690 if (mExtras == null) {
7691 mExtras = new Bundle();
7692 }
7693 mExtras.putIBinder(name, value);
7694 return this;
7695 }
7696
7697 /**
7698 * Copy all extras in 'src' in to this intent.
7699 *
7700 * @param src Contains the extras to copy.
7701 *
7702 * @see #putExtra
7703 */
7704 public Intent putExtras(Intent src) {
7705 if (src.mExtras != null) {
7706 if (mExtras == null) {
7707 mExtras = new Bundle(src.mExtras);
7708 } else {
7709 mExtras.putAll(src.mExtras);
7710 }
7711 }
7712 return this;
7713 }
7714
7715 /**
7716 * Add a set of extended data to the intent. The keys must include a package
7717 * prefix, for example the app com.android.contacts would use names
7718 * like "com.android.contacts.ShowAll".
7719 *
7720 * @param extras The Bundle of extras to add to this intent.
7721 *
7722 * @see #putExtra
7723 * @see #removeExtra
7724 */
7725 public Intent putExtras(Bundle extras) {
7726 if (mExtras == null) {
7727 mExtras = new Bundle();
7728 }
7729 mExtras.putAll(extras);
7730 return this;
7731 }
7732
7733 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007734 * Completely replace the extras in the Intent with the extras in the
7735 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007736 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007737 * @param src The exact extras contained in this Intent are copied
7738 * into the target intent, replacing any that were previously there.
7739 */
7740 public Intent replaceExtras(Intent src) {
7741 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7742 return this;
7743 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007744
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007745 /**
7746 * Completely replace the extras in the Intent with the given Bundle of
7747 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007748 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007749 * @param extras The new set of extras in the Intent, or null to erase
7750 * all extras.
7751 */
7752 public Intent replaceExtras(Bundle extras) {
7753 mExtras = extras != null ? new Bundle(extras) : null;
7754 return this;
7755 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007756
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007757 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007758 * Remove extended data from the intent.
7759 *
7760 * @see #putExtra
7761 */
7762 public void removeExtra(String name) {
7763 if (mExtras != null) {
7764 mExtras.remove(name);
7765 if (mExtras.size() == 0) {
7766 mExtras = null;
7767 }
7768 }
7769 }
7770
7771 /**
7772 * Set special flags controlling how this intent is handled. Most values
7773 * here depend on the type of component being executed by the Intent,
7774 * specifically the FLAG_ACTIVITY_* flags are all for use with
7775 * {@link Context#startActivity Context.startActivity()} and the
7776 * FLAG_RECEIVER_* flags are all for use with
7777 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7778 *
Scott Main7aee61f2011-02-08 11:25:01 -08007779 * <p>See the
7780 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7781 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007782 * the behavior of your application.
7783 *
7784 * @param flags The desired flags.
7785 *
7786 * @return Returns the same Intent object, for chaining multiple calls
7787 * into a single statement.
7788 *
7789 * @see #getFlags
7790 * @see #addFlags
7791 *
7792 * @see #FLAG_GRANT_READ_URI_PERMISSION
7793 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007794 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7795 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007796 * @see #FLAG_DEBUG_LOG_RESOLUTION
7797 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007798 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007799 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007800 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007801 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007802 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7803 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007804 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007805 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007806 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007807 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007808 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007809 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007810 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007811 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7812 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007813 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007814 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007815 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007816 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7817 */
7818 public Intent setFlags(int flags) {
7819 mFlags = flags;
7820 return this;
7821 }
7822
7823 /**
7824 * Add additional flags to the intent (or with existing flags
7825 * value).
7826 *
7827 * @param flags The new flags to set.
7828 *
7829 * @return Returns the same Intent object, for chaining multiple calls
7830 * into a single statement.
7831 *
7832 * @see #setFlags
7833 */
7834 public Intent addFlags(int flags) {
7835 mFlags |= flags;
7836 return this;
7837 }
7838
7839 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007840 * (Usually optional) Set an explicit application package name that limits
7841 * the components this Intent will resolve to. If left to the default
7842 * value of null, all components in all applications will considered.
7843 * If non-null, the Intent can only match the components in the given
7844 * application package.
7845 *
7846 * @param packageName The name of the application package to handle the
7847 * intent, or null to allow any application package.
7848 *
7849 * @return Returns the same Intent object, for chaining multiple calls
7850 * into a single statement.
7851 *
7852 * @see #getPackage
7853 * @see #resolveActivity
7854 */
7855 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007856 if (packageName != null && mSelector != null) {
7857 throw new IllegalArgumentException(
7858 "Can't set package name when selector is already set");
7859 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007860 mPackage = packageName;
7861 return this;
7862 }
7863
7864 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007865 * (Usually optional) Explicitly set the component to handle the intent.
7866 * If left with the default value of null, the system will determine the
7867 * appropriate class to use based on the other fields (action, data,
7868 * type, categories) in the Intent. If this class is defined, the
7869 * specified class will always be used regardless of the other fields. You
7870 * should only set this value when you know you absolutely want a specific
7871 * class to be used; otherwise it is better to let the system find the
7872 * appropriate class so that you will respect the installed applications
7873 * and user preferences.
7874 *
7875 * @param component The name of the application component to handle the
7876 * intent, or null to let the system find one for you.
7877 *
7878 * @return Returns the same Intent object, for chaining multiple calls
7879 * into a single statement.
7880 *
7881 * @see #setClass
7882 * @see #setClassName(Context, String)
7883 * @see #setClassName(String, String)
7884 * @see #getComponent
7885 * @see #resolveActivity
7886 */
7887 public Intent setComponent(ComponentName component) {
7888 mComponent = component;
7889 return this;
7890 }
7891
7892 /**
7893 * Convenience for calling {@link #setComponent} with an
7894 * explicit class name.
7895 *
7896 * @param packageContext A Context of the application package implementing
7897 * this class.
7898 * @param className The name of a class inside of the application package
7899 * that will be used as the component for this Intent.
7900 *
7901 * @return Returns the same Intent object, for chaining multiple calls
7902 * into a single statement.
7903 *
7904 * @see #setComponent
7905 * @see #setClass
7906 */
7907 public Intent setClassName(Context packageContext, String className) {
7908 mComponent = new ComponentName(packageContext, className);
7909 return this;
7910 }
7911
7912 /**
7913 * Convenience for calling {@link #setComponent} with an
7914 * explicit application package name and class name.
7915 *
7916 * @param packageName The name of the package implementing the desired
7917 * component.
7918 * @param className The name of a class inside of the application package
7919 * that will be used as the component for this Intent.
7920 *
7921 * @return Returns the same Intent object, for chaining multiple calls
7922 * into a single statement.
7923 *
7924 * @see #setComponent
7925 * @see #setClass
7926 */
7927 public Intent setClassName(String packageName, String className) {
7928 mComponent = new ComponentName(packageName, className);
7929 return this;
7930 }
7931
7932 /**
7933 * Convenience for calling {@link #setComponent(ComponentName)} with the
7934 * name returned by a {@link Class} object.
7935 *
7936 * @param packageContext A Context of the application package implementing
7937 * this class.
7938 * @param cls The class name to set, equivalent to
7939 * <code>setClassName(context, cls.getName())</code>.
7940 *
7941 * @return Returns the same Intent object, for chaining multiple calls
7942 * into a single statement.
7943 *
7944 * @see #setComponent
7945 */
7946 public Intent setClass(Context packageContext, Class<?> cls) {
7947 mComponent = new ComponentName(packageContext, cls);
7948 return this;
7949 }
7950
7951 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007952 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7953 * used as a hint to the receiver for animations and the like. Null means that there
7954 * is no source bounds.
7955 */
7956 public void setSourceBounds(Rect r) {
7957 if (r != null) {
7958 mSourceBounds = new Rect(r);
7959 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007960 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007961 }
7962 }
7963
Tor Norbyed9273d62013-05-30 15:59:53 -07007964 /** @hide */
7965 @IntDef(flag = true,
7966 value = {
7967 FILL_IN_ACTION,
7968 FILL_IN_DATA,
7969 FILL_IN_CATEGORIES,
7970 FILL_IN_COMPONENT,
7971 FILL_IN_PACKAGE,
7972 FILL_IN_SOURCE_BOUNDS,
7973 FILL_IN_SELECTOR,
7974 FILL_IN_CLIP_DATA
7975 })
7976 @Retention(RetentionPolicy.SOURCE)
7977 public @interface FillInFlags {}
7978
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007979 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007980 * Use with {@link #fillIn} to allow the current action value to be
7981 * overwritten, even if it is already set.
7982 */
7983 public static final int FILL_IN_ACTION = 1<<0;
7984
7985 /**
7986 * Use with {@link #fillIn} to allow the current data or type value
7987 * overwritten, even if it is already set.
7988 */
7989 public static final int FILL_IN_DATA = 1<<1;
7990
7991 /**
7992 * Use with {@link #fillIn} to allow the current categories to be
7993 * overwritten, even if they are already set.
7994 */
7995 public static final int FILL_IN_CATEGORIES = 1<<2;
7996
7997 /**
7998 * Use with {@link #fillIn} to allow the current component value to be
7999 * overwritten, even if it is already set.
8000 */
8001 public static final int FILL_IN_COMPONENT = 1<<3;
8002
8003 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008004 * Use with {@link #fillIn} to allow the current package value to be
8005 * overwritten, even if it is already set.
8006 */
8007 public static final int FILL_IN_PACKAGE = 1<<4;
8008
8009 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008010 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008011 * overwritten, even if it is already set.
8012 */
8013 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8014
8015 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008016 * Use with {@link #fillIn} to allow the current selector to be
8017 * overwritten, even if it is already set.
8018 */
8019 public static final int FILL_IN_SELECTOR = 1<<6;
8020
8021 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008022 * Use with {@link #fillIn} to allow the current ClipData to be
8023 * overwritten, even if it is already set.
8024 */
8025 public static final int FILL_IN_CLIP_DATA = 1<<7;
8026
8027 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008028 * Copy the contents of <var>other</var> in to this object, but only
8029 * where fields are not defined by this object. For purposes of a field
8030 * being defined, the following pieces of data in the Intent are
8031 * considered to be separate fields:
8032 *
8033 * <ul>
8034 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008035 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008036 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8037 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008038 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008039 * <li> component, as set by {@link #setComponent(ComponentName)} or
8040 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008041 * <li> source bounds, as set by {@link #setSourceBounds}.
8042 * <li> selector, as set by {@link #setSelector(Intent)}.
8043 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008044 * <li> each top-level name in the associated extras.
8045 * </ul>
8046 *
8047 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008048 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008049 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8050 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8051 * the restriction where the corresponding field will not be replaced if
8052 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008053 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008054 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8055 * is explicitly specified. The selector will only be copied if
8056 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008057 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008058 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8059 * and Intent B with {action="gotit", data-type="some/thing",
8060 * categories="one","two"}.
8061 *
8062 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8063 * containing: {action="gotit", data-type="some/thing",
8064 * categories="bar"}.
8065 *
8066 * @param other Another Intent whose values are to be used to fill in
8067 * the current one.
8068 * @param flags Options to control which fields can be filled in.
8069 *
8070 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008071 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008072 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8073 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8074 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008075 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008076 @FillInFlags
8077 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008078 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008079 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008080 if (other.mAction != null
8081 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008082 mAction = other.mAction;
8083 changes |= FILL_IN_ACTION;
8084 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008085 if ((other.mData != null || other.mType != null)
8086 && ((mData == null && mType == null)
8087 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008088 mData = other.mData;
8089 mType = other.mType;
8090 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008091 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008092 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008093 if (other.mCategories != null
8094 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008095 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008096 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008097 }
8098 changes |= FILL_IN_CATEGORIES;
8099 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008100 if (other.mPackage != null
8101 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008102 // Only do this if mSelector is not set.
8103 if (mSelector == null) {
8104 mPackage = other.mPackage;
8105 changes |= FILL_IN_PACKAGE;
8106 }
8107 }
8108 // Selector is special: it can only be set if explicitly allowed,
8109 // for the same reason as the component name.
8110 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8111 if (mPackage == null) {
8112 mSelector = new Intent(other.mSelector);
8113 mPackage = null;
8114 changes |= FILL_IN_SELECTOR;
8115 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008116 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008117 if (other.mClipData != null
8118 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8119 mClipData = other.mClipData;
8120 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008121 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008122 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008123 // Component is special: it can -only- be set if explicitly allowed,
8124 // since otherwise the sender could force the intent somewhere the
8125 // originator didn't intend.
8126 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008127 mComponent = other.mComponent;
8128 changes |= FILL_IN_COMPONENT;
8129 }
8130 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008131 if (other.mSourceBounds != null
8132 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8133 mSourceBounds = new Rect(other.mSourceBounds);
8134 changes |= FILL_IN_SOURCE_BOUNDS;
8135 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008136 if (mExtras == null) {
8137 if (other.mExtras != null) {
8138 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008139 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008140 }
8141 } else if (other.mExtras != null) {
8142 try {
8143 Bundle newb = new Bundle(other.mExtras);
8144 newb.putAll(mExtras);
8145 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008146 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008147 } catch (RuntimeException e) {
8148 // Modifying the extras can cause us to unparcel the contents
8149 // of the bundle, and if we do this in the system process that
8150 // may fail. We really should handle this (i.e., the Bundle
8151 // impl shouldn't be on top of a plain map), but for now just
8152 // ignore it and keep the original contents. :(
8153 Log.w("Intent", "Failure filling in extras", e);
8154 }
8155 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008156 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8157 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8158 mContentUserHint = other.mContentUserHint;
8159 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008160 return changes;
8161 }
8162
8163 /**
8164 * Wrapper class holding an Intent and implementing comparisons on it for
8165 * the purpose of filtering. The class implements its
8166 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8167 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8168 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8169 * on the wrapped Intent.
8170 */
8171 public static final class FilterComparison {
8172 private final Intent mIntent;
8173 private final int mHashCode;
8174
8175 public FilterComparison(Intent intent) {
8176 mIntent = intent;
8177 mHashCode = intent.filterHashCode();
8178 }
8179
8180 /**
8181 * Return the Intent that this FilterComparison represents.
8182 * @return Returns the Intent held by the FilterComparison. Do
8183 * not modify!
8184 */
8185 public Intent getIntent() {
8186 return mIntent;
8187 }
8188
8189 @Override
8190 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008191 if (obj instanceof FilterComparison) {
8192 Intent other = ((FilterComparison)obj).mIntent;
8193 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008194 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008195 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008196 }
8197
8198 @Override
8199 public int hashCode() {
8200 return mHashCode;
8201 }
8202 }
8203
8204 /**
8205 * Determine if two intents are the same for the purposes of intent
8206 * resolution (filtering). That is, if their action, data, type,
8207 * class, and categories are the same. This does <em>not</em> compare
8208 * any extra data included in the intents.
8209 *
8210 * @param other The other Intent to compare against.
8211 *
8212 * @return Returns true if action, data, type, class, and categories
8213 * are the same.
8214 */
8215 public boolean filterEquals(Intent other) {
8216 if (other == null) {
8217 return false;
8218 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008219 if (!Objects.equals(this.mAction, other.mAction)) return false;
8220 if (!Objects.equals(this.mData, other.mData)) return false;
8221 if (!Objects.equals(this.mType, other.mType)) return false;
8222 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8223 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8224 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008225
8226 return true;
8227 }
8228
8229 /**
8230 * Generate hash code that matches semantics of filterEquals().
8231 *
8232 * @return Returns the hash value of the action, data, type, class, and
8233 * categories.
8234 *
8235 * @see #filterEquals
8236 */
8237 public int filterHashCode() {
8238 int code = 0;
8239 if (mAction != null) {
8240 code += mAction.hashCode();
8241 }
8242 if (mData != null) {
8243 code += mData.hashCode();
8244 }
8245 if (mType != null) {
8246 code += mType.hashCode();
8247 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008248 if (mPackage != null) {
8249 code += mPackage.hashCode();
8250 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008251 if (mComponent != null) {
8252 code += mComponent.hashCode();
8253 }
8254 if (mCategories != null) {
8255 code += mCategories.hashCode();
8256 }
8257 return code;
8258 }
8259
8260 @Override
8261 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008262 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008263
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008264 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008265 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008266 b.append(" }");
8267
8268 return b.toString();
8269 }
8270
8271 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008272 public String toInsecureString() {
8273 StringBuilder b = new StringBuilder(128);
8274
8275 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008276 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008277 b.append(" }");
8278
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008279 return b.toString();
8280 }
Romain Guy4969af72009-06-17 10:53:19 -07008281
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008282 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008283 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008284 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008285
8286 b.append("Intent { ");
8287 toShortString(b, false, true, true, true);
8288 b.append(" }");
8289
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008290 return b.toString();
8291 }
8292
8293 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008294 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8295 StringBuilder b = new StringBuilder(128);
8296 toShortString(b, secure, comp, extras, clip);
8297 return b.toString();
8298 }
8299
8300 /** @hide */
8301 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8302 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008303 boolean first = true;
8304 if (mAction != null) {
8305 b.append("act=").append(mAction);
8306 first = false;
8307 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008308 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008309 if (!first) {
8310 b.append(' ');
8311 }
8312 first = false;
8313 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008314 for (int i=0; i<mCategories.size(); i++) {
8315 if (i > 0) b.append(',');
8316 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008317 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008318 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008319 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008320 if (mData != null) {
8321 if (!first) {
8322 b.append(' ');
8323 }
8324 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008325 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008326 if (secure) {
8327 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008328 } else {
8329 b.append(mData);
8330 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008331 }
8332 if (mType != null) {
8333 if (!first) {
8334 b.append(' ');
8335 }
8336 first = false;
8337 b.append("typ=").append(mType);
8338 }
8339 if (mFlags != 0) {
8340 if (!first) {
8341 b.append(' ');
8342 }
8343 first = false;
8344 b.append("flg=0x").append(Integer.toHexString(mFlags));
8345 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008346 if (mPackage != null) {
8347 if (!first) {
8348 b.append(' ');
8349 }
8350 first = false;
8351 b.append("pkg=").append(mPackage);
8352 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008353 if (comp && mComponent != null) {
8354 if (!first) {
8355 b.append(' ');
8356 }
8357 first = false;
8358 b.append("cmp=").append(mComponent.flattenToShortString());
8359 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008360 if (mSourceBounds != null) {
8361 if (!first) {
8362 b.append(' ');
8363 }
8364 first = false;
8365 b.append("bnds=").append(mSourceBounds.toShortString());
8366 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008367 if (mClipData != null) {
8368 if (!first) {
8369 b.append(' ');
8370 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008371 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008372 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008373 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008374 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008375 if (mClipData.getDescription() != null) {
8376 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8377 } else {
8378 first = true;
8379 }
8380 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008381 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008382 first = false;
8383 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008384 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008385 if (extras && mExtras != null) {
8386 if (!first) {
8387 b.append(' ');
8388 }
8389 first = false;
8390 b.append("(has extras)");
8391 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008392 if (mContentUserHint != UserHandle.USER_CURRENT) {
8393 if (!first) {
8394 b.append(' ');
8395 }
8396 first = false;
8397 b.append("u=").append(mContentUserHint);
8398 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008399 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008400 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008401 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008402 b.append("}");
8403 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008404 }
8405
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008406 /**
8407 * Call {@link #toUri} with 0 flags.
8408 * @deprecated Use {@link #toUri} instead.
8409 */
8410 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008411 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008412 return toUri(0);
8413 }
8414
8415 /**
8416 * Convert this Intent into a String holding a URI representation of it.
8417 * The returned URI string has been properly URI encoded, so it can be
8418 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8419 * Intent's data as the base URI, with an additional fragment describing
8420 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008421 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008422 * <p>You can convert the returned string back to an Intent with
8423 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008424 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008425 * @param flags Additional operating flags. Either 0,
8426 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008427 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008428 * @return Returns a URI encoding URI string describing the entire contents
8429 * of the Intent.
8430 */
8431 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008432 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008433 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8434 if (mPackage == null) {
8435 throw new IllegalArgumentException(
8436 "Intent must include an explicit package name to build an android-app: "
8437 + this);
8438 }
8439 uri.append("android-app://");
8440 uri.append(mPackage);
8441 String scheme = null;
8442 if (mData != null) {
8443 scheme = mData.getScheme();
8444 if (scheme != null) {
8445 uri.append('/');
8446 uri.append(scheme);
8447 String authority = mData.getEncodedAuthority();
8448 if (authority != null) {
8449 uri.append('/');
8450 uri.append(authority);
8451 String path = mData.getEncodedPath();
8452 if (path != null) {
8453 uri.append(path);
8454 }
8455 String queryParams = mData.getEncodedQuery();
8456 if (queryParams != null) {
8457 uri.append('?');
8458 uri.append(queryParams);
8459 }
8460 String fragment = mData.getEncodedFragment();
8461 if (fragment != null) {
8462 uri.append('#');
8463 uri.append(fragment);
8464 }
8465 }
8466 }
8467 }
8468 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8469 mPackage, flags);
8470 return uri.toString();
8471 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008472 String scheme = null;
8473 if (mData != null) {
8474 String data = mData.toString();
8475 if ((flags&URI_INTENT_SCHEME) != 0) {
8476 final int N = data.length();
8477 for (int i=0; i<N; i++) {
8478 char c = data.charAt(i);
8479 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8480 || c == '.' || c == '-') {
8481 continue;
8482 }
8483 if (c == ':' && i > 0) {
8484 // Valid scheme.
8485 scheme = data.substring(0, i);
8486 uri.append("intent:");
8487 data = data.substring(i+1);
8488 break;
8489 }
Tom Taylord4a47292009-12-21 13:59:18 -08008490
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008491 // No scheme.
8492 break;
8493 }
8494 }
8495 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008496
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008497 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8498 uri.append("intent:");
8499 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008500
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008501 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008502
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008503 return uri.toString();
8504 }
8505
8506 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8507 String defPackage, int flags) {
8508 StringBuilder frag = new StringBuilder(128);
8509
8510 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008511 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008512 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008513 // Note that for now we are not going to try to handle the
8514 // data part; not clear how to represent this as a URI, and
8515 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008516 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8517 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008518 }
8519
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008520 if (frag.length() > 0) {
8521 uri.append("#Intent;");
8522 uri.append(frag);
8523 uri.append("end");
8524 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008525 }
8526
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008527 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8528 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008529 if (scheme != null) {
8530 uri.append("scheme=").append(scheme).append(';');
8531 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008532 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008533 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008534 }
8535 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008536 for (int i=0; i<mCategories.size(); i++) {
8537 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008538 }
8539 }
8540 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008541 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008542 }
8543 if (mFlags != 0) {
8544 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8545 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008546 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008547 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8548 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008549 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008550 uri.append("component=").append(Uri.encode(
8551 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008552 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008553 if (mSourceBounds != null) {
8554 uri.append("sourceBounds=")
8555 .append(Uri.encode(mSourceBounds.flattenToString()))
8556 .append(';');
8557 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008558 if (mExtras != null) {
8559 for (String key : mExtras.keySet()) {
8560 final Object value = mExtras.get(key);
8561 char entryType =
8562 value instanceof String ? 'S' :
8563 value instanceof Boolean ? 'B' :
8564 value instanceof Byte ? 'b' :
8565 value instanceof Character ? 'c' :
8566 value instanceof Double ? 'd' :
8567 value instanceof Float ? 'f' :
8568 value instanceof Integer ? 'i' :
8569 value instanceof Long ? 'l' :
8570 value instanceof Short ? 's' :
8571 '\0';
8572
8573 if (entryType != '\0') {
8574 uri.append(entryType);
8575 uri.append('.');
8576 uri.append(Uri.encode(key));
8577 uri.append('=');
8578 uri.append(Uri.encode(value.toString()));
8579 uri.append(';');
8580 }
8581 }
8582 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008583 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008584
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008585 public int describeContents() {
8586 return (mExtras != null) ? mExtras.describeContents() : 0;
8587 }
8588
8589 public void writeToParcel(Parcel out, int flags) {
8590 out.writeString(mAction);
8591 Uri.writeToParcel(out, mData);
8592 out.writeString(mType);
8593 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008594 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008595 ComponentName.writeToParcel(mComponent, out);
8596
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008597 if (mSourceBounds != null) {
8598 out.writeInt(1);
8599 mSourceBounds.writeToParcel(out, flags);
8600 } else {
8601 out.writeInt(0);
8602 }
8603
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008604 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008605 final int N = mCategories.size();
8606 out.writeInt(N);
8607 for (int i=0; i<N; i++) {
8608 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008609 }
8610 } else {
8611 out.writeInt(0);
8612 }
8613
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008614 if (mSelector != null) {
8615 out.writeInt(1);
8616 mSelector.writeToParcel(out, flags);
8617 } else {
8618 out.writeInt(0);
8619 }
8620
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008621 if (mClipData != null) {
8622 out.writeInt(1);
8623 mClipData.writeToParcel(out, flags);
8624 } else {
8625 out.writeInt(0);
8626 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008627 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008628 out.writeBundle(mExtras);
8629 }
8630
8631 public static final Parcelable.Creator<Intent> CREATOR
8632 = new Parcelable.Creator<Intent>() {
8633 public Intent createFromParcel(Parcel in) {
8634 return new Intent(in);
8635 }
8636 public Intent[] newArray(int size) {
8637 return new Intent[size];
8638 }
8639 };
8640
Dianne Hackborneb034652009-09-07 00:49:58 -07008641 /** @hide */
8642 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008643 readFromParcel(in);
8644 }
8645
8646 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008647 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008648 mData = Uri.CREATOR.createFromParcel(in);
8649 mType = in.readString();
8650 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008651 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 mComponent = ComponentName.readFromParcel(in);
8653
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008654 if (in.readInt() != 0) {
8655 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8656 }
8657
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008658 int N = in.readInt();
8659 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008660 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008661 int i;
8662 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008663 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008664 }
8665 } else {
8666 mCategories = null;
8667 }
8668
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008669 if (in.readInt() != 0) {
8670 mSelector = new Intent(in);
8671 }
8672
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008673 if (in.readInt() != 0) {
8674 mClipData = new ClipData(in);
8675 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008676 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008677 mExtras = in.readBundle();
8678 }
8679
8680 /**
8681 * Parses the "intent" element (and its children) from XML and instantiates
8682 * an Intent object. The given XML parser should be located at the tag
8683 * where parsing should start (often named "intent"), from which the
8684 * basic action, data, type, and package and class name will be
8685 * retrieved. The function will then parse in to any child elements,
8686 * looking for <category android:name="xxx"> tags to add categories and
8687 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8688 * to the intent.
8689 *
8690 * @param resources The Resources to use when inflating resources.
8691 * @param parser The XML parser pointing at an "intent" tag.
8692 * @param attrs The AttributeSet interface for retrieving extended
8693 * attribute data at the current <var>parser</var> location.
8694 * @return An Intent object matching the XML data.
8695 * @throws XmlPullParserException If there was an XML parsing error.
8696 * @throws IOException If there was an I/O error.
8697 */
8698 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8699 throws XmlPullParserException, IOException {
8700 Intent intent = new Intent();
8701
8702 TypedArray sa = resources.obtainAttributes(attrs,
8703 com.android.internal.R.styleable.Intent);
8704
8705 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8706
8707 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8708 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8709 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8710
8711 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8712 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8713 if (packageName != null && className != null) {
8714 intent.setComponent(new ComponentName(packageName, className));
8715 }
8716
8717 sa.recycle();
8718
8719 int outerDepth = parser.getDepth();
8720 int type;
8721 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8722 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8723 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8724 continue;
8725 }
8726
8727 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008728 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008729 sa = resources.obtainAttributes(attrs,
8730 com.android.internal.R.styleable.IntentCategory);
8731 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8732 sa.recycle();
8733
8734 if (cat != null) {
8735 intent.addCategory(cat);
8736 }
8737 XmlUtils.skipCurrentTag(parser);
8738
Craig Mautner21d24a22014-04-23 11:45:37 -07008739 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008740 if (intent.mExtras == null) {
8741 intent.mExtras = new Bundle();
8742 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008743 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008744 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008745
8746 } else {
8747 XmlUtils.skipCurrentTag(parser);
8748 }
8749 }
8750
8751 return intent;
8752 }
Nick Pellyccae4122012-01-09 14:12:58 -08008753
Craig Mautner21d24a22014-04-23 11:45:37 -07008754 /** @hide */
8755 public void saveToXml(XmlSerializer out) throws IOException {
8756 if (mAction != null) {
8757 out.attribute(null, ATTR_ACTION, mAction);
8758 }
8759 if (mData != null) {
8760 out.attribute(null, ATTR_DATA, mData.toString());
8761 }
8762 if (mType != null) {
8763 out.attribute(null, ATTR_TYPE, mType);
8764 }
8765 if (mComponent != null) {
8766 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8767 }
8768 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8769
8770 if (mCategories != null) {
8771 out.startTag(null, TAG_CATEGORIES);
8772 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8773 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8774 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008775 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008776 }
8777 }
8778
8779 /** @hide */
8780 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8781 XmlPullParserException {
8782 Intent intent = new Intent();
8783 final int outerDepth = in.getDepth();
8784
8785 int attrCount = in.getAttributeCount();
8786 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8787 final String attrName = in.getAttributeName(attrNdx);
8788 final String attrValue = in.getAttributeValue(attrNdx);
8789 if (ATTR_ACTION.equals(attrName)) {
8790 intent.setAction(attrValue);
8791 } else if (ATTR_DATA.equals(attrName)) {
8792 intent.setData(Uri.parse(attrValue));
8793 } else if (ATTR_TYPE.equals(attrName)) {
8794 intent.setType(attrValue);
8795 } else if (ATTR_COMPONENT.equals(attrName)) {
8796 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8797 } else if (ATTR_FLAGS.equals(attrName)) {
8798 intent.setFlags(Integer.valueOf(attrValue, 16));
8799 } else {
8800 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8801 }
8802 }
8803
8804 int event;
8805 String name;
8806 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8807 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8808 if (event == XmlPullParser.START_TAG) {
8809 name = in.getName();
8810 if (TAG_CATEGORIES.equals(name)) {
8811 attrCount = in.getAttributeCount();
8812 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8813 intent.addCategory(in.getAttributeValue(attrNdx));
8814 }
8815 } else {
8816 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8817 XmlUtils.skipCurrentTag(in);
8818 }
8819 }
8820 }
8821
8822 return intent;
8823 }
8824
Nick Pellyccae4122012-01-09 14:12:58 -08008825 /**
8826 * Normalize a MIME data type.
8827 *
8828 * <p>A normalized MIME type has white-space trimmed,
8829 * content-type parameters removed, and is lower-case.
8830 * This aligns the type with Android best practices for
8831 * intent filtering.
8832 *
8833 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8834 * "text/x-vCard" becomes "text/x-vcard".
8835 *
8836 * <p>All MIME types received from outside Android (such as user input,
8837 * or external sources like Bluetooth, NFC, or the Internet) should
8838 * be normalized before they are used to create an Intent.
8839 *
8840 * @param type MIME data type to normalize
8841 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008842 * @see #setType
8843 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008844 */
8845 public static String normalizeMimeType(String type) {
8846 if (type == null) {
8847 return null;
8848 }
8849
Elliott Hughescb64d432013-08-02 10:00:44 -07008850 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008851
8852 final int semicolonIndex = type.indexOf(';');
8853 if (semicolonIndex != -1) {
8854 type = type.substring(0, semicolonIndex);
8855 }
8856 return type;
8857 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008858
8859 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008860 * Prepare this {@link Intent} to leave an app process.
8861 *
8862 * @hide
8863 */
8864 public void prepareToLeaveProcess() {
8865 setAllowFds(false);
8866
8867 if (mSelector != null) {
8868 mSelector.prepareToLeaveProcess();
8869 }
8870 if (mClipData != null) {
8871 mClipData.prepareToLeaveProcess();
8872 }
8873
8874 if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
8875 // There are several ACTION_MEDIA_* broadcasts that send file://
8876 // Uris, so only check common actions.
8877 if (ACTION_VIEW.equals(mAction) ||
8878 ACTION_EDIT.equals(mAction) ||
8879 ACTION_ATTACH_DATA.equals(mAction)) {
8880 mData.checkFileUriExposed("Intent.getData()");
8881 }
8882 }
8883 }
8884
8885 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008886 * @hide
8887 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008888 public void prepareToEnterProcess() {
8889 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008890 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8891 fixUris(mContentUserHint);
8892 mContentUserHint = UserHandle.USER_CURRENT;
8893 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008894 }
8895 }
8896
8897 /**
8898 * @hide
8899 */
8900 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008901 Uri data = getData();
8902 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008903 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008904 }
8905 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008906 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008907 }
8908 String action = getAction();
8909 if (ACTION_SEND.equals(action)) {
8910 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8911 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008912 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008913 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008914 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008915 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8916 if (streams != null) {
8917 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8918 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008919 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008920 }
8921 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8922 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008923 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8924 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8925 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8926 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8927 if (output != null) {
8928 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8929 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008930 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008931 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008932
8933 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008934 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008935 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8936 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008937 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008938 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008939 * @hide
8940 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008941 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008942 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008943 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008944
8945 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008946 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008947
8948 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008949 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008950 // Inspect contained intents to see if we need to migrate extras. We
8951 // don't promote ClipData to the parent, since ChooserActivity will
8952 // already start the picked item as the caller, and we can't combine
8953 // the flags in a safe way.
8954
8955 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07008956 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008957 final Intent intent = getParcelableExtra(EXTRA_INTENT);
8958 if (intent != null) {
8959 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07008960 }
8961 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008962 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008963 try {
8964 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
8965 if (intents != null) {
8966 for (int i = 0; i < intents.length; i++) {
8967 final Intent intent = (Intent) intents[i];
8968 if (intent != null) {
8969 migrated |= intent.migrateExtraStreamToClipData();
8970 }
8971 }
8972 }
8973 } catch (ClassCastException e) {
8974 }
8975 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008976
8977 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008978 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008979 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8980 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
8981 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
8982 if (stream != null || text != null || htmlText != null) {
8983 final ClipData clipData = new ClipData(
8984 null, new String[] { getType() },
8985 new ClipData.Item(text, htmlText, null, stream));
8986 setClipData(clipData);
8987 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008988 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008989 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008990 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008991 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008992
8993 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07008994 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07008995 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8996 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
8997 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
8998 int num = -1;
8999 if (streams != null) {
9000 num = streams.size();
9001 }
9002 if (texts != null) {
9003 if (num >= 0 && num != texts.size()) {
9004 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009005 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009006 }
9007 num = texts.size();
9008 }
9009 if (htmlTexts != null) {
9010 if (num >= 0 && num != htmlTexts.size()) {
9011 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009012 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009013 }
9014 num = htmlTexts.size();
9015 }
9016 if (num > 0) {
9017 final ClipData clipData = new ClipData(
9018 null, new String[] { getType() },
9019 makeClipItem(streams, texts, htmlTexts, 0));
9020
9021 for (int i = 1; i < num; i++) {
9022 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9023 }
9024
9025 setClipData(clipData);
9026 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009027 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009028 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009029 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009030 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009031 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9032 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9033 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9034 final Uri output;
9035 try {
9036 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9037 } catch (ClassCastException e) {
9038 return false;
9039 }
9040 if (output != null) {
9041 setClipData(ClipData.newRawUri("", output));
9042 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9043 return true;
9044 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009045 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009046
9047 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009048 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009049
9050 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9051 ArrayList<String> htmlTexts, int which) {
9052 Uri uri = streams != null ? streams.get(which) : null;
9053 CharSequence text = texts != null ? texts.get(which) : null;
9054 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9055 return new ClipData.Item(text, htmlText, null, uri);
9056 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009057
9058 /** @hide */
9059 public boolean isDocument() {
9060 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9061 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009062}