blob: 182475ff6da4862029f3f0eb616fbae1defefee4 [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
Tor Norbye7b9c9122013-05-30 16:48:33 -070019import android.annotation.AnyRes;
Tor Norbyed9273d62013-05-30 15:59:53 -070020import android.annotation.IntDef;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050023import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070024import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050025import android.content.pm.ApplicationInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070026import android.content.pm.PackageManager;
27import android.content.pm.ResolveInfo;
28import android.content.res.Resources;
29import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080030import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.net.Uri;
32import android.os.Bundle;
33import android.os.IBinder;
34import android.os.Parcel;
35import android.os.Parcelable;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000036import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050037import android.os.ResultReceiver;
38import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070039import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010040import android.os.UserHandle;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070041import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070042import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050043import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070044import android.provider.OpenableColumns;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070046import android.util.AttributeSet;
47import android.util.Log;
Dianne Hackborn2269d1572010-02-24 19:54:22 -080048import com.android.internal.util.XmlUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import org.xmlpull.v1.XmlPullParser;
50import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070051import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070052
53import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080054import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070055import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070056import java.lang.annotation.Retention;
57import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058import java.net.URISyntaxException;
59import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080060import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070061import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080062import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070063import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070064import java.util.Set;
65
Jason Monk2f68e8a2016-02-23 17:57:28 -050066import static android.content.ContentProvider.maybeAddUserId;
67
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068/**
69 * An intent is an abstract description of an operation to be performed. It
70 * can be used with {@link Context#startActivity(Intent) startActivity} to
71 * launch an {@link android.app.Activity},
72 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
73 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
74 * and {@link android.content.Context#startService} or
75 * {@link android.content.Context#bindService} to communicate with a
76 * background {@link android.app.Service}.
77 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070078 * <p>An Intent provides a facility for performing late runtime binding between the code in
79 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070080 * can be thought of as the glue between activities. It is basically a passive data structure
81 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070082 *
83 * <div class="special reference">
84 * <h3>Developer Guides</h3>
85 * <p>For information about how to create and resolve intents, read the
86 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
87 * developer guide.</p>
88 * </div>
89 *
90 * <a name="IntentStructure"></a>
91 * <h3>Intent Structure</h3>
92 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070093 *
94 * <ul>
95 * <li> <p><b>action</b> -- The general action to be performed, such as
96 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
97 * etc.</p>
98 * </li>
99 * <li> <p><b>data</b> -- The data to operate on, such as a person record
100 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
101 * </li>
102 * </ul>
103 *
104 *
105 * <p>Some examples of action/data pairs are:</p>
106 *
107 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700108 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700109 * information about the person whose identifier is "1".</p>
110 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700111 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700112 * the phone dialer with the person filled in.</p>
113 * </li>
114 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
115 * the phone dialer with the given number filled in. Note how the
116 * VIEW action does what what is considered the most reasonable thing for
117 * a particular URI.</p>
118 * </li>
119 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
120 * the phone dialer with the given number filled in.</p>
121 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700122 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700123 * information about the person whose identifier is "1".</p>
124 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700125 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * a list of people, which the user can browse through. This example is a
127 * typical top-level entry into the Contacts application, showing you the
128 * list of people. Selecting a particular person to view would result in a
129 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
130 * being used to start an activity to display that person.</p>
131 * </li>
132 * </ul>
133 *
134 * <p>In addition to these primary attributes, there are a number of secondary
135 * attributes that you can also include with an intent:</p>
136 *
137 * <ul>
138 * <li> <p><b>category</b> -- Gives additional information about the action
139 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
140 * appear in the Launcher as a top-level application, while
141 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
142 * of alternative actions the user can perform on a piece of data.</p>
143 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
144 * intent data. Normally the type is inferred from the data itself.
145 * By setting this attribute, you disable that evaluation and force
146 * an explicit type.</p>
147 * <li> <p><b>component</b> -- Specifies an explicit name of a component
148 * class to use for the intent. Normally this is determined by looking
149 * at the other information in the intent (the action, data/type, and
150 * categories) and matching that with a component that can handle it.
151 * If this attribute is set then none of the evaluation is performed,
152 * and this component is used exactly as is. By specifying this attribute,
153 * all of the other Intent attributes become optional.</p>
154 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
155 * This can be used to provide extended information to the component.
156 * For example, if we have a action to send an e-mail message, we could
157 * also include extra pieces of data here to supply a subject, body,
158 * etc.</p>
159 * </ul>
160 *
161 * <p>Here are some examples of other operations you can specify as intents
162 * using these additional parameters:</p>
163 *
164 * <ul>
165 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
166 * Launch the home screen.</p>
167 * </li>
168 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
169 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
170 * vnd.android.cursor.item/phone}</i></b>
171 * -- Display the list of people's phone numbers, allowing the user to
172 * browse through them and pick one and return it to the parent activity.</p>
173 * </li>
174 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
175 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
176 * -- Display all pickers for data that can be opened with
177 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
178 * allowing the user to pick one of them and then some data inside of it
179 * and returning the resulting URI to the caller. This can be used,
180 * for example, in an e-mail application to allow the user to pick some
181 * data to include as an attachment.</p>
182 * </li>
183 * </ul>
184 *
185 * <p>There are a variety of standard Intent action and category constants
186 * defined in the Intent class, but applications can also define their own.
187 * These strings use java style scoping, to ensure they are unique -- for
188 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700189 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700190 *
191 * <p>Put together, the set of actions, data types, categories, and extra data
192 * defines a language for the system allowing for the expression of phrases
193 * such as "call john smith's cell". As applications are added to the system,
194 * they can extend this language by adding new actions, types, and categories, or
195 * they can modify the behavior of existing phrases by supplying their own
196 * activities that handle them.</p>
197 *
198 * <a name="IntentResolution"></a>
199 * <h3>Intent Resolution</h3>
200 *
201 * <p>There are two primary forms of intents you will use.
202 *
203 * <ul>
204 * <li> <p><b>Explicit Intents</b> have specified a component (via
205 * {@link #setComponent} or {@link #setClass}), which provides the exact
206 * class to be run. Often these will not include any other information,
207 * simply being a way for an application to launch various internal
208 * activities it has as the user interacts with the application.
209 *
210 * <li> <p><b>Implicit Intents</b> have not specified a component;
211 * instead, they must include enough information for the system to
212 * determine which of the available components is best to run for that
213 * intent.
214 * </ul>
215 *
216 * <p>When using implicit intents, given such an arbitrary intent we need to
217 * know what to do with it. This is handled by the process of <em>Intent
218 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
219 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
220 * more activities/receivers) that can handle it.</p>
221 *
222 * <p>The intent resolution mechanism basically revolves around matching an
223 * Intent against all of the &lt;intent-filter&gt; descriptions in the
224 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
225 * objects explicitly registered with {@link Context#registerReceiver}.) More
226 * details on this can be found in the documentation on the {@link
227 * IntentFilter} class.</p>
228 *
229 * <p>There are three pieces of information in the Intent that are used for
230 * resolution: the action, type, and category. Using this information, a query
231 * is done on the {@link PackageManager} for a component that can handle the
232 * intent. The appropriate component is determined based on the intent
233 * information supplied in the <code>AndroidManifest.xml</code> file as
234 * follows:</p>
235 *
236 * <ul>
237 * <li> <p>The <b>action</b>, if given, must be listed by the component as
238 * one it handles.</p>
239 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
240 * already supplied in the Intent. Like the action, if a type is
241 * included in the intent (either explicitly or implicitly in its
242 * data), then this must be listed by the component as one it handles.</p>
243 * <li> For data that is not a <code>content:</code> URI and where no explicit
244 * type is included in the Intent, instead the <b>scheme</b> of the
245 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
246 * considered. Again like the action, if we are matching a scheme it
247 * must be listed by the component as one it can handle.
248 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
249 * by the activity as categories it handles. That is, if you include
250 * the categories {@link #CATEGORY_LAUNCHER} and
251 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
252 * with an intent that lists <em>both</em> of those categories.
253 * Activities will very often need to support the
254 * {@link #CATEGORY_DEFAULT} so that they can be found by
255 * {@link Context#startActivity Context.startActivity()}.</p>
256 * </ul>
257 *
258 * <p>For example, consider the Note Pad sample application that
259 * allows user to browse through a list of notes data and view details about
260 * individual items. Text in italics indicate places were you would replace a
261 * name with one specific to your own package.</p>
262 *
263 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
264 * package="<i>com.android.notepad</i>"&gt;
265 * &lt;application android:icon="@drawable/app_notes"
266 * android:label="@string/app_name"&gt;
267 *
268 * &lt;provider class=".NotePadProvider"
269 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
270 *
271 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
272 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700273 * &lt;action android:name="android.intent.action.MAIN" /&gt;
274 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700275 * &lt;/intent-filter&gt;
276 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700277 * &lt;action android:name="android.intent.action.VIEW" /&gt;
278 * &lt;action android:name="android.intent.action.EDIT" /&gt;
279 * &lt;action android:name="android.intent.action.PICK" /&gt;
280 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
281 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 * &lt;/intent-filter&gt;
283 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700284 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
285 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
286 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;/activity&gt;
289 *
290 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
291 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700292 * &lt;action android:name="android.intent.action.VIEW" /&gt;
293 * &lt;action android:name="android.intent.action.EDIT" /&gt;
294 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 *
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="android.intent.action.INSERT" /&gt;
300 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
301 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700302 * &lt;/intent-filter&gt;
303 *
304 * &lt;/activity&gt;
305 *
306 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
307 * android:theme="@android:style/Theme.Dialog"&gt;
308 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700309 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
310 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
311 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
312 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
313 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700314 * &lt;/intent-filter&gt;
315 * &lt;/activity&gt;
316 *
317 * &lt;/application&gt;
318 * &lt;/manifest&gt;</pre>
319 *
320 * <p>The first activity,
321 * <code>com.android.notepad.NotesList</code>, serves as our main
322 * entry into the app. It can do three things as described by its three intent
323 * templates:
324 * <ol>
325 * <li><pre>
326 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700327 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
328 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700329 * &lt;/intent-filter&gt;</pre>
330 * <p>This provides a top-level entry into the NotePad application: the standard
331 * MAIN action is a main entry point (not requiring any other information in
332 * the Intent), and the LAUNCHER category says that this entry point should be
333 * listed in the application launcher.</p>
334 * <li><pre>
335 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700336 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
337 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
338 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
339 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
340 * &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700341 * &lt;/intent-filter&gt;</pre>
342 * <p>This declares the things that the activity can do on a directory of
343 * notes. The type being supported is given with the &lt;type&gt; tag, where
344 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
345 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
346 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
347 * The activity allows the user to view or edit the directory of data (via
348 * the VIEW and EDIT actions), or to pick a particular note and return it
349 * to the caller (via the PICK action). Note also the DEFAULT category
350 * supplied here: this is <em>required</em> for the
351 * {@link Context#startActivity Context.startActivity} method to resolve your
352 * activity when its component name is not explicitly specified.</p>
353 * <li><pre>
354 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700355 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
356 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
357 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700358 * &lt;/intent-filter&gt;</pre>
359 * <p>This filter describes the ability return to the caller a note selected by
360 * the user without needing to know where it came from. The data type
361 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
362 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
363 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
364 * The GET_CONTENT action is similar to the PICK action, where the activity
365 * will return to its caller a piece of data selected by the user. Here,
366 * however, the caller specifies the type of data they desire instead of
367 * the type of data the user will be picking from.</p>
368 * </ol>
369 *
370 * <p>Given these capabilities, the following intents will resolve to the
371 * NotesList activity:</p>
372 *
373 * <ul>
374 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
375 * activities that can be used as top-level entry points into an
376 * application.</p>
377 * <li> <p><b>{ action=android.app.action.MAIN,
378 * category=android.app.category.LAUNCHER }</b> is the actual intent
379 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700380 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700381 * data=content://com.google.provider.NotePad/notes }</b>
382 * displays a list of all the notes under
383 * "content://com.google.provider.NotePad/notes", which
384 * the user can browse through and see the details on.</p>
385 * <li> <p><b>{ action=android.app.action.PICK
386 * data=content://com.google.provider.NotePad/notes }</b>
387 * provides a list of the notes under
388 * "content://com.google.provider.NotePad/notes", from which
389 * the user can pick a note whose data URL is returned back to the caller.</p>
390 * <li> <p><b>{ action=android.app.action.GET_CONTENT
391 * type=vnd.android.cursor.item/vnd.google.note }</b>
392 * is similar to the pick action, but allows the caller to specify the
393 * kind of data they want back so that the system can find the appropriate
394 * activity to pick something of that data type.</p>
395 * </ul>
396 *
397 * <p>The second activity,
398 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
399 * note entry and allows them to edit it. It can do two things as described
400 * by its two intent templates:
401 * <ol>
402 * <li><pre>
403 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700404 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
405 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
406 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
407 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700408 * &lt;/intent-filter&gt;</pre>
409 * <p>The first, primary, purpose of this activity is to let the user interact
410 * with a single note, as decribed by the MIME type
411 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
412 * either VIEW a note or allow the user to EDIT it. Again we support the
413 * DEFAULT category to allow the activity to be launched without explicitly
414 * specifying its component.</p>
415 * <li><pre>
416 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700417 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
418 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
419 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700420 * &lt;/intent-filter&gt;</pre>
421 * <p>The secondary use of this activity is to insert a new note entry into
422 * an existing directory of notes. This is used when the user creates a new
423 * note: the INSERT action is executed on the directory of notes, causing
424 * this activity to run and have the user create the new note data which
425 * it then adds to the content provider.</p>
426 * </ol>
427 *
428 * <p>Given these capabilities, the following intents will resolve to the
429 * NoteEditor activity:</p>
430 *
431 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700432 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700433 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
434 * shows the user the content of note <var>{ID}</var>.</p>
435 * <li> <p><b>{ action=android.app.action.EDIT
436 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
437 * allows the user to edit the content of note <var>{ID}</var>.</p>
438 * <li> <p><b>{ action=android.app.action.INSERT
439 * data=content://com.google.provider.NotePad/notes }</b>
440 * creates a new, empty note in the notes list at
441 * "content://com.google.provider.NotePad/notes"
442 * and allows the user to edit it. If they keep their changes, the URI
443 * of the newly created note is returned to the caller.</p>
444 * </ul>
445 *
446 * <p>The last activity,
447 * <code>com.android.notepad.TitleEditor</code>, allows the user to
448 * edit the title of a note. This could be implemented as a class that the
449 * application directly invokes (by explicitly setting its component in
450 * the Intent), but here we show a way you can publish alternative
451 * operations on existing data:</p>
452 *
453 * <pre>
454 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700455 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
456 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
457 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
458 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
459 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700460 * &lt;/intent-filter&gt;</pre>
461 *
462 * <p>In the single intent template here, we
463 * have created our own private action called
464 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
465 * edit the title of a note. It must be invoked on a specific note
466 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
467 * view and edit actions, but here displays and edits the title contained
468 * in the note data.
469 *
470 * <p>In addition to supporting the default category as usual, our title editor
471 * also supports two other standard categories: ALTERNATIVE and
472 * SELECTED_ALTERNATIVE. Implementing
473 * these categories allows others to find the special action it provides
474 * without directly knowing about it, through the
475 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
476 * more often to build dynamic menu items with
477 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
478 * template here was also supply an explicit name for the template
479 * (via <code>android:label="@string/resolve_title"</code>) to better control
480 * what the user sees when presented with this activity as an alternative
481 * action to the data they are viewing.
482 *
483 * <p>Given these capabilities, the following intent will resolve to the
484 * TitleEditor activity:</p>
485 *
486 * <ul>
487 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
488 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
489 * displays and allows the user to edit the title associated
490 * with note <var>{ID}</var>.</p>
491 * </ul>
492 *
493 * <h3>Standard Activity Actions</h3>
494 *
495 * <p>These are the current standard actions that Intent defines for launching
496 * activities (usually through {@link Context#startActivity}. The most
497 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
498 * {@link #ACTION_EDIT}.
499 *
500 * <ul>
501 * <li> {@link #ACTION_MAIN}
502 * <li> {@link #ACTION_VIEW}
503 * <li> {@link #ACTION_ATTACH_DATA}
504 * <li> {@link #ACTION_EDIT}
505 * <li> {@link #ACTION_PICK}
506 * <li> {@link #ACTION_CHOOSER}
507 * <li> {@link #ACTION_GET_CONTENT}
508 * <li> {@link #ACTION_DIAL}
509 * <li> {@link #ACTION_CALL}
510 * <li> {@link #ACTION_SEND}
511 * <li> {@link #ACTION_SENDTO}
512 * <li> {@link #ACTION_ANSWER}
513 * <li> {@link #ACTION_INSERT}
514 * <li> {@link #ACTION_DELETE}
515 * <li> {@link #ACTION_RUN}
516 * <li> {@link #ACTION_SYNC}
517 * <li> {@link #ACTION_PICK_ACTIVITY}
518 * <li> {@link #ACTION_SEARCH}
519 * <li> {@link #ACTION_WEB_SEARCH}
520 * <li> {@link #ACTION_FACTORY_TEST}
521 * </ul>
522 *
523 * <h3>Standard Broadcast Actions</h3>
524 *
525 * <p>These are the current standard actions that Intent defines for receiving
526 * broadcasts (usually through {@link Context#registerReceiver} or a
527 * &lt;receiver&gt; tag in a manifest).
528 *
529 * <ul>
530 * <li> {@link #ACTION_TIME_TICK}
531 * <li> {@link #ACTION_TIME_CHANGED}
532 * <li> {@link #ACTION_TIMEZONE_CHANGED}
533 * <li> {@link #ACTION_BOOT_COMPLETED}
534 * <li> {@link #ACTION_PACKAGE_ADDED}
535 * <li> {@link #ACTION_PACKAGE_CHANGED}
536 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800537 * <li> {@link #ACTION_PACKAGE_RESTARTED}
538 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000539 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
540 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700541 * <li> {@link #ACTION_UID_REMOVED}
542 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700543 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700544 * <li> {@link #ACTION_POWER_DISCONNECTED}
545 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700546 * </ul>
547 *
548 * <h3>Standard Categories</h3>
549 *
550 * <p>These are the current standard categories that can be used to further
551 * clarify an Intent via {@link #addCategory}.
552 *
553 * <ul>
554 * <li> {@link #CATEGORY_DEFAULT}
555 * <li> {@link #CATEGORY_BROWSABLE}
556 * <li> {@link #CATEGORY_TAB}
557 * <li> {@link #CATEGORY_ALTERNATIVE}
558 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
559 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800560 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700561 * <li> {@link #CATEGORY_HOME}
562 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700563 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400564 * <li> {@link #CATEGORY_CAR_DOCK}
565 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500566 * <li> {@link #CATEGORY_LE_DESK_DOCK}
567 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200568 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700569 * <li> {@link #CATEGORY_APP_MARKET}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700570 * </ul>
571 *
572 * <h3>Standard Extra Data</h3>
573 *
574 * <p>These are the current standard fields that can be used as extra data via
575 * {@link #putExtra}.
576 *
577 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800578 * <li> {@link #EXTRA_ALARM_COUNT}
579 * <li> {@link #EXTRA_BCC}
580 * <li> {@link #EXTRA_CC}
581 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
582 * <li> {@link #EXTRA_DATA_REMOVED}
583 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500584 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
585 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800586 * <li> {@link #EXTRA_DOCK_STATE_CAR}
587 * <li> {@link #EXTRA_DOCK_STATE_DESK}
588 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
589 * <li> {@link #EXTRA_DONT_KILL_APP}
590 * <li> {@link #EXTRA_EMAIL}
591 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700594 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800595 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700596 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800597 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
598 * <li> {@link #EXTRA_REPLACING}
599 * <li> {@link #EXTRA_SHORTCUT_ICON}
600 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
601 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700602 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800603 * <li> {@link #EXTRA_SHORTCUT_NAME}
604 * <li> {@link #EXTRA_SUBJECT}
605 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_TITLE}
608 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700609 * </ul>
610 *
611 * <h3>Flags</h3>
612 *
613 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800614 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
615 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800617public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700618 private static final String ATTR_ACTION = "action";
619 private static final String TAG_CATEGORIES = "categories";
620 private static final String ATTR_CATEGORY = "category";
621 private static final String TAG_EXTRA = "extra";
622 private static final String ATTR_TYPE = "type";
623 private static final String ATTR_COMPONENT = "component";
624 private static final String ATTR_DATA = "data";
625 private static final String ATTR_FLAGS = "flags";
626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700627 // ---------------------------------------------------------------------
628 // ---------------------------------------------------------------------
629 // Standard intent activity actions (see action variable).
630
631 /**
632 * Activity Action: Start as a main entry point, does not expect to
633 * receive data.
634 * <p>Input: nothing
635 * <p>Output: nothing
636 */
637 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
638 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 /**
641 * Activity Action: Display the data to the user. This is the most common
642 * action performed on data -- it is the generic action you can use on
643 * a piece of data to get the most reasonable thing to occur. For example,
644 * when used on a contacts entry it will view the entry; when used on a
645 * mailto: URI it will bring up a compose window filled with the information
646 * supplied by the URI; when used with a tel: URI it will invoke the
647 * dialer.
648 * <p>Input: {@link #getData} is URI from which to retrieve data.
649 * <p>Output: nothing.
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
656 * performed on a piece of data.
657 */
658 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800659
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700660 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900661 * Activity Action: Quick view the data. Launches a quick viewer for
662 * a URI or a list of URIs.
663 * <p>Input: {@link #getData} is a mandatory content URI of the item to
664 * preview. {@link #getClipData} contains an optional list of content URIs
665 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
666 * optional index of the URI in the clip data to show first.
Steve McKayc78bcb82015-07-31 14:35:22 -0700667 * <p>Output: nothing.
Steve McKayc78bcb82015-07-31 14:35:22 -0700668 */
669 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
670 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
671
672 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700673 * Used to indicate that some piece of data should be attached to some other
674 * place. For example, image data could be attached to a contact. It is up
675 * to the recipient to decide where the data should be attached; the intent
676 * does not specify the ultimate destination.
677 * <p>Input: {@link #getData} is URI of data to be attached.
678 * <p>Output: nothing.
679 */
680 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
681 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800682
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700683 /**
684 * Activity Action: Provide explicit editable access to the given data.
685 * <p>Input: {@link #getData} is URI of data to be edited.
686 * <p>Output: nothing.
687 */
688 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
689 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800690
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700691 /**
692 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
693 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
694 * The extras can contain type specific data to pass through to the editing/creating
695 * activity.
696 * <p>Output: The URI of the item that was picked. This must be a content:
697 * URI so that any receiver can access it.
698 */
699 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
700 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800701
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700702 /**
703 * Activity Action: Pick an item from the data, returning what was selected.
704 * <p>Input: {@link #getData} is URI containing a directory of data
705 * (vnd.android.cursor.dir/*) from which to pick an item.
706 * <p>Output: The URI of the item that was picked.
707 */
708 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
709 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800710
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700711 /**
712 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713 * <p>Input: Nothing.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 * <p>Output: An Intent representing the shortcut. The intent must contain three
715 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
716 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800717 * (value: ShortcutIconResource).</p>
718 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700719 * @see #EXTRA_SHORTCUT_INTENT
720 * @see #EXTRA_SHORTCUT_NAME
721 * @see #EXTRA_SHORTCUT_ICON
722 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
723 * @see android.content.Intent.ShortcutIconResource
724 */
725 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
726 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
727
728 /**
729 * The name of the extra used to define the Intent of a shortcut.
730 *
731 * @see #ACTION_CREATE_SHORTCUT
732 */
733 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
734 /**
735 * The name of the extra used to define the name of a shortcut.
736 *
737 * @see #ACTION_CREATE_SHORTCUT
738 */
739 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
740 /**
741 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
742 *
743 * @see #ACTION_CREATE_SHORTCUT
744 */
745 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
746 /**
747 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
748 *
749 * @see #ACTION_CREATE_SHORTCUT
750 * @see android.content.Intent.ShortcutIconResource
751 */
752 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
753 "android.intent.extra.shortcut.ICON_RESOURCE";
754
755 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500756 * An activity that provides a user interface for adjusting application preferences.
757 * Optional but recommended settings for all applications which have settings.
758 */
759 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
760 public static final String ACTION_APPLICATION_PREFERENCES
761 = "android.intent.action.APPLICATION_PREFERENCES";
762
763 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800764 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 *
766 * @see Intent#ACTION_CREATE_SHORTCUT
767 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800768 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
769 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 */
771 public static class ShortcutIconResource implements Parcelable {
772 /**
773 * The package name of the application containing the icon.
774 */
775 public String packageName;
776
777 /**
778 * The resource name of the icon, including package, name and type.
779 */
780 public String resourceName;
781
782 /**
783 * Creates a new ShortcutIconResource for the specified context and resource
784 * identifier.
785 *
786 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700787 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700788 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700789 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700791 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 ShortcutIconResource icon = new ShortcutIconResource();
793 icon.packageName = context.getPackageName();
794 icon.resourceName = context.getResources().getResourceName(resourceId);
795 return icon;
796 }
797
798 /**
799 * Used to read a ShortcutIconResource from a Parcel.
800 */
801 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
802 new Parcelable.Creator<ShortcutIconResource>() {
803
804 public ShortcutIconResource createFromParcel(Parcel source) {
805 ShortcutIconResource icon = new ShortcutIconResource();
806 icon.packageName = source.readString();
807 icon.resourceName = source.readString();
808 return icon;
809 }
810
811 public ShortcutIconResource[] newArray(int size) {
812 return new ShortcutIconResource[size];
813 }
814 };
815
816 /**
817 * No special parcel contents.
818 */
819 public int describeContents() {
820 return 0;
821 }
822
823 public void writeToParcel(Parcel dest, int flags) {
824 dest.writeString(packageName);
825 dest.writeString(resourceName);
826 }
827
828 @Override
829 public String toString() {
830 return resourceName;
831 }
832 }
833
834 /**
835 * Activity Action: Display an activity chooser, allowing the user to pick
836 * what they want to before proceeding. This can be used as an alternative
837 * to the standard activity picker that is displayed by the system when
838 * you try to start an activity with multiple possible matches, with these
839 * differences in behavior:
840 * <ul>
841 * <li>You can specify the title that will appear in the activity chooser.
842 * <li>The user does not have the option to make one of the matching
843 * activities a preferred activity, and all possible activities will
844 * always be shown even if one of them is currently marked as the
845 * preferred activity.
846 * </ul>
847 * <p>
848 * This action should be used when the user will naturally expect to
849 * select an activity in order to proceed. An example if when not to use
850 * it is when the user clicks on a "mailto:" link. They would naturally
851 * expect to go directly to their mail app, so startActivity() should be
852 * called directly: it will
853 * either launch the current preferred app, or put up a dialog allowing the
854 * user to pick an app to use and optionally marking that as preferred.
855 * <p>
856 * In contrast, if the user is selecting a menu item to send a picture
857 * they are viewing to someone else, there are many different things they
858 * may want to do at this point: send it through e-mail, upload it to a
859 * web service, etc. In this case the CHOOSER action should be used, to
860 * always present to the user a list of the things they can do, with a
861 * nice title given by the caller such as "Send this photo with:".
862 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700863 * If you need to grant URI permissions through a chooser, you must specify
864 * the permissions to be granted on the ACTION_CHOOSER Intent
865 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
866 * {@link #setClipData} to specify the URIs to be granted as well as
867 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
868 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
869 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700870 * As a convenience, an Intent of this form can be created with the
871 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700872 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700873 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700874 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
875 * and can optionally have a {@link #EXTRA_TITLE} field containing the
876 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700877 * <p>
878 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700879 */
880 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
881 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
882
883 /**
884 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
885 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700886 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
887 * target intent, also optionally supplying a title. If the target
888 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
889 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
890 * set in the returned chooser intent, with its ClipData set appropriately:
891 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500892 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700893 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700894 * @param target The Intent that the user will be selecting an activity
895 * to perform.
896 * @param title Optional title that will be displayed in the chooser.
897 * @return Return a new Intent object that you can hand to
898 * {@link Context#startActivity(Intent) Context.startActivity()} and
899 * related methods.
900 */
901 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700902 return createChooser(target, title, null);
903 }
904
905 /**
906 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
907 *
908 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
909 * target intent, also optionally supplying a title. If the target
910 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
911 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
912 * set in the returned chooser intent, with its ClipData set appropriately:
913 * either a direct reflection of {@link #getClipData()} if that is non-null,
914 * or a new ClipData built from {@link #getData()}.</p>
915 *
916 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
917 * when the user makes a choice. This can be useful if the calling application wants
918 * to remember the last chosen target and surface it as a more prominent or one-touch
919 * affordance elsewhere in the UI for next time.</p>
920 *
921 * @param target The Intent that the user will be selecting an activity
922 * to perform.
923 * @param title Optional title that will be displayed in the chooser.
924 * @param sender Optional IntentSender to be called when a choice is made.
925 * @return Return a new Intent object that you can hand to
926 * {@link Context#startActivity(Intent) Context.startActivity()} and
927 * related methods.
928 */
929 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 Intent intent = new Intent(ACTION_CHOOSER);
931 intent.putExtra(EXTRA_INTENT, target);
932 if (title != null) {
933 intent.putExtra(EXTRA_TITLE, title);
934 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700935
Adam Powell0b3c1122014-10-09 12:50:14 -0700936 if (sender != null) {
937 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
938 }
939
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700940 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700941 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
942 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
943 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700944 if (permFlags != 0) {
945 ClipData targetClipData = target.getClipData();
946 if (targetClipData == null && target.getData() != null) {
947 ClipData.Item item = new ClipData.Item(target.getData());
948 String[] mimeTypes;
949 if (target.getType() != null) {
950 mimeTypes = new String[] { target.getType() };
951 } else {
952 mimeTypes = new String[] { };
953 }
954 targetClipData = new ClipData(null, mimeTypes, item);
955 }
956 if (targetClipData != null) {
957 intent.setClipData(targetClipData);
958 intent.addFlags(permFlags);
959 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700960 }
Dianne Hackborne302a162012-05-15 14:58:32 -0700961
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700962 return intent;
963 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700964
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700965 /**
966 * Activity Action: Allow the user to select a particular kind of data and
967 * return it. This is different than {@link #ACTION_PICK} in that here we
968 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -0800969 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700970 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900971 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700972 * etc.
973 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900974 * 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 -0700975 * of data, such as a person contact, you set the MIME type to the kind of
976 * data you want and launch it with {@link Context#startActivity(Intent)}.
977 * The system will then launch the best application to select that kind
978 * of data for you.
979 * <p>
980 * You may also be interested in any of a set of types of content the user
981 * can pick. For example, an e-mail application that wants to allow the
982 * user to add an attachment to an e-mail message can use this action to
983 * bring up a list of all of the types of content the user can attach.
984 * <p>
985 * In this case, you should wrap the GET_CONTENT intent with a chooser
986 * (through {@link #createChooser}), which will give the proper interface
987 * for the user to pick how to send your data and allow you to specify
988 * a prompt indicating what they are doing. You will usually specify a
989 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
990 * broad range of content types the user can select from.
991 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900992 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700993 * only pick from data that can be represented as a stream. This is
994 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
995 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800996 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +0900997 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -0800998 * is locally available on the device. For example, if this extra is set
999 * to true then an image picker should not show any pictures that are available
1000 * from a remote server but not already on the local device (thus requiring
1001 * they be downloaded when opened).
1002 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001003 * If the caller can handle multiple returned items (the user performing
1004 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1005 * to indicate this.
1006 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001007 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1008 * that no URI is supplied in the intent, as there are no constraints on
1009 * where the returned data originally comes from. You may also include the
1010 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001011 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001012 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1013 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001014 * <p>
1015 * Output: The URI of the item that was picked. This must be a content:
1016 * URI so that any receiver can access it.
1017 */
1018 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1019 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1020 /**
1021 * Activity Action: Dial a number as specified by the data. This shows a
1022 * UI with the number being dialed, allowing the user to explicitly
1023 * initiate the call.
1024 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1025 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1026 * number.
1027 * <p>Output: nothing.
1028 */
1029 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1030 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1031 /**
1032 * Activity Action: Perform a call to someone specified by the data.
1033 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1034 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1035 * number.
1036 * <p>Output: nothing.
1037 *
1038 * <p>Note: there will be restrictions on which applications can initiate a
1039 * call; most applications should use the {@link #ACTION_DIAL}.
1040 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1041 * numbers. Applications can <strong>dial</strong> emergency numbers using
1042 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001043 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001044 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001045 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001046 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001047 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001048 */
1049 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1050 public static final String ACTION_CALL = "android.intent.action.CALL";
1051 /**
1052 * Activity Action: Perform a call to an emergency number specified by the
1053 * data.
1054 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1055 * tel: URI of an explicit phone number.
1056 * <p>Output: nothing.
1057 * @hide
1058 */
1059 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1060 /**
1061 * Activity action: Perform a call to any number (emergency or not)
1062 * specified by the data.
1063 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1064 * tel: URI of an explicit phone number.
1065 * <p>Output: nothing.
1066 * @hide
1067 */
1068 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1069 /**
Santos Cordon15a13782015-03-31 18:32:31 -07001070 * Activity action: Activate the current SIM card. If SIM cards do not require activation,
1071 * sending this intent is a no-op.
1072 * <p>Input: No data should be specified. get*Extra may have an optional
1073 * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
1074 * send the activation result.
1075 * <p>Output: nothing.
1076 * @hide
1077 */
1078 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1079 public static final String ACTION_SIM_ACTIVATION_REQUEST =
1080 "android.intent.action.SIM_ACTIVATION_REQUEST";
1081 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001082 * Activity Action: Send a message to someone specified by the data.
1083 * <p>Input: {@link #getData} is URI describing the target.
1084 * <p>Output: nothing.
1085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1088 /**
1089 * Activity Action: Deliver some data to someone else. Who the data is
1090 * being delivered to is not specified; it is up to the receiver of this
1091 * action to ask the user where the data should be sent.
1092 * <p>
1093 * When launching a SEND intent, you should usually wrap it in a chooser
1094 * (through {@link #createChooser}), which will give the proper interface
1095 * for the user to pick how to send your data and allow you to specify
1096 * a prompt indicating what they are doing.
1097 * <p>
1098 * Input: {@link #getType} is the MIME type of the data being sent.
1099 * get*Extra can have either a {@link #EXTRA_TEXT}
1100 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1101 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1102 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1103 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001104 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1105 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1106 * your text with HTML formatting.
1107 * <p>
1108 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1109 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1110 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1111 * content: URIs and other advanced features of {@link ClipData}. If
1112 * using this approach, you still must supply the same data through the
1113 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1114 * for compatibility with old applications. If you don't set a ClipData,
1115 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001116 * <p>
1117 * Optional standard extras, which may be interpreted by some recipients as
1118 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1119 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1120 * <p>
1121 * Output: nothing.
1122 */
1123 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1124 public static final String ACTION_SEND = "android.intent.action.SEND";
1125 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001126 * Activity Action: Deliver multiple data to someone else.
1127 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001128 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001129 * <p>
1130 * Input: {@link #getType} is the MIME type of the data being sent.
1131 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001132 * #EXTRA_STREAM} field, containing the data to be sent. If using
1133 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1134 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001135 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001136 * Multiple types are supported, and receivers should handle mixed types
1137 * whenever possible. The right way for the receiver to check them is to
1138 * use the content resolver on each URI. The intent sender should try to
1139 * put the most concrete mime type in the intent type, but it can fall
1140 * back to {@literal <type>/*} or {@literal *}/* as needed.
1141 * <p>
1142 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1143 * be image/jpg, but if you are sending image/jpg and image/png, then the
1144 * intent's type should be image/*.
1145 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001146 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1147 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1148 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1149 * content: URIs and other advanced features of {@link ClipData}. If
1150 * using this approach, you still must supply the same data through the
1151 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1152 * for compatibility with old applications. If you don't set a ClipData,
1153 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1154 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001155 * Optional standard extras, which may be interpreted by some recipients as
1156 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1157 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1158 * <p>
1159 * Output: nothing.
1160 */
1161 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1162 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1163 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001164 * Activity Action: Handle an incoming phone call.
1165 * <p>Input: nothing.
1166 * <p>Output: nothing.
1167 */
1168 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1169 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1170 /**
1171 * Activity Action: Insert an empty item into the given container.
1172 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1173 * in which to place the data.
1174 * <p>Output: URI of the new data that was created.
1175 */
1176 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1177 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1178 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001179 * Activity Action: Create a new item in the given container, initializing it
1180 * from the current contents of the clipboard.
1181 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1182 * in which to place the data.
1183 * <p>Output: URI of the new data that was created.
1184 */
1185 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1186 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1187 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001188 * Activity Action: Delete the given data from its container.
1189 * <p>Input: {@link #getData} is URI of data to be deleted.
1190 * <p>Output: nothing.
1191 */
1192 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1193 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1194 /**
1195 * Activity Action: Run the data, whatever that means.
1196 * <p>Input: ? (Note: this is currently specific to the test harness.)
1197 * <p>Output: nothing.
1198 */
1199 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1200 public static final String ACTION_RUN = "android.intent.action.RUN";
1201 /**
1202 * Activity Action: Perform a data synchronization.
1203 * <p>Input: ?
1204 * <p>Output: ?
1205 */
1206 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1207 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1208 /**
1209 * Activity Action: Pick an activity given an intent, returning the class
1210 * selected.
1211 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1212 * used with {@link PackageManager#queryIntentActivities} to determine the
1213 * set of activities from which to pick.
1214 * <p>Output: Class name of the activity that was selected.
1215 */
1216 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1217 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1218 /**
1219 * Activity Action: Perform a search.
1220 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1221 * is the text to search for. If empty, simply
1222 * enter your search results Activity with the search UI activated.
1223 * <p>Output: nothing.
1224 */
1225 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1226 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1227 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001228 * Activity Action: Start the platform-defined tutorial
1229 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1230 * is the text to search for. If empty, simply
1231 * enter your search results Activity with the search UI activated.
1232 * <p>Output: nothing.
1233 */
1234 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1235 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1236 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001237 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001238 * <p>
1239 * Input: {@link android.app.SearchManager#QUERY
1240 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1241 * a url starts with http or https, the site will be opened. If it is plain
1242 * text, Google search will be applied.
1243 * <p>
1244 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001245 */
1246 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1247 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001248
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001249 /**
Jim Miller07994402012-05-02 14:22:27 -07001250 * Activity Action: Perform assist action.
1251 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001252 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1253 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001254 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1255 * information.
Jim Miller07994402012-05-02 14:22:27 -07001256 * Output: nothing.
1257 */
1258 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1259 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001260
1261 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001262 * Activity Action: Perform voice assist action.
1263 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001264 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1265 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001266 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001267 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001268 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001269 */
1270 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1271 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1272
1273 /**
Adam Skory7140a252013-09-11 12:04:58 +01001274 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1275 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001276 */
1277 public static final String EXTRA_ASSIST_PACKAGE
1278 = "android.intent.extra.ASSIST_PACKAGE";
1279
1280 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001281 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1282 * application package at the time the assist was invoked.
1283 */
1284 public static final String EXTRA_ASSIST_UID
1285 = "android.intent.extra.ASSIST_UID";
1286
1287 /**
Adam Skory7140a252013-09-11 12:04:58 +01001288 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1289 * information supplied by the current foreground app at the time of the assist request.
1290 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001291 */
1292 public static final String EXTRA_ASSIST_CONTEXT
1293 = "android.intent.extra.ASSIST_CONTEXT";
1294
Jim Miller07994402012-05-02 14:22:27 -07001295 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001296 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1297 * keyboard as the primary input device for assistance.
1298 */
1299 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1300 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1301
1302 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001303 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1304 * that was used to invoke the assist.
1305 */
1306 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1307 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1308
1309 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001310 * Activity Action: List all available applications
1311 * <p>Input: Nothing.
1312 * <p>Output: nothing.
1313 */
1314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1315 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1316 /**
1317 * Activity Action: Show settings for choosing wallpaper
1318 * <p>Input: Nothing.
1319 * <p>Output: Nothing.
1320 */
1321 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1322 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1323
1324 /**
1325 * Activity Action: Show activity for reporting a bug.
1326 * <p>Input: Nothing.
1327 * <p>Output: Nothing.
1328 */
1329 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1330 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1331
1332 /**
1333 * Activity Action: Main entry point for factory tests. Only used when
1334 * the device is booting in factory test node. The implementing package
1335 * must be installed in the system image.
1336 * <p>Input: nothing
1337 * <p>Output: nothing
1338 */
1339 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1340
1341 /**
1342 * Activity Action: The user pressed the "call" button to go to the dialer
1343 * or other appropriate UI for placing a call.
1344 * <p>Input: Nothing.
1345 * <p>Output: Nothing.
1346 */
1347 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1348 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1349
1350 /**
1351 * Activity Action: Start Voice Command.
1352 * <p>Input: Nothing.
1353 * <p>Output: Nothing.
1354 */
1355 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1356 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001357
1358 /**
1359 * Activity Action: Start action associated with long pressing on the
1360 * search key.
1361 * <p>Input: Nothing.
1362 * <p>Output: Nothing.
1363 */
1364 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1365 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001366
Jacek Surazski86b6c532009-05-13 14:38:28 +02001367 /**
1368 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1369 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001370 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001371 * <p>Input: No data is specified. The bug report is passed in using
1372 * an {@link #EXTRA_BUG_REPORT} field.
1373 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001374 *
1375 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001376 */
1377 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001379
1380 /**
1381 * Activity Action: Show power usage information to the user.
1382 * <p>Input: Nothing.
1383 * <p>Output: Nothing.
1384 */
1385 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1386 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001387
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001388 /**
1389 * Activity Action: Setup wizard to launch after a platform update. This
1390 * activity should have a string meta-data field associated with it,
1391 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1392 * the platform for setup. The activity will be launched only if
1393 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1394 * same value.
1395 * <p>Input: Nothing.
1396 * <p>Output: Nothing.
1397 * @hide
1398 */
1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1400 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001401
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001402 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001403 * Activity Action: Show settings for managing network data usage of a
1404 * specific application. Applications should define an activity that offers
1405 * options to control data usage.
1406 */
1407 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1408 public static final String ACTION_MANAGE_NETWORK_USAGE =
1409 "android.intent.action.MANAGE_NETWORK_USAGE";
1410
1411 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001412 * Activity Action: Launch application installer.
1413 * <p>
1414 * Input: The data must be a content: or file: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001415 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1416 * you can also use "package:<package-name>" to install an application for the
1417 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001418 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1419 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1420 * <p>
1421 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1422 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001423 * <p>
1424 * <strong>Note:</strong>If your app is targeting API level higher than 22 you
1425 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1426 * in order to launch the application installer.
1427 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001428 *
1429 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1430 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1431 * @see #EXTRA_RETURN_RESULT
1432 */
1433 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1434 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1435
1436 /**
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001437 * Activity Action: Launch ephemeral installer.
1438 * <p>
1439 * Input: The data must be a http: URI that the ephemeral application is registered
1440 * to handle.
1441 * <p class="note">
1442 * This is a protected intent that can only be sent by the system.
1443 * </p>
1444 *
1445 * @hide
1446 */
1447 @SystemApi
1448 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1449 public static final String ACTION_INSTALL_EPHEMERAL_PACKAGE
1450 = "android.intent.action.INSTALL_EPHEMERAL_PACKAGE";
1451
1452 /**
1453 * Service Action: Resolve ephemeral application.
1454 * <p>
1455 * The system will have a persistent connection to this service.
1456 * This is a protected intent that can only be sent by the system.
1457 * </p>
1458 *
1459 * @hide
1460 */
1461 @SystemApi
1462 @SdkConstant(SdkConstantType.SERVICE_ACTION)
1463 public static final String ACTION_RESOLVE_EPHEMERAL_PACKAGE
1464 = "android.intent.action.RESOLVE_EPHEMERAL_PACKAGE";
1465
1466 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001467 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1468 * package. Specifies the installer package name; this package will receive the
1469 * {@link #ACTION_APP_ERROR} intent.
1470 */
1471 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1472 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1473
1474 /**
1475 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1476 * package. Specifies that the application being installed should not be
1477 * treated as coming from an unknown source, but as coming from the app
1478 * invoking the Intent. For this to work you must start the installer with
1479 * startActivityForResult().
1480 */
1481 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1482 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1483
1484 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001485 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1486 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001487 * data field originated from.
1488 */
rich cannings706e8ba2012-08-20 13:20:14 -07001489 public static final String EXTRA_ORIGINATING_URI
1490 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001491
1492 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001493 * This extra can be used with any Intent used to launch an activity, supplying information
1494 * about who is launching that activity. This field contains a {@link android.net.Uri}
1495 * object, typically an http: or https: URI of the web site that the referral came from;
1496 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1497 * a native application that it came from.
1498 *
1499 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1500 * instead of directly retrieving the extra. It is also valid for applications to
1501 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1502 * a string, not a Uri; the field here, if supplied, will always take precedence,
1503 * however.</p>
1504 *
1505 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001506 */
1507 public static final String EXTRA_REFERRER
1508 = "android.intent.extra.REFERRER";
1509
1510 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001511 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1512 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1513 * not be created, in particular when Intent extras are supplied through the
1514 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1515 * schemes.
1516 *
1517 * @see #EXTRA_REFERRER
1518 */
1519 public static final String EXTRA_REFERRER_NAME
1520 = "android.intent.extra.REFERRER_NAME";
1521
1522 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001523 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1524 * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
1525 * @hide
1526 */
1527 public static final String EXTRA_ORIGINATING_UID
1528 = "android.intent.extra.ORIGINATING_UID";
1529
1530 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001531 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1532 * package. Tells the installer UI to skip the confirmation with the user
1533 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001534 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1535 * will no longer show an interstitial message about updating existing
1536 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001537 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001538 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001539 public static final String EXTRA_ALLOW_REPLACE
1540 = "android.intent.extra.ALLOW_REPLACE";
1541
1542 /**
1543 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1544 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1545 * return to the application the result code of the install/uninstall. The returned result
1546 * code will be {@link android.app.Activity#RESULT_OK} on success or
1547 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1548 */
1549 public static final String EXTRA_RETURN_RESULT
1550 = "android.intent.extra.RETURN_RESULT";
1551
1552 /**
1553 * Package manager install result code. @hide because result codes are not
1554 * yet ready to be exposed.
1555 */
1556 public static final String EXTRA_INSTALL_RESULT
1557 = "android.intent.extra.INSTALL_RESULT";
1558
1559 /**
1560 * Activity Action: Launch application uninstaller.
1561 * <p>
1562 * Input: The data must be a package: URI whose scheme specific part is
1563 * the package name of the current installed package to be uninstalled.
1564 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1565 * <p>
1566 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1567 * succeeded.
1568 */
1569 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1570 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1571
1572 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001573 * Specify whether the package should be uninstalled for all users.
1574 * @hide because these should not be part of normal application flow.
1575 */
1576 public static final String EXTRA_UNINSTALL_ALL_USERS
1577 = "android.intent.extra.UNINSTALL_ALL_USERS";
1578
1579 /**
Suprabh Shukla74a2fe42016-01-27 12:57:24 -08001580 * Specified when the uninstall confirmation dialog is not required to be shown.
1581 * Use with {@link #ACTION_UNINSTALL_PACKAGE}
1582 * @hide
1583 */
1584 public static final String EXTRA_SKIP_UNINSTALL_CONFIRMATION =
1585 "android.intent.extra.SKIP_UNINSTALL_CONFIRMATION";
1586
1587 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001588 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1589 * describing the last run version of the platform that was setup.
1590 * @hide
1591 */
1592 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1593
Svet Ganov3695b8a2015-03-24 16:30:25 -07001594 /**
1595 * Activity action: Launch UI to manage the permissions of an app.
1596 * <p>
1597 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1598 * will be managed by the launched UI.
1599 * </p>
1600 * <p>
1601 * Output: Nothing.
1602 * </p>
1603 *
1604 * @see #EXTRA_PACKAGE_NAME
1605 *
1606 * @hide
1607 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001608 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1609 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1610 "android.intent.action.MANAGE_APP_PERMISSIONS";
1611
1612 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001613 * Activity action: Launch UI to manage permissions.
1614 * <p>
1615 * Input: Nothing.
1616 * </p>
1617 * <p>
1618 * Output: Nothing.
1619 * </p>
1620 *
1621 * @hide
1622 */
Svet Ganov321f0152015-05-16 22:51:50 -07001623 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1624 public static final String ACTION_MANAGE_PERMISSIONS =
1625 "android.intent.action.MANAGE_PERMISSIONS";
1626
1627 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001628 * Activity action: Launch UI to review permissions for an app.
1629 * The system uses this intent if permission review for apps not
1630 * supporting the new runtime permissions model is enabled. In
1631 * this mode a permission review is required before any of the
1632 * app components can run.
1633 * <p>
1634 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1635 * permissions will be reviewed (mandatory).
1636 * </p>
1637 * <p>
1638 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1639 * be fired after the permission review (optional).
1640 * </p>
1641 * <p>
1642 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1643 * be invoked after the permission review (optional).
1644 * </p>
1645 * <p>
1646 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1647 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1648 * </p>
1649 * <p>
1650 * Output: Nothing.
1651 * </p>
1652 *
1653 * @see #EXTRA_PACKAGE_NAME
1654 * @see #EXTRA_INTENT
1655 * @see #EXTRA_REMOTE_CALLBACK
1656 * @see #EXTRA_RESULT_NEEDED
1657 *
1658 * @hide
1659 */
1660 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1661 public static final String ACTION_REVIEW_PERMISSIONS =
1662 "android.intent.action.REVIEW_PERMISSIONS";
1663
1664 /**
1665 * Intent extra: A callback for reporting remote result as a bundle.
1666 * <p>
1667 * Type: IRemoteCallback
1668 * </p>
1669 *
1670 * @hide
1671 */
1672 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1673
1674 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001675 * Intent extra: An app package name.
1676 * <p>
1677 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001678 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001679 *
1680 * @hide
1681 */
1682 @SystemApi
1683 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1684
1685 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001686 * Intent extra: An extra for specifying whether a result is needed.
1687 * <p>
1688 * Type: boolean
1689 * </p>
1690 *
1691 * @hide
1692 */
1693 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1694
1695 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001696 * Broadcast action that requests current permission granted information. It will respond
1697 * to the request by sending a broadcast with action defined by
1698 * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
Makoto Onukibbb912a2015-06-05 16:27:23 -07001699 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
1700 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
1701 * a null upon failure.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001702 *
Makoto Onukibbb912a2015-06-05 16:27:23 -07001703 * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
1704 * number of permissions requested and the number of granted additional permissions
1705 * by that package will be calculated and included as the first
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001706 * and second elements respectively of an int[] in the response as
Makoto Onukibbb912a2015-06-05 16:27:23 -07001707 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}. The response will also deliver the list
1708 * of localized permission group names that are granted in
1709 * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001710 *
1711 * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
1712 * permissions and the total number of apps requesting runtime permissions will be the first
1713 * and second elements respectively of an int[] in the response as
1714 * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
1715 *
1716 * @hide
1717 */
1718 public static final String ACTION_GET_PERMISSIONS_COUNT
1719 = "android.intent.action.GET_PERMISSIONS_COUNT";
1720
1721 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001722 * Broadcast action that requests list of all apps that have runtime permissions. It will
1723 * respond to the request by sending a broadcast with action defined by
1724 * {@link #EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT}. The response will contain
1725 * {@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT}, as well as
1726 * {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}, with contents described below or
1727 * a null upon failure.
1728 *
1729 * <p>{@link #EXTRA_GET_PERMISSIONS_APP_LIST_RESULT} will contain a list of package names of
1730 * apps that have runtime permissions. {@link #EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT}
1731 * will contain the list of app labels corresponding ot the apps in the first list.
1732 *
1733 * @hide
1734 */
1735 public static final String ACTION_GET_PERMISSIONS_PACKAGES
1736 = "android.intent.action.GET_PERMISSIONS_PACKAGES";
1737
1738 /**
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001739 * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
1740 * @hide
1741 */
1742 public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
1743 = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
1744
1745 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001746 * List of CharSequence of localized permission group labels.
1747 * @hide
1748 */
1749 public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
1750 = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
1751
1752 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001753 * String list of apps that have one or more runtime permissions.
1754 * @hide
1755 */
1756 public static final String EXTRA_GET_PERMISSIONS_APP_LIST_RESULT
1757 = "android.intent.extra.GET_PERMISSIONS_APP_LIST_RESULT";
1758
1759 /**
1760 * String list of app labels for apps that have one or more runtime permissions.
1761 * @hide
1762 */
1763 public static final String EXTRA_GET_PERMISSIONS_APP_LABEL_LIST_RESULT
1764 = "android.intent.extra.GET_PERMISSIONS_APP_LABEL_LIST_RESULT";
1765
1766 /**
Anthony Hugh3575a402015-10-26 17:47:05 -07001767 * Boolean list describing if the app is a system app for apps that have one or more runtime
1768 * permissions.
1769 * @hide
1770 */
1771 public static final String EXTRA_GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT
1772 = "android.intent.extra.GET_PERMISSIONS_IS_SYSTEM_APP_LIST_RESULT";
1773
1774 /**
Makoto Onukibbb912a2015-06-05 16:27:23 -07001775 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
Jason Monk9cfa0cc2015-05-22 14:50:21 -04001776 * @hide
1777 */
1778 public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
1779 = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
1780
1781 /**
Vinod Krishnan61665cc2015-08-31 19:30:20 -07001782 * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_PACKAGES} broadcasts.
1783 * @hide
1784 */
1785 public static final String EXTRA_GET_PERMISSIONS_PACKAGES_RESPONSE_INTENT
1786 = "android.intent.extra.GET_PERMISSIONS_PACKAGES_RESONSE_INTENT";
1787
1788 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001789 * Activity action: Launch UI to manage which apps have a given permission.
1790 * <p>
1791 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1792 * to which will be managed by the launched UI.
1793 * </p>
1794 * <p>
1795 * Output: Nothing.
1796 * </p>
1797 *
1798 * @see #EXTRA_PERMISSION_NAME
1799 *
1800 * @hide
1801 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001802 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1803 public static final String ACTION_MANAGE_PERMISSION_APPS =
1804 "android.intent.action.MANAGE_PERMISSION_APPS";
1805
1806 /**
1807 * Intent extra: The name of a permission.
1808 * <p>
1809 * Type: String
1810 * </p>
1811 *
1812 * @hide
1813 */
1814 @SystemApi
1815 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1816
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001817 // ---------------------------------------------------------------------
1818 // ---------------------------------------------------------------------
1819 // Standard intent broadcast actions (see action variable).
1820
1821 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001822 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1823 * <p>
1824 * For historical reasons, the name of this broadcast action refers to the power
1825 * state of the screen but it is actually sent in response to changes in the
1826 * overall interactive state of the device.
1827 * </p><p>
1828 * This broadcast is sent when the device becomes non-interactive which may have
1829 * nothing to do with the screen turning off. To determine the
1830 * actual state of the screen, use {@link android.view.Display#getState}.
1831 * </p><p>
1832 * See {@link android.os.PowerManager#isInteractive} for details.
1833 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001834 * You <em>cannot</em> receive this through components declared in
1835 * manifests, only by explicitly registering for it with
1836 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1837 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001838 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001839 * <p class="note">This is a protected intent that can only be sent
1840 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001841 */
1842 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1843 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001844
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001845 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001846 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1847 * <p>
1848 * For historical reasons, the name of this broadcast action refers to the power
1849 * state of the screen but it is actually sent in response to changes in the
1850 * overall interactive state of the device.
1851 * </p><p>
1852 * This broadcast is sent when the device becomes interactive which may have
1853 * nothing to do with the screen turning on. To determine the
1854 * actual state of the screen, use {@link android.view.Display#getState}.
1855 * </p><p>
1856 * See {@link android.os.PowerManager#isInteractive} for details.
1857 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001858 * You <em>cannot</em> receive this through components declared in
1859 * manifests, only by explicitly registering for it with
1860 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1861 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001862 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001863 * <p class="note">This is a protected intent that can only be sent
1864 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001865 */
1866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1867 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001868
1869 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001870 * Broadcast Action: Sent after the system stops dreaming.
1871 *
1872 * <p class="note">This is a protected intent that can only be sent by the system.
1873 * It is only sent to registered receivers.</p>
1874 */
1875 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1876 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1877
1878 /**
1879 * Broadcast Action: Sent after the system starts dreaming.
1880 *
1881 * <p class="note">This is a protected intent that can only be sent by the system.
1882 * It is only sent to registered receivers.</p>
1883 */
1884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1885 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1886
1887 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001888 * 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 -07001889 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001890 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001891 * <p class="note">This is a protected intent that can only be sent
1892 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001893 */
1894 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001895 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001896
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001897 /**
1898 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001899 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001900 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001901 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1902 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001903 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001904 * <p class="note">This is a protected intent that can only be sent
1905 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001906 */
1907 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1908 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1909 /**
1910 * Broadcast Action: The time was set.
1911 */
1912 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1913 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1914 /**
1915 * Broadcast Action: The date has changed.
1916 */
1917 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1918 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
1919 /**
1920 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
1921 * <ul>
1922 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
1923 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08001924 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001925 * <p class="note">This is a protected intent that can only be sent
1926 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001927 */
1928 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1929 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
1930 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07001931 * Clear DNS Cache Action: This is broadcast when networks have changed and old
1932 * DNS entries should be tossed.
1933 * @hide
1934 */
1935 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1936 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
1937 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001938 * Alarm Changed Action: This is broadcast when the AlarmClock
1939 * application's alarm is set or unset. It is used by the
1940 * AlarmClock application and the StatusBar service.
1941 * @hide
1942 */
1943 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1944 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001945
1946 /**
1947 * Broadcast Action: This is broadcast once, after the system has finished
1948 * booting and the user is in a "locked" state. A user is locked when their
1949 * credential-encrypted private app data storage is unavailable. Once the
1950 * user has entered their credentials (such as a lock pattern or PIN) for
1951 * the first time, the {@link #ACTION_BOOT_COMPLETED} broadcast will be
1952 * sent.
1953 * <p>
1954 * You must hold the
1955 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
1956 * order to receive this broadcast.
1957 * <p class="note">
1958 * This is a protected intent that can only be sent by the system.
1959 */
1960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1961 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
1962
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001963 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001964 * Broadcast Action: This is broadcast once, after the system has finished
1965 * booting. It can be used to perform application-specific initialization,
1966 * such as installing alarms. You must hold the
1967 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
1968 * in order to receive this broadcast.
Tom Taylord4a47292009-12-21 13:59:18 -08001969 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001970 * <p class="note">This is a protected intent that can only be sent
1971 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001972 */
1973 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1974 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07001975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001976 /**
1977 * Broadcast Action: This is broadcast when a user action should request a
1978 * temporary system dialog to dismiss. Some examples of temporary system
1979 * dialogs are the notification window-shade and the recent tasks dialog.
1980 */
1981 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
1982 /**
1983 * Broadcast Action: Trigger the download and eventual installation
1984 * of a package.
1985 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08001986 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001987 * <p class="note">This is a protected intent that can only be sent
1988 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001989 *
1990 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001991 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001992 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
1995 /**
1996 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07001997 * device. The data contains the name of the package. Note that the
1998 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07001999 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002000 * <ul>
2001 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2002 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2003 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same 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 Project54b6cfa2008-10-21 07:00:00 -07002008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2011 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002012 * Broadcast Action: A new version of an application package has been
2013 * installed, replacing an existing version that was previously installed.
2014 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002015 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002016 * <ul>
2017 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2018 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002019 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002020 * <p class="note">This is a protected intent that can only be sent
2021 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002022 */
2023 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2024 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2025 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002026 * Broadcast Action: A new version of your application has been installed
2027 * over an existing one. This is only sent to the application that was
2028 * replaced. It does not contain any additional data; to receive it, just
2029 * use an intent filter for this action.
2030 *
2031 * <p class="note">This is a protected intent that can only be sent
2032 * by the system.
2033 */
2034 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2035 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2036 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002037 * Broadcast Action: An existing application package has been removed from
2038 * the device. The data contains the name of the package. The package
2039 * that is being installed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002040 * <ul>
2041 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2042 * to the package.
2043 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2044 * application -- data and code -- is being removed.
2045 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2046 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2047 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002048 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002049 * <p class="note">This is a protected intent that can only be sent
2050 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002051 */
2052 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2053 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2054 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002055 * Broadcast Action: An existing application package has been completely
2056 * removed from the device. The data contains the name of the package.
2057 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2058 * {@link #EXTRA_DATA_REMOVED} is true and
2059 * {@link #EXTRA_REPLACING} is false of that broadcast.
2060 *
2061 * <ul>
2062 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2063 * to the package.
2064 * </ul>
2065 *
2066 * <p class="note">This is a protected intent that can only be sent
2067 * by the system.
2068 */
2069 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2070 public static final String ACTION_PACKAGE_FULLY_REMOVED
2071 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2072 /**
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002073 * Broadcast Action: An existing application package has been changed (e.g.
2074 * a component has been enabled or disabled). The data contains the name of
2075 * the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002076 * <ul>
2077 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002078 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002079 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002080 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2081 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002082 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002083 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002084 * <p class="note">This is a protected intent that can only be sent
2085 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002086 */
2087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2088 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2089 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002090 * @hide
2091 * Broadcast Action: Ask system services if there is any reason to
2092 * restart the given package. The data contains the name of the
2093 * package.
2094 * <ul>
2095 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2096 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2097 * </ul>
2098 *
2099 * <p class="note">This is a protected intent that can only be sent
2100 * by the system.
2101 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002102 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002103 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2104 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2105 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002106 * Broadcast Action: The user has restarted a package, and all of its
2107 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002108 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002109 * be removed. Note that the restarted package does <em>not</em>
2110 * receive this broadcast.
2111 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002112 * <ul>
2113 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2114 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002115 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002116 * <p class="note">This is a protected intent that can only be sent
2117 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002118 */
2119 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2120 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2121 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002122 * Broadcast Action: The user has cleared the data of a package. This should
2123 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002124 * its persistent data is erased and this broadcast sent.
2125 * Note that the cleared package does <em>not</em>
2126 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002127 * <ul>
2128 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2129 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002130 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002131 * <p class="note">This is a protected intent that can only be sent
2132 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 */
2134 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2135 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2136 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002137 * Broadcast Action: Packages have been suspended.
2138 * <p>Includes the following extras:
2139 * <ul>
2140 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2141 * </ul>
2142 *
2143 * <p class="note">This is a protected intent that can only be sent
2144 * by the system. It is only sent to registered receivers.
2145 */
2146 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2147 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2148 /**
2149 * Broadcast Action: Packages have been unsuspended.
2150 * <p>Includes the following extras:
2151 * <ul>
2152 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2153 * </ul>
2154 *
2155 * <p class="note">This is a protected intent that can only be sent
2156 * by the system. It is only sent to registered receivers.
2157 */
2158 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2159 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2160 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002161 * Broadcast Action: A user ID has been removed from the system. The user
2162 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002163 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002164 * <p class="note">This is a protected intent that can only be sent
2165 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002166 */
2167 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2168 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002169
2170 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002171 * Broadcast Action: Sent to the installer package of an application
2172 * when that application is first launched (that is the first time it
2173 * is moved out of the stopped state). The data contains the name of the package.
2174 *
2175 * <p class="note">This is a protected intent that can only be sent
2176 * by the system.
2177 */
2178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2180
2181 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002182 * Broadcast Action: Sent to the system package verifier when a package
2183 * needs to be verified. The data contains the package URI.
2184 * <p class="note">
2185 * This is a protected intent that can only be sent by the system.
2186 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2190
2191 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002192 * Broadcast Action: Sent to the system package verifier when a package is
2193 * verified. The data contains the package URI.
2194 * <p class="note">
2195 * This is a protected intent that can only be sent by the system.
2196 */
2197 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2198 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2199
2200 /**
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002201 * Broadcast Action: Sent to the system intent filter verifier when an intent filter
2202 * needs to be verified. The data contains the filter data hosts to be verified against.
2203 * <p class="note">
2204 * This is a protected intent that can only be sent by the system.
2205 * </p>
2206 *
2207 * @hide
2208 */
2209 @SystemApi
2210 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2211 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2212
2213 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002214 * Broadcast Action: Resources for a set of packages (which were
2215 * previously unavailable) are currently
2216 * available since the media on which they exist is available.
2217 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2218 * list of packages whose availability changed.
2219 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2220 * list of uids of packages whose availability changed.
2221 * Note that the
2222 * packages in this list do <em>not</em> receive this broadcast.
2223 * The specified set of packages are now available on the system.
2224 * <p>Includes the following extras:
2225 * <ul>
2226 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2227 * whose resources(were previously unavailable) are currently available.
2228 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2229 * packages whose resources(were previously unavailable)
2230 * are currently available.
2231 * </ul>
2232 *
2233 * <p class="note">This is a protected intent that can only be sent
2234 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002235 */
2236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002237 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2238 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002239
2240 /**
2241 * Broadcast Action: Resources for a set of packages are currently
2242 * unavailable since the media on which they exist is unavailable.
2243 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2244 * list of packages whose availability changed.
2245 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2246 * list of uids of packages whose availability changed.
2247 * The specified set of packages can no longer be
2248 * launched and are practically unavailable on the system.
2249 * <p>Inclues the following extras:
2250 * <ul>
2251 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2252 * whose resources are no longer available.
2253 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2254 * whose resources are no longer available.
2255 * </ul>
2256 *
2257 * <p class="note">This is a protected intent that can only be sent
2258 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002259 */
2260 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002261 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002262 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002263
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002264 /**
2265 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002266 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002267 * This should <em>only</em> be used to determine when the wallpaper
2268 * has changed to show the new wallpaper to the user. You should certainly
2269 * never, in response to this, change the wallpaper or other attributes of
2270 * it such as the suggested size. That would be crazy, right? You'd cause
2271 * all kinds of loops, especially if other apps are doing similar things,
2272 * right? Of course. So please don't do this.
2273 *
2274 * @deprecated Modern applications should use
2275 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2276 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2277 * shown behind their UI, rather than watching for this broadcast and
2278 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002279 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002280 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002281 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2282 /**
2283 * Broadcast Action: The current device {@link android.content.res.Configuration}
2284 * (orientation, locale, etc) has changed. When such a change happens, the
2285 * UIs (view hierarchy) will need to be rebuilt based on this new
2286 * information; for the most part, applications don't need to worry about
2287 * this, because the system will take care of stopping and restarting the
2288 * application to make sure it sees the new changes. Some system code that
2289 * can not be restarted will need to watch for this action and handle it
2290 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002291 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002292 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002293 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002294 * in manifests, only by explicitly registering for it with
2295 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2296 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002297 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002298 * <p class="note">This is a protected intent that can only be sent
2299 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002300 *
2301 * @see android.content.res.Configuration
2302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2304 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2305 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002306 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002307 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002308 * <p class="note">This is a protected intent that can only be sent
2309 * by the system.
2310 */
2311 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2312 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2313 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002314 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2315 * charging state, level, and other information about the battery.
2316 * See {@link android.os.BatteryManager} for documentation on the
2317 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002318 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002319 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002320 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002321 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002322 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002323 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2324 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2325 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2326 * broadcasts that are sent and can be received through manifest
2327 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002328 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002329 * <p class="note">This is a protected intent that can only be sent
2330 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002331 */
2332 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2333 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2334 /**
2335 * Broadcast Action: Indicates low battery condition on the device.
2336 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002337 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002338 * <p class="note">This is a protected intent that can only be sent
2339 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002340 */
2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2342 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2343 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002344 * Broadcast Action: Indicates the battery is now okay after being low.
2345 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2346 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002347 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002348 * <p class="note">This is a protected intent that can only be sent
2349 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002350 */
2351 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2352 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2353 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002354 * Broadcast Action: External power has been connected to the device.
2355 * This is intended for applications that wish to register specifically to this notification.
2356 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2357 * stay active to receive this notification. This action can be used to implement actions
2358 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002359 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002360 * <p class="note">This is a protected intent that can only be sent
2361 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002362 */
2363 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002364 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002365 /**
2366 * Broadcast Action: External power has been removed from the device.
2367 * This is intended for applications that wish to register specifically to this notification.
2368 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2369 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002370 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002371 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002372 * <p class="note">This is a protected intent that can only be sent
2373 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002374 */
2375 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002376 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002377 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002378 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002379 * Broadcast Action: Device is shutting down.
2380 * This is broadcast when the device is being shut down (completely turned
2381 * off, not sleeping). Once the broadcast is complete, the final shutdown
2382 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002383 * to handle this, since the foreground activity will be paused as well.
Tom Taylord4a47292009-12-21 13:59:18 -08002384 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002385 * <p class="note">This is a protected intent that can only be sent
2386 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002387 * <p>May include the following extras:
2388 * <ul>
2389 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2390 * shutdown is only for userspace processes. If not set, assumed to be false.
2391 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002392 */
2393 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002394 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002395 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002396 * Activity Action: Start this activity to request system shutdown.
2397 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002398 * to request confirmation from the user before shutting down. The optional boolean
2399 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2400 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002401 *
2402 * <p class="note">This is a protected intent that can only be sent
2403 * by the system.
2404 *
2405 * {@hide}
2406 */
2407 public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
2408 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002409 * Broadcast Action: A sticky broadcast that indicates low memory
2410 * condition on the device
Tom Taylord4a47292009-12-21 13:59:18 -08002411 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002412 * <p class="note">This is a protected intent that can only be sent
2413 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002414 */
2415 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2416 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2417 /**
2418 * Broadcast Action: Indicates low memory condition on the device no longer exists
Tom Taylord4a47292009-12-21 13:59:18 -08002419 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002420 * <p class="note">This is a protected intent that can only be sent
2421 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002422 */
2423 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2424 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2425 /**
Jake Hambybb371632010-08-23 18:16:48 -07002426 * Broadcast Action: A sticky broadcast that indicates a memory full
2427 * condition on the device. This is intended for activities that want
2428 * to be able to fill the data partition completely, leaving only
2429 * enough free space to prevent system-wide SQLite failures.
2430 *
2431 * <p class="note">This is a protected intent that can only be sent
2432 * by the system.
2433 *
2434 * {@hide}
2435 */
2436 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2437 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2438 /**
2439 * Broadcast Action: Indicates memory full condition on the device
2440 * no longer exists.
2441 *
2442 * <p class="note">This is a protected intent that can only be sent
2443 * by the system.
2444 *
2445 * {@hide}
2446 */
2447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2448 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2449 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002450 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2451 * and package management should be started.
2452 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2453 * notification.
2454 */
2455 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2456 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2457 /**
2458 * Broadcast Action: The device has entered USB Mass Storage mode.
2459 * This is used mainly for the USB Settings panel.
2460 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2461 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002462 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002464 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2466
2467 /**
2468 * Broadcast Action: The device has exited USB Mass Storage mode.
2469 * This is used mainly for the USB Settings panel.
2470 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2471 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002472 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002473 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002474 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002475 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2476
2477 /**
2478 * Broadcast Action: External media has been removed.
2479 * The path to the mount point for the removed media is contained in the Intent.mData field.
2480 */
2481 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2482 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2483
2484 /**
2485 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002486 * 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 -07002487 */
2488 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2489 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2490
2491 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002492 * Broadcast Action: External media is present, and being disk-checked
2493 * 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 -08002494 */
2495 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2496 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2497
2498 /**
2499 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2500 * 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 -08002501 */
2502 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2503 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2504
2505 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002506 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002507 * 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 -07002508 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2509 * media was mounted read only.
2510 */
2511 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2512 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2513
2514 /**
2515 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002516 * 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 -07002517 */
2518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2519 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2520
2521 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002522 * Broadcast Action: External media is no longer being shared via USB mass storage.
2523 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2524 *
2525 * @hide
2526 */
2527 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2528
2529 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002530 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2531 * The path to the mount point for the removed media is contained in the Intent.mData field.
2532 */
2533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2534 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2535
2536 /**
2537 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002538 * 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 -07002539 */
2540 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2541 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2542
2543 /**
2544 * Broadcast Action: User has expressed the desire to remove the external storage media.
2545 * Applications should close all files they have open within the mount point when they receive this intent.
2546 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2547 */
2548 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2549 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2550
2551 /**
2552 * Broadcast Action: The media scanner has started scanning a directory.
2553 * The path to the directory being scanned is contained in the Intent.mData field.
2554 */
2555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2556 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2557
2558 /**
2559 * Broadcast Action: The media scanner has finished scanning a directory.
2560 * The path to the scanned directory is contained in the Intent.mData field.
2561 */
2562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2563 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2564
2565 /**
2566 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2567 * The path to the file is contained in the Intent.mData field.
2568 */
2569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2570 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2571
2572 /**
2573 * Broadcast Action: The "Media Button" was pressed. Includes a single
2574 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2575 * caused the broadcast.
2576 */
2577 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2578 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2579
2580 /**
2581 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2582 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2583 * caused the broadcast.
2584 */
2585 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2586 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2587
2588 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2589 // location; they are not general-purpose actions.
2590
2591 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002592 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002593 */
2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2595 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2596 "android.intent.action.GTALK_CONNECTED";
2597
2598 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002599 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002600 */
2601 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2602 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2603 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002604
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002605 /**
2606 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002607 */
2608 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2609 public static final String ACTION_INPUT_METHOD_CHANGED =
2610 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002611
2612 /**
2613 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2614 * more radios have been turned off or on. The intent will have the following extra value:</p>
2615 * <ul>
2616 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2617 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2618 * turned off</li>
2619 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002620 *
Peng Xua35b5532016-01-20 00:05:45 -08002621 * <p class="note">This is a protected intent that can only be sent by the system.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002622 */
2623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2624 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2625
2626 /**
2627 * Broadcast Action: Some content providers have parts of their namespace
2628 * where they publish new events or items that the user may be especially
2629 * interested in. For these things, they may broadcast this action when the
2630 * set of interesting items change.
2631 *
2632 * For example, GmailProvider sends this notification when the set of unread
2633 * mail in the inbox changes.
2634 *
2635 * <p>The data of the intent identifies which part of which provider
2636 * changed. When queried through the content resolver, the data URI will
2637 * return the data set in question.
2638 *
2639 * <p>The intent will have the following extra values:
2640 * <ul>
2641 * <li><em>count</em> - The number of items in the data set. This is the
2642 * same as the number of items in the cursor returned by querying the
2643 * data URI. </li>
2644 * </ul>
2645 *
2646 * This intent will be sent at boot (if the count is non-zero) and when the
2647 * data set changes. It is possible for the data set to change without the
2648 * count changing (for example, if a new unread message arrives in the same
2649 * sync operation in which a message is archived). The phone should still
2650 * ring/vibrate/etc as normal in this case.
2651 */
2652 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2653 public static final String ACTION_PROVIDER_CHANGED =
2654 "android.intent.action.PROVIDER_CHANGED";
2655
2656 /**
2657 * Broadcast Action: Wired Headset plugged in or unplugged.
2658 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002659 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2660 * and documentation.
2661 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002662 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002663 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002664 */
2665 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002666 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002667
2668 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002669 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2670 * <ul>
2671 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2672 * </ul>
2673 *
2674 * <p class="note">This is a protected intent that can only be sent
2675 * by the system.
2676 *
2677 * @hide
2678 */
2679 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2680 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2681 = "android.intent.action.ADVANCED_SETTINGS";
2682
2683 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002684 * Broadcast Action: Sent after application restrictions are changed.
2685 *
2686 * <p class="note">This is a protected intent that can only be sent
2687 * by the system.</p>
2688 */
2689 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2690 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2691 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2692
2693 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002694 * Broadcast Action: An outgoing call is about to be placed.
2695 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002696 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002697 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002698 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002699 * the phone number originally intended to be dialed.</li>
2700 * </ul>
2701 * <p>Once the broadcast is finished, the resultData is used as the actual
2702 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002703 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002704 * outgoing call in turn: for example, a parental control application
2705 * might verify that the user is authorized to place the call at that
2706 * time, then a number-rewriting application might add an area code if
2707 * one was not specified.</p>
2708 * <p>For consistency, any receiver whose purpose is to prohibit phone
2709 * calls should have a priority of 0, to ensure it will see the final
2710 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002711 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002712 * should have a positive priority.
2713 * Negative priorities are reserved for the system for this broadcast;
2714 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002715 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2716 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002717 * <p>Emergency calls cannot be intercepted using this mechanism, and
2718 * other calls cannot be modified to call emergency numbers using this
2719 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002720 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2721 * call to use their own service instead. Those apps should first prevent
2722 * the call from being placed by setting resultData to <code>null</code>
2723 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002724 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2726 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002727 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002728 * <p class="note">This is a protected intent that can only be sent
2729 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002730 */
2731 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2732 public static final String ACTION_NEW_OUTGOING_CALL =
2733 "android.intent.action.NEW_OUTGOING_CALL";
2734
2735 /**
2736 * Broadcast Action: Have the device reboot. This is only for use by
2737 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002738 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002739 * <p class="note">This is a protected intent that can only be sent
2740 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002741 */
2742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2743 public static final String ACTION_REBOOT =
2744 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002745
Wei Huang97ecc9c2009-05-11 17:44:20 -07002746 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08002747 * Broadcast Action: A sticky broadcast for changes in the physical
2748 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08002749 *
2750 * <p>The intent will have the following extra values:
2751 * <ul>
2752 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08002753 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08002754 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08002755 * <p>This is intended for monitoring the current physical dock state.
2756 * See {@link android.app.UiModeManager} for the normal API dealing with
2757 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002758 */
2759 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2760 public static final String ACTION_DOCK_EVENT =
2761 "android.intent.action.DOCK_EVENT";
2762
2763 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08002764 * Broadcast Action: A broadcast when idle maintenance can be started.
2765 * This means that the user is not interacting with the device and is
2766 * not expected to do so soon. Typical use of the idle maintenance is
2767 * to perform somehow expensive tasks that can be postponed at a moment
2768 * when they will not degrade user experience.
2769 * <p>
2770 * <p class="note">In order to keep the device responsive in case of an
2771 * unexpected user interaction, implementations of a maintenance task
2772 * should be interruptible. In such a scenario a broadcast with action
2773 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
2774 * should not do the maintenance work in
2775 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
2776 * maintenance service by {@link Context#startService(Intent)}. Also
2777 * you should hold a wake lock while your maintenance service is running
2778 * to prevent the device going to sleep.
2779 * </p>
2780 * <p>
2781 * <p class="note">This is a protected intent that can only be sent by
2782 * the system.
2783 * </p>
2784 *
2785 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07002786 *
2787 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002788 */
2789 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2790 public static final String ACTION_IDLE_MAINTENANCE_START =
2791 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
2792
2793 /**
2794 * Broadcast Action: A broadcast when idle maintenance should be stopped.
2795 * This means that the user was not interacting with the device as a result
2796 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
2797 * was sent and now the user started interacting with the device. Typical
2798 * use of the idle maintenance is to perform somehow expensive tasks that
2799 * can be postponed at a moment when they will not degrade user experience.
2800 * <p>
2801 * <p class="note">In order to keep the device responsive in case of an
2802 * unexpected user interaction, implementations of a maintenance task
2803 * should be interruptible. Hence, on receiving a broadcast with this
2804 * action, the maintenance task should be interrupted as soon as possible.
2805 * In other words, you should not do the maintenance work in
2806 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
2807 * maintenance service that was started on receiving of
2808 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
2809 * lock you acquired when your maintenance service started.
2810 * </p>
2811 * <p class="note">This is a protected intent that can only be sent
2812 * by the system.
2813 *
2814 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07002815 *
2816 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08002817 */
2818 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2819 public static final String ACTION_IDLE_MAINTENANCE_END =
2820 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
2821
2822 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07002823 * Broadcast Action: a remote intent is to be broadcasted.
2824 *
2825 * A remote intent is used for remote RPC between devices. The remote intent
2826 * is serialized and sent from one device to another device. The receiving
2827 * device parses the remote intent and broadcasts it. Note that anyone can
2828 * broadcast a remote intent. However, if the intent receiver of the remote intent
2829 * does not trust intent broadcasts from arbitrary intent senders, it should require
2830 * the sender to hold certain permissions so only trusted sender's broadcast will be
2831 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07002832 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07002833 */
2834 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07002835 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07002836
Dianne Hackborn9acc0302009-08-25 00:27:12 -07002837 /**
2838 * Broadcast Action: hook for permforming cleanup after a system update.
2839 *
2840 * The broadcast is sent when the system is booting, before the
2841 * BOOT_COMPLETED broadcast. It is only sent to receivers in the system
2842 * image. A receiver for this should do its work and then disable itself
2843 * so that it does not get run again at the next boot.
2844 * @hide
2845 */
2846 public static final String ACTION_PRE_BOOT_COMPLETED =
2847 "android.intent.action.PRE_BOOT_COMPLETED";
2848
Amith Yamasani13593602012-03-22 16:16:17 -07002849 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002850 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07002851 * on restricted users. The broadcast intent contains an extra
2852 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
2853 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
2854 * String[] depending on the restriction type.<p/>
2855 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07002856 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
2857 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
2858 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07002859 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
2860 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08002861 * @see RestrictionEntry
2862 */
2863 public static final String ACTION_GET_RESTRICTION_ENTRIES =
2864 "android.intent.action.GET_RESTRICTION_ENTRIES";
2865
2866 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002867 * Sent the first time a user is starting, to allow system apps to
2868 * perform one time initialization. (This will not be seen by third
2869 * party applications because a newly initialized user does not have any
2870 * third party applications installed for it.) This is sent early in
2871 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002872 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
2873 * broadcast, since it is part of a visible user interaction; be as quick
2874 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002875 */
2876 public static final String ACTION_USER_INITIALIZE =
2877 "android.intent.action.USER_INITIALIZE";
2878
2879 /**
2880 * Sent when a user switch is happening, causing the process's user to be
2881 * brought to the foreground. This is only sent to receivers registered
2882 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2883 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002884 * foreground. This is sent as a foreground
2885 * broadcast, since it is part of a visible user interaction; be as quick
2886 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002887 */
2888 public static final String ACTION_USER_FOREGROUND =
2889 "android.intent.action.USER_FOREGROUND";
2890
2891 /**
2892 * Sent when a user switch is happening, causing the process's user to be
2893 * sent to the background. This is only sent to receivers registered
2894 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2895 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002896 * background. This is sent as a foreground
2897 * broadcast, since it is part of a visible user interaction; be as quick
2898 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002899 */
2900 public static final String ACTION_USER_BACKGROUND =
2901 "android.intent.action.USER_BACKGROUND";
2902
2903 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002904 * Broadcast sent to the system when a user is added. Carries an extra
2905 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
2906 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002907 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002908 * @hide
2909 */
2910 public static final String ACTION_USER_ADDED =
2911 "android.intent.action.USER_ADDED";
2912
2913 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002914 * Broadcast sent by the system when a user is started. Carries an extra
2915 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002916 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002917 * that has been started. This is sent as a foreground
2918 * broadcast, since it is part of a visible user interaction; be as quick
2919 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002920 * @hide
2921 */
2922 public static final String ACTION_USER_STARTED =
2923 "android.intent.action.USER_STARTED";
2924
2925 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07002926 * Broadcast sent when a user is in the process of starting. Carries an extra
2927 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2928 * sent to registered receivers, not manifest receivers. It is sent to all
2929 * users (including the one that is being started). You must hold
2930 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2931 * this broadcast. This is sent as a background broadcast, since
2932 * its result is not part of the primary UX flow; to safely keep track of
2933 * started/stopped state of a user you can use this in conjunction with
2934 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
2935 * other user state broadcasts since those are foreground broadcasts so can
2936 * execute in a different order.
2937 * @hide
2938 */
2939 public static final String ACTION_USER_STARTING =
2940 "android.intent.action.USER_STARTING";
2941
2942 /**
2943 * Broadcast sent when a user is going to be stopped. Carries an extra
2944 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
2945 * sent to registered receivers, not manifest receivers. It is sent to all
2946 * users (including the one that is being stopped). You must hold
2947 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
2948 * this broadcast. The user will not stop until all receivers have
2949 * handled the broadcast. This is sent as a background broadcast, since
2950 * its result is not part of the primary UX flow; to safely keep track of
2951 * started/stopped state of a user you can use this in conjunction with
2952 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
2953 * other user state broadcasts since those are foreground broadcasts so can
2954 * execute in a different order.
2955 * @hide
2956 */
2957 public static final String ACTION_USER_STOPPING =
2958 "android.intent.action.USER_STOPPING";
2959
2960 /**
2961 * Broadcast sent to the system when a user is stopped. Carries an extra
2962 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
2963 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
2964 * specific package. This is only sent to registered receivers, not manifest
2965 * receivers. It is sent to all running users <em>except</em> the one that
2966 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07002967 * @hide
2968 */
2969 public static final String ACTION_USER_STOPPED =
2970 "android.intent.action.USER_STOPPED";
2971
2972 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002973 * 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 -07002974 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07002975 * one that has been removed. The user will not be completely removed until all receivers have
2976 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002977 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002978 * @hide
2979 */
2980 public static final String ACTION_USER_REMOVED =
2981 "android.intent.action.USER_REMOVED";
2982
2983 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07002984 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07002985 * the userHandle of the user to become the current one. This is only sent to
2986 * registered receivers, not manifest receivers. It is sent to all running users.
2987 * You must hold
2988 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07002989 * @hide
2990 */
2991 public static final String ACTION_USER_SWITCHED =
2992 "android.intent.action.USER_SWITCHED";
2993
Amith Yamasanie928d7d2012-09-17 21:46:51 -07002994 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07002995 * Broadcast Action: Sent when the credential-encrypted private storage has
2996 * become unlocked for the target user. This is only sent to registered
2997 * receivers, not manifest receivers.
2998 */
2999 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3000 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3001
3002 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003003 * Broadcast sent to the system when a user's information changes. Carries an extra
3004 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003005 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003006 * @hide
3007 */
3008 public static final String ACTION_USER_INFO_CHANGED =
3009 "android.intent.action.USER_INFO_CHANGED";
3010
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003011 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003012 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3013 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003014 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3015 * that need to display merged content across both primary and managed profiles need to
3016 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003017 * not manifest receivers.
3018 */
3019 public static final String ACTION_MANAGED_PROFILE_ADDED =
3020 "android.intent.action.MANAGED_PROFILE_ADDED";
3021
3022 /**
3023 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003024 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3025 * Only applications (for example Launchers) that need to display merged content across both
3026 * primary and managed profiles need to worry about this broadcast. This is only sent to
3027 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003028 */
3029 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3030 "android.intent.action.MANAGED_PROFILE_REMOVED";
3031
3032 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003033 * Broadcast sent to the primary user when the credential-encrypted private storage for
3034 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3035 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3036 * Launchers) that need to display merged content across both primary and managed profiles
3037 * need to worry about this broadcast. This is only sent to registered receivers,
3038 * not manifest receivers.
3039 */
3040 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3041 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3042
3043 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003044 * Broadcast sent to the primary user when an associated managed profile's availability has
Rubin Xuf13c9802016-01-21 18:06:00 +00003045 * changed. This includes when the user toggles the profile's quiet mode. Carries an extra
3046 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3047 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3048 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003049 */
3050 public static final String ACTION_MANAGED_PROFILE_AVAILABILITY_CHANGED =
3051 "android.intent.action.MANAGED_PROFILE_AVAILABILITY_CHANGED";
3052
3053 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003054 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3055 */
3056 public static final String ACTION_QUICK_CLOCK =
3057 "android.intent.action.QUICK_CLOCK";
3058
Michael Wright0087a142013-02-05 16:29:39 -08003059 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003060 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003061 * @hide
3062 */
3063 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3064 "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3065
Justin Kohd378ad72013-04-01 12:18:26 -07003066 /**
3067 * Broadcast Action: A global button was pressed. Includes a single
3068 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3069 * caused the broadcast.
3070 * @hide
3071 */
3072 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3073
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003074 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003075 * Broadcast Action: Sent when media resource is granted.
3076 * <p>
3077 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3078 * granted.
3079 * </p>
3080 * <p class="note">
3081 * This is a protected intent that can only be sent by the system.
3082 * </p>
3083 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003084 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003085 * </p>
3086 *
3087 * @hide
3088 */
3089 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3090 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3091
3092 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003093 * Activity Action: Allow the user to select and return one or more existing
3094 * documents. When invoked, the system will display the various
3095 * {@link DocumentsProvider} instances installed on the device, letting the
3096 * user interactively navigate through them. These documents include local
3097 * media, such as photos and video, and documents provided by installed
3098 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003099 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003100 * Each document is represented as a {@code content://} URI backed by a
3101 * {@link DocumentsProvider}, which can be opened as a stream with
3102 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3103 * {@link android.provider.DocumentsContract.Document} metadata.
3104 * <p>
3105 * All selected documents are returned to the calling application with
3106 * persistable read and write permission grants. If you want to maintain
3107 * access to the documents across device reboots, you need to explicitly
3108 * take the persistable permissions using
3109 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3110 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003111 * Callers must indicate the acceptable document MIME types through
3112 * {@link #setType(String)}. For example, to select photos, use
3113 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3114 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3115 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003116 * <p>
3117 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003118 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3119 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003120 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003121 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3122 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003123 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003124 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003125 * Output: The URI of the item that was picked, returned in
3126 * {@link #getData()}. This must be a {@code content://} URI so that any
3127 * receiver can access it. If multiple documents were selected, they are
3128 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003129 *
3130 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003131 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003132 * @see #ACTION_CREATE_DOCUMENT
3133 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003134 */
3135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3136 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3137
3138 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003139 * Activity Action: Allow the user to create a new document. When invoked,
3140 * the system will display the various {@link DocumentsProvider} instances
3141 * installed on the device, letting the user navigate through them. The
3142 * returned document may be a newly created document with no content, or it
3143 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003144 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003145 * Each document is represented as a {@code content://} URI backed by a
3146 * {@link DocumentsProvider}, which can be opened as a stream with
3147 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3148 * {@link android.provider.DocumentsContract.Document} metadata.
3149 * <p>
3150 * Callers must indicate the concrete MIME type of the document being
3151 * created by setting {@link #setType(String)}. This MIME type cannot be
3152 * changed after the document is created.
3153 * <p>
3154 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3155 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003156 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003157 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3158 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003159 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003160 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003161 * Output: The URI of the item that was created. This must be a
3162 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003163 *
3164 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003165 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003166 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003167 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003168 */
3169 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3170 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3171
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003172 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003173 * Activity Action: Allow the user to pick a directory subtree. When
3174 * invoked, the system will display the various {@link DocumentsProvider}
3175 * instances installed on the device, letting the user navigate through
3176 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003177 * <p>
3178 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003179 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3180 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3181 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003182 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003183 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003184 *
3185 * @see DocumentsContract
3186 */
3187 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003188 public static final String
3189 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003190
Felipe Lemec7b1f892016-01-15 15:02:31 -08003191 /**
Peng Xua35b5532016-01-20 00:05:45 -08003192 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3193 * exisiting sensor being disconnected.
3194 *
3195 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3196 *
3197 * {@hide}
3198 */
3199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3200 public static final String
3201 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3202
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003203 /** {@hide} */
3204 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3205
Christopher Tate6597e342015-02-17 12:15:25 -08003206 /**
3207 * Broadcast action: report that a settings element is being restored from backup. The intent
3208 * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3209 * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
3210 * is the value of that settings entry prior to the restore operation. All of these values are
3211 * represented as strings.
3212 *
3213 * <p>This broadcast is sent only for settings provider entries known to require special handling
3214 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3215 * the provider's backup agent implementation.
3216 *
3217 * @see #EXTRA_SETTING_NAME
3218 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3219 * @see #EXTRA_SETTING_NEW_VALUE
3220 * {@hide}
3221 */
3222 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3223
3224 /** {@hide} */
3225 public static final String EXTRA_SETTING_NAME = "setting_name";
3226 /** {@hide} */
3227 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3228 /** {@hide} */
3229 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3230
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003231 /**
3232 * Activity Action: Process a piece of text.
3233 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3234 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3235 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3236 */
3237 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3238 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3239 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003240 * The name of the extra used to define the text to be processed, as a
3241 * CharSequence. Note that this may be a styled CharSequence, so you must use
3242 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003243 */
3244 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3245 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003246 * 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 +00003247 */
3248 public static final String EXTRA_PROCESS_TEXT_READONLY =
3249 "android.intent.extra.PROCESS_TEXT_READONLY";
3250
Bryce Leebc58f592015-09-25 16:43:01 -07003251 /**
3252 * Broadcast action: reports when a new thermal event has been reached. When the device
3253 * is reaching its maximum temperatue, the thermal level reported
3254 * {@hide}
3255 */
3256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3257 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3258
3259 /** {@hide} */
3260 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3261
3262 /**
3263 * Thermal state when the device is normal. 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_NORMAL = 0;
3268
3269 /**
3270 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003271 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003272 * {@hide}
3273 */
3274 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3275
3276 /**
3277 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003278 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003279 * {@hide}
3280 */
3281 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3282
3283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003284 // ---------------------------------------------------------------------
3285 // ---------------------------------------------------------------------
3286 // Standard intent categories (see addCategory()).
3287
3288 /**
3289 * Set if the activity should be an option for the default action
3290 * (center press) to perform on a piece of data. Setting this will
3291 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003292 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003293 * Intent when initiating an action -- it is for use in intent filters
3294 * specified in packages.
3295 */
3296 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3297 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3298 /**
3299 * Activities that can be safely invoked from a browser must support this
3300 * category. For example, if the user is viewing a web page or an e-mail
3301 * and clicks on a link in the text, the Intent generated execute that
3302 * link will require the BROWSABLE category, so that only activities
3303 * supporting this category will be considered as possible actions. By
3304 * supporting this category, you are promising that there is nothing
3305 * damaging (without user intervention) that can happen by invoking any
3306 * matching Intent.
3307 */
3308 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3309 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3310 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003311 * Categories for activities that can participate in voice interaction.
3312 * An activity that supports this category must be prepared to run with
3313 * no UI shown at all (though in some case it may have a UI shown), and
3314 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3315 */
3316 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3317 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3318 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003319 * Set if the activity should be considered as an alternative action to
3320 * the data the user is currently viewing. See also
3321 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3322 * applies to the selection in a list of items.
3323 *
3324 * <p>Supporting this category means that you would like your activity to be
3325 * displayed in the set of alternative things the user can do, usually as
3326 * part of the current activity's options menu. You will usually want to
3327 * include a specific label in the &lt;intent-filter&gt; of this action
3328 * describing to the user what it does.
3329 *
3330 * <p>The action of IntentFilter with this category is important in that it
3331 * describes the specific action the target will perform. This generally
3332 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
3333 * a specific name such as "com.android.camera.action.CROP. Only one
3334 * alternative of any particular action will be shown to the user, so using
3335 * a specific action like this makes sure that your alternative will be
3336 * displayed while also allowing other applications to provide their own
3337 * overrides of that particular action.
3338 */
3339 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3340 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
3341 /**
3342 * Set if the activity should be considered as an alternative selection
3343 * action to the data the user has currently selected. This is like
3344 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
3345 * of items from which the user can select, giving them alternatives to the
3346 * default action that will be performed on it.
3347 */
3348 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3349 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
3350 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003351 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003352 */
3353 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3354 public static final String CATEGORY_TAB = "android.intent.category.TAB";
3355 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003356 * Should be displayed in the top-level launcher.
3357 */
3358 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3359 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
3360 /**
Jose Lima38b75b62014-03-11 10:41:39 -07003361 * Indicates an activity optimized for Leanback mode, and that should
3362 * be displayed in the Leanback launcher.
3363 */
3364 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3365 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
3366 /**
Jose Lima73915cf2014-07-29 17:16:31 -07003367 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
3368 * @hide
3369 */
3370 @SystemApi
3371 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
3372 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003373 * Provides information about the package it is in; typically used if
3374 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
3375 * a front-door to the user without having to be shown in the all apps list.
3376 */
3377 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3378 public static final String CATEGORY_INFO = "android.intent.category.INFO";
3379 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003380 * This is the home activity, that is the first activity that is displayed
3381 * when the device boots.
3382 */
3383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3384 public static final String CATEGORY_HOME = "android.intent.category.HOME";
3385 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07003386 * This is the home activity that is displayed when the device is finished setting up and ready
3387 * for use.
3388 * @hide
3389 */
3390 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3391 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
3392 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07003393 * This is the setup wizard activity, that is the first activity that is displayed
3394 * when the user sets up the device for the first time.
3395 * @hide
3396 */
3397 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3398 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
3399 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003400 * This activity is a preference panel.
3401 */
3402 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3403 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
3404 /**
3405 * This activity is a development preference panel.
3406 */
3407 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3408 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
3409 /**
3410 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003411 */
3412 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3413 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
3414 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07003415 * This activity allows the user to browse and download new applications.
3416 */
3417 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3418 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
3419 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003420 * This activity may be exercised by the monkey or other automated test tools.
3421 */
3422 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3423 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
3424 /**
3425 * To be used as a test (not part of the normal user experience).
3426 */
3427 public static final String CATEGORY_TEST = "android.intent.category.TEST";
3428 /**
3429 * To be used as a unit test (run through the Test Harness).
3430 */
3431 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
3432 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003433 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003434 * experience).
3435 */
3436 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003437
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003438 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003439 * Used to indicate that an intent only wants URIs that can be opened with
3440 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
3441 * must support at least the columns defined in {@link OpenableColumns} when
3442 * queried.
3443 *
3444 * @see #ACTION_GET_CONTENT
3445 * @see #ACTION_OPEN_DOCUMENT
3446 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003447 */
3448 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3449 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
3450
3451 /**
3452 * To be used as code under test for framework instrumentation tests.
3453 */
3454 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
3455 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04003456 /**
3457 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003458 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3459 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003460 */
3461 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3462 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
3463 /**
3464 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08003465 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3466 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04003467 */
3468 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3469 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003470 /**
3471 * An activity to run when device is inserted into a analog (low end) dock.
3472 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3473 * information, see {@link android.app.UiModeManager}.
3474 */
3475 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3476 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
3477
3478 /**
3479 * An activity to run when device is inserted into a digital (high end) dock.
3480 * Used with {@link #ACTION_MAIN} to launch an activity. For more
3481 * information, see {@link android.app.UiModeManager}.
3482 */
3483 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3484 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003485
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003486 /**
3487 * Used to indicate that the activity can be used in a car environment.
3488 */
3489 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3490 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
3491
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003492 // ---------------------------------------------------------------------
3493 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08003494 // Application launch intent categories (see addCategory()).
3495
3496 /**
3497 * Used with {@link #ACTION_MAIN} to launch the browser application.
3498 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003499 * <p>NOTE: This should not be used as the primary key of an Intent,
3500 * since it will not result in the app launching with the correct
3501 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003502 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003503 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003504 */
3505 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3506 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
3507
3508 /**
3509 * Used with {@link #ACTION_MAIN} to launch the calculator application.
3510 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003511 * <p>NOTE: This should not be used as the primary key of an Intent,
3512 * since it will not result in the app launching with the correct
3513 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003514 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003515 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003516 */
3517 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3518 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
3519
3520 /**
3521 * Used with {@link #ACTION_MAIN} to launch the calendar application.
3522 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003523 * <p>NOTE: This should not be used as the primary key of an Intent,
3524 * since it will not result in the app launching with the correct
3525 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003526 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003527 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003528 */
3529 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3530 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
3531
3532 /**
3533 * Used with {@link #ACTION_MAIN} to launch the contacts application.
3534 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003535 * <p>NOTE: This should not be used as the primary key of an Intent,
3536 * since it will not result in the app launching with the correct
3537 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003538 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003539 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003540 */
3541 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3542 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
3543
3544 /**
3545 * Used with {@link #ACTION_MAIN} to launch the email application.
3546 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003547 * <p>NOTE: This should not be used as the primary key of an Intent,
3548 * since it will not result in the app launching with the correct
3549 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003550 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003551 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003552 */
3553 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3554 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
3555
3556 /**
3557 * Used with {@link #ACTION_MAIN} to launch the gallery application.
3558 * The activity should be able to view and manipulate image and video files
3559 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003560 * <p>NOTE: This should not be used as the primary key of an Intent,
3561 * since it will not result in the app launching with the correct
3562 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003563 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003564 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003565 */
3566 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3567 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
3568
3569 /**
3570 * Used with {@link #ACTION_MAIN} to launch the maps application.
3571 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003572 * <p>NOTE: This should not be used as the primary key of an Intent,
3573 * since it will not result in the app launching with the correct
3574 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003575 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003576 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003577 */
3578 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3579 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
3580
3581 /**
3582 * Used with {@link #ACTION_MAIN} to launch the messaging application.
3583 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003584 * <p>NOTE: This should not be used as the primary key of an Intent,
3585 * since it will not result in the app launching with the correct
3586 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003587 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003588 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003589 */
3590 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3591 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
3592
3593 /**
3594 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003595 * The activity should be able to play, browse, or manipulate music files
3596 * stored on the device.
3597 * <p>NOTE: This should not be used as the primary key of an Intent,
3598 * since it will not result in the app launching with the correct
3599 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08003600 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08003601 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08003602 */
3603 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3604 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
3605
3606 // ---------------------------------------------------------------------
3607 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003608 // Standard extra data keys.
3609
3610 /**
3611 * The initial data to place in a newly created record. Use with
3612 * {@link #ACTION_INSERT}. The data here is a Map containing the same
3613 * fields as would be given to the underlying ContentProvider.insert()
3614 * call.
3615 */
3616 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
3617
3618 /**
3619 * A constant CharSequence that is associated with the Intent, used with
3620 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
3621 * this may be a styled CharSequence, so you must use
3622 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
3623 * retrieve it.
3624 */
3625 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
3626
3627 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07003628 * A constant String that is associated with the Intent, used with
3629 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
3630 * as HTML formatted text. Note that you <em>must</em> also supply
3631 * {@link #EXTRA_TEXT}.
3632 */
3633 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
3634
3635 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003636 * A content: URI holding a stream of data associated with the Intent,
3637 * used with {@link #ACTION_SEND} to supply the data being sent.
3638 */
3639 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
3640
3641 /**
3642 * A String[] holding e-mail addresses that should be delivered to.
3643 */
3644 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
3645
3646 /**
3647 * A String[] holding e-mail addresses that should be carbon copied.
3648 */
3649 public static final String EXTRA_CC = "android.intent.extra.CC";
3650
3651 /**
3652 * A String[] holding e-mail addresses that should be blind carbon copied.
3653 */
3654 public static final String EXTRA_BCC = "android.intent.extra.BCC";
3655
3656 /**
3657 * A constant string holding the desired subject line of a message.
3658 */
3659 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
3660
3661 /**
3662 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07003663 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003664 */
3665 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
3666
3667 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01003668 * An int representing the user id to be used.
3669 *
3670 * @hide
3671 */
3672 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
3673
3674 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00003675 * An int representing the task id to be retrieved. This is used when a launch from recents is
3676 * intercepted by another action such as credentials confirmation to remember which task should
3677 * be resumed when complete.
3678 *
3679 * @hide
3680 */
3681 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
3682
3683 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07003684 * An Intent[] describing additional, alternate choices you would like shown with
3685 * {@link #ACTION_CHOOSER}.
3686 *
3687 * <p>An app may be capable of providing several different payload types to complete a
3688 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
3689 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
3690 * several different supported sending mechanisms for sharing, such as the actual "image/*"
3691 * photo data or a hosted link where the photos can be viewed.</p>
3692 *
3693 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
3694 * first/primary/preferred intent in the set. Additional intents specified in
3695 * this extra are ordered; by default intents that appear earlier in the array will be
3696 * preferred over intents that appear later in the array as matches for the same
3697 * target component. To alter this preference, a calling app may also supply
3698 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
3699 */
3700 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
3701
3702 /**
3703 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
3704 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
3705 *
3706 * <p>An app preparing an action for another app to complete may wish to allow the user to
3707 * disambiguate between several options for completing the action based on the chosen target
3708 * or otherwise refine the action before it is invoked.
3709 * </p>
3710 *
3711 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
3712 * <ul>
3713 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
3714 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
3715 * chosen target beyond the first</li>
3716 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
3717 * should fill in and send once the disambiguation is complete</li>
3718 * </ul>
3719 */
3720 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
3721 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
3722
3723 /**
3724 * A {@link ResultReceiver} used to return data back to the sender.
3725 *
3726 * <p>Used to complete an app-specific
3727 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
3728 *
3729 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
3730 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
3731 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
3732 * when the user selects a target component from the chooser. It is up to the recipient
3733 * to send a result to this ResultReceiver to signal that disambiguation is complete
3734 * and that the chooser should invoke the user's choice.</p>
3735 *
3736 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
3737 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
3738 * to match and fill in the final Intent or ChooserTarget before starting it.
3739 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
3740 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
3741 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
3742 *
3743 * <p>The result code passed to the ResultReceiver should be
3744 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
3745 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
3746 * the chooser should finish without starting a target.</p>
3747 */
3748 public static final String EXTRA_RESULT_RECEIVER
3749 = "android.intent.extra.RESULT_RECEIVER";
3750
3751 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003752 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00003753 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003754 */
3755 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
3756
3757 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07003758 * A Parcelable[] of {@link Intent} or
3759 * {@link android.content.pm.LabeledIntent} objects as set with
3760 * {@link #putExtra(String, Parcelable[])} of additional activities to place
3761 * a the front of the list of choices, when shown to the user with a
3762 * {@link #ACTION_CHOOSER}.
3763 */
3764 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
3765
3766 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08003767 * A {@link IntentSender} to start after ephemeral installation success.
3768 * @hide
3769 */
3770 @SystemApi
3771 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
3772
3773 /**
3774 * A {@link IntentSender} to start after ephemeral installation failure.
3775 * @hide
3776 */
3777 @SystemApi
3778 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
3779
3780 /**
Adam Powelle49d9392014-07-17 18:45:19 -07003781 * A Bundle forming a mapping of potential target package names to different extras Bundles
3782 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
3783 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
3784 * be currently installed on the device.
3785 *
3786 * <p>An application may choose to provide alternate extras for the case where a user
3787 * selects an activity from a predetermined set of target packages. If the activity
3788 * the user selects from the chooser belongs to a package with its package name as
3789 * a key in this bundle, the corresponding extras for that package will be merged with
3790 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
3791 * extra has the same key as an extra already present in the intent it will overwrite
3792 * the extra from the intent.</p>
3793 *
3794 * <p><em>Examples:</em>
3795 * <ul>
3796 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
3797 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
3798 * parameters for that target.</li>
3799 * <li>An application may offer additional metadata for known targets of a given intent
3800 * to pass along information only relevant to that target such as account or content
3801 * identifiers already known to that application.</li>
3802 * </ul></p>
3803 */
3804 public static final String EXTRA_REPLACEMENT_EXTRAS =
3805 "android.intent.extra.REPLACEMENT_EXTRAS";
3806
3807 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07003808 * An {@link IntentSender} that will be notified if a user successfully chooses a target
3809 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
3810 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
3811 * {@link ComponentName} of the chosen component.
3812 *
3813 * <p>In some situations this callback may never come, for example if the user abandons
3814 * the chooser, switches to another task or any number of other reasons. Apps should not
3815 * be written assuming that this callback will always occur.</p>
3816 */
3817 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
3818 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
3819
3820 /**
3821 * The {@link ComponentName} chosen by the user to complete an action.
3822 *
3823 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
3824 */
3825 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
3826
3827 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003828 * A {@link android.view.KeyEvent} object containing the event that
3829 * triggered the creation of the Intent it is in.
3830 */
3831 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
3832
3833 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07003834 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
3835 * before shutting down.
3836 *
3837 * {@hide}
3838 */
3839 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
3840
3841 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07003842 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
3843 * requested by the user.
3844 *
3845 * {@hide}
3846 */
3847 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
3848 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
3849
3850 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003851 * 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 -07003852 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
3853 * of restarting the application.
3854 */
3855 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
3856
3857 /**
3858 * A String holding the phone number originally entered in
3859 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
3860 * number to call in a {@link android.content.Intent#ACTION_CALL}.
3861 */
3862 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02003863
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003864 /**
3865 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
3866 * intents to supply the uid the package had been assigned. Also an optional
3867 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
3868 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
3869 * purpose.
3870 */
3871 public static final String EXTRA_UID = "android.intent.extra.UID";
3872
3873 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003874 * @hide String array of package names.
3875 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08003876 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08003877 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
3878
3879 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003880 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3881 * intents to indicate whether this represents a full uninstall (removing
3882 * both the code and its data) or a partial uninstall (leaving its data,
3883 * implying that this is an update).
3884 */
3885 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003886
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003887 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07003888 * @hide
3889 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3890 * intents to indicate that at this point the package has been removed for
3891 * all users on the device.
3892 */
3893 public static final String EXTRA_REMOVED_FOR_ALL_USERS
3894 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
3895
3896 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003897 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
3898 * intents to indicate that this is a replacement of the package, so this
3899 * broadcast will immediately be followed by an add broadcast for a
3900 * different version of the same package.
3901 */
3902 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07003903
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003904 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003905 * Used as an int extra field in {@link android.app.AlarmManager} intents
3906 * to tell the application being invoked how many pending alarms are being
3907 * delievered with the intent. For one-shot alarms this will always be 1.
3908 * For recurring alarms, this might be greater than 1 if the device was
3909 * asleep or powered off at the time an earlier alarm would have been
3910 * delivered.
3911 */
3912 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07003913
Jacek Surazski86b6c532009-05-13 14:38:28 +02003914 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003915 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
3916 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07003917 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
3918 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003919 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
3920 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
3921 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003922 */
3923 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
3924
3925 /**
3926 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3927 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003928 */
3929 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
3930
3931 /**
3932 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3933 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003934 */
3935 public static final int EXTRA_DOCK_STATE_DESK = 1;
3936
3937 /**
3938 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3939 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05003940 */
3941 public static final int EXTRA_DOCK_STATE_CAR = 2;
3942
3943 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05003944 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3945 * to represent that the phone is in a analog (low end) dock.
3946 */
3947 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
3948
3949 /**
3950 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
3951 * to represent that the phone is in a digital (high end) dock.
3952 */
3953 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
3954
3955 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003956 * Boolean that can be supplied as meta-data with a dock activity, to
3957 * indicate that the dock should take over the home key when it is active.
3958 */
3959 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08003960
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07003961 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02003962 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
3963 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02003964 */
3965 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
3966
3967 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003968 * Used in the extra field in the remote intent. It's astring token passed with the
3969 * remote intent.
3970 */
3971 public static final String EXTRA_REMOTE_INTENT_TOKEN =
3972 "android.intent.extra.remote_intent_token";
3973
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003974 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003975 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003976 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003977 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08003978 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07003979 "android.intent.extra.changed_component_name";
3980
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07003981 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003982 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08003983 * and contains a string array of all of the components that have changed. If
3984 * the state of the overall package has changed, then it will contain an entry
3985 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08003986 */
3987 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
3988 "android.intent.extra.changed_component_name_list";
3989
3990 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003991 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08003992 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00003993 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
3994 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
3995 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003996 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08003997 */
3998 public static final String EXTRA_CHANGED_PACKAGE_LIST =
3999 "android.intent.extra.changed_package_list";
4000
4001 /**
4002 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004003 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4004 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004005 * and contains an integer array of uids of all of the components
4006 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004007 */
4008 public static final String EXTRA_CHANGED_UID_LIST =
4009 "android.intent.extra.changed_uid_list";
4010
4011 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004012 * @hide
4013 * Magic extra system code can use when binding, to give a label for
4014 * who it is that has bound to a service. This is an integer giving
4015 * a framework string resource that can be displayed to the user.
4016 */
4017 public static final String EXTRA_CLIENT_LABEL =
4018 "android.intent.extra.client_label";
4019
4020 /**
4021 * @hide
4022 * Magic extra system code can use when binding, to give a PendingIntent object
4023 * that can be launched for the user to disable the system's use of this
4024 * service.
4025 */
4026 public static final String EXTRA_CLIENT_INTENT =
4027 "android.intent.extra.client_intent";
4028
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004029 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004030 * Extra used to indicate that an intent should only return data that is on
4031 * the local device. This is a boolean extra; the default is false. If true,
4032 * an implementation should only allow the user to select data that is
4033 * already on the device, not requiring it be downloaded from a remote
4034 * service when opened.
4035 *
4036 * @see #ACTION_GET_CONTENT
4037 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004038 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004039 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004040 */
4041 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004042 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004043
Amith Yamasani13593602012-03-22 16:16:17 -07004044 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004045 * Extra used to indicate that an intent can allow the user to select and
4046 * return multiple items. This is a boolean extra; the default is false. If
4047 * true, an implementation is allowed to present the user with a UI where
4048 * they can pick multiple items that are all returned to the caller. When
4049 * this happens, they should be returned as the {@link #getClipData()} part
4050 * of the result Intent.
4051 *
4052 * @see #ACTION_GET_CONTENT
4053 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004054 */
4055 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004056 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004057
4058 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004059 * The integer userHandle carried with broadcast intents related to addition, removal and
4060 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4061 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4062 *
Amith Yamasani13593602012-03-22 16:16:17 -07004063 * @hide
4064 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004065 public static final String EXTRA_USER_HANDLE =
4066 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004067
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004068 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004069 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4070 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4071 */
4072 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004073 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004074
4075 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004076 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004077 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4078 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004079 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004080 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4081
4082 /**
4083 * Extra sent in the intent to the BroadcastReceiver that handles
4084 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4085 * the restrictions as key/value pairs.
4086 */
4087 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4088 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004089
Amith Yamasani86118ba2013-03-28 14:33:16 -07004090 /**
4091 * Extra used in the response from a BroadcastReceiver that handles
4092 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4093 */
4094 public static final String EXTRA_RESTRICTIONS_INTENT =
4095 "android.intent.extra.restrictions_intent";
4096
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004097 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004098 * Extra used to communicate a set of acceptable MIME types. The type of the
4099 * extra is {@code String[]}. Values may be a combination of concrete MIME
4100 * types (such as "image/png") and/or partial MIME types (such as
4101 * "audio/*").
4102 *
4103 * @see #ACTION_GET_CONTENT
4104 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004105 */
4106 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
4107
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004108 /**
4109 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
4110 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07004111 * When this is true, hardware devices can use this information to determine that
4112 * they shouldn't do a complete shutdown of their device since this is not a
4113 * complete shutdown down to the kernel, but only user space restarting.
4114 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07004115 */
4116 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
4117 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
4118
Narayan Kamathccb2a0862013-12-19 14:49:36 +00004119 /**
4120 * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
4121 * user has set their time format preferences to the 24 hour format.
4122 *
4123 * @hide for internal use only.
4124 */
4125 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
4126 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
4127
Jeff Sharkey004a4b22014-09-24 11:45:24 -07004128 /** {@hide} */
4129 public static final String EXTRA_REASON = "android.intent.extra.REASON";
4130
Rubin Xue8490f12015-06-25 12:17:48 +01004131 /** {@hide} */
4132 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
4133
Santos Cordon15a13782015-03-31 18:32:31 -07004134 /**
4135 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
4136 * activation request.
4137 * TODO: Add information about the structure and response data used with the pending intent.
4138 * @hide
4139 */
4140 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
4141 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
4142
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09004143 /**
4144 * Optional index with semantics depending on the intent action.
4145 * @see #ACTION_QUICK_VIEW
4146 */
Steve McKay6eaf38632015-08-04 10:11:01 -07004147 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
4148
Rubin Xu0a29ecd2015-11-04 15:11:48 +00004149 /**
4150 * Optional boolean extra indicating whether quiet mode has been switched on or off.
4151 */
4152 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004153
4154 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004155 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004156 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004157 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
4158 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004159 *
4160 * @hide
4161 */
4162 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
4163 "android.intent.extra.MEDIA_RESOURCE_TYPE";
4164
4165 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004166 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004167 * to represent that a video codec is allowed to use.
4168 *
4169 * @hide
4170 */
4171 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
4172
4173 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08004174 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09004175 * to represent that a audio codec is allowed to use.
4176 *
4177 * @hide
4178 */
4179 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
4180
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004181 // ---------------------------------------------------------------------
4182 // ---------------------------------------------------------------------
4183 // Intent flags (see mFlags variable).
4184
Tor Norbyed9273d62013-05-30 15:59:53 -07004185 /** @hide */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004186 @IntDef(flag = true, value = {
4187 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
4188 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07004189 @Retention(RetentionPolicy.SOURCE)
4190 public @interface GrantUriMode {}
4191
Jeff Sharkey846318a2014-04-04 12:12:41 -07004192 /** @hide */
4193 @IntDef(flag = true, value = {
4194 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
4195 @Retention(RetentionPolicy.SOURCE)
4196 public @interface AccessUriMode {}
4197
4198 /**
4199 * Test if given mode flags specify an access mode, which must be at least
4200 * read and/or write.
4201 *
4202 * @hide
4203 */
4204 public static boolean isAccessUriMode(int modeFlags) {
4205 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
4206 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
4207 }
4208
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004209 /**
4210 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004211 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004212 * specified in its ClipData. When applying to an Intent's ClipData,
4213 * all URIs as well as recursive traversals through data or other ClipData
4214 * in Intent items will be granted; only the grant flags of the top-level
4215 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 */
4217 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
4218 /**
4219 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004220 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004221 * specified in its ClipData. When applying to an Intent's ClipData,
4222 * all URIs as well as recursive traversals through data or other ClipData
4223 * in Intent items will be granted; only the grant flags of the top-level
4224 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004225 */
4226 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
4227 /**
4228 * Can be set by the caller to indicate that this Intent is coming from
4229 * a background operation, not from direct user interaction.
4230 */
4231 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
4232 /**
4233 * A flag you can enable for debugging: when set, log messages will be
4234 * printed during the resolution of this intent to show you what has
4235 * been found to create the final resolved list.
4236 */
4237 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08004238 /**
4239 * If set, this intent will not match any components in packages that
4240 * are currently stopped. If this is not set, then the default behavior
4241 * is to include such applications in the result.
4242 */
4243 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
4244 /**
4245 * If set, this intent will always match any components in packages that
4246 * are currently stopped. This is the default behavior when
4247 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
4248 * flags are set, this one wins (it allows overriding of exclude for
4249 * places where the framework may automatically set the exclude flag).
4250 */
4251 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004252
4253 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004254 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004255 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004256 * persisted across device reboots until explicitly revoked with
4257 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
4258 * grant for possible persisting; the receiving application must call
4259 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
4260 * actually persist.
4261 *
4262 * @see ContentResolver#takePersistableUriPermission(Uri, int)
4263 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
4264 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004265 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004266 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07004267 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07004268
4269 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07004270 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
4271 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
4272 * applies to any URI that is a prefix match against the original granted
4273 * URI. (Without this flag, the URI must match exactly for access to be
4274 * granted.) Another URI is considered a prefix match only when scheme,
4275 * authority, and all path segments defined by the prefix are an exact
4276 * match.
4277 */
4278 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
4279
4280 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004281 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004282 * homework and verified that they correctly handle packages and components
4283 * that come and go over time. In particular:
4284 * <ul>
4285 * <li>Apps installed on external storage, which will appear to be
4286 * uninstalled while the the device is ejected.
4287 * <li>Apps with encryption unaware components, which will appear to not
4288 * exist while the device is locked.
4289 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004290 *
4291 * @hide
4292 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07004293 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07004294
4295 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004296 * If set, the new activity is not kept in the history stack. As soon as
4297 * the user navigates away from it, the activity is finished. This may also
4298 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
4299 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07004300 *
4301 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
4302 * is never invoked when the current activity starts a new activity which
4303 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004304 */
4305 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
4306 /**
4307 * If set, the activity will not be launched if it is already running
4308 * at the top of the history stack.
4309 */
4310 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
4311 /**
4312 * If set, this activity will become the start of a new task on this
4313 * history stack. A task (from the activity that started it to the
4314 * next task activity) defines an atomic group of activities that the
4315 * user can move to. Tasks can be moved to the foreground and background;
4316 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07004317 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08004318 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4319 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004320 *
4321 * <p>This flag is generally used by activities that want
4322 * to present a "launcher" style behavior: they give the user a list of
4323 * separate things that can be done, which otherwise run completely
4324 * independently of the activity launching them.
4325 *
4326 * <p>When using this flag, if a task is already running for the activity
4327 * you are now starting, then a new activity will not be started; instead,
4328 * the current task will simply be brought to the front of the screen with
4329 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
4330 * to disable this behavior.
4331 *
4332 * <p>This flag can not be used when the caller is requesting a result from
4333 * the activity being launched.
4334 */
4335 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
4336 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07004337 * This flag is used to create a new task and launch an activity into it.
4338 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
4339 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
4340 * search through existing tasks for ones matching this Intent. Only if no such
4341 * task is found would a new task be created. When paired with
4342 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
4343 * the search for a matching task and unconditionally start a new task.
4344 *
4345 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
4346 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004347 * top-level application launcher.</strong> Used in conjunction with
4348 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
4349 * behavior of bringing an existing task to the foreground. When set,
4350 * a new task is <em>always</em> started to host the Activity for the
4351 * Intent, regardless of whether there is already an existing task running
4352 * the same thing.
4353 *
4354 * <p><strong>Because the default system does not include graphical task management,
4355 * you should not use this flag unless you provide some way for a user to
4356 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07004357 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07004358 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
4359 * creating new document tasks.
4360 *
4361 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07004362 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004363 *
Scott Main7aee61f2011-02-08 11:25:01 -08004364 * <p>See
4365 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4366 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004367 *
4368 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
4369 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004370 */
4371 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
4372 /**
4373 * If set, and the activity being launched is already running in the
4374 * current task, then instead of launching a new instance of that activity,
4375 * all of the other activities on top of it will be closed and this Intent
4376 * will be delivered to the (now on top) old activity as a new Intent.
4377 *
4378 * <p>For example, consider a task consisting of the activities: A, B, C, D.
4379 * If D calls startActivity() with an Intent that resolves to the component
4380 * of activity B, then C and D will be finished and B receive the given
4381 * Intent, resulting in the stack now being: A, B.
4382 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004383 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004384 * either receive the new intent you are starting here in its
4385 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004386 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07004387 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
4388 * the same intent, then it will be finished and re-created; for all other
4389 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
4390 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004391 *
4392 * <p>This launch mode can also be used to good effect in conjunction with
4393 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
4394 * of a task, it will bring any currently running instance of that task
4395 * to the foreground, and then clear it to its root state. This is
4396 * especially useful, for example, when launching an activity from the
4397 * notification manager.
4398 *
Scott Main7aee61f2011-02-08 11:25:01 -08004399 * <p>See
4400 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
4401 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004402 */
4403 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
4404 /**
4405 * If set and this intent is being used to launch a new activity from an
4406 * existing one, then the reply target of the existing activity will be
4407 * transfered to the new activity. This way the new activity can call
4408 * {@link android.app.Activity#setResult} and have that result sent back to
4409 * the reply target of the original activity.
4410 */
4411 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
4412 /**
4413 * If set and this intent is being used to launch a new activity from an
4414 * existing one, the current activity will not be counted as the top
4415 * activity for deciding whether the new intent should be delivered to
4416 * the top instead of starting a new one. The previous activity will
4417 * be used as the top, with the assumption being that the current activity
4418 * will finish itself immediately.
4419 */
4420 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
4421 /**
4422 * If set, the new activity is not kept in the list of recently launched
4423 * activities.
4424 */
4425 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
4426 /**
4427 * This flag is not normally set by application code, but set for you by
4428 * the system as described in the
4429 * {@link android.R.styleable#AndroidManifestActivity_launchMode
4430 * launchMode} documentation for the singleTask mode.
4431 */
4432 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
4433 /**
4434 * If set, and this activity is either being started in a new task or
4435 * bringing to the top an existing task, then it will be launched as
4436 * the front door of the task. This will result in the application of
4437 * any affinities needed to have that task in the proper state (either
4438 * moving activities to or from it), or simply resetting that task to
4439 * its initial state if needed.
4440 */
4441 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
4442 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004443 * This flag is not normally set by application code, but set for you by
4444 * the system if this activity is being launched from history
4445 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004446 */
4447 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004448 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004449 * @deprecated As of API 21 this performs identically to
4450 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08004451 */
4452 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004453 /**
Craig Mautner026596b2014-05-21 15:35:44 -07004454 * This flag is used to open a document into a new task rooted at the activity launched
4455 * by this Intent. Through the use of this flag, or its equivalent attribute,
4456 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00004457 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004458 *
Craig Mautner026596b2014-05-21 15:35:44 -07004459 * <p>The use of the activity attribute form of this,
4460 * {@link android.R.attr#documentLaunchMode}, is
4461 * preferred over the Intent flag described here. The attribute form allows the
4462 * Activity to specify multiple document behavior for all launchers of the Activity
4463 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004464 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07004465 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
4466 * it is kept after the activity is finished is different than the use of
4467 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
4468 * this flag is being used to create a new recents entry, then by default that entry
4469 * will be removed once the activity is finished. You can modify this behavior with
4470 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
4471 *
Craig Mautner026596b2014-05-21 15:35:44 -07004472 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
4473 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
4474 * equivalent of the Activity manifest specifying {@link
4475 * android.R.attr#documentLaunchMode}="intoExisting". When used with
4476 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
4477 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07004478 *
Craig Mautner026596b2014-05-21 15:35:44 -07004479 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07004480 *
Craig Mautner026596b2014-05-21 15:35:44 -07004481 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07004482 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
4483 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07004484 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07004485 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004486 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004487 * callback from occurring on the current frontmost activity before it is
4488 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07004489 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004490 * <p>Typically, an activity can rely on that callback to indicate that an
4491 * explicit user action has caused their activity to be moved out of the
4492 * foreground. The callback marks an appropriate point in the activity's
4493 * lifecycle for it to dismiss any notifications that it intends to display
4494 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07004495 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004496 * <p>If an activity is ever started via any non-user-driven events such as
4497 * phone-call receipt or an alarm handler, this flag should be passed to {@link
4498 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07004499 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08004500 */
4501 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004502 /**
4503 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4504 * this flag will cause the launched activity to be brought to the front of its
4505 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07004506 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004507 * <p>For example, consider a task consisting of four activities: A, B, C, D.
4508 * If D calls startActivity() with an Intent that resolves to the component
4509 * of activity B, then B will be brought to the front of the history stack,
4510 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07004511 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004512 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07004513 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004514 */
4515 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004516 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004517 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4518 * this flag will prevent the system from applying an activity transition
4519 * animation to go to the next activity state. This doesn't mean an
4520 * animation will never run -- if another activity change happens that doesn't
4521 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004522 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07004523 * when you are going to do a series of activity operations but the
4524 * animation seen by the user shouldn't be driven by the first activity
4525 * change but rather a later one.
4526 */
4527 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
4528 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08004529 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4530 * this flag will cause any existing task that would be associated with the
4531 * activity to be cleared before the activity is started. That is, the activity
4532 * becomes the new root of an otherwise empty task, and any old activities
4533 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4534 */
4535 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
4536 /**
4537 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
4538 * this flag will cause a newly launching task to be placed on top of the current
4539 * home activity task (if there is one). That is, pressing back from the task
4540 * will always return the user to home even if that was not the last activity they
4541 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
4542 */
4543 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
4544 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07004545 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
4546 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004547 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07004548 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07004549 * this flag. When set and the task's activity is finished, the recents
4550 * entry will remain in the interface for the user to re-launch it, like a
4551 * recents entry for a top-level application.
4552 * <p>
4553 * The receiving activity can override this request with
4554 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
4555 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07004556 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07004557 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07004558 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07004559
4560 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004561 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
4562 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08004563 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
4564 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004565 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08004566 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08004567
4568 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004569 * If set, when sending a broadcast only registered receivers will be
4570 * called -- no BroadcastReceiver components will be launched.
4571 */
4572 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004573 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004574 * If set, when sending a broadcast the new broadcast will replace
4575 * any existing pending broadcast that matches it. Matching is defined
4576 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
4577 * true for the intents of the two broadcasts. When a match is found,
4578 * the new broadcast (and receivers associated with it) will replace the
4579 * existing one in the pending broadcast list, remaining at the same
4580 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08004581 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08004582 * <p>This flag is most typically used with sticky broadcasts, which
4583 * only care about delivering the most recent values of the broadcast
4584 * to their receivers.
4585 */
4586 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
4587 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08004588 * If set, when sending a broadcast the recipient is allowed to run at
4589 * foreground priority, with a shorter timeout interval. During normal
4590 * broadcasts the receivers are not automatically hoisted out of the
4591 * background priority class.
4592 */
4593 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
4594 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07004595 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
4596 * They can still propagate results through to later receivers, but they can not prevent
4597 * later receivers from seeing the broadcast.
4598 */
4599 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
4600 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004601 * If set, when sending a broadcast <i>before boot has completed</i> only
4602 * registered receivers will be called -- no BroadcastReceiver components
4603 * will be launched. Sticky intent state will be recorded properly even
4604 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
4605 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07004606 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004607 * <p>This flag is only for use by system sevices as a convenience to
4608 * avoid having to implement a more complex mechanism around detection
4609 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07004610 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004611 * @hide
4612 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004613 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07004614 /**
4615 * Set when this broadcast is for a boot upgrade, a special mode that
4616 * allows the broadcast to be sent before the system is ready and launches
4617 * the app process with no providers running in it.
4618 * @hide
4619 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07004620 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08004621 /**
4622 * If set, the broadcast will always go to manifest receivers in background (cached
4623 * or not running) apps, regardless of whether that would be done by default. By
4624 * default they will only receive broadcasts if the broadcast has specified an
4625 * explicit component or package name.
4626 * @hide
4627 */
4628 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
4629 /**
4630 * If set, the broadcast will never go to manifest receivers in background (cached
4631 * or not running) apps, regardless of whether that would be done by default. By
4632 * default they will receive broadcasts if the broadcast has specified an
4633 * explicit component or package name.
4634 * @hide
4635 */
4636 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004637
Dianne Hackbornfa82f222009-09-17 15:14:12 -07004638 /**
4639 * @hide Flags that can't be changed with PendingIntent.
4640 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07004641 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
4642 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4643 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08004644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004645 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004646 // ---------------------------------------------------------------------
4647 // toUri() and parseUri() options.
4648
4649 /**
4650 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4651 * always has the "intent:" scheme. This syntax can be used when you want
4652 * to later disambiguate between URIs that are intended to describe an
4653 * Intent vs. all others that should be treated as raw URIs. When used
4654 * with {@link #parseUri}, any other scheme will result in a generic
4655 * VIEW action for that raw URI.
4656 */
4657 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08004658
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004659 /**
4660 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
4661 * always has the "android-app:" scheme. This is a variation of
4662 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
4663 * http/https URI being delivered to a specific package name. The format
4664 * is:
4665 *
4666 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004667 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004668 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08004669 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
4670 * you must also include a scheme; including a path also requires both a host and a scheme.
4671 * The final #Intent; fragment can be used without a scheme, host, or path.
4672 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08004673 * used with intents that have a {@link #setSelector}, since the base intent
4674 * will always have an explicit package name.</p>
4675 *
4676 * <p>Some examples of how this scheme maps to Intent objects:</p>
4677 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
4678 * <colgroup align="left" />
4679 * <colgroup align="left" />
4680 * <thead>
4681 * <tr><th>URI</th> <th>Intent</th></tr>
4682 * </thead>
4683 *
4684 * <tbody>
4685 * <tr><td><code>android-app://com.example.app</code></td>
4686 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4687 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
4688 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4689 * </table></td>
4690 * </tr>
4691 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
4692 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4693 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4694 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
4695 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4696 * </table></td>
4697 * </tr>
4698 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
4699 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4700 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
4701 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4702 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4703 * </table></td>
4704 * </tr>
4705 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4706 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4707 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4708 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4709 * </table></td>
4710 * </tr>
4711 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
4712 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
4713 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4714 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
4715 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4716 * </table></td>
4717 * </tr>
4718 * <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>
4719 * <td><table border="" style="margin:0" >
4720 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
4721 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
4722 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
4723 * </table></td>
4724 * </tr>
4725 * </tbody>
4726 * </table>
4727 */
4728 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
4729
Dianne Hackborn24b1c232014-11-20 17:17:39 -08004730 /**
4731 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
4732 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
4733 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
4734 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
4735 * generated Intent can not cause unexpected data access to happen.
4736 *
4737 * <p>If you do not trust the source of the URI being parsed, you should still do further
4738 * processing to protect yourself from it. In particular, when using it to start an
4739 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
4740 * that can handle it.</p>
4741 */
4742 public static final int URI_ALLOW_UNSAFE = 1<<2;
4743
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004744 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004745
4746 private String mAction;
4747 private Uri mData;
4748 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004749 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004750 private ComponentName mComponent;
4751 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004752 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004753 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004754 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004755 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004756 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004757 private int mContentUserHint = UserHandle.USER_CURRENT;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004758
4759 // ---------------------------------------------------------------------
4760
4761 /**
4762 * Create an empty intent.
4763 */
4764 public Intent() {
4765 }
4766
4767 /**
4768 * Copy constructor.
4769 */
4770 public Intent(Intent o) {
4771 this.mAction = o.mAction;
4772 this.mData = o.mData;
4773 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004774 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004775 this.mComponent = o.mComponent;
4776 this.mFlags = o.mFlags;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01004777 this.mContentUserHint = o.mContentUserHint;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004778 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004779 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004780 }
4781 if (o.mExtras != null) {
4782 this.mExtras = new Bundle(o.mExtras);
4783 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08004784 if (o.mSourceBounds != null) {
4785 this.mSourceBounds = new Rect(o.mSourceBounds);
4786 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004787 if (o.mSelector != null) {
4788 this.mSelector = new Intent(o.mSelector);
4789 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08004790 if (o.mClipData != null) {
4791 this.mClipData = new ClipData(o.mClipData);
4792 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004793 }
4794
4795 @Override
4796 public Object clone() {
4797 return new Intent(this);
4798 }
4799
4800 private Intent(Intent o, boolean all) {
4801 this.mAction = o.mAction;
4802 this.mData = o.mData;
4803 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004804 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004805 this.mComponent = o.mComponent;
4806 if (o.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07004807 this.mCategories = new ArraySet<String>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004808 }
4809 }
4810
4811 /**
4812 * Make a clone of only the parts of the Intent that are relevant for
4813 * filter matching: the action, data, type, component, and categories.
4814 */
4815 public Intent cloneFilter() {
4816 return new Intent(this, false);
4817 }
4818
4819 /**
4820 * Create an intent with a given action. All other fields (data, type,
4821 * class) are null. Note that the action <em>must</em> be in a
4822 * namespace because Intents are used globally in the system -- for
4823 * example the system VIEW action is android.intent.action.VIEW; an
4824 * application's custom action would be something like
4825 * com.google.app.myapp.CUSTOM_ACTION.
4826 *
4827 * @param action The Intent action, such as ACTION_VIEW.
4828 */
4829 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004830 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004831 }
4832
4833 /**
4834 * Create an intent with a given action and for a given data url. Note
4835 * that the action <em>must</em> be in a namespace because Intents are
4836 * used globally in the system -- for example the system VIEW action is
4837 * android.intent.action.VIEW; an application's custom action would be
4838 * something like com.google.app.myapp.CUSTOM_ACTION.
4839 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004840 * <p><em>Note: scheme and host name matching in the Android framework is
4841 * case-sensitive, unlike the formal RFC. As a result,
4842 * you should always ensure that you write your Uri with these elements
4843 * using lower case letters, and normalize any Uris you receive from
4844 * outside of Android to ensure the scheme and host is lower case.</em></p>
4845 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004846 * @param action The Intent action, such as ACTION_VIEW.
4847 * @param uri The Intent data URI.
4848 */
4849 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004850 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004851 mData = uri;
4852 }
4853
4854 /**
4855 * Create an intent for a specific component. All other fields (action, data,
4856 * type, class) are null, though they can be modified later with explicit
4857 * calls. This provides a convenient way to create an intent that is
4858 * intended to execute a hard-coded class name, rather than relying on the
4859 * system to find an appropriate class for you; see {@link #setComponent}
4860 * for more information on the repercussions of this.
4861 *
4862 * @param packageContext A Context of the application package implementing
4863 * this class.
4864 * @param cls The component class that is to be used for the intent.
4865 *
4866 * @see #setClass
4867 * @see #setComponent
4868 * @see #Intent(String, android.net.Uri , Context, Class)
4869 */
4870 public Intent(Context packageContext, Class<?> cls) {
4871 mComponent = new ComponentName(packageContext, cls);
4872 }
4873
4874 /**
4875 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07004876 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004877 * construct the Intent and then calling {@link #setClass} to set its
4878 * class.
4879 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07004880 * <p><em>Note: scheme and host name matching in the Android framework is
4881 * case-sensitive, unlike the formal RFC. As a result,
4882 * you should always ensure that you write your Uri with these elements
4883 * using lower case letters, and normalize any Uris you receive from
4884 * outside of Android to ensure the scheme and host is lower case.</em></p>
4885 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004886 * @param action The Intent action, such as ACTION_VIEW.
4887 * @param uri The Intent data URI.
4888 * @param packageContext A Context of the application package implementing
4889 * this class.
4890 * @param cls The component class that is to be used for the intent.
4891 *
4892 * @see #Intent(String, android.net.Uri)
4893 * @see #Intent(Context, Class)
4894 * @see #setClass
4895 * @see #setComponent
4896 */
4897 public Intent(String action, Uri uri,
4898 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08004899 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004900 mData = uri;
4901 mComponent = new ComponentName(packageContext, cls);
4902 }
4903
4904 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004905 * Create an intent to launch the main (root) activity of a task. This
4906 * is the Intent that is started when the application's is launched from
4907 * Home. For anything else that wants to launch an application in the
4908 * same way, it is important that they use an Intent structured the same
4909 * way, and can use this function to ensure this is the case.
4910 *
4911 * <p>The returned Intent has the given Activity component as its explicit
4912 * component, {@link #ACTION_MAIN} as its action, and includes the
4913 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4914 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4915 * to do that through {@link #addFlags(int)} on the returned Intent.
4916 *
4917 * @param mainActivity The main activity component that this Intent will
4918 * launch.
4919 * @return Returns a newly created Intent that can be used to launch the
4920 * activity as a main application entry.
4921 *
4922 * @see #setClass
4923 * @see #setComponent
4924 */
4925 public static Intent makeMainActivity(ComponentName mainActivity) {
4926 Intent intent = new Intent(ACTION_MAIN);
4927 intent.setComponent(mainActivity);
4928 intent.addCategory(CATEGORY_LAUNCHER);
4929 return intent;
4930 }
4931
4932 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004933 * Make an Intent for the main activity of an application, without
4934 * specifying a specific activity to run but giving a selector to find
4935 * the activity. This results in a final Intent that is structured
4936 * the same as when the application is launched from
4937 * Home. For anything else that wants to launch an application in the
4938 * same way, it is important that they use an Intent structured the same
4939 * way, and can use this function to ensure this is the case.
4940 *
4941 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
4942 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
4943 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
4944 * to do that through {@link #addFlags(int)} on the returned Intent.
4945 *
4946 * @param selectorAction The action name of the Intent's selector.
4947 * @param selectorCategory The name of a category to add to the Intent's
4948 * selector.
4949 * @return Returns a newly created Intent that can be used to launch the
4950 * activity as a main application entry.
4951 *
4952 * @see #setSelector(Intent)
4953 */
4954 public static Intent makeMainSelectorActivity(String selectorAction,
4955 String selectorCategory) {
4956 Intent intent = new Intent(ACTION_MAIN);
4957 intent.addCategory(CATEGORY_LAUNCHER);
4958 Intent selector = new Intent();
4959 selector.setAction(selectorAction);
4960 selector.addCategory(selectorCategory);
4961 intent.setSelector(selector);
4962 return intent;
4963 }
4964
4965 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08004966 * Make an Intent that can be used to re-launch an application's task
4967 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
4968 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
4969 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
4970 *
4971 * @param mainActivity The activity component that is the root of the
4972 * task; this is the activity that has been published in the application's
4973 * manifest as the main launcher icon.
4974 *
4975 * @return Returns a newly created Intent that can be used to relaunch the
4976 * activity's task in its root state.
4977 */
4978 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
4979 Intent intent = makeMainActivity(mainActivity);
4980 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
4981 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
4982 return intent;
4983 }
4984
4985 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004986 * Call {@link #parseUri} with 0 flags.
4987 * @deprecated Use {@link #parseUri} instead.
4988 */
4989 @Deprecated
4990 public static Intent getIntent(String uri) throws URISyntaxException {
4991 return parseUri(uri, 0);
4992 }
Tom Taylord4a47292009-12-21 13:59:18 -08004993
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004994 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004995 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004996 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07004997 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07004998 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004999 *
5000 * <p>The URI given here must not be relative -- that is, it must include
5001 * the scheme and full path.
5002 *
5003 * @param uri The URI to turn into an Intent.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005004 * @param flags Additional processing flags. Either 0,
5005 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005006 *
5007 * @return Intent The newly created Intent object.
5008 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005009 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
5010 * it bad (as parsed by the Uri class) or the Intent data within the
5011 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08005012 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005013 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 */
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005015 public static Intent parseUri(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005016 int i = 0;
5017 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005018 final boolean androidApp = uri.startsWith("android-app:");
5019
5020 // Validate intent scheme if requested.
5021 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
5022 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005023 Intent intent = new Intent(ACTION_VIEW);
5024 try {
5025 intent.setData(Uri.parse(uri));
5026 } catch (IllegalArgumentException e) {
5027 throw new URISyntaxException(uri, e.getMessage());
5028 }
5029 return intent;
5030 }
5031 }
Tom Taylord4a47292009-12-21 13:59:18 -08005032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005033 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005034 // simple case
5035 if (i == -1) {
5036 if (!androidApp) {
5037 return new Intent(ACTION_VIEW, Uri.parse(uri));
5038 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005039
5040 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005041 } else if (!uri.startsWith("#Intent;", i)) {
5042 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005043 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005044 } else {
5045 i = -1;
5046 }
5047 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005048
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005049 // new format
5050 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005051 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005052 boolean explicitAction = false;
5053 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005054
5055 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005056 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005057 String data;
5058 if (i >= 0) {
5059 data = uri.substring(0, i);
5060 i += 8; // length of "#Intent;"
5061 } else {
5062 data = uri;
5063 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005064
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005065 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005066 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005067 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005068 if (eq < 0) eq = i-1;
5069 int semi = uri.indexOf(';', i);
5070 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005071
5072 // action
5073 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005074 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005075 if (!inSelector) {
5076 explicitAction = true;
5077 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005078 }
5079
5080 // categories
5081 else if (uri.startsWith("category=", i)) {
5082 intent.addCategory(value);
5083 }
5084
5085 // type
5086 else if (uri.startsWith("type=", i)) {
5087 intent.mType = value;
5088 }
5089
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005090 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005091 else if (uri.startsWith("launchFlags=", i)) {
5092 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005093 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5094 intent.mFlags &= ~IMMUTABLE_FLAGS;
5095 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005096 }
5097
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005098 // package
5099 else if (uri.startsWith("package=", i)) {
5100 intent.mPackage = value;
5101 }
5102
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005103 // component
5104 else if (uri.startsWith("component=", i)) {
5105 intent.mComponent = ComponentName.unflattenFromString(value);
5106 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005107
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005108 // scheme
5109 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005110 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005111 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005112 } else {
5113 scheme = value;
5114 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005115 }
5116
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005117 // source bounds
5118 else if (uri.startsWith("sourceBounds=", i)) {
5119 intent.mSourceBounds = Rect.unflattenFromString(value);
5120 }
5121
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005122 // selector
5123 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
5124 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005125 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005126 }
5127
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005128 // extra
5129 else {
5130 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005131 // create Bundle if it doesn't already exist
5132 if (intent.mExtras == null) intent.mExtras = new Bundle();
5133 Bundle b = intent.mExtras;
5134 // add EXTRA
5135 if (uri.startsWith("S.", i)) b.putString(key, value);
5136 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
5137 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
5138 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
5139 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
5140 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
5141 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
5142 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
5143 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
5144 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
5145 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005146
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005147 // move to the next item
5148 i = semi + 1;
5149 }
5150
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005151 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005152 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005153 if (baseIntent.mPackage == null) {
5154 baseIntent.setSelector(intent);
5155 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005156 intent = baseIntent;
5157 }
5158
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005159 if (data != null) {
5160 if (data.startsWith("intent:")) {
5161 data = data.substring(7);
5162 if (scheme != null) {
5163 data = scheme + ':' + data;
5164 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005165 } else if (data.startsWith("android-app:")) {
5166 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
5167 // Correctly formed android-app, first part is package name.
5168 int end = data.indexOf('/', 14);
5169 if (end < 0) {
5170 // All we have is a package name.
5171 intent.mPackage = data.substring(14);
5172 if (!explicitAction) {
5173 intent.setAction(ACTION_MAIN);
5174 }
5175 data = "";
5176 } else {
5177 // Target the Intent at the given package name always.
5178 String authority = null;
5179 intent.mPackage = data.substring(14, end);
5180 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005181 if ((end+1) < data.length()) {
5182 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
5183 // Found a scheme, remember it.
5184 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005185 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08005186 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
5187 // Found a authority, remember it.
5188 authority = data.substring(end+1, newEnd);
5189 end = newEnd;
5190 }
5191 } else {
5192 // All we have is a scheme.
5193 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005194 }
5195 }
5196 if (scheme == null) {
5197 // If there was no scheme, then this just targets the package.
5198 if (!explicitAction) {
5199 intent.setAction(ACTION_MAIN);
5200 }
5201 data = "";
5202 } else if (authority == null) {
5203 data = scheme + ":";
5204 } else {
5205 data = scheme + "://" + authority + data.substring(end);
5206 }
5207 }
5208 } else {
5209 data = "";
5210 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005211 }
Tom Taylord4a47292009-12-21 13:59:18 -08005212
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005213 if (data.length() > 0) {
5214 try {
5215 intent.mData = Uri.parse(data);
5216 } catch (IllegalArgumentException e) {
5217 throw new URISyntaxException(uri, e.getMessage());
5218 }
5219 }
5220 }
Tom Taylord4a47292009-12-21 13:59:18 -08005221
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005222 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07005223
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005224 } catch (IndexOutOfBoundsException e) {
5225 throw new URISyntaxException(uri, "illegal Intent URI format", i);
5226 }
5227 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005228
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005229 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005230 return getIntentOld(uri, 0);
5231 }
5232
5233 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005234 Intent intent;
5235
5236 int i = uri.lastIndexOf('#');
5237 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005238 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005239 final int intentFragmentStart = i;
5240 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005241
5242 i++;
5243
5244 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005245 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005246 i += 7;
5247 int j = uri.indexOf(')', i);
5248 action = uri.substring(i, j);
5249 i = j + 1;
5250 }
5251
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005252 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005253
5254 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005255 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005256 i += 11;
5257 int j = uri.indexOf(')', i);
5258 while (i < j) {
5259 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07005260 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005261 if (i < sep) {
5262 intent.addCategory(uri.substring(i, sep));
5263 }
5264 i = sep + 1;
5265 }
5266 i = j + 1;
5267 }
5268
5269 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005270 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005271 i += 5;
5272 int j = uri.indexOf(')', i);
5273 intent.mType = uri.substring(i, j);
5274 i = j + 1;
5275 }
5276
5277 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005278 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005279 i += 12;
5280 int j = uri.indexOf(')', i);
5281 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005282 if ((flags& URI_ALLOW_UNSAFE) == 0) {
5283 intent.mFlags &= ~IMMUTABLE_FLAGS;
5284 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005285 i = j + 1;
5286 }
5287
5288 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005289 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005290 i += 10;
5291 int j = uri.indexOf(')', i);
5292 int sep = uri.indexOf('!', i);
5293 if (sep >= 0 && sep < j) {
5294 String pkg = uri.substring(i, sep);
5295 String cls = uri.substring(sep + 1, j);
5296 intent.mComponent = new ComponentName(pkg, cls);
5297 }
5298 i = j + 1;
5299 }
5300
5301 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005302 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005303 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07005304
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005305 final int closeParen = uri.indexOf(')', i);
5306 if (closeParen == -1) throw new URISyntaxException(uri,
5307 "EXTRA missing trailing ')'", i);
5308
5309 while (i < closeParen) {
5310 // fetch the key value
5311 int j = uri.indexOf('=', i);
5312 if (j <= i + 1 || i >= closeParen) {
5313 throw new URISyntaxException(uri, "EXTRA missing '='", i);
5314 }
5315 char type = uri.charAt(i);
5316 i++;
5317 String key = uri.substring(i, j);
5318 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07005319
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005320 // get type-value
5321 j = uri.indexOf('!', i);
5322 if (j == -1 || j >= closeParen) j = closeParen;
5323 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5324 String value = uri.substring(i, j);
5325 i = j;
5326
5327 // create Bundle if it doesn't already exist
5328 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07005329
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005330 // add item to bundle
5331 try {
5332 switch (type) {
5333 case 'S':
5334 intent.mExtras.putString(key, Uri.decode(value));
5335 break;
5336 case 'B':
5337 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
5338 break;
5339 case 'b':
5340 intent.mExtras.putByte(key, Byte.parseByte(value));
5341 break;
5342 case 'c':
5343 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
5344 break;
5345 case 'd':
5346 intent.mExtras.putDouble(key, Double.parseDouble(value));
5347 break;
5348 case 'f':
5349 intent.mExtras.putFloat(key, Float.parseFloat(value));
5350 break;
5351 case 'i':
5352 intent.mExtras.putInt(key, Integer.parseInt(value));
5353 break;
5354 case 'l':
5355 intent.mExtras.putLong(key, Long.parseLong(value));
5356 break;
5357 case 's':
5358 intent.mExtras.putShort(key, Short.parseShort(value));
5359 break;
5360 default:
5361 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
5362 }
5363 } catch (NumberFormatException e) {
5364 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
5365 }
The Android Open Source Project10592532009-03-18 17:39:46 -07005366
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367 char ch = uri.charAt(i);
5368 if (ch == ')') break;
5369 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
5370 i++;
5371 }
5372 }
5373
Dianne Hackborn6cca1592009-09-20 12:40:03 -07005374 if (isIntentFragment) {
5375 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
5376 } else {
5377 intent.mData = Uri.parse(uri);
5378 }
Tom Taylord4a47292009-12-21 13:59:18 -08005379
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005380 if (intent.mAction == null) {
5381 // By default, if no action is specified, then use VIEW.
5382 intent.mAction = ACTION_VIEW;
5383 }
5384
5385 } else {
5386 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
5387 }
5388
5389 return intent;
5390 }
5391
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005392 /** @hide */
5393 public interface CommandOptionHandler {
5394 boolean handleOption(String opt, ShellCommand cmd);
5395 }
5396
5397 /** @hide */
5398 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
5399 throws URISyntaxException {
5400 Intent intent = new Intent();
5401 Intent baseIntent = intent;
5402 boolean hasIntentInfo = false;
5403
5404 Uri data = null;
5405 String type = null;
5406
5407 String opt;
5408 while ((opt=cmd.getNextOption()) != null) {
5409 switch (opt) {
5410 case "-a":
5411 intent.setAction(cmd.getNextArgRequired());
5412 if (intent == baseIntent) {
5413 hasIntentInfo = true;
5414 }
5415 break;
5416 case "-d":
5417 data = Uri.parse(cmd.getNextArgRequired());
5418 if (intent == baseIntent) {
5419 hasIntentInfo = true;
5420 }
5421 break;
5422 case "-t":
5423 type = cmd.getNextArgRequired();
5424 if (intent == baseIntent) {
5425 hasIntentInfo = true;
5426 }
5427 break;
5428 case "-c":
5429 intent.addCategory(cmd.getNextArgRequired());
5430 if (intent == baseIntent) {
5431 hasIntentInfo = true;
5432 }
5433 break;
5434 case "-e":
5435 case "--es": {
5436 String key = cmd.getNextArgRequired();
5437 String value = cmd.getNextArgRequired();
5438 intent.putExtra(key, value);
5439 }
5440 break;
5441 case "--esn": {
5442 String key = cmd.getNextArgRequired();
5443 intent.putExtra(key, (String) null);
5444 }
5445 break;
5446 case "--ei": {
5447 String key = cmd.getNextArgRequired();
5448 String value = cmd.getNextArgRequired();
5449 intent.putExtra(key, Integer.decode(value));
5450 }
5451 break;
5452 case "--eu": {
5453 String key = cmd.getNextArgRequired();
5454 String value = cmd.getNextArgRequired();
5455 intent.putExtra(key, Uri.parse(value));
5456 }
5457 break;
5458 case "--ecn": {
5459 String key = cmd.getNextArgRequired();
5460 String value = cmd.getNextArgRequired();
5461 ComponentName cn = ComponentName.unflattenFromString(value);
5462 if (cn == null)
5463 throw new IllegalArgumentException("Bad component name: " + value);
5464 intent.putExtra(key, cn);
5465 }
5466 break;
5467 case "--eia": {
5468 String key = cmd.getNextArgRequired();
5469 String value = cmd.getNextArgRequired();
5470 String[] strings = value.split(",");
5471 int[] list = new int[strings.length];
5472 for (int i = 0; i < strings.length; i++) {
5473 list[i] = Integer.decode(strings[i]);
5474 }
5475 intent.putExtra(key, list);
5476 }
5477 break;
5478 case "--eial": {
5479 String key = cmd.getNextArgRequired();
5480 String value = cmd.getNextArgRequired();
5481 String[] strings = value.split(",");
5482 ArrayList<Integer> list = new ArrayList<>(strings.length);
5483 for (int i = 0; i < strings.length; i++) {
5484 list.add(Integer.decode(strings[i]));
5485 }
5486 intent.putExtra(key, list);
5487 }
5488 break;
5489 case "--el": {
5490 String key = cmd.getNextArgRequired();
5491 String value = cmd.getNextArgRequired();
5492 intent.putExtra(key, Long.valueOf(value));
5493 }
5494 break;
5495 case "--ela": {
5496 String key = cmd.getNextArgRequired();
5497 String value = cmd.getNextArgRequired();
5498 String[] strings = value.split(",");
5499 long[] list = new long[strings.length];
5500 for (int i = 0; i < strings.length; i++) {
5501 list[i] = Long.valueOf(strings[i]);
5502 }
5503 intent.putExtra(key, list);
5504 hasIntentInfo = true;
5505 }
5506 break;
5507 case "--elal": {
5508 String key = cmd.getNextArgRequired();
5509 String value = cmd.getNextArgRequired();
5510 String[] strings = value.split(",");
5511 ArrayList<Long> list = new ArrayList<>(strings.length);
5512 for (int i = 0; i < strings.length; i++) {
5513 list.add(Long.valueOf(strings[i]));
5514 }
5515 intent.putExtra(key, list);
5516 hasIntentInfo = true;
5517 }
5518 break;
5519 case "--ef": {
5520 String key = cmd.getNextArgRequired();
5521 String value = cmd.getNextArgRequired();
5522 intent.putExtra(key, Float.valueOf(value));
5523 hasIntentInfo = true;
5524 }
5525 break;
5526 case "--efa": {
5527 String key = cmd.getNextArgRequired();
5528 String value = cmd.getNextArgRequired();
5529 String[] strings = value.split(",");
5530 float[] list = new float[strings.length];
5531 for (int i = 0; i < strings.length; i++) {
5532 list[i] = Float.valueOf(strings[i]);
5533 }
5534 intent.putExtra(key, list);
5535 hasIntentInfo = true;
5536 }
5537 break;
5538 case "--efal": {
5539 String key = cmd.getNextArgRequired();
5540 String value = cmd.getNextArgRequired();
5541 String[] strings = value.split(",");
5542 ArrayList<Float> list = new ArrayList<>(strings.length);
5543 for (int i = 0; i < strings.length; i++) {
5544 list.add(Float.valueOf(strings[i]));
5545 }
5546 intent.putExtra(key, list);
5547 hasIntentInfo = true;
5548 }
5549 break;
5550 case "--esa": {
5551 String key = cmd.getNextArgRequired();
5552 String value = cmd.getNextArgRequired();
5553 // Split on commas unless they are preceeded by an escape.
5554 // The escape character must be escaped for the string and
5555 // again for the regex, thus four escape characters become one.
5556 String[] strings = value.split("(?<!\\\\),");
5557 intent.putExtra(key, strings);
5558 hasIntentInfo = true;
5559 }
5560 break;
5561 case "--esal": {
5562 String key = cmd.getNextArgRequired();
5563 String value = cmd.getNextArgRequired();
5564 // Split on commas unless they are preceeded by an escape.
5565 // The escape character must be escaped for the string and
5566 // again for the regex, thus four escape characters become one.
5567 String[] strings = value.split("(?<!\\\\),");
5568 ArrayList<String> list = new ArrayList<>(strings.length);
5569 for (int i = 0; i < strings.length; i++) {
5570 list.add(strings[i]);
5571 }
5572 intent.putExtra(key, list);
5573 hasIntentInfo = true;
5574 }
5575 break;
5576 case "--ez": {
5577 String key = cmd.getNextArgRequired();
5578 String value = cmd.getNextArgRequired().toLowerCase();
5579 // Boolean.valueOf() results in false for anything that is not "true", which is
5580 // error-prone in shell commands
5581 boolean arg;
5582 if ("true".equals(value) || "t".equals(value)) {
5583 arg = true;
5584 } else if ("false".equals(value) || "f".equals(value)) {
5585 arg = false;
5586 } else {
5587 try {
5588 arg = Integer.decode(value) != 0;
5589 } catch (NumberFormatException ex) {
5590 throw new IllegalArgumentException("Invalid boolean value: " + value);
5591 }
5592 }
5593
5594 intent.putExtra(key, arg);
5595 }
5596 break;
5597 case "-n": {
5598 String str = cmd.getNextArgRequired();
5599 ComponentName cn = ComponentName.unflattenFromString(str);
5600 if (cn == null)
5601 throw new IllegalArgumentException("Bad component name: " + str);
5602 intent.setComponent(cn);
5603 if (intent == baseIntent) {
5604 hasIntentInfo = true;
5605 }
5606 }
5607 break;
5608 case "-p": {
5609 String str = cmd.getNextArgRequired();
5610 intent.setPackage(str);
5611 if (intent == baseIntent) {
5612 hasIntentInfo = true;
5613 }
5614 }
5615 break;
5616 case "-f":
5617 String str = cmd.getNextArgRequired();
5618 intent.setFlags(Integer.decode(str).intValue());
5619 break;
5620 case "--grant-read-uri-permission":
5621 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
5622 break;
5623 case "--grant-write-uri-permission":
5624 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
5625 break;
5626 case "--grant-persistable-uri-permission":
5627 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
5628 break;
5629 case "--grant-prefix-uri-permission":
5630 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
5631 break;
5632 case "--exclude-stopped-packages":
5633 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
5634 break;
5635 case "--include-stopped-packages":
5636 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
5637 break;
5638 case "--debug-log-resolution":
5639 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
5640 break;
5641 case "--activity-brought-to-front":
5642 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
5643 break;
5644 case "--activity-clear-top":
5645 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
5646 break;
5647 case "--activity-clear-when-task-reset":
5648 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
5649 break;
5650 case "--activity-exclude-from-recents":
5651 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
5652 break;
5653 case "--activity-launched-from-history":
5654 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
5655 break;
5656 case "--activity-multiple-task":
5657 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
5658 break;
5659 case "--activity-no-animation":
5660 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
5661 break;
5662 case "--activity-no-history":
5663 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
5664 break;
5665 case "--activity-no-user-action":
5666 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
5667 break;
5668 case "--activity-previous-is-top":
5669 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
5670 break;
5671 case "--activity-reorder-to-front":
5672 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
5673 break;
5674 case "--activity-reset-task-if-needed":
5675 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
5676 break;
5677 case "--activity-single-top":
5678 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
5679 break;
5680 case "--activity-clear-task":
5681 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
5682 break;
5683 case "--activity-task-on-home":
5684 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
5685 break;
5686 case "--receiver-registered-only":
5687 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
5688 break;
5689 case "--receiver-replace-pending":
5690 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
5691 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005692 case "--receiver-foreground":
5693 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
5694 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005695 case "--selector":
5696 intent.setDataAndType(data, type);
5697 intent = new Intent();
5698 break;
5699 default:
5700 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
5701 // Okay, caller handled this option.
5702 } else {
5703 throw new IllegalArgumentException("Unknown option: " + opt);
5704 }
5705 break;
5706 }
5707 }
5708 intent.setDataAndType(data, type);
5709
5710 final boolean hasSelector = intent != baseIntent;
5711 if (hasSelector) {
5712 // A selector was specified; fix up.
5713 baseIntent.setSelector(intent);
5714 intent = baseIntent;
5715 }
5716
5717 String arg = cmd.getNextArg();
5718 baseIntent = null;
5719 if (arg == null) {
5720 if (hasSelector) {
5721 // If a selector has been specified, and no arguments
5722 // have been supplied for the main Intent, then we can
5723 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
5724 // need to have a component name specified yet, the
5725 // selector will take care of that.
5726 baseIntent = new Intent(Intent.ACTION_MAIN);
5727 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5728 }
5729 } else if (arg.indexOf(':') >= 0) {
5730 // The argument is a URI. Fully parse it, and use that result
5731 // to fill in any data not specified so far.
5732 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
5733 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
5734 } else if (arg.indexOf('/') >= 0) {
5735 // The argument is a component name. Build an Intent to launch
5736 // it.
5737 baseIntent = new Intent(Intent.ACTION_MAIN);
5738 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5739 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
5740 } else {
5741 // Assume the argument is a package name.
5742 baseIntent = new Intent(Intent.ACTION_MAIN);
5743 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
5744 baseIntent.setPackage(arg);
5745 }
5746 if (baseIntent != null) {
5747 Bundle extras = intent.getExtras();
5748 intent.replaceExtras((Bundle)null);
5749 Bundle uriExtras = baseIntent.getExtras();
5750 baseIntent.replaceExtras((Bundle)null);
5751 if (intent.getAction() != null && baseIntent.getCategories() != null) {
5752 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
5753 for (String c : cats) {
5754 baseIntent.removeCategory(c);
5755 }
5756 }
5757 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
5758 if (extras == null) {
5759 extras = uriExtras;
5760 } else if (uriExtras != null) {
5761 uriExtras.putAll(extras);
5762 extras = uriExtras;
5763 }
5764 intent.replaceExtras(extras);
5765 hasIntentInfo = true;
5766 }
5767
5768 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
5769 return intent;
5770 }
5771
5772 /** @hide */
5773 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
5774 final String[] lines = new String[] {
5775 "<INTENT> specifications include these flags and arguments:",
5776 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
5777 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
5778 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
5779 " [--esn <EXTRA_KEY> ...]",
5780 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
5781 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
5782 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
5783 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
5784 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
5785 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
5786 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5787 " (mutiple extras passed as Integer[])",
5788 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
5789 " (mutiple extras passed as List<Integer>)",
5790 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5791 " (mutiple extras passed as Long[])",
5792 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
5793 " (mutiple extras passed as List<Long>)",
5794 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5795 " (mutiple extras passed as Float[])",
5796 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
5797 " (mutiple extras passed as List<Float>)",
5798 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5799 " (mutiple extras passed as String[]; to embed a comma into a string,",
5800 " escape it using \"\\,\")",
5801 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
5802 " (mutiple extras passed as List<String>; to embed a comma into a string,",
5803 " escape it using \"\\,\")",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005804 " [--f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005805 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
5806 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
5807 " [--debug-log-resolution] [--exclude-stopped-packages]",
5808 " [--include-stopped-packages]",
5809 " [--activity-brought-to-front] [--activity-clear-top]",
5810 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
5811 " [--activity-launched-from-history] [--activity-multiple-task]",
5812 " [--activity-no-animation] [--activity-no-history]",
5813 " [--activity-no-user-action] [--activity-previous-is-top]",
5814 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
5815 " [--activity-single-top] [--activity-clear-task]",
5816 " [--activity-task-on-home]",
5817 " [--receiver-registered-only] [--receiver-replace-pending]",
Felipe Leme3cb48cd2016-01-27 08:39:09 -08005818 " [--receiver-foreground]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08005819 " [--selector]",
5820 " [<URI> | <PACKAGE> | <COMPONENT>]"
5821 };
5822 for (String line : lines) {
5823 pw.print(prefix);
5824 pw.println(line);
5825 }
5826 }
5827
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005828 /**
5829 * Retrieve the general action to be performed, such as
5830 * {@link #ACTION_VIEW}. The action describes the general way the rest of
5831 * the information in the intent should be interpreted -- most importantly,
5832 * what to do with the data returned by {@link #getData}.
5833 *
5834 * @return The action of this intent or null if none is specified.
5835 *
5836 * @see #setAction
5837 */
5838 public String getAction() {
5839 return mAction;
5840 }
5841
5842 /**
5843 * Retrieve data this intent is operating on. This URI specifies the name
5844 * of the data; often it uses the content: scheme, specifying data in a
5845 * content provider. Other schemes may be handled by specific activities,
5846 * such as http: by the web browser.
5847 *
5848 * @return The URI of the data this intent is targeting or null.
5849 *
5850 * @see #getScheme
5851 * @see #setData
5852 */
5853 public Uri getData() {
5854 return mData;
5855 }
5856
5857 /**
5858 * The same as {@link #getData()}, but returns the URI as an encoded
5859 * String.
5860 */
5861 public String getDataString() {
5862 return mData != null ? mData.toString() : null;
5863 }
5864
5865 /**
5866 * Return the scheme portion of the intent's data. If the data is null or
5867 * does not include a scheme, null is returned. Otherwise, the scheme
5868 * prefix without the final ':' is returned, i.e. "http".
5869 *
5870 * <p>This is the same as calling getData().getScheme() (and checking for
5871 * null data).
5872 *
5873 * @return The scheme of this intent.
5874 *
5875 * @see #getData
5876 */
5877 public String getScheme() {
5878 return mData != null ? mData.getScheme() : null;
5879 }
5880
5881 /**
5882 * Retrieve any explicit MIME type included in the intent. This is usually
5883 * null, as the type is determined by the intent data.
5884 *
5885 * @return If a type was manually set, it is returned; else null is
5886 * returned.
5887 *
5888 * @see #resolveType(ContentResolver)
5889 * @see #setType
5890 */
5891 public String getType() {
5892 return mType;
5893 }
5894
5895 /**
5896 * Return the MIME data type of this intent. If the type field is
5897 * explicitly set, that is simply returned. Otherwise, if the data is set,
5898 * the type of that data is returned. If neither fields are set, a null is
5899 * returned.
5900 *
5901 * @return The MIME type of this intent.
5902 *
5903 * @see #getType
5904 * @see #resolveType(ContentResolver)
5905 */
5906 public String resolveType(Context context) {
5907 return resolveType(context.getContentResolver());
5908 }
5909
5910 /**
5911 * Return the MIME data type of this intent. If the type field is
5912 * explicitly set, that is simply returned. Otherwise, if the data is set,
5913 * the type of that data is returned. If neither fields are set, a null is
5914 * returned.
5915 *
5916 * @param resolver A ContentResolver that can be used to determine the MIME
5917 * type of the intent's data.
5918 *
5919 * @return The MIME type of this intent.
5920 *
5921 * @see #getType
5922 * @see #resolveType(Context)
5923 */
5924 public String resolveType(ContentResolver resolver) {
5925 if (mType != null) {
5926 return mType;
5927 }
5928 if (mData != null) {
5929 if ("content".equals(mData.getScheme())) {
5930 return resolver.getType(mData);
5931 }
5932 }
5933 return null;
5934 }
5935
5936 /**
5937 * Return the MIME data type of this intent, only if it will be needed for
5938 * intent resolution. This is not generally useful for application code;
5939 * it is used by the frameworks for communicating with back-end system
5940 * services.
5941 *
5942 * @param resolver A ContentResolver that can be used to determine the MIME
5943 * type of the intent's data.
5944 *
5945 * @return The MIME type of this intent, or null if it is unknown or not
5946 * needed.
5947 */
5948 public String resolveTypeIfNeeded(ContentResolver resolver) {
5949 if (mComponent != null) {
5950 return mType;
5951 }
5952 return resolveType(resolver);
5953 }
5954
5955 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005956 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005957 *
5958 * @param category The category to check.
5959 *
5960 * @return boolean True if the intent contains the category, else false.
5961 *
5962 * @see #getCategories
5963 * @see #addCategory
5964 */
5965 public boolean hasCategory(String category) {
5966 return mCategories != null && mCategories.contains(category);
5967 }
5968
5969 /**
5970 * Return the set of all categories in the intent. If there are no categories,
5971 * returns NULL.
5972 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005973 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005974 *
5975 * @see #hasCategory
5976 * @see #addCategory
5977 */
5978 public Set<String> getCategories() {
5979 return mCategories;
5980 }
5981
5982 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005983 * Return the specific selector associated with this Intent. If there is
5984 * none, returns null. See {@link #setSelector} for more information.
5985 *
5986 * @see #setSelector
5987 */
5988 public Intent getSelector() {
5989 return mSelector;
5990 }
5991
5992 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005993 * Return the {@link ClipData} associated with this Intent. If there is
5994 * none, returns null. See {@link #setClipData} for more information.
5995 *
John Spurlock125d1332013-11-25 11:58:37 -05005996 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005997 */
5998 public ClipData getClipData() {
5999 return mClipData;
6000 }
6001
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006002 /** @hide */
6003 public int getContentUserHint() {
6004 return mContentUserHint;
6005 }
6006
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006007 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 * Sets the ClassLoader that will be used when unmarshalling
6009 * any Parcelable values from the extras of this Intent.
6010 *
6011 * @param loader a ClassLoader, or null to use the default loader
6012 * at the time of unmarshalling.
6013 */
6014 public void setExtrasClassLoader(ClassLoader loader) {
6015 if (mExtras != null) {
6016 mExtras.setClassLoader(loader);
6017 }
6018 }
6019
6020 /**
6021 * Returns true if an extra value is associated with the given name.
6022 * @param name the extra's name
6023 * @return true if the given extra is present.
6024 */
6025 public boolean hasExtra(String name) {
6026 return mExtras != null && mExtras.containsKey(name);
6027 }
6028
6029 /**
6030 * Returns true if the Intent's extras contain a parcelled file descriptor.
6031 * @return true if the Intent contains a parcelled file descriptor.
6032 */
6033 public boolean hasFileDescriptors() {
6034 return mExtras != null && mExtras.hasFileDescriptors();
6035 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006036
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04006037 /** @hide */
6038 public void setAllowFds(boolean allowFds) {
6039 if (mExtras != null) {
6040 mExtras.setAllowFds(allowFds);
6041 }
6042 }
6043
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006044 /**
6045 * Retrieve extended data from the intent.
6046 *
6047 * @param name The name of the desired item.
6048 *
6049 * @return the value of an item that previously added with putExtra()
6050 * or null if none was found.
6051 *
6052 * @deprecated
6053 * @hide
6054 */
6055 @Deprecated
6056 public Object getExtra(String name) {
6057 return getExtra(name, null);
6058 }
6059
6060 /**
6061 * Retrieve extended data from the intent.
6062 *
6063 * @param name The name of the desired item.
6064 * @param defaultValue the value to be returned if no value of the desired
6065 * type is stored with the given name.
6066 *
6067 * @return the value of an item that previously added with putExtra()
6068 * or the default value if none was found.
6069 *
6070 * @see #putExtra(String, boolean)
6071 */
6072 public boolean getBooleanExtra(String name, boolean defaultValue) {
6073 return mExtras == null ? defaultValue :
6074 mExtras.getBoolean(name, defaultValue);
6075 }
6076
6077 /**
6078 * Retrieve extended data from the intent.
6079 *
6080 * @param name The name of the desired item.
6081 * @param defaultValue the value to be returned if no value of the desired
6082 * type is stored with the given name.
6083 *
6084 * @return the value of an item that previously added with putExtra()
6085 * or the default value if none was found.
6086 *
6087 * @see #putExtra(String, byte)
6088 */
6089 public byte getByteExtra(String name, byte defaultValue) {
6090 return mExtras == null ? defaultValue :
6091 mExtras.getByte(name, defaultValue);
6092 }
6093
6094 /**
6095 * Retrieve extended data from the intent.
6096 *
6097 * @param name The name of the desired item.
6098 * @param defaultValue the value to be returned if no value of the desired
6099 * type is stored with the given name.
6100 *
6101 * @return the value of an item that previously added with putExtra()
6102 * or the default value if none was found.
6103 *
6104 * @see #putExtra(String, short)
6105 */
6106 public short getShortExtra(String name, short defaultValue) {
6107 return mExtras == null ? defaultValue :
6108 mExtras.getShort(name, defaultValue);
6109 }
6110
6111 /**
6112 * Retrieve extended data from the intent.
6113 *
6114 * @param name The name of the desired item.
6115 * @param defaultValue the value to be returned if no value of the desired
6116 * type is stored with the given name.
6117 *
6118 * @return the value of an item that previously added with putExtra()
6119 * or the default value if none was found.
6120 *
6121 * @see #putExtra(String, char)
6122 */
6123 public char getCharExtra(String name, char defaultValue) {
6124 return mExtras == null ? defaultValue :
6125 mExtras.getChar(name, defaultValue);
6126 }
6127
6128 /**
6129 * Retrieve extended data from the intent.
6130 *
6131 * @param name The name of the desired item.
6132 * @param defaultValue the value to be returned if no value of the desired
6133 * type is stored with the given name.
6134 *
6135 * @return the value of an item that previously added with putExtra()
6136 * or the default value if none was found.
6137 *
6138 * @see #putExtra(String, int)
6139 */
6140 public int getIntExtra(String name, int defaultValue) {
6141 return mExtras == null ? defaultValue :
6142 mExtras.getInt(name, defaultValue);
6143 }
6144
6145 /**
6146 * Retrieve extended data from the intent.
6147 *
6148 * @param name The name of the desired item.
6149 * @param defaultValue the value to be returned if no value of the desired
6150 * type is stored with the given name.
6151 *
6152 * @return the value of an item that previously added with putExtra()
6153 * or the default value if none was found.
6154 *
6155 * @see #putExtra(String, long)
6156 */
6157 public long getLongExtra(String name, long defaultValue) {
6158 return mExtras == null ? defaultValue :
6159 mExtras.getLong(name, defaultValue);
6160 }
6161
6162 /**
6163 * Retrieve extended data from the intent.
6164 *
6165 * @param name The name of the desired item.
6166 * @param defaultValue the value to be returned if no value of the desired
6167 * type is stored with the given name.
6168 *
6169 * @return the value of an item that previously added with putExtra(),
6170 * or the default value if no such item is present
6171 *
6172 * @see #putExtra(String, float)
6173 */
6174 public float getFloatExtra(String name, float defaultValue) {
6175 return mExtras == null ? defaultValue :
6176 mExtras.getFloat(name, defaultValue);
6177 }
6178
6179 /**
6180 * Retrieve extended data from the intent.
6181 *
6182 * @param name The name of the desired item.
6183 * @param defaultValue the value to be returned if no value of the desired
6184 * type is stored with the given name.
6185 *
6186 * @return the value of an item that previously added with putExtra()
6187 * or the default value if none was found.
6188 *
6189 * @see #putExtra(String, double)
6190 */
6191 public double getDoubleExtra(String name, double defaultValue) {
6192 return mExtras == null ? defaultValue :
6193 mExtras.getDouble(name, defaultValue);
6194 }
6195
6196 /**
6197 * Retrieve extended data from the intent.
6198 *
6199 * @param name The name of the desired item.
6200 *
6201 * @return the value of an item that previously added with putExtra()
6202 * or null if no String value was found.
6203 *
6204 * @see #putExtra(String, String)
6205 */
6206 public String getStringExtra(String name) {
6207 return mExtras == null ? null : mExtras.getString(name);
6208 }
6209
6210 /**
6211 * Retrieve extended data from the intent.
6212 *
6213 * @param name The name of the desired item.
6214 *
6215 * @return the value of an item that previously added with putExtra()
6216 * or null if no CharSequence value was found.
6217 *
6218 * @see #putExtra(String, CharSequence)
6219 */
6220 public CharSequence getCharSequenceExtra(String name) {
6221 return mExtras == null ? null : mExtras.getCharSequence(name);
6222 }
6223
6224 /**
6225 * Retrieve extended data from the intent.
6226 *
6227 * @param name The name of the desired item.
6228 *
6229 * @return the value of an item that previously added with putExtra()
6230 * or null if no Parcelable value was found.
6231 *
6232 * @see #putExtra(String, Parcelable)
6233 */
6234 public <T extends Parcelable> T getParcelableExtra(String name) {
6235 return mExtras == null ? null : mExtras.<T>getParcelable(name);
6236 }
6237
6238 /**
6239 * Retrieve extended data from the intent.
6240 *
6241 * @param name The name of the desired item.
6242 *
6243 * @return the value of an item that previously added with putExtra()
6244 * or null if no Parcelable[] value was found.
6245 *
6246 * @see #putExtra(String, Parcelable[])
6247 */
6248 public Parcelable[] getParcelableArrayExtra(String name) {
6249 return mExtras == null ? null : mExtras.getParcelableArray(name);
6250 }
6251
6252 /**
6253 * Retrieve extended data from the intent.
6254 *
6255 * @param name The name of the desired item.
6256 *
6257 * @return the value of an item that previously added with putExtra()
6258 * or null if no ArrayList<Parcelable> value was found.
6259 *
6260 * @see #putParcelableArrayListExtra(String, ArrayList)
6261 */
6262 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
6263 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
6264 }
6265
6266 /**
6267 * Retrieve extended data from the intent.
6268 *
6269 * @param name The name of the desired item.
6270 *
6271 * @return the value of an item that previously added with putExtra()
6272 * or null if no Serializable value was found.
6273 *
6274 * @see #putExtra(String, Serializable)
6275 */
6276 public Serializable getSerializableExtra(String name) {
6277 return mExtras == null ? null : mExtras.getSerializable(name);
6278 }
6279
6280 /**
6281 * Retrieve extended data from the intent.
6282 *
6283 * @param name The name of the desired item.
6284 *
6285 * @return the value of an item that previously added with putExtra()
6286 * or null if no ArrayList<Integer> value was found.
6287 *
6288 * @see #putIntegerArrayListExtra(String, ArrayList)
6289 */
6290 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
6291 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
6292 }
6293
6294 /**
6295 * Retrieve extended data from the intent.
6296 *
6297 * @param name The name of the desired item.
6298 *
6299 * @return the value of an item that previously added with putExtra()
6300 * or null if no ArrayList<String> value was found.
6301 *
6302 * @see #putStringArrayListExtra(String, ArrayList)
6303 */
6304 public ArrayList<String> getStringArrayListExtra(String name) {
6305 return mExtras == null ? null : mExtras.getStringArrayList(name);
6306 }
6307
6308 /**
6309 * Retrieve extended data from the intent.
6310 *
6311 * @param name The name of the desired item.
6312 *
6313 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006314 * or null if no ArrayList<CharSequence> value was found.
6315 *
6316 * @see #putCharSequenceArrayListExtra(String, ArrayList)
6317 */
6318 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
6319 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
6320 }
6321
6322 /**
6323 * Retrieve extended data from the intent.
6324 *
6325 * @param name The name of the desired item.
6326 *
6327 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006328 * or null if no boolean array value was found.
6329 *
6330 * @see #putExtra(String, boolean[])
6331 */
6332 public boolean[] getBooleanArrayExtra(String name) {
6333 return mExtras == null ? null : mExtras.getBooleanArray(name);
6334 }
6335
6336 /**
6337 * Retrieve extended data from the intent.
6338 *
6339 * @param name The name of the desired item.
6340 *
6341 * @return the value of an item that previously added with putExtra()
6342 * or null if no byte array value was found.
6343 *
6344 * @see #putExtra(String, byte[])
6345 */
6346 public byte[] getByteArrayExtra(String name) {
6347 return mExtras == null ? null : mExtras.getByteArray(name);
6348 }
6349
6350 /**
6351 * Retrieve extended data from the intent.
6352 *
6353 * @param name The name of the desired item.
6354 *
6355 * @return the value of an item that previously added with putExtra()
6356 * or null if no short array value was found.
6357 *
6358 * @see #putExtra(String, short[])
6359 */
6360 public short[] getShortArrayExtra(String name) {
6361 return mExtras == null ? null : mExtras.getShortArray(name);
6362 }
6363
6364 /**
6365 * Retrieve extended data from the intent.
6366 *
6367 * @param name The name of the desired item.
6368 *
6369 * @return the value of an item that previously added with putExtra()
6370 * or null if no char array value was found.
6371 *
6372 * @see #putExtra(String, char[])
6373 */
6374 public char[] getCharArrayExtra(String name) {
6375 return mExtras == null ? null : mExtras.getCharArray(name);
6376 }
6377
6378 /**
6379 * Retrieve extended data from the intent.
6380 *
6381 * @param name The name of the desired item.
6382 *
6383 * @return the value of an item that previously added with putExtra()
6384 * or null if no int array value was found.
6385 *
6386 * @see #putExtra(String, int[])
6387 */
6388 public int[] getIntArrayExtra(String name) {
6389 return mExtras == null ? null : mExtras.getIntArray(name);
6390 }
6391
6392 /**
6393 * Retrieve extended data from the intent.
6394 *
6395 * @param name The name of the desired item.
6396 *
6397 * @return the value of an item that previously added with putExtra()
6398 * or null if no long array value was found.
6399 *
6400 * @see #putExtra(String, long[])
6401 */
6402 public long[] getLongArrayExtra(String name) {
6403 return mExtras == null ? null : mExtras.getLongArray(name);
6404 }
6405
6406 /**
6407 * Retrieve extended data from the intent.
6408 *
6409 * @param name The name of the desired item.
6410 *
6411 * @return the value of an item that previously added with putExtra()
6412 * or null if no float array value was found.
6413 *
6414 * @see #putExtra(String, float[])
6415 */
6416 public float[] getFloatArrayExtra(String name) {
6417 return mExtras == null ? null : mExtras.getFloatArray(name);
6418 }
6419
6420 /**
6421 * Retrieve extended data from the intent.
6422 *
6423 * @param name The name of the desired item.
6424 *
6425 * @return the value of an item that previously added with putExtra()
6426 * or null if no double array value was found.
6427 *
6428 * @see #putExtra(String, double[])
6429 */
6430 public double[] getDoubleArrayExtra(String name) {
6431 return mExtras == null ? null : mExtras.getDoubleArray(name);
6432 }
6433
6434 /**
6435 * Retrieve extended data from the intent.
6436 *
6437 * @param name The name of the desired item.
6438 *
6439 * @return the value of an item that previously added with putExtra()
6440 * or null if no String array value was found.
6441 *
6442 * @see #putExtra(String, String[])
6443 */
6444 public String[] getStringArrayExtra(String name) {
6445 return mExtras == null ? null : mExtras.getStringArray(name);
6446 }
6447
6448 /**
6449 * Retrieve extended data from the intent.
6450 *
6451 * @param name The name of the desired item.
6452 *
6453 * @return the value of an item that previously added with putExtra()
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00006454 * or null if no CharSequence array value was found.
6455 *
6456 * @see #putExtra(String, CharSequence[])
6457 */
6458 public CharSequence[] getCharSequenceArrayExtra(String name) {
6459 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
6460 }
6461
6462 /**
6463 * Retrieve extended data from the intent.
6464 *
6465 * @param name The name of the desired item.
6466 *
6467 * @return the value of an item that previously added with putExtra()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006468 * or null if no Bundle value was found.
6469 *
6470 * @see #putExtra(String, Bundle)
6471 */
6472 public Bundle getBundleExtra(String name) {
6473 return mExtras == null ? null : mExtras.getBundle(name);
6474 }
6475
6476 /**
6477 * Retrieve extended data from the intent.
6478 *
6479 * @param name The name of the desired item.
6480 *
6481 * @return the value of an item that previously added with putExtra()
6482 * or null if no IBinder value was found.
6483 *
6484 * @see #putExtra(String, IBinder)
6485 *
6486 * @deprecated
6487 * @hide
6488 */
6489 @Deprecated
6490 public IBinder getIBinderExtra(String name) {
6491 return mExtras == null ? null : mExtras.getIBinder(name);
6492 }
6493
6494 /**
6495 * Retrieve extended data from the intent.
6496 *
6497 * @param name The name of the desired item.
6498 * @param defaultValue The default value to return in case no item is
6499 * associated with the key 'name'
6500 *
6501 * @return the value of an item that previously added with putExtra()
6502 * or defaultValue if none was found.
6503 *
6504 * @see #putExtra
6505 *
6506 * @deprecated
6507 * @hide
6508 */
6509 @Deprecated
6510 public Object getExtra(String name, Object defaultValue) {
6511 Object result = defaultValue;
6512 if (mExtras != null) {
6513 Object result2 = mExtras.get(name);
6514 if (result2 != null) {
6515 result = result2;
6516 }
6517 }
6518
6519 return result;
6520 }
6521
6522 /**
6523 * Retrieves a map of extended data from the intent.
6524 *
6525 * @return the map of all extras previously added with putExtra(),
6526 * or null if none have been added.
6527 */
6528 public Bundle getExtras() {
6529 return (mExtras != null)
6530 ? new Bundle(mExtras)
6531 : null;
6532 }
6533
6534 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07006535 * Filter extras to only basic types.
6536 * @hide
6537 */
6538 public void removeUnsafeExtras() {
6539 if (mExtras != null) {
6540 mExtras.filterValues();
6541 }
6542 }
6543
6544 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006545 * Retrieve any special flags associated with this intent. You will
6546 * normally just set them with {@link #setFlags} and let the system
6547 * take the appropriate action with them.
6548 *
6549 * @return int The currently set flags.
6550 *
6551 * @see #setFlags
6552 */
6553 public int getFlags() {
6554 return mFlags;
6555 }
6556
Dianne Hackborne7f97212011-02-24 14:40:20 -08006557 /** @hide */
6558 public boolean isExcludingStopped() {
6559 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
6560 == FLAG_EXCLUDE_STOPPED_PACKAGES;
6561 }
6562
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006563 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006564 * Retrieve the application package name this Intent is limited to. When
6565 * resolving an Intent, if non-null this limits the resolution to only
6566 * components in the given application package.
6567 *
6568 * @return The name of the application package for the Intent.
6569 *
6570 * @see #resolveActivity
6571 * @see #setPackage
6572 */
6573 public String getPackage() {
6574 return mPackage;
6575 }
6576
6577 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006578 * Retrieve the concrete component associated with the intent. When receiving
6579 * an intent, this is the component that was found to best handle it (that is,
6580 * yourself) and will always be non-null; in all other cases it will be
6581 * null unless explicitly set.
6582 *
6583 * @return The name of the application component to handle the intent.
6584 *
6585 * @see #resolveActivity
6586 * @see #setComponent
6587 */
6588 public ComponentName getComponent() {
6589 return mComponent;
6590 }
6591
6592 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006593 * Get the bounds of the sender of this intent, in screen coordinates. This can be
6594 * used as a hint to the receiver for animations and the like. Null means that there
6595 * is no source bounds.
6596 */
6597 public Rect getSourceBounds() {
6598 return mSourceBounds;
6599 }
6600
6601 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006602 * Return the Activity component that should be used to handle this intent.
6603 * The appropriate component is determined based on the information in the
6604 * intent, evaluated as follows:
6605 *
6606 * <p>If {@link #getComponent} returns an explicit class, that is returned
6607 * without any further consideration.
6608 *
6609 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
6610 * category to be considered.
6611 *
6612 * <p>If {@link #getAction} is non-NULL, the activity must handle this
6613 * action.
6614 *
6615 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
6616 * this type.
6617 *
6618 * <p>If {@link #addCategory} has added any categories, the activity must
6619 * handle ALL of the categories specified.
6620 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006621 * <p>If {@link #getPackage} is non-NULL, only activity components in
6622 * that application package will be considered.
6623 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006624 * <p>If there are no activities that satisfy all of these conditions, a
6625 * null string is returned.
6626 *
6627 * <p>If multiple activities are found to satisfy the intent, the one with
6628 * the highest priority will be used. If there are multiple activities
6629 * with the same priority, the system will either pick the best activity
6630 * based on user preference, or resolve to a system class that will allow
6631 * the user to pick an activity and forward from there.
6632 *
6633 * <p>This method is implemented simply by calling
6634 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
6635 * true.</p>
6636 * <p> This API is called for you as part of starting an activity from an
6637 * intent. You do not normally need to call it yourself.</p>
6638 *
6639 * @param pm The package manager with which to resolve the Intent.
6640 *
6641 * @return Name of the component implementing an activity that can
6642 * display the intent.
6643 *
6644 * @see #setComponent
6645 * @see #getComponent
6646 * @see #resolveActivityInfo
6647 */
6648 public ComponentName resolveActivity(PackageManager pm) {
6649 if (mComponent != null) {
6650 return mComponent;
6651 }
6652
6653 ResolveInfo info = pm.resolveActivity(
6654 this, PackageManager.MATCH_DEFAULT_ONLY);
6655 if (info != null) {
6656 return new ComponentName(
6657 info.activityInfo.applicationInfo.packageName,
6658 info.activityInfo.name);
6659 }
6660
6661 return null;
6662 }
6663
6664 /**
6665 * Resolve the Intent into an {@link ActivityInfo}
6666 * describing the activity that should execute the intent. Resolution
6667 * follows the same rules as described for {@link #resolveActivity}, but
6668 * you get back the completely information about the resolved activity
6669 * instead of just its class name.
6670 *
6671 * @param pm The package manager with which to resolve the Intent.
6672 * @param flags Addition information to retrieve as per
6673 * {@link PackageManager#getActivityInfo(ComponentName, int)
6674 * PackageManager.getActivityInfo()}.
6675 *
6676 * @return PackageManager.ActivityInfo
6677 *
6678 * @see #resolveActivity
6679 */
6680 public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
6681 ActivityInfo ai = null;
6682 if (mComponent != null) {
6683 try {
6684 ai = pm.getActivityInfo(mComponent, flags);
6685 } catch (PackageManager.NameNotFoundException e) {
6686 // ignore
6687 }
6688 } else {
6689 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07006690 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006691 if (info != null) {
6692 ai = info.activityInfo;
6693 }
6694 }
6695
6696 return ai;
6697 }
6698
6699 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07006700 * Special function for use by the system to resolve service
6701 * intents to system apps. Throws an exception if there are
6702 * multiple potential matches to the Intent. Returns null if
6703 * there are no matches.
6704 * @hide
6705 */
6706 public ComponentName resolveSystemService(PackageManager pm, int flags) {
6707 if (mComponent != null) {
6708 return mComponent;
6709 }
6710
6711 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
6712 if (results == null) {
6713 return null;
6714 }
6715 ComponentName comp = null;
6716 for (int i=0; i<results.size(); i++) {
6717 ResolveInfo ri = results.get(i);
6718 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
6719 continue;
6720 }
6721 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
6722 ri.serviceInfo.name);
6723 if (comp != null) {
6724 throw new IllegalStateException("Multiple system services handle " + this
6725 + ": " + comp + ", " + foundComp);
6726 }
6727 comp = foundComp;
6728 }
6729 return comp;
6730 }
6731
6732 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006733 * Set the general action to be performed.
6734 *
6735 * @param action An action name, such as ACTION_VIEW. Application-specific
6736 * actions should be prefixed with the vendor's package name.
6737 *
6738 * @return Returns the same Intent object, for chaining multiple calls
6739 * into a single statement.
6740 *
6741 * @see #getAction
6742 */
6743 public Intent setAction(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006744 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006745 return this;
6746 }
6747
6748 /**
6749 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08006750 * clears any type that was previously set by {@link #setType} or
6751 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006752 *
Nick Pellyccae4122012-01-09 14:12:58 -08006753 * <p><em>Note: scheme matching in the Android framework is
6754 * case-sensitive, unlike the formal RFC. As a result,
6755 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006756 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006757 * {@link #setDataAndNormalize}
6758 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006759 *
Nick Pellyccae4122012-01-09 14:12:58 -08006760 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006761 *
6762 * @return Returns the same Intent object, for chaining multiple calls
6763 * into a single statement.
6764 *
6765 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08006766 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07006767 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006768 */
6769 public Intent setData(Uri data) {
6770 mData = data;
6771 mType = null;
6772 return this;
6773 }
6774
6775 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006776 * Normalize and set the data this intent is operating on.
6777 *
6778 * <p>This method automatically clears any type that was
6779 * previously set (for example, by {@link #setType}).
6780 *
6781 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006782 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08006783 * so really this is just a convenience method for
6784 * <pre>
6785 * setData(data.normalize())
6786 * </pre>
6787 *
6788 * @param data The Uri of the data this intent is now targeting.
6789 *
6790 * @return Returns the same Intent object, for chaining multiple calls
6791 * into a single statement.
6792 *
6793 * @see #getData
6794 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006795 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006796 */
6797 public Intent setDataAndNormalize(Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006798 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08006799 }
6800
6801 /**
6802 * Set an explicit MIME data type.
6803 *
6804 * <p>This is used to create intents that only specify a type and not data,
6805 * for example to indicate the type of data to return.
6806 *
6807 * <p>This method automatically clears any data that was
6808 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07006809 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006810 * <p><em>Note: MIME type matching in the Android framework is
6811 * case-sensitive, unlike formal RFC MIME types. As a result,
6812 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08006813 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
6814 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006815 *
6816 * @param type The MIME type of the data being handled by this intent.
6817 *
6818 * @return Returns the same Intent object, for chaining multiple calls
6819 * into a single statement.
6820 *
6821 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08006822 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006823 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08006824 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006825 */
6826 public Intent setType(String type) {
6827 mData = null;
6828 mType = type;
6829 return this;
6830 }
6831
6832 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006833 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006834 *
Nick Pellyccae4122012-01-09 14:12:58 -08006835 * <p>This is used to create intents that only specify a type and not data,
6836 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006837 *
Nick Pellyccae4122012-01-09 14:12:58 -08006838 * <p>This method automatically clears any data that was
6839 * previously set (for example by {@link #setData}).
6840 *
6841 * <p>The MIME type is normalized using
6842 * {@link #normalizeMimeType} before it is set,
6843 * so really this is just a convenience method for
6844 * <pre>
6845 * setType(Intent.normalizeMimeType(type))
6846 * </pre>
6847 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006848 * @param type The MIME type of the data being handled by this intent.
6849 *
6850 * @return Returns the same Intent object, for chaining multiple calls
6851 * into a single statement.
6852 *
Nick Pellyccae4122012-01-09 14:12:58 -08006853 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006854 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08006855 * @see #normalizeMimeType
6856 */
6857 public Intent setTypeAndNormalize(String type) {
6858 return setType(normalizeMimeType(type));
6859 }
6860
6861 /**
6862 * (Usually optional) Set the data for the intent along with an explicit
6863 * MIME data type. This method should very rarely be used -- it allows you
6864 * to override the MIME type that would ordinarily be inferred from the
6865 * data with your own type given here.
6866 *
6867 * <p><em>Note: MIME type and Uri scheme matching in the
6868 * Android framework is case-sensitive, unlike the formal RFC definitions.
6869 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006870 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08006871 * {@link #setDataAndTypeAndNormalize}
6872 * to ensure that they are converted to lower case.</em>
6873 *
6874 * @param data The Uri of the data this intent is now targeting.
6875 * @param type The MIME type of the data being handled by this intent.
6876 *
6877 * @return Returns the same Intent object, for chaining multiple calls
6878 * into a single statement.
6879 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006880 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08006881 * @see #setData
6882 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006883 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006884 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006885 */
6886 public Intent setDataAndType(Uri data, String type) {
6887 mData = data;
6888 mType = type;
6889 return this;
6890 }
6891
6892 /**
Nick Pellyccae4122012-01-09 14:12:58 -08006893 * (Usually optional) Normalize and set both the data Uri and an explicit
6894 * MIME data type. This method should very rarely be used -- it allows you
6895 * to override the MIME type that would ordinarily be inferred from the
6896 * data with your own type given here.
6897 *
6898 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006899 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08006900 * before they are set, so really this is just a convenience method for
6901 * <pre>
6902 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
6903 * </pre>
6904 *
6905 * @param data The Uri of the data this intent is now targeting.
6906 * @param type The MIME type of the data being handled by this intent.
6907 *
6908 * @return Returns the same Intent object, for chaining multiple calls
6909 * into a single statement.
6910 *
6911 * @see #setType
6912 * @see #setData
6913 * @see #setDataAndType
6914 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006915 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08006916 */
6917 public Intent setDataAndTypeAndNormalize(Uri data, String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04006918 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08006919 }
6920
6921 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006922 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006923 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006924 * activities that provide <em>all</em> of the requested categories will be
6925 * used.
6926 *
6927 * @param category The desired category. This can be either one of the
6928 * predefined Intent categories, or a custom category in your own
6929 * namespace.
6930 *
6931 * @return Returns the same Intent object, for chaining multiple calls
6932 * into a single statement.
6933 *
6934 * @see #hasCategory
6935 * @see #removeCategory
6936 */
6937 public Intent addCategory(String category) {
6938 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006939 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006940 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08006941 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006942 return this;
6943 }
6944
6945 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09006946 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006947 *
6948 * @param category The category to remove.
6949 *
6950 * @see #addCategory
6951 */
6952 public void removeCategory(String category) {
6953 if (mCategories != null) {
6954 mCategories.remove(category);
6955 if (mCategories.size() == 0) {
6956 mCategories = null;
6957 }
6958 }
6959 }
6960
6961 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006962 * Set a selector for this Intent. This is a modification to the kinds of
6963 * things the Intent will match. If the selector is set, it will be used
6964 * when trying to find entities that can handle the Intent, instead of the
6965 * main contents of the Intent. This allows you build an Intent containing
6966 * a generic protocol while targeting it more specifically.
6967 *
6968 * <p>An example of where this may be used is with things like
6969 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
6970 * Intent that will launch the Browser application. However, the correct
6971 * main entry point of an application is actually {@link #ACTION_MAIN}
6972 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
6973 * used to specify the actual Activity to launch. If you launch the browser
6974 * with something different, undesired behavior may happen if the user has
6975 * previously or later launches it the normal way, since they do not match.
6976 * Instead, you can build an Intent with the MAIN action (but no ComponentName
6977 * yet specified) and set a selector with {@link #ACTION_MAIN} and
6978 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
6979 *
6980 * <p>Setting a selector does not impact the behavior of
6981 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
6982 * desired behavior of a selector -- it does not impact the base meaning
6983 * of the Intent, just what kinds of things will be matched against it
6984 * when determining who can handle it.</p>
6985 *
6986 * <p>You can not use both a selector and {@link #setPackage(String)} on
6987 * the same base Intent.</p>
6988 *
6989 * @param selector The desired selector Intent; set to null to not use
6990 * a special selector.
6991 */
6992 public void setSelector(Intent selector) {
6993 if (selector == this) {
6994 throw new IllegalArgumentException(
6995 "Intent being set as a selector of itself");
6996 }
6997 if (selector != null && mPackage != null) {
6998 throw new IllegalArgumentException(
6999 "Can't set selector when package name is already set");
7000 }
7001 mSelector = selector;
7002 }
7003
7004 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007005 * Set a {@link ClipData} associated with this Intent. This replaces any
7006 * previously set ClipData.
7007 *
7008 * <p>The ClipData in an intent is not used for Intent matching or other
7009 * such operations. Semantically it is like extras, used to transmit
7010 * additional data with the Intent. The main feature of using this over
7011 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
7012 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
7013 * items included in the clip data. This is useful, in particular, if
7014 * you want to transmit an Intent containing multiple <code>content:</code>
7015 * URIs for which the recipient may not have global permission to access the
7016 * content provider.
7017 *
7018 * <p>If the ClipData contains items that are themselves Intents, any
7019 * grant flags in those Intents will be ignored. Only the top-level flags
7020 * of the main Intent are respected, and will be applied to all Uri or
7021 * Intent items in the clip (or sub-items of the clip).
7022 *
7023 * <p>The MIME type, label, and icon in the ClipData object are not
7024 * directly used by Intent. Applications should generally rely on the
7025 * MIME type of the Intent itself, not what it may find in the ClipData.
7026 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05007027 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007028 *
7029 * @param clip The new clip to set. May be null to clear the current clip.
7030 */
7031 public void setClipData(ClipData clip) {
7032 mClipData = clip;
7033 }
7034
7035 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007036 * This is NOT a secure mechanism to identify the user who sent the intent.
7037 * When the intent is sent to a different user, it is used to fix uris by adding the userId
7038 * who sent the intent.
7039 * @hide
7040 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01007041 public void prepareToLeaveUser(int userId) {
7042 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
7043 // We want mContentUserHint to refer to the original user, so don't do anything.
7044 if (mContentUserHint == UserHandle.USER_CURRENT) {
7045 mContentUserHint = userId;
7046 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007047 }
7048
7049 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007050 * 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 boolean 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 #getBooleanExtra(String, boolean)
7063 */
7064 public Intent putExtra(String name, boolean value) {
7065 if (mExtras == null) {
7066 mExtras = new Bundle();
7067 }
7068 mExtras.putBoolean(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 byte 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 #getByteExtra(String, byte)
7086 */
7087 public Intent putExtra(String name, byte value) {
7088 if (mExtras == null) {
7089 mExtras = new Bundle();
7090 }
7091 mExtras.putByte(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 char 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 #getCharExtra(String, char)
7109 */
7110 public Intent putExtra(String name, char value) {
7111 if (mExtras == null) {
7112 mExtras = new Bundle();
7113 }
7114 mExtras.putChar(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 short 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 #getShortExtra(String, short)
7132 */
7133 public Intent putExtra(String name, short value) {
7134 if (mExtras == null) {
7135 mExtras = new Bundle();
7136 }
7137 mExtras.putShort(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 integer 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 #getIntExtra(String, int)
7155 */
7156 public Intent putExtra(String name, int value) {
7157 if (mExtras == null) {
7158 mExtras = new Bundle();
7159 }
7160 mExtras.putInt(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 long 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 #getLongExtra(String, long)
7178 */
7179 public Intent putExtra(String name, long value) {
7180 if (mExtras == null) {
7181 mExtras = new Bundle();
7182 }
7183 mExtras.putLong(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 float 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 #getFloatExtra(String, float)
7201 */
7202 public Intent putExtra(String name, float value) {
7203 if (mExtras == null) {
7204 mExtras = new Bundle();
7205 }
7206 mExtras.putFloat(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 double 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 #getDoubleExtra(String, double)
7224 */
7225 public Intent putExtra(String name, double value) {
7226 if (mExtras == null) {
7227 mExtras = new Bundle();
7228 }
7229 mExtras.putDouble(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 String 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 #getStringExtra(String)
7247 */
7248 public Intent putExtra(String name, String value) {
7249 if (mExtras == null) {
7250 mExtras = new Bundle();
7251 }
7252 mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
7270 */
7271 public Intent putExtra(String name, CharSequence value) {
7272 if (mExtras == null) {
7273 mExtras = new Bundle();
7274 }
7275 mExtras.putCharSequence(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 #getParcelableExtra(String)
7293 */
7294 public Intent putExtra(String name, Parcelable value) {
7295 if (mExtras == null) {
7296 mExtras = new Bundle();
7297 }
7298 mExtras.putParcelable(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 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 #getParcelableArrayExtra(String)
7316 */
7317 public Intent putExtra(String name, Parcelable[] value) {
7318 if (mExtras == null) {
7319 mExtras = new Bundle();
7320 }
7321 mExtras.putParcelableArray(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<Parcelable> 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 #getParcelableArrayListExtra(String)
7339 */
7340 public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
7341 if (mExtras == null) {
7342 mExtras = new Bundle();
7343 }
7344 mExtras.putParcelableArrayList(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<Integer> 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 #getIntegerArrayListExtra(String)
7362 */
7363 public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
7364 if (mExtras == null) {
7365 mExtras = new Bundle();
7366 }
7367 mExtras.putIntegerArrayList(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.
7377 * @param value The ArrayList<String> 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 #getStringArrayListExtra(String)
7385 */
7386 public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
7387 if (mExtras == null) {
7388 mExtras = new Bundle();
7389 }
7390 mExtras.putStringArrayList(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.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007400 * @param value The ArrayList<CharSequence> 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 #getCharSequenceArrayListExtra(String)
7408 */
7409 public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
7410 if (mExtras == null) {
7411 mExtras = new Bundle();
7412 }
7413 mExtras.putCharSequenceArrayList(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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007423 * @param value The Serializable 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 #getSerializableExtra(String)
7431 */
7432 public Intent putExtra(String name, Serializable value) {
7433 if (mExtras == null) {
7434 mExtras = new Bundle();
7435 }
7436 mExtras.putSerializable(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 boolean 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 #getBooleanArrayExtra(String)
7454 */
7455 public Intent putExtra(String name, boolean[] value) {
7456 if (mExtras == null) {
7457 mExtras = new Bundle();
7458 }
7459 mExtras.putBooleanArray(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 byte 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 #getByteArrayExtra(String)
7477 */
7478 public Intent putExtra(String name, byte[] value) {
7479 if (mExtras == null) {
7480 mExtras = new Bundle();
7481 }
7482 mExtras.putByteArray(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 short 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 #getShortArrayExtra(String)
7500 */
7501 public Intent putExtra(String name, short[] value) {
7502 if (mExtras == null) {
7503 mExtras = new Bundle();
7504 }
7505 mExtras.putShortArray(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 char 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 #getCharArrayExtra(String)
7523 */
7524 public Intent putExtra(String name, char[] value) {
7525 if (mExtras == null) {
7526 mExtras = new Bundle();
7527 }
7528 mExtras.putCharArray(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 int 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 #getIntArrayExtra(String)
7546 */
7547 public Intent putExtra(String name, int[] value) {
7548 if (mExtras == null) {
7549 mExtras = new Bundle();
7550 }
7551 mExtras.putIntArray(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 byte 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 #getLongArrayExtra(String)
7569 */
7570 public Intent putExtra(String name, long[] value) {
7571 if (mExtras == null) {
7572 mExtras = new Bundle();
7573 }
7574 mExtras.putLongArray(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 float 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 #getFloatArrayExtra(String)
7592 */
7593 public Intent putExtra(String name, float[] value) {
7594 if (mExtras == null) {
7595 mExtras = new Bundle();
7596 }
7597 mExtras.putFloatArray(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 double 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 #getDoubleArrayExtra(String)
7615 */
7616 public Intent putExtra(String name, double[] value) {
7617 if (mExtras == null) {
7618 mExtras = new Bundle();
7619 }
7620 mExtras.putDoubleArray(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.
7630 * @param value The String 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 #getStringArrayExtra(String)
7638 */
7639 public Intent putExtra(String name, String[] value) {
7640 if (mExtras == null) {
7641 mExtras = new Bundle();
7642 }
7643 mExtras.putStringArray(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.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007653 * @param value The CharSequence array 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 #getCharSequenceArrayExtra(String)
7661 */
7662 public Intent putExtra(String name, CharSequence[] value) {
7663 if (mExtras == null) {
7664 mExtras = new Bundle();
7665 }
7666 mExtras.putCharSequenceArray(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.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007676 * @param value The Bundle 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 #getBundleExtra(String)
7684 */
7685 public Intent putExtra(String name, Bundle value) {
7686 if (mExtras == null) {
7687 mExtras = new Bundle();
7688 }
7689 mExtras.putBundle(name, value);
7690 return this;
7691 }
7692
7693 /**
7694 * Add extended data to the intent. The name must include a package
7695 * prefix, for example the app com.android.contacts would use names
7696 * like "com.android.contacts.ShowAll".
7697 *
7698 * @param name The name of the extra data, with package prefix.
7699 * @param value The IBinder data value.
7700 *
7701 * @return Returns the same Intent object, for chaining multiple calls
7702 * into a single statement.
7703 *
7704 * @see #putExtras
7705 * @see #removeExtra
7706 * @see #getIBinderExtra(String)
7707 *
7708 * @deprecated
7709 * @hide
7710 */
7711 @Deprecated
7712 public Intent putExtra(String name, IBinder value) {
7713 if (mExtras == null) {
7714 mExtras = new Bundle();
7715 }
7716 mExtras.putIBinder(name, value);
7717 return this;
7718 }
7719
7720 /**
7721 * Copy all extras in 'src' in to this intent.
7722 *
7723 * @param src Contains the extras to copy.
7724 *
7725 * @see #putExtra
7726 */
7727 public Intent putExtras(Intent src) {
7728 if (src.mExtras != null) {
7729 if (mExtras == null) {
7730 mExtras = new Bundle(src.mExtras);
7731 } else {
7732 mExtras.putAll(src.mExtras);
7733 }
7734 }
7735 return this;
7736 }
7737
7738 /**
7739 * Add a set of extended data to the intent. The keys must include a package
7740 * prefix, for example the app com.android.contacts would use names
7741 * like "com.android.contacts.ShowAll".
7742 *
7743 * @param extras The Bundle of extras to add to this intent.
7744 *
7745 * @see #putExtra
7746 * @see #removeExtra
7747 */
7748 public Intent putExtras(Bundle extras) {
7749 if (mExtras == null) {
7750 mExtras = new Bundle();
7751 }
7752 mExtras.putAll(extras);
7753 return this;
7754 }
7755
7756 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007757 * Completely replace the extras in the Intent with the extras in the
7758 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07007759 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007760 * @param src The exact extras contained in this Intent are copied
7761 * into the target intent, replacing any that were previously there.
7762 */
7763 public Intent replaceExtras(Intent src) {
7764 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
7765 return this;
7766 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007767
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007768 /**
7769 * Completely replace the extras in the Intent with the given Bundle of
7770 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07007771 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007772 * @param extras The new set of extras in the Intent, or null to erase
7773 * all extras.
7774 */
7775 public Intent replaceExtras(Bundle extras) {
7776 mExtras = extras != null ? new Bundle(extras) : null;
7777 return this;
7778 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007779
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007780 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 * Remove extended data from the intent.
7782 *
7783 * @see #putExtra
7784 */
7785 public void removeExtra(String name) {
7786 if (mExtras != null) {
7787 mExtras.remove(name);
7788 if (mExtras.size() == 0) {
7789 mExtras = null;
7790 }
7791 }
7792 }
7793
7794 /**
7795 * Set special flags controlling how this intent is handled. Most values
7796 * here depend on the type of component being executed by the Intent,
7797 * specifically the FLAG_ACTIVITY_* flags are all for use with
7798 * {@link Context#startActivity Context.startActivity()} and the
7799 * FLAG_RECEIVER_* flags are all for use with
7800 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
7801 *
Scott Main7aee61f2011-02-08 11:25:01 -08007802 * <p>See the
7803 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
7804 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007805 * the behavior of your application.
7806 *
7807 * @param flags The desired flags.
7808 *
7809 * @return Returns the same Intent object, for chaining multiple calls
7810 * into a single statement.
7811 *
7812 * @see #getFlags
7813 * @see #addFlags
7814 *
7815 * @see #FLAG_GRANT_READ_URI_PERMISSION
7816 * @see #FLAG_GRANT_WRITE_URI_PERMISSION
Jeff Sharkey846318a2014-04-04 12:12:41 -07007817 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
7818 * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 * @see #FLAG_DEBUG_LOG_RESOLUTION
7820 * @see #FLAG_FROM_BACKGROUND
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007821 * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007822 * @see #FLAG_ACTIVITY_CLEAR_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007823 * @see #FLAG_ACTIVITY_CLEAR_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007824 * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007825 * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
7826 * @see #FLAG_ACTIVITY_FORWARD_RESULT
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007827 * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007828 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
Craig Mautnerd00f4742014-03-12 14:17:26 -07007829 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007830 * @see #FLAG_ACTIVITY_NEW_TASK
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007831 * @see #FLAG_ACTIVITY_NO_ANIMATION
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007832 * @see #FLAG_ACTIVITY_NO_HISTORY
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08007833 * @see #FLAG_ACTIVITY_NO_USER_ACTION
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08007834 * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
7835 * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007836 * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007837 * @see #FLAG_ACTIVITY_SINGLE_TOP
Dianne Hackborn621e17d2010-11-22 15:59:56 -08007838 * @see #FLAG_ACTIVITY_TASK_ON_HOME
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007839 * @see #FLAG_RECEIVER_REGISTERED_ONLY
7840 */
7841 public Intent setFlags(int flags) {
7842 mFlags = flags;
7843 return this;
7844 }
7845
7846 /**
7847 * Add additional flags to the intent (or with existing flags
7848 * value).
7849 *
7850 * @param flags The new flags to set.
7851 *
7852 * @return Returns the same Intent object, for chaining multiple calls
7853 * into a single statement.
7854 *
7855 * @see #setFlags
7856 */
7857 public Intent addFlags(int flags) {
7858 mFlags |= flags;
7859 return this;
7860 }
7861
7862 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007863 * (Usually optional) Set an explicit application package name that limits
7864 * the components this Intent will resolve to. If left to the default
7865 * value of null, all components in all applications will considered.
7866 * If non-null, the Intent can only match the components in the given
7867 * application package.
7868 *
7869 * @param packageName The name of the application package to handle the
7870 * intent, or null to allow any application package.
7871 *
7872 * @return Returns the same Intent object, for chaining multiple calls
7873 * into a single statement.
7874 *
7875 * @see #getPackage
7876 * @see #resolveActivity
7877 */
7878 public Intent setPackage(String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007879 if (packageName != null && mSelector != null) {
7880 throw new IllegalArgumentException(
7881 "Can't set package name when selector is already set");
7882 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007883 mPackage = packageName;
7884 return this;
7885 }
7886
7887 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007888 * (Usually optional) Explicitly set the component to handle the intent.
7889 * If left with the default value of null, the system will determine the
7890 * appropriate class to use based on the other fields (action, data,
7891 * type, categories) in the Intent. If this class is defined, the
7892 * specified class will always be used regardless of the other fields. You
7893 * should only set this value when you know you absolutely want a specific
7894 * class to be used; otherwise it is better to let the system find the
7895 * appropriate class so that you will respect the installed applications
7896 * and user preferences.
7897 *
7898 * @param component The name of the application component to handle the
7899 * intent, or null to let the system find one for you.
7900 *
7901 * @return Returns the same Intent object, for chaining multiple calls
7902 * into a single statement.
7903 *
7904 * @see #setClass
7905 * @see #setClassName(Context, String)
7906 * @see #setClassName(String, String)
7907 * @see #getComponent
7908 * @see #resolveActivity
7909 */
7910 public Intent setComponent(ComponentName component) {
7911 mComponent = component;
7912 return this;
7913 }
7914
7915 /**
7916 * Convenience for calling {@link #setComponent} with an
7917 * explicit class name.
7918 *
7919 * @param packageContext A Context of the application package implementing
7920 * this class.
7921 * @param className The name of a class inside of the application package
7922 * that will be used as the component for this Intent.
7923 *
7924 * @return Returns the same Intent object, for chaining multiple calls
7925 * into a single statement.
7926 *
7927 * @see #setComponent
7928 * @see #setClass
7929 */
7930 public Intent setClassName(Context packageContext, String className) {
7931 mComponent = new ComponentName(packageContext, className);
7932 return this;
7933 }
7934
7935 /**
7936 * Convenience for calling {@link #setComponent} with an
7937 * explicit application package name and class name.
7938 *
7939 * @param packageName The name of the package implementing the desired
7940 * component.
7941 * @param className The name of a class inside of the application package
7942 * that will be used as the component for this Intent.
7943 *
7944 * @return Returns the same Intent object, for chaining multiple calls
7945 * into a single statement.
7946 *
7947 * @see #setComponent
7948 * @see #setClass
7949 */
7950 public Intent setClassName(String packageName, String className) {
7951 mComponent = new ComponentName(packageName, className);
7952 return this;
7953 }
7954
7955 /**
7956 * Convenience for calling {@link #setComponent(ComponentName)} with the
7957 * name returned by a {@link Class} object.
7958 *
7959 * @param packageContext A Context of the application package implementing
7960 * this class.
7961 * @param cls The class name to set, equivalent to
7962 * <code>setClassName(context, cls.getName())</code>.
7963 *
7964 * @return Returns the same Intent object, for chaining multiple calls
7965 * into a single statement.
7966 *
7967 * @see #setComponent
7968 */
7969 public Intent setClass(Context packageContext, Class<?> cls) {
7970 mComponent = new ComponentName(packageContext, cls);
7971 return this;
7972 }
7973
7974 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007975 * Set the bounds of the sender of this intent, in screen coordinates. This can be
7976 * used as a hint to the receiver for animations and the like. Null means that there
7977 * is no source bounds.
7978 */
7979 public void setSourceBounds(Rect r) {
7980 if (r != null) {
7981 mSourceBounds = new Rect(r);
7982 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07007983 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007984 }
7985 }
7986
Tor Norbyed9273d62013-05-30 15:59:53 -07007987 /** @hide */
7988 @IntDef(flag = true,
7989 value = {
7990 FILL_IN_ACTION,
7991 FILL_IN_DATA,
7992 FILL_IN_CATEGORIES,
7993 FILL_IN_COMPONENT,
7994 FILL_IN_PACKAGE,
7995 FILL_IN_SOURCE_BOUNDS,
7996 FILL_IN_SELECTOR,
7997 FILL_IN_CLIP_DATA
7998 })
7999 @Retention(RetentionPolicy.SOURCE)
8000 public @interface FillInFlags {}
8001
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008002 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008003 * Use with {@link #fillIn} to allow the current action value to be
8004 * overwritten, even if it is already set.
8005 */
8006 public static final int FILL_IN_ACTION = 1<<0;
8007
8008 /**
8009 * Use with {@link #fillIn} to allow the current data or type value
8010 * overwritten, even if it is already set.
8011 */
8012 public static final int FILL_IN_DATA = 1<<1;
8013
8014 /**
8015 * Use with {@link #fillIn} to allow the current categories to be
8016 * overwritten, even if they are already set.
8017 */
8018 public static final int FILL_IN_CATEGORIES = 1<<2;
8019
8020 /**
8021 * Use with {@link #fillIn} to allow the current component value to be
8022 * overwritten, even if it is already set.
8023 */
8024 public static final int FILL_IN_COMPONENT = 1<<3;
8025
8026 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008027 * Use with {@link #fillIn} to allow the current package value to be
8028 * overwritten, even if it is already set.
8029 */
8030 public static final int FILL_IN_PACKAGE = 1<<4;
8031
8032 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008033 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008034 * overwritten, even if it is already set.
8035 */
8036 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
8037
8038 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008039 * Use with {@link #fillIn} to allow the current selector to be
8040 * overwritten, even if it is already set.
8041 */
8042 public static final int FILL_IN_SELECTOR = 1<<6;
8043
8044 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008045 * Use with {@link #fillIn} to allow the current ClipData to be
8046 * overwritten, even if it is already set.
8047 */
8048 public static final int FILL_IN_CLIP_DATA = 1<<7;
8049
8050 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008051 * Copy the contents of <var>other</var> in to this object, but only
8052 * where fields are not defined by this object. For purposes of a field
8053 * being defined, the following pieces of data in the Intent are
8054 * considered to be separate fields:
8055 *
8056 * <ul>
8057 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08008058 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008059 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
8060 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008061 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008062 * <li> component, as set by {@link #setComponent(ComponentName)} or
8063 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008064 * <li> source bounds, as set by {@link #setSourceBounds}.
8065 * <li> selector, as set by {@link #setSelector(Intent)}.
8066 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008067 * <li> each top-level name in the associated extras.
8068 * </ul>
8069 *
8070 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008071 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008072 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8073 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
8074 * the restriction where the corresponding field will not be replaced if
8075 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008076 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008077 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
8078 * is explicitly specified. The selector will only be copied if
8079 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07008080 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008081 * <p>For example, consider Intent A with {data="foo", categories="bar"}
8082 * and Intent B with {action="gotit", data-type="some/thing",
8083 * categories="one","two"}.
8084 *
8085 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
8086 * containing: {action="gotit", data-type="some/thing",
8087 * categories="bar"}.
8088 *
8089 * @param other Another Intent whose values are to be used to fill in
8090 * the current one.
8091 * @param flags Options to control which fields can be filled in.
8092 *
8093 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008094 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07008095 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
8096 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
8097 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008098 */
Tor Norbyed9273d62013-05-30 15:59:53 -07008099 @FillInFlags
8100 public int fillIn(Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008101 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008102 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008103 if (other.mAction != null
8104 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008105 mAction = other.mAction;
8106 changes |= FILL_IN_ACTION;
8107 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008108 if ((other.mData != null || other.mType != null)
8109 && ((mData == null && mType == null)
8110 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008111 mData = other.mData;
8112 mType = other.mType;
8113 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008114 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008115 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008116 if (other.mCategories != null
8117 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008118 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008119 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008120 }
8121 changes |= FILL_IN_CATEGORIES;
8122 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008123 if (other.mPackage != null
8124 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008125 // Only do this if mSelector is not set.
8126 if (mSelector == null) {
8127 mPackage = other.mPackage;
8128 changes |= FILL_IN_PACKAGE;
8129 }
8130 }
8131 // Selector is special: it can only be set if explicitly allowed,
8132 // for the same reason as the component name.
8133 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
8134 if (mPackage == null) {
8135 mSelector = new Intent(other.mSelector);
8136 mPackage = null;
8137 changes |= FILL_IN_SELECTOR;
8138 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008139 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008140 if (other.mClipData != null
8141 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
8142 mClipData = other.mClipData;
8143 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008144 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008145 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008146 // Component is special: it can -only- be set if explicitly allowed,
8147 // since otherwise the sender could force the intent somewhere the
8148 // originator didn't intend.
8149 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008150 mComponent = other.mComponent;
8151 changes |= FILL_IN_COMPONENT;
8152 }
8153 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008154 if (other.mSourceBounds != null
8155 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
8156 mSourceBounds = new Rect(other.mSourceBounds);
8157 changes |= FILL_IN_SOURCE_BOUNDS;
8158 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159 if (mExtras == null) {
8160 if (other.mExtras != null) {
8161 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008162 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008163 }
8164 } else if (other.mExtras != null) {
8165 try {
8166 Bundle newb = new Bundle(other.mExtras);
8167 newb.putAll(mExtras);
8168 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008169 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008170 } catch (RuntimeException e) {
8171 // Modifying the extras can cause us to unparcel the contents
8172 // of the bundle, and if we do this in the system process that
8173 // may fail. We really should handle this (i.e., the Bundle
8174 // impl shouldn't be on top of a plain map), but for now just
8175 // ignore it and keep the original contents. :(
8176 Log.w("Intent", "Failure filling in extras", e);
8177 }
8178 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008179 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
8180 && other.mContentUserHint != UserHandle.USER_CURRENT) {
8181 mContentUserHint = other.mContentUserHint;
8182 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 return changes;
8184 }
8185
8186 /**
8187 * Wrapper class holding an Intent and implementing comparisons on it for
8188 * the purpose of filtering. The class implements its
8189 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
8190 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
8191 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
8192 * on the wrapped Intent.
8193 */
8194 public static final class FilterComparison {
8195 private final Intent mIntent;
8196 private final int mHashCode;
8197
8198 public FilterComparison(Intent intent) {
8199 mIntent = intent;
8200 mHashCode = intent.filterHashCode();
8201 }
8202
8203 /**
8204 * Return the Intent that this FilterComparison represents.
8205 * @return Returns the Intent held by the FilterComparison. Do
8206 * not modify!
8207 */
8208 public Intent getIntent() {
8209 return mIntent;
8210 }
8211
8212 @Override
8213 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008214 if (obj instanceof FilterComparison) {
8215 Intent other = ((FilterComparison)obj).mIntent;
8216 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008217 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08008218 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008219 }
8220
8221 @Override
8222 public int hashCode() {
8223 return mHashCode;
8224 }
8225 }
8226
8227 /**
8228 * Determine if two intents are the same for the purposes of intent
8229 * resolution (filtering). That is, if their action, data, type,
8230 * class, and categories are the same. This does <em>not</em> compare
8231 * any extra data included in the intents.
8232 *
8233 * @param other The other Intent to compare against.
8234 *
8235 * @return Returns true if action, data, type, class, and categories
8236 * are the same.
8237 */
8238 public boolean filterEquals(Intent other) {
8239 if (other == null) {
8240 return false;
8241 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07008242 if (!Objects.equals(this.mAction, other.mAction)) return false;
8243 if (!Objects.equals(this.mData, other.mData)) return false;
8244 if (!Objects.equals(this.mType, other.mType)) return false;
8245 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
8246 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
8247 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008248
8249 return true;
8250 }
8251
8252 /**
8253 * Generate hash code that matches semantics of filterEquals().
8254 *
8255 * @return Returns the hash value of the action, data, type, class, and
8256 * categories.
8257 *
8258 * @see #filterEquals
8259 */
8260 public int filterHashCode() {
8261 int code = 0;
8262 if (mAction != null) {
8263 code += mAction.hashCode();
8264 }
8265 if (mData != null) {
8266 code += mData.hashCode();
8267 }
8268 if (mType != null) {
8269 code += mType.hashCode();
8270 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008271 if (mPackage != null) {
8272 code += mPackage.hashCode();
8273 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008274 if (mComponent != null) {
8275 code += mComponent.hashCode();
8276 }
8277 if (mCategories != null) {
8278 code += mCategories.hashCode();
8279 }
8280 return code;
8281 }
8282
8283 @Override
8284 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008285 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008286
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008287 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008288 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008289 b.append(" }");
8290
8291 return b.toString();
8292 }
8293
8294 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008295 public String toInsecureString() {
8296 StringBuilder b = new StringBuilder(128);
8297
8298 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008299 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008300 b.append(" }");
8301
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008302 return b.toString();
8303 }
Romain Guy4969af72009-06-17 10:53:19 -07008304
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008305 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008306 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008307 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008308
8309 b.append("Intent { ");
8310 toShortString(b, false, true, true, true);
8311 b.append(" }");
8312
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008313 return b.toString();
8314 }
8315
8316 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008317 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
8318 StringBuilder b = new StringBuilder(128);
8319 toShortString(b, secure, comp, extras, clip);
8320 return b.toString();
8321 }
8322
8323 /** @hide */
8324 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
8325 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008326 boolean first = true;
8327 if (mAction != null) {
8328 b.append("act=").append(mAction);
8329 first = false;
8330 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008331 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008332 if (!first) {
8333 b.append(' ');
8334 }
8335 first = false;
8336 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008337 for (int i=0; i<mCategories.size(); i++) {
8338 if (i > 0) b.append(',');
8339 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008340 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008341 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008342 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008343 if (mData != null) {
8344 if (!first) {
8345 b.append(' ');
8346 }
8347 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07008348 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07008349 if (secure) {
8350 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07008351 } else {
8352 b.append(mData);
8353 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008354 }
8355 if (mType != null) {
8356 if (!first) {
8357 b.append(' ');
8358 }
8359 first = false;
8360 b.append("typ=").append(mType);
8361 }
8362 if (mFlags != 0) {
8363 if (!first) {
8364 b.append(' ');
8365 }
8366 first = false;
8367 b.append("flg=0x").append(Integer.toHexString(mFlags));
8368 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008369 if (mPackage != null) {
8370 if (!first) {
8371 b.append(' ');
8372 }
8373 first = false;
8374 b.append("pkg=").append(mPackage);
8375 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008376 if (comp && mComponent != null) {
8377 if (!first) {
8378 b.append(' ');
8379 }
8380 first = false;
8381 b.append("cmp=").append(mComponent.flattenToShortString());
8382 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008383 if (mSourceBounds != null) {
8384 if (!first) {
8385 b.append(' ');
8386 }
8387 first = false;
8388 b.append("bnds=").append(mSourceBounds.toShortString());
8389 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008390 if (mClipData != null) {
8391 if (!first) {
8392 b.append(' ');
8393 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008394 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008395 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008396 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008397 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07008398 if (mClipData.getDescription() != null) {
8399 first = !mClipData.getDescription().toShortStringTypesOnly(b);
8400 } else {
8401 first = true;
8402 }
8403 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008404 }
Dianne Hackbornae498722015-08-14 13:29:47 -07008405 first = false;
8406 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008407 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008408 if (extras && mExtras != null) {
8409 if (!first) {
8410 b.append(' ');
8411 }
8412 first = false;
8413 b.append("(has extras)");
8414 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008415 if (mContentUserHint != UserHandle.USER_CURRENT) {
8416 if (!first) {
8417 b.append(' ');
8418 }
8419 first = false;
8420 b.append("u=").append(mContentUserHint);
8421 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008422 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008423 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008424 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008425 b.append("}");
8426 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008427 }
8428
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008429 /**
8430 * Call {@link #toUri} with 0 flags.
8431 * @deprecated Use {@link #toUri} instead.
8432 */
8433 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008434 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008435 return toUri(0);
8436 }
8437
8438 /**
8439 * Convert this Intent into a String holding a URI representation of it.
8440 * The returned URI string has been properly URI encoded, so it can be
8441 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
8442 * Intent's data as the base URI, with an additional fragment describing
8443 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08008444 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008445 * <p>You can convert the returned string back to an Intent with
8446 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08008447 *
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008448 * @param flags Additional operating flags. Either 0,
8449 * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
Tom Taylord4a47292009-12-21 13:59:18 -08008450 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008451 * @return Returns a URI encoding URI string describing the entire contents
8452 * of the Intent.
8453 */
8454 public String toUri(int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07008455 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008456 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
8457 if (mPackage == null) {
8458 throw new IllegalArgumentException(
8459 "Intent must include an explicit package name to build an android-app: "
8460 + this);
8461 }
8462 uri.append("android-app://");
8463 uri.append(mPackage);
8464 String scheme = null;
8465 if (mData != null) {
8466 scheme = mData.getScheme();
8467 if (scheme != null) {
8468 uri.append('/');
8469 uri.append(scheme);
8470 String authority = mData.getEncodedAuthority();
8471 if (authority != null) {
8472 uri.append('/');
8473 uri.append(authority);
8474 String path = mData.getEncodedPath();
8475 if (path != null) {
8476 uri.append(path);
8477 }
8478 String queryParams = mData.getEncodedQuery();
8479 if (queryParams != null) {
8480 uri.append('?');
8481 uri.append(queryParams);
8482 }
8483 String fragment = mData.getEncodedFragment();
8484 if (fragment != null) {
8485 uri.append('#');
8486 uri.append(fragment);
8487 }
8488 }
8489 }
8490 }
8491 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
8492 mPackage, flags);
8493 return uri.toString();
8494 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008495 String scheme = null;
8496 if (mData != null) {
8497 String data = mData.toString();
8498 if ((flags&URI_INTENT_SCHEME) != 0) {
8499 final int N = data.length();
8500 for (int i=0; i<N; i++) {
8501 char c = data.charAt(i);
8502 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
8503 || c == '.' || c == '-') {
8504 continue;
8505 }
8506 if (c == ':' && i > 0) {
8507 // Valid scheme.
8508 scheme = data.substring(0, i);
8509 uri.append("intent:");
8510 data = data.substring(i+1);
8511 break;
8512 }
Tom Taylord4a47292009-12-21 13:59:18 -08008513
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008514 // No scheme.
8515 break;
8516 }
8517 }
8518 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08008519
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008520 } else if ((flags&URI_INTENT_SCHEME) != 0) {
8521 uri.append("intent:");
8522 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008523
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008524 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008525
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008526 return uri.toString();
8527 }
8528
8529 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
8530 String defPackage, int flags) {
8531 StringBuilder frag = new StringBuilder(128);
8532
8533 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008534 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08008535 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008536 // Note that for now we are not going to try to handle the
8537 // data part; not clear how to represent this as a URI, and
8538 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008539 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
8540 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008541 }
8542
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008543 if (frag.length() > 0) {
8544 uri.append("#Intent;");
8545 uri.append(frag);
8546 uri.append("end");
8547 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008548 }
8549
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008550 private void toUriInner(StringBuilder uri, String scheme, String defAction,
8551 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008552 if (scheme != null) {
8553 uri.append("scheme=").append(scheme).append(';');
8554 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008555 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008556 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008557 }
8558 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008559 for (int i=0; i<mCategories.size(); i++) {
8560 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008561 }
8562 }
8563 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008564 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008565 }
8566 if (mFlags != 0) {
8567 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
8568 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08008569 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008570 uri.append("package=").append(Uri.encode(mPackage)).append(';');
8571 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008572 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008573 uri.append("component=").append(Uri.encode(
8574 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008576 if (mSourceBounds != null) {
8577 uri.append("sourceBounds=")
8578 .append(Uri.encode(mSourceBounds.flattenToString()))
8579 .append(';');
8580 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008581 if (mExtras != null) {
8582 for (String key : mExtras.keySet()) {
8583 final Object value = mExtras.get(key);
8584 char entryType =
8585 value instanceof String ? 'S' :
8586 value instanceof Boolean ? 'B' :
8587 value instanceof Byte ? 'b' :
8588 value instanceof Character ? 'c' :
8589 value instanceof Double ? 'd' :
8590 value instanceof Float ? 'f' :
8591 value instanceof Integer ? 'i' :
8592 value instanceof Long ? 'l' :
8593 value instanceof Short ? 's' :
8594 '\0';
8595
8596 if (entryType != '\0') {
8597 uri.append(entryType);
8598 uri.append('.');
8599 uri.append(Uri.encode(key));
8600 uri.append('=');
8601 uri.append(Uri.encode(value.toString()));
8602 uri.append(';');
8603 }
8604 }
8605 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008606 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008607
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008608 public int describeContents() {
8609 return (mExtras != null) ? mExtras.describeContents() : 0;
8610 }
8611
8612 public void writeToParcel(Parcel out, int flags) {
8613 out.writeString(mAction);
8614 Uri.writeToParcel(out, mData);
8615 out.writeString(mType);
8616 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008617 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008618 ComponentName.writeToParcel(mComponent, out);
8619
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008620 if (mSourceBounds != null) {
8621 out.writeInt(1);
8622 mSourceBounds.writeToParcel(out, flags);
8623 } else {
8624 out.writeInt(0);
8625 }
8626
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008627 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008628 final int N = mCategories.size();
8629 out.writeInt(N);
8630 for (int i=0; i<N; i++) {
8631 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008632 }
8633 } else {
8634 out.writeInt(0);
8635 }
8636
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008637 if (mSelector != null) {
8638 out.writeInt(1);
8639 mSelector.writeToParcel(out, flags);
8640 } else {
8641 out.writeInt(0);
8642 }
8643
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008644 if (mClipData != null) {
8645 out.writeInt(1);
8646 mClipData.writeToParcel(out, flags);
8647 } else {
8648 out.writeInt(0);
8649 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008650 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008651 out.writeBundle(mExtras);
8652 }
8653
8654 public static final Parcelable.Creator<Intent> CREATOR
8655 = new Parcelable.Creator<Intent>() {
8656 public Intent createFromParcel(Parcel in) {
8657 return new Intent(in);
8658 }
8659 public Intent[] newArray(int size) {
8660 return new Intent[size];
8661 }
8662 };
8663
Dianne Hackborneb034652009-09-07 00:49:58 -07008664 /** @hide */
8665 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008666 readFromParcel(in);
8667 }
8668
8669 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008670 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008671 mData = Uri.CREATOR.createFromParcel(in);
8672 mType = in.readString();
8673 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008674 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008675 mComponent = ComponentName.readFromParcel(in);
8676
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008677 if (in.readInt() != 0) {
8678 mSourceBounds = Rect.CREATOR.createFromParcel(in);
8679 }
8680
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008681 int N = in.readInt();
8682 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008683 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008684 int i;
8685 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008686 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008687 }
8688 } else {
8689 mCategories = null;
8690 }
8691
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008692 if (in.readInt() != 0) {
8693 mSelector = new Intent(in);
8694 }
8695
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008696 if (in.readInt() != 0) {
8697 mClipData = new ClipData(in);
8698 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008699 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008700 mExtras = in.readBundle();
8701 }
8702
8703 /**
8704 * Parses the "intent" element (and its children) from XML and instantiates
8705 * an Intent object. The given XML parser should be located at the tag
8706 * where parsing should start (often named "intent"), from which the
8707 * basic action, data, type, and package and class name will be
8708 * retrieved. The function will then parse in to any child elements,
8709 * looking for <category android:name="xxx"> tags to add categories and
8710 * <extra android:name="xxx" android:value="yyy"> to attach extra data
8711 * to the intent.
8712 *
8713 * @param resources The Resources to use when inflating resources.
8714 * @param parser The XML parser pointing at an "intent" tag.
8715 * @param attrs The AttributeSet interface for retrieving extended
8716 * attribute data at the current <var>parser</var> location.
8717 * @return An Intent object matching the XML data.
8718 * @throws XmlPullParserException If there was an XML parsing error.
8719 * @throws IOException If there was an I/O error.
8720 */
8721 public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
8722 throws XmlPullParserException, IOException {
8723 Intent intent = new Intent();
8724
8725 TypedArray sa = resources.obtainAttributes(attrs,
8726 com.android.internal.R.styleable.Intent);
8727
8728 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
8729
8730 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
8731 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
8732 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
8733
8734 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
8735 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
8736 if (packageName != null && className != null) {
8737 intent.setComponent(new ComponentName(packageName, className));
8738 }
8739
8740 sa.recycle();
8741
8742 int outerDepth = parser.getDepth();
8743 int type;
8744 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
8745 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
8746 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
8747 continue;
8748 }
8749
8750 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07008751 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008752 sa = resources.obtainAttributes(attrs,
8753 com.android.internal.R.styleable.IntentCategory);
8754 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
8755 sa.recycle();
8756
8757 if (cat != null) {
8758 intent.addCategory(cat);
8759 }
8760 XmlUtils.skipCurrentTag(parser);
8761
Craig Mautner21d24a22014-04-23 11:45:37 -07008762 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008763 if (intent.mExtras == null) {
8764 intent.mExtras = new Bundle();
8765 }
Craig Mautner21d24a22014-04-23 11:45:37 -07008766 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008767 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008768
8769 } else {
8770 XmlUtils.skipCurrentTag(parser);
8771 }
8772 }
8773
8774 return intent;
8775 }
Nick Pellyccae4122012-01-09 14:12:58 -08008776
Craig Mautner21d24a22014-04-23 11:45:37 -07008777 /** @hide */
8778 public void saveToXml(XmlSerializer out) throws IOException {
8779 if (mAction != null) {
8780 out.attribute(null, ATTR_ACTION, mAction);
8781 }
8782 if (mData != null) {
8783 out.attribute(null, ATTR_DATA, mData.toString());
8784 }
8785 if (mType != null) {
8786 out.attribute(null, ATTR_TYPE, mType);
8787 }
8788 if (mComponent != null) {
8789 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
8790 }
8791 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
8792
8793 if (mCategories != null) {
8794 out.startTag(null, TAG_CATEGORIES);
8795 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
8796 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
8797 }
Craig Mautner43e52ed2014-06-16 17:18:52 -07008798 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -07008799 }
8800 }
8801
8802 /** @hide */
8803 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
8804 XmlPullParserException {
8805 Intent intent = new Intent();
8806 final int outerDepth = in.getDepth();
8807
8808 int attrCount = in.getAttributeCount();
8809 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8810 final String attrName = in.getAttributeName(attrNdx);
8811 final String attrValue = in.getAttributeValue(attrNdx);
8812 if (ATTR_ACTION.equals(attrName)) {
8813 intent.setAction(attrValue);
8814 } else if (ATTR_DATA.equals(attrName)) {
8815 intent.setData(Uri.parse(attrValue));
8816 } else if (ATTR_TYPE.equals(attrName)) {
8817 intent.setType(attrValue);
8818 } else if (ATTR_COMPONENT.equals(attrName)) {
8819 intent.setComponent(ComponentName.unflattenFromString(attrValue));
8820 } else if (ATTR_FLAGS.equals(attrName)) {
8821 intent.setFlags(Integer.valueOf(attrValue, 16));
8822 } else {
8823 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
8824 }
8825 }
8826
8827 int event;
8828 String name;
8829 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
8830 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
8831 if (event == XmlPullParser.START_TAG) {
8832 name = in.getName();
8833 if (TAG_CATEGORIES.equals(name)) {
8834 attrCount = in.getAttributeCount();
8835 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
8836 intent.addCategory(in.getAttributeValue(attrNdx));
8837 }
8838 } else {
8839 Log.w("Intent", "restoreFromXml: unknown name=" + name);
8840 XmlUtils.skipCurrentTag(in);
8841 }
8842 }
8843 }
8844
8845 return intent;
8846 }
8847
Nick Pellyccae4122012-01-09 14:12:58 -08008848 /**
8849 * Normalize a MIME data type.
8850 *
8851 * <p>A normalized MIME type has white-space trimmed,
8852 * content-type parameters removed, and is lower-case.
8853 * This aligns the type with Android best practices for
8854 * intent filtering.
8855 *
8856 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
8857 * "text/x-vCard" becomes "text/x-vcard".
8858 *
8859 * <p>All MIME types received from outside Android (such as user input,
8860 * or external sources like Bluetooth, NFC, or the Internet) should
8861 * be normalized before they are used to create an Intent.
8862 *
8863 * @param type MIME data type to normalize
8864 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -05008865 * @see #setType
8866 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -08008867 */
8868 public static String normalizeMimeType(String type) {
8869 if (type == null) {
8870 return null;
8871 }
8872
Elliott Hughescb64d432013-08-02 10:00:44 -07008873 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -08008874
8875 final int semicolonIndex = type.indexOf(';');
8876 if (semicolonIndex != -1) {
8877 type = type.substring(0, semicolonIndex);
8878 }
8879 return type;
8880 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008881
8882 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008883 * Prepare this {@link Intent} to leave an app process.
8884 *
8885 * @hide
8886 */
Jeff Sharkey344744b2016-01-28 19:03:30 -07008887 public void prepareToLeaveProcess(Context context) {
8888 final boolean leavingPackage = (mComponent == null)
8889 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
8890 prepareToLeaveProcess(leavingPackage);
8891 }
8892
8893 /**
8894 * Prepare this {@link Intent} to leave an app process.
8895 *
8896 * @hide
8897 */
8898 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008899 setAllowFds(false);
8900
8901 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008902 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008903 }
8904 if (mClipData != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008905 mClipData.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008906 }
8907
Jeff Sharkeya8b42782016-01-30 17:58:09 -07008908 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
8909 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -07008910 switch (mAction) {
8911 case ACTION_MEDIA_REMOVED:
8912 case ACTION_MEDIA_UNMOUNTED:
8913 case ACTION_MEDIA_CHECKING:
8914 case ACTION_MEDIA_NOFS:
8915 case ACTION_MEDIA_MOUNTED:
8916 case ACTION_MEDIA_SHARED:
8917 case ACTION_MEDIA_UNSHARED:
8918 case ACTION_MEDIA_BAD_REMOVAL:
8919 case ACTION_MEDIA_UNMOUNTABLE:
8920 case ACTION_MEDIA_EJECT:
8921 case ACTION_MEDIA_SCANNER_STARTED:
8922 case ACTION_MEDIA_SCANNER_FINISHED:
8923 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -07008924 case ACTION_PACKAGE_NEEDS_VERIFICATION:
8925 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -07008926 // Ignore legacy actions
8927 break;
8928 default:
8929 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -07008930 }
8931 }
8932 }
8933
8934 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008935 * @hide
8936 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008937 public void prepareToEnterProcess() {
8938 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +00008939 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
8940 fixUris(mContentUserHint);
8941 mContentUserHint = UserHandle.USER_CURRENT;
8942 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008943 }
8944 }
8945
8946 /**
8947 * @hide
8948 */
8949 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008950 Uri data = getData();
8951 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008952 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008953 }
8954 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008955 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008956 }
8957 String action = getAction();
8958 if (ACTION_SEND.equals(action)) {
8959 final Uri stream = getParcelableExtra(EXTRA_STREAM);
8960 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008961 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008962 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008963 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008964 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
8965 if (streams != null) {
8966 ArrayList<Uri> newStreams = new ArrayList<Uri>();
8967 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008968 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008969 }
8970 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
8971 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008972 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
8973 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
8974 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
8975 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
8976 if (output != null) {
8977 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
8978 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008979 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008980 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +01008981
8982 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008983 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008984 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
8985 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008986 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008987 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008988 * @hide
8989 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008990 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008991 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008992 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008993
8994 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008995 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07008996
8997 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07008998 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07008999 // Inspect contained intents to see if we need to migrate extras. We
9000 // don't promote ClipData to the parent, since ChooserActivity will
9001 // already start the picked item as the caller, and we can't combine
9002 // the flags in a safe way.
9003
9004 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -07009005 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009006 final Intent intent = getParcelableExtra(EXTRA_INTENT);
9007 if (intent != null) {
9008 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -07009009 }
9010 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009011 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -07009012 try {
9013 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
9014 if (intents != null) {
9015 for (int i = 0; i < intents.length; i++) {
9016 final Intent intent = (Intent) intents[i];
9017 if (intent != null) {
9018 migrated |= intent.migrateExtraStreamToClipData();
9019 }
9020 }
9021 }
9022 } catch (ClassCastException e) {
9023 }
9024 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009025
9026 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009027 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009028 final Uri stream = getParcelableExtra(EXTRA_STREAM);
9029 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
9030 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
9031 if (stream != null || text != null || htmlText != null) {
9032 final ClipData clipData = new ClipData(
9033 null, new String[] { getType() },
9034 new ClipData.Item(text, htmlText, null, stream));
9035 setClipData(clipData);
9036 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009037 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009038 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009039 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009040 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009041
9042 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009043 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009044 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
9045 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
9046 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
9047 int num = -1;
9048 if (streams != null) {
9049 num = streams.size();
9050 }
9051 if (texts != null) {
9052 if (num >= 0 && num != texts.size()) {
9053 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009054 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009055 }
9056 num = texts.size();
9057 }
9058 if (htmlTexts != null) {
9059 if (num >= 0 && num != htmlTexts.size()) {
9060 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009061 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009062 }
9063 num = htmlTexts.size();
9064 }
9065 if (num > 0) {
9066 final ClipData clipData = new ClipData(
9067 null, new String[] { getType() },
9068 makeClipItem(streams, texts, htmlTexts, 0));
9069
9070 for (int i = 1; i < num; i++) {
9071 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
9072 }
9073
9074 setClipData(clipData);
9075 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009076 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -07009077 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009078 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -07009079 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009080 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
9081 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
9082 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
9083 final Uri output;
9084 try {
9085 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
9086 } catch (ClassCastException e) {
9087 return false;
9088 }
9089 if (output != null) {
9090 setClipData(ClipData.newRawUri("", output));
9091 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
9092 return true;
9093 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009094 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07009095
9096 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -07009097 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -07009098
9099 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
9100 ArrayList<String> htmlTexts, int which) {
9101 Uri uri = streams != null ? streams.get(which) : null;
9102 CharSequence text = texts != null ? texts.get(which) : null;
9103 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
9104 return new ClipData.Item(text, htmlText, null, uri);
9105 }
Craig Mautnerd00f4742014-03-12 14:17:26 -07009106
9107 /** @hide */
9108 public boolean isDocument() {
9109 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
9110 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009111}