blob: ea0811086d52b6377633983600ce81c9b6a231a8 [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
Makoto Onuki7d1911f2017-06-09 12:30:09 -070019import static android.content.ContentProvider.maybeAddUserId;
20
Tor Norbye7b9c9122013-05-30 16:48:33 -070021import android.annotation.AnyRes;
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -070022import android.annotation.BroadcastBehavior;
Tor Norbyed9273d62013-05-30 15:59:53 -070023import android.annotation.IntDef;
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060024import android.annotation.NonNull;
25import android.annotation.Nullable;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070026import android.annotation.SdkConstant;
27import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050028import android.annotation.SystemApi;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070029import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050030import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060031import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070032import android.content.pm.PackageManager;
33import android.content.pm.ResolveInfo;
34import android.content.res.Resources;
35import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080036import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060038import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.os.Bundle;
40import android.os.IBinder;
41import android.os.Parcel;
42import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070043import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000044import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050045import android.os.ResultReceiver;
46import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070047import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010048import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070049import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070050import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070051import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050052import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070053import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000054import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050055import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070056import android.util.AttributeSet;
57import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070058import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070059
Dianne Hackborn2269d1572010-02-24 19:54:22 -080060import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070061
Jason Monk2f68e8a2016-02-23 17:57:28 -050062import org.xmlpull.v1.XmlPullParser;
63import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070064import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065
66import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080067import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070069import java.lang.annotation.Retention;
70import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.net.URISyntaxException;
72import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080073import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070074import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080075import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070076import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070077import java.util.Set;
78
79/**
80 * An intent is an abstract description of an operation to be performed. It
81 * can be used with {@link Context#startActivity(Intent) startActivity} to
82 * launch an {@link android.app.Activity},
83 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
84 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
85 * and {@link android.content.Context#startService} or
86 * {@link android.content.Context#bindService} to communicate with a
87 * background {@link android.app.Service}.
88 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070089 * <p>An Intent provides a facility for performing late runtime binding between the code in
90 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070091 * can be thought of as the glue between activities. It is basically a passive data structure
92 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070093 *
94 * <div class="special reference">
95 * <h3>Developer Guides</h3>
96 * <p>For information about how to create and resolve intents, read the
97 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
98 * developer guide.</p>
99 * </div>
100 *
101 * <a name="IntentStructure"></a>
102 * <h3>Intent Structure</h3>
103 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700104 *
105 * <ul>
106 * <li> <p><b>action</b> -- The general action to be performed, such as
107 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
108 * etc.</p>
109 * </li>
110 * <li> <p><b>data</b> -- The data to operate on, such as a person record
111 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
112 * </li>
113 * </ul>
114 *
115 *
116 * <p>Some examples of action/data pairs are:</p>
117 *
118 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700119 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700120 * information about the person whose identifier is "1".</p>
121 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700122 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700123 * the phone dialer with the person filled in.</p>
124 * </li>
125 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
126 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700127 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700128 * a particular URI.</p>
129 * </li>
130 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
131 * the phone dialer with the given number filled in.</p>
132 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700133 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700134 * information about the person whose identifier is "1".</p>
135 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700136 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700137 * a list of people, which the user can browse through. This example is a
138 * typical top-level entry into the Contacts application, showing you the
139 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700140 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700141 * being used to start an activity to display that person.</p>
142 * </li>
143 * </ul>
144 *
145 * <p>In addition to these primary attributes, there are a number of secondary
146 * attributes that you can also include with an intent:</p>
147 *
148 * <ul>
149 * <li> <p><b>category</b> -- Gives additional information about the action
150 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
151 * appear in the Launcher as a top-level application, while
152 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
153 * of alternative actions the user can perform on a piece of data.</p>
154 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
155 * intent data. Normally the type is inferred from the data itself.
156 * By setting this attribute, you disable that evaluation and force
157 * an explicit type.</p>
158 * <li> <p><b>component</b> -- Specifies an explicit name of a component
159 * class to use for the intent. Normally this is determined by looking
160 * at the other information in the intent (the action, data/type, and
161 * categories) and matching that with a component that can handle it.
162 * If this attribute is set then none of the evaluation is performed,
163 * and this component is used exactly as is. By specifying this attribute,
164 * all of the other Intent attributes become optional.</p>
165 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
166 * This can be used to provide extended information to the component.
167 * For example, if we have a action to send an e-mail message, we could
168 * also include extra pieces of data here to supply a subject, body,
169 * etc.</p>
170 * </ul>
171 *
172 * <p>Here are some examples of other operations you can specify as intents
173 * using these additional parameters:</p>
174 *
175 * <ul>
176 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
177 * Launch the home screen.</p>
178 * </li>
179 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
180 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
181 * vnd.android.cursor.item/phone}</i></b>
182 * -- Display the list of people's phone numbers, allowing the user to
183 * browse through them and pick one and return it to the parent activity.</p>
184 * </li>
185 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
186 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
187 * -- Display all pickers for data that can be opened with
188 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
189 * allowing the user to pick one of them and then some data inside of it
190 * and returning the resulting URI to the caller. This can be used,
191 * for example, in an e-mail application to allow the user to pick some
192 * data to include as an attachment.</p>
193 * </li>
194 * </ul>
195 *
196 * <p>There are a variety of standard Intent action and category constants
197 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700198 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700199 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700200 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700201 *
202 * <p>Put together, the set of actions, data types, categories, and extra data
203 * defines a language for the system allowing for the expression of phrases
204 * such as "call john smith's cell". As applications are added to the system,
205 * they can extend this language by adding new actions, types, and categories, or
206 * they can modify the behavior of existing phrases by supplying their own
207 * activities that handle them.</p>
208 *
209 * <a name="IntentResolution"></a>
210 * <h3>Intent Resolution</h3>
211 *
212 * <p>There are two primary forms of intents you will use.
213 *
214 * <ul>
215 * <li> <p><b>Explicit Intents</b> have specified a component (via
216 * {@link #setComponent} or {@link #setClass}), which provides the exact
217 * class to be run. Often these will not include any other information,
218 * simply being a way for an application to launch various internal
219 * activities it has as the user interacts with the application.
220 *
221 * <li> <p><b>Implicit Intents</b> have not specified a component;
222 * instead, they must include enough information for the system to
223 * determine which of the available components is best to run for that
224 * intent.
225 * </ul>
226 *
227 * <p>When using implicit intents, given such an arbitrary intent we need to
228 * know what to do with it. This is handled by the process of <em>Intent
229 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
230 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
231 * more activities/receivers) that can handle it.</p>
232 *
233 * <p>The intent resolution mechanism basically revolves around matching an
234 * Intent against all of the &lt;intent-filter&gt; descriptions in the
235 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
236 * objects explicitly registered with {@link Context#registerReceiver}.) More
237 * details on this can be found in the documentation on the {@link
238 * IntentFilter} class.</p>
239 *
240 * <p>There are three pieces of information in the Intent that are used for
241 * resolution: the action, type, and category. Using this information, a query
242 * is done on the {@link PackageManager} for a component that can handle the
243 * intent. The appropriate component is determined based on the intent
244 * information supplied in the <code>AndroidManifest.xml</code> file as
245 * follows:</p>
246 *
247 * <ul>
248 * <li> <p>The <b>action</b>, if given, must be listed by the component as
249 * one it handles.</p>
250 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
251 * already supplied in the Intent. Like the action, if a type is
252 * included in the intent (either explicitly or implicitly in its
253 * data), then this must be listed by the component as one it handles.</p>
254 * <li> For data that is not a <code>content:</code> URI and where no explicit
255 * type is included in the Intent, instead the <b>scheme</b> of the
256 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
257 * considered. Again like the action, if we are matching a scheme it
258 * must be listed by the component as one it can handle.
259 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
260 * by the activity as categories it handles. That is, if you include
261 * the categories {@link #CATEGORY_LAUNCHER} and
262 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
263 * with an intent that lists <em>both</em> of those categories.
264 * Activities will very often need to support the
265 * {@link #CATEGORY_DEFAULT} so that they can be found by
266 * {@link Context#startActivity Context.startActivity()}.</p>
267 * </ul>
268 *
269 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700270 * allows a user to browse through a list of notes data and view details about
271 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700272 * name with one specific to your own package.</p>
273 *
274 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
275 * package="<i>com.android.notepad</i>"&gt;
276 * &lt;application android:icon="@drawable/app_notes"
277 * android:label="@string/app_name"&gt;
278 *
279 * &lt;provider class=".NotePadProvider"
280 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
281 *
282 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
283 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700284 * &lt;action android:name="android.intent.action.MAIN" /&gt;
285 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700286 * &lt;/intent-filter&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.VIEW" /&gt;
289 * &lt;action android:name="android.intent.action.EDIT" /&gt;
290 * &lt;action android:name="android.intent.action.PICK" /&gt;
291 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
292 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700293 * &lt;/intent-filter&gt;
294 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700295 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
296 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
297 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700298 * &lt;/intent-filter&gt;
299 * &lt;/activity&gt;
300 *
301 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
302 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700303 * &lt;action android:name="android.intent.action.VIEW" /&gt;
304 * &lt;action android:name="android.intent.action.EDIT" /&gt;
305 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
306 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700307 * &lt;/intent-filter&gt;
308 *
309 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700310 * &lt;action android:name="android.intent.action.INSERT" /&gt;
311 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
312 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700313 * &lt;/intent-filter&gt;
314 *
315 * &lt;/activity&gt;
316 *
317 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
318 * android:theme="@android:style/Theme.Dialog"&gt;
319 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700320 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
321 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
322 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
323 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
324 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700325 * &lt;/intent-filter&gt;
326 * &lt;/activity&gt;
327 *
328 * &lt;/application&gt;
329 * &lt;/manifest&gt;</pre>
330 *
331 * <p>The first activity,
332 * <code>com.android.notepad.NotesList</code>, serves as our main
333 * entry into the app. It can do three things as described by its three intent
334 * templates:
335 * <ol>
336 * <li><pre>
337 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700338 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
339 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700340 * &lt;/intent-filter&gt;</pre>
341 * <p>This provides a top-level entry into the NotePad application: the standard
342 * MAIN action is a main entry point (not requiring any other information in
343 * the Intent), and the LAUNCHER category says that this entry point should be
344 * listed in the application launcher.</p>
345 * <li><pre>
346 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700347 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
348 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
349 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
350 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700351 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700352 * &lt;/intent-filter&gt;</pre>
353 * <p>This declares the things that the activity can do on a directory of
354 * notes. The type being supported is given with the &lt;type&gt; tag, where
355 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
356 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
357 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
358 * The activity allows the user to view or edit the directory of data (via
359 * the VIEW and EDIT actions), or to pick a particular note and return it
360 * to the caller (via the PICK action). Note also the DEFAULT category
361 * supplied here: this is <em>required</em> for the
362 * {@link Context#startActivity Context.startActivity} method to resolve your
363 * activity when its component name is not explicitly specified.</p>
364 * <li><pre>
365 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700366 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
367 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
368 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700369 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700370 * <p>This filter describes the ability to return to the caller a note selected by
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700371 * the user without needing to know where it came from. The data type
372 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
373 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
374 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
375 * The GET_CONTENT action is similar to the PICK action, where the activity
376 * will return to its caller a piece of data selected by the user. Here,
377 * however, the caller specifies the type of data they desire instead of
378 * the type of data the user will be picking from.</p>
379 * </ol>
380 *
381 * <p>Given these capabilities, the following intents will resolve to the
382 * NotesList activity:</p>
383 *
384 * <ul>
385 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
386 * activities that can be used as top-level entry points into an
387 * application.</p>
388 * <li> <p><b>{ action=android.app.action.MAIN,
389 * category=android.app.category.LAUNCHER }</b> is the actual intent
390 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700391 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700392 * data=content://com.google.provider.NotePad/notes }</b>
393 * displays a list of all the notes under
394 * "content://com.google.provider.NotePad/notes", which
395 * the user can browse through and see the details on.</p>
396 * <li> <p><b>{ action=android.app.action.PICK
397 * data=content://com.google.provider.NotePad/notes }</b>
398 * provides a list of the notes under
399 * "content://com.google.provider.NotePad/notes", from which
400 * the user can pick a note whose data URL is returned back to the caller.</p>
401 * <li> <p><b>{ action=android.app.action.GET_CONTENT
402 * type=vnd.android.cursor.item/vnd.google.note }</b>
403 * is similar to the pick action, but allows the caller to specify the
404 * kind of data they want back so that the system can find the appropriate
405 * activity to pick something of that data type.</p>
406 * </ul>
407 *
408 * <p>The second activity,
409 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
410 * note entry and allows them to edit it. It can do two things as described
411 * by its two intent templates:
412 * <ol>
413 * <li><pre>
414 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700415 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
416 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
417 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
418 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700419 * &lt;/intent-filter&gt;</pre>
420 * <p>The first, primary, purpose of this activity is to let the user interact
421 * with a single note, as decribed by the MIME type
422 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
423 * either VIEW a note or allow the user to EDIT it. Again we support the
424 * DEFAULT category to allow the activity to be launched without explicitly
425 * specifying its component.</p>
426 * <li><pre>
427 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700428 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
429 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
430 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700431 * &lt;/intent-filter&gt;</pre>
432 * <p>The secondary use of this activity is to insert a new note entry into
433 * an existing directory of notes. This is used when the user creates a new
434 * note: the INSERT action is executed on the directory of notes, causing
435 * this activity to run and have the user create the new note data which
436 * it then adds to the content provider.</p>
437 * </ol>
438 *
439 * <p>Given these capabilities, the following intents will resolve to the
440 * NoteEditor activity:</p>
441 *
442 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700443 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700444 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
445 * shows the user the content of note <var>{ID}</var>.</p>
446 * <li> <p><b>{ action=android.app.action.EDIT
447 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
448 * allows the user to edit the content of note <var>{ID}</var>.</p>
449 * <li> <p><b>{ action=android.app.action.INSERT
450 * data=content://com.google.provider.NotePad/notes }</b>
451 * creates a new, empty note in the notes list at
452 * "content://com.google.provider.NotePad/notes"
453 * and allows the user to edit it. If they keep their changes, the URI
454 * of the newly created note is returned to the caller.</p>
455 * </ul>
456 *
457 * <p>The last activity,
458 * <code>com.android.notepad.TitleEditor</code>, allows the user to
459 * edit the title of a note. This could be implemented as a class that the
460 * application directly invokes (by explicitly setting its component in
461 * the Intent), but here we show a way you can publish alternative
462 * operations on existing data:</p>
463 *
464 * <pre>
465 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700466 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
467 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
468 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
469 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
470 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700471 * &lt;/intent-filter&gt;</pre>
472 *
473 * <p>In the single intent template here, we
474 * have created our own private action called
475 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
476 * edit the title of a note. It must be invoked on a specific note
477 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
478 * view and edit actions, but here displays and edits the title contained
479 * in the note data.
480 *
481 * <p>In addition to supporting the default category as usual, our title editor
482 * also supports two other standard categories: ALTERNATIVE and
483 * SELECTED_ALTERNATIVE. Implementing
484 * these categories allows others to find the special action it provides
485 * without directly knowing about it, through the
486 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
487 * more often to build dynamic menu items with
488 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
489 * template here was also supply an explicit name for the template
490 * (via <code>android:label="@string/resolve_title"</code>) to better control
491 * what the user sees when presented with this activity as an alternative
492 * action to the data they are viewing.
493 *
494 * <p>Given these capabilities, the following intent will resolve to the
495 * TitleEditor activity:</p>
496 *
497 * <ul>
498 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
499 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
500 * displays and allows the user to edit the title associated
501 * with note <var>{ID}</var>.</p>
502 * </ul>
503 *
504 * <h3>Standard Activity Actions</h3>
505 *
506 * <p>These are the current standard actions that Intent defines for launching
507 * activities (usually through {@link Context#startActivity}. The most
508 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
509 * {@link #ACTION_EDIT}.
510 *
511 * <ul>
512 * <li> {@link #ACTION_MAIN}
513 * <li> {@link #ACTION_VIEW}
514 * <li> {@link #ACTION_ATTACH_DATA}
515 * <li> {@link #ACTION_EDIT}
516 * <li> {@link #ACTION_PICK}
517 * <li> {@link #ACTION_CHOOSER}
518 * <li> {@link #ACTION_GET_CONTENT}
519 * <li> {@link #ACTION_DIAL}
520 * <li> {@link #ACTION_CALL}
521 * <li> {@link #ACTION_SEND}
522 * <li> {@link #ACTION_SENDTO}
523 * <li> {@link #ACTION_ANSWER}
524 * <li> {@link #ACTION_INSERT}
525 * <li> {@link #ACTION_DELETE}
526 * <li> {@link #ACTION_RUN}
527 * <li> {@link #ACTION_SYNC}
528 * <li> {@link #ACTION_PICK_ACTIVITY}
529 * <li> {@link #ACTION_SEARCH}
530 * <li> {@link #ACTION_WEB_SEARCH}
531 * <li> {@link #ACTION_FACTORY_TEST}
532 * </ul>
533 *
534 * <h3>Standard Broadcast Actions</h3>
535 *
536 * <p>These are the current standard actions that Intent defines for receiving
537 * broadcasts (usually through {@link Context#registerReceiver} or a
538 * &lt;receiver&gt; tag in a manifest).
539 *
540 * <ul>
541 * <li> {@link #ACTION_TIME_TICK}
542 * <li> {@link #ACTION_TIME_CHANGED}
543 * <li> {@link #ACTION_TIMEZONE_CHANGED}
544 * <li> {@link #ACTION_BOOT_COMPLETED}
545 * <li> {@link #ACTION_PACKAGE_ADDED}
546 * <li> {@link #ACTION_PACKAGE_CHANGED}
547 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800548 * <li> {@link #ACTION_PACKAGE_RESTARTED}
549 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000550 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
551 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700552 * <li> {@link #ACTION_UID_REMOVED}
553 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700554 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700555 * <li> {@link #ACTION_POWER_DISCONNECTED}
556 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700557 * </ul>
558 *
559 * <h3>Standard Categories</h3>
560 *
561 * <p>These are the current standard categories that can be used to further
562 * clarify an Intent via {@link #addCategory}.
563 *
564 * <ul>
565 * <li> {@link #CATEGORY_DEFAULT}
566 * <li> {@link #CATEGORY_BROWSABLE}
567 * <li> {@link #CATEGORY_TAB}
568 * <li> {@link #CATEGORY_ALTERNATIVE}
569 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
570 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800571 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700572 * <li> {@link #CATEGORY_HOME}
573 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400575 * <li> {@link #CATEGORY_CAR_DOCK}
576 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500577 * <li> {@link #CATEGORY_LE_DESK_DOCK}
578 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200579 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700580 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800581 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700582 * </ul>
583 *
584 * <h3>Standard Extra Data</h3>
585 *
586 * <p>These are the current standard fields that can be used as extra data via
587 * {@link #putExtra}.
588 *
589 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800590 * <li> {@link #EXTRA_ALARM_COUNT}
591 * <li> {@link #EXTRA_BCC}
592 * <li> {@link #EXTRA_CC}
593 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
594 * <li> {@link #EXTRA_DATA_REMOVED}
595 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500596 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
597 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800598 * <li> {@link #EXTRA_DOCK_STATE_CAR}
599 * <li> {@link #EXTRA_DOCK_STATE_DESK}
600 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
601 * <li> {@link #EXTRA_DONT_KILL_APP}
602 * <li> {@link #EXTRA_EMAIL}
603 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700604 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800605 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700606 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700608 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
610 * <li> {@link #EXTRA_REPLACING}
611 * <li> {@link #EXTRA_SHORTCUT_ICON}
612 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
613 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800615 * <li> {@link #EXTRA_SHORTCUT_NAME}
616 * <li> {@link #EXTRA_SUBJECT}
617 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700618 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800619 * <li> {@link #EXTRA_TITLE}
620 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 * </ul>
622 *
623 * <h3>Flags</h3>
624 *
625 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800626 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
627 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700628 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800629public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700630 private static final String ATTR_ACTION = "action";
631 private static final String TAG_CATEGORIES = "categories";
632 private static final String ATTR_CATEGORY = "category";
633 private static final String TAG_EXTRA = "extra";
634 private static final String ATTR_TYPE = "type";
635 private static final String ATTR_COMPONENT = "component";
636 private static final String ATTR_DATA = "data";
637 private static final String ATTR_FLAGS = "flags";
638
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700639 // ---------------------------------------------------------------------
640 // ---------------------------------------------------------------------
641 // Standard intent activity actions (see action variable).
642
643 /**
644 * Activity Action: Start as a main entry point, does not expect to
645 * receive data.
646 * <p>Input: nothing
647 * <p>Output: nothing
648 */
649 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
650 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800651
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700652 /**
653 * Activity Action: Display the data to the user. This is the most common
654 * action performed on data -- it is the generic action you can use on
655 * a piece of data to get the most reasonable thing to occur. For example,
656 * when used on a contacts entry it will view the entry; when used on a
657 * mailto: URI it will bring up a compose window filled with the information
658 * supplied by the URI; when used with a tel: URI it will invoke the
659 * dialer.
660 * <p>Input: {@link #getData} is URI from which to retrieve data.
661 * <p>Output: nothing.
662 */
663 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
664 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800665
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700666 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700667 * Extra that can be included on activity intents coming from the storage UI
668 * when it launches sub-activities to manage various types of storage. For example,
669 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
670 * the images on the device, and in that case also include this extra to tell the
671 * app it is coming from the storage UI so should help the user manage storage of
672 * this type.
673 */
674 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
675
676 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700677 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
678 * performed on a piece of data.
679 */
680 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800681
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700682 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900683 * Activity Action: Quick view the data. Launches a quick viewer for
684 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900685 * <p>Activities handling this intent action should handle the vast majority of
686 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700687 * <p>Quick viewers must render the quick view image locally, and must not send
688 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900689 * <p>Input: {@link #getData} is a mandatory content URI of the item to
690 * preview. {@link #getClipData} contains an optional list of content URIs
691 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
692 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700693 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
694 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700695 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900696 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700697 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700698 */
699 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
700 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
701
702 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700703 * Used to indicate that some piece of data should be attached to some other
704 * place. For example, image data could be attached to a contact. It is up
705 * to the recipient to decide where the data should be attached; the intent
706 * does not specify the ultimate destination.
707 * <p>Input: {@link #getData} is URI of data to be attached.
708 * <p>Output: nothing.
709 */
710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
711 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800712
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700713 /**
714 * Activity Action: Provide explicit editable access to the given data.
715 * <p>Input: {@link #getData} is URI of data to be edited.
716 * <p>Output: nothing.
717 */
718 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
719 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800720
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700721 /**
722 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
723 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
724 * The extras can contain type specific data to pass through to the editing/creating
725 * activity.
726 * <p>Output: The URI of the item that was picked. This must be a content:
727 * URI so that any receiver can access it.
728 */
729 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
730 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800731
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700732 /**
733 * Activity Action: Pick an item from the data, returning what was selected.
734 * <p>Input: {@link #getData} is URI containing a directory of data
735 * (vnd.android.cursor.dir/*) from which to pick an item.
736 * <p>Output: The URI of the item that was picked.
737 */
738 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
739 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800740
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700741 /**
742 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800743 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800744 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
745 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700746 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
747 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800748 * (value: ShortcutIconResource).</p>
749 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800750 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700751 * @see #EXTRA_SHORTCUT_INTENT
752 * @see #EXTRA_SHORTCUT_NAME
753 * @see #EXTRA_SHORTCUT_ICON
754 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
755 * @see android.content.Intent.ShortcutIconResource
756 */
757 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
758 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
759
760 /**
761 * The name of the extra used to define the Intent of a shortcut.
762 *
763 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800764 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700765 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
768 /**
769 * The name of the extra used to define the name of a shortcut.
770 *
771 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800772 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700773 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
776 /**
777 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
778 *
779 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800780 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700781 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800782 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
784 /**
785 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
786 *
787 * @see #ACTION_CREATE_SHORTCUT
788 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800789 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700790 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800791 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
793 "android.intent.extra.shortcut.ICON_RESOURCE";
794
795 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500796 * An activity that provides a user interface for adjusting application preferences.
797 * Optional but recommended settings for all applications which have settings.
798 */
799 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
800 public static final String ACTION_APPLICATION_PREFERENCES
801 = "android.intent.action.APPLICATION_PREFERENCES";
802
803 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700804 * Activity Action: Launch an activity showing the app information.
805 * For applications which install other applications (such as app stores), it is recommended
806 * to handle this action for providing the app information to the user.
807 *
808 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
809 * to be displayed.
810 * <p>Output: Nothing.
811 */
812 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
813 public static final String ACTION_SHOW_APP_INFO
814 = "android.intent.action.SHOW_APP_INFO";
815
816 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800817 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700818 *
819 * @see Intent#ACTION_CREATE_SHORTCUT
820 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800821 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
822 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700823 */
824 public static class ShortcutIconResource implements Parcelable {
825 /**
826 * The package name of the application containing the icon.
827 */
828 public String packageName;
829
830 /**
831 * The resource name of the icon, including package, name and type.
832 */
833 public String resourceName;
834
835 /**
836 * Creates a new ShortcutIconResource for the specified context and resource
837 * identifier.
838 *
839 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700840 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700841 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700842 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700844 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845 ShortcutIconResource icon = new ShortcutIconResource();
846 icon.packageName = context.getPackageName();
847 icon.resourceName = context.getResources().getResourceName(resourceId);
848 return icon;
849 }
850
851 /**
852 * Used to read a ShortcutIconResource from a Parcel.
853 */
854 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
855 new Parcelable.Creator<ShortcutIconResource>() {
856
857 public ShortcutIconResource createFromParcel(Parcel source) {
858 ShortcutIconResource icon = new ShortcutIconResource();
859 icon.packageName = source.readString();
860 icon.resourceName = source.readString();
861 return icon;
862 }
863
864 public ShortcutIconResource[] newArray(int size) {
865 return new ShortcutIconResource[size];
866 }
867 };
868
869 /**
870 * No special parcel contents.
871 */
872 public int describeContents() {
873 return 0;
874 }
875
876 public void writeToParcel(Parcel dest, int flags) {
877 dest.writeString(packageName);
878 dest.writeString(resourceName);
879 }
880
881 @Override
882 public String toString() {
883 return resourceName;
884 }
885 }
886
887 /**
888 * Activity Action: Display an activity chooser, allowing the user to pick
889 * what they want to before proceeding. This can be used as an alternative
890 * to the standard activity picker that is displayed by the system when
891 * you try to start an activity with multiple possible matches, with these
892 * differences in behavior:
893 * <ul>
894 * <li>You can specify the title that will appear in the activity chooser.
895 * <li>The user does not have the option to make one of the matching
896 * activities a preferred activity, and all possible activities will
897 * always be shown even if one of them is currently marked as the
898 * preferred activity.
899 * </ul>
900 * <p>
901 * This action should be used when the user will naturally expect to
902 * select an activity in order to proceed. An example if when not to use
903 * it is when the user clicks on a "mailto:" link. They would naturally
904 * expect to go directly to their mail app, so startActivity() should be
905 * called directly: it will
906 * either launch the current preferred app, or put up a dialog allowing the
907 * user to pick an app to use and optionally marking that as preferred.
908 * <p>
909 * In contrast, if the user is selecting a menu item to send a picture
910 * they are viewing to someone else, there are many different things they
911 * may want to do at this point: send it through e-mail, upload it to a
912 * web service, etc. In this case the CHOOSER action should be used, to
913 * always present to the user a list of the things they can do, with a
914 * nice title given by the caller such as "Send this photo with:".
915 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700916 * If you need to grant URI permissions through a chooser, you must specify
917 * the permissions to be granted on the ACTION_CHOOSER Intent
918 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
919 * {@link #setClipData} to specify the URIs to be granted as well as
920 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
921 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
922 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700923 * As a convenience, an Intent of this form can be created with the
924 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700925 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700926 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700927 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
928 * and can optionally have a {@link #EXTRA_TITLE} field containing the
929 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700930 * <p>
931 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700932 */
933 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
934 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
935
936 /**
937 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
938 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700939 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
940 * target intent, also optionally supplying a title. If the target
941 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
942 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
943 * set in the returned chooser intent, with its ClipData set appropriately:
944 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500945 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700946 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700947 * @param target The Intent that the user will be selecting an activity
948 * to perform.
949 * @param title Optional title that will be displayed in the chooser.
950 * @return Return a new Intent object that you can hand to
951 * {@link Context#startActivity(Intent) Context.startActivity()} and
952 * related methods.
953 */
954 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700955 return createChooser(target, title, null);
956 }
957
958 /**
959 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
960 *
961 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
962 * target intent, also optionally supplying a title. If the target
963 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
964 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
965 * set in the returned chooser intent, with its ClipData set appropriately:
966 * either a direct reflection of {@link #getClipData()} if that is non-null,
967 * or a new ClipData built from {@link #getData()}.</p>
968 *
969 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
970 * when the user makes a choice. This can be useful if the calling application wants
971 * to remember the last chosen target and surface it as a more prominent or one-touch
972 * affordance elsewhere in the UI for next time.</p>
973 *
974 * @param target The Intent that the user will be selecting an activity
975 * to perform.
976 * @param title Optional title that will be displayed in the chooser.
977 * @param sender Optional IntentSender to be called when a choice is made.
978 * @return Return a new Intent object that you can hand to
979 * {@link Context#startActivity(Intent) Context.startActivity()} and
980 * related methods.
981 */
982 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700983 Intent intent = new Intent(ACTION_CHOOSER);
984 intent.putExtra(EXTRA_INTENT, target);
985 if (title != null) {
986 intent.putExtra(EXTRA_TITLE, title);
987 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700988
Adam Powell0b3c1122014-10-09 12:50:14 -0700989 if (sender != null) {
990 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
991 }
992
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700993 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700994 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
995 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
996 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700997 if (permFlags != 0) {
998 ClipData targetClipData = target.getClipData();
999 if (targetClipData == null && target.getData() != null) {
1000 ClipData.Item item = new ClipData.Item(target.getData());
1001 String[] mimeTypes;
1002 if (target.getType() != null) {
1003 mimeTypes = new String[] { target.getType() };
1004 } else {
1005 mimeTypes = new String[] { };
1006 }
1007 targetClipData = new ClipData(null, mimeTypes, item);
1008 }
1009 if (targetClipData != null) {
1010 intent.setClipData(targetClipData);
1011 intent.addFlags(permFlags);
1012 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001013 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001014
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001015 return intent;
1016 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001017
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001018 /**
1019 * Activity Action: Allow the user to select a particular kind of data and
1020 * return it. This is different than {@link #ACTION_PICK} in that here we
1021 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001022 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001023 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001024 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001025 * etc.
1026 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001027 * 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 -07001028 * of data, such as a person contact, you set the MIME type to the kind of
1029 * data you want and launch it with {@link Context#startActivity(Intent)}.
1030 * The system will then launch the best application to select that kind
1031 * of data for you.
1032 * <p>
1033 * You may also be interested in any of a set of types of content the user
1034 * can pick. For example, an e-mail application that wants to allow the
1035 * user to add an attachment to an e-mail message can use this action to
1036 * bring up a list of all of the types of content the user can attach.
1037 * <p>
1038 * In this case, you should wrap the GET_CONTENT intent with a chooser
1039 * (through {@link #createChooser}), which will give the proper interface
1040 * for the user to pick how to send your data and allow you to specify
1041 * a prompt indicating what they are doing. You will usually specify a
1042 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1043 * broad range of content types the user can select from.
1044 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001045 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001046 * only pick from data that can be represented as a stream. This is
1047 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1048 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001049 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001050 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001051 * is locally available on the device. For example, if this extra is set
1052 * to true then an image picker should not show any pictures that are available
1053 * from a remote server but not already on the local device (thus requiring
1054 * they be downloaded when opened).
1055 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001056 * If the caller can handle multiple returned items (the user performing
1057 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1058 * to indicate this.
1059 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001060 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1061 * that no URI is supplied in the intent, as there are no constraints on
1062 * where the returned data originally comes from. You may also include the
1063 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001064 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001065 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1066 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001067 * <p>
1068 * Output: The URI of the item that was picked. This must be a content:
1069 * URI so that any receiver can access it.
1070 */
1071 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1072 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1073 /**
1074 * Activity Action: Dial a number as specified by the data. This shows a
1075 * UI with the number being dialed, allowing the user to explicitly
1076 * initiate the call.
1077 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1078 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1079 * number.
1080 * <p>Output: nothing.
1081 */
1082 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1083 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1084 /**
1085 * Activity Action: Perform a call to someone specified by the data.
1086 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1087 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1088 * number.
1089 * <p>Output: nothing.
1090 *
1091 * <p>Note: there will be restrictions on which applications can initiate a
1092 * call; most applications should use the {@link #ACTION_DIAL}.
1093 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1094 * numbers. Applications can <strong>dial</strong> emergency numbers using
1095 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001096 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001097 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001098 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001099 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001100 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001101 */
1102 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1103 public static final String ACTION_CALL = "android.intent.action.CALL";
1104 /**
1105 * Activity Action: Perform a call to an emergency number specified by the
1106 * data.
1107 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1108 * tel: URI of an explicit phone number.
1109 * <p>Output: nothing.
1110 * @hide
1111 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001112 @SystemApi
1113 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001114 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1115 /**
1116 * Activity action: Perform a call to any number (emergency or not)
1117 * specified by the data.
1118 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1119 * tel: URI of an explicit phone number.
1120 * <p>Output: nothing.
1121 * @hide
1122 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001123 @SystemApi
1124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001125 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001126
Santos Cordon15a13782015-03-31 18:32:31 -07001127 /**
fionaxuadfe7002017-02-17 17:20:46 -08001128 * Activity Action: Main entry point for carrier setup apps.
1129 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1130 * carrier service and typically require
1131 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1132 * fulfill their duties.
1133 */
1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1135 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1136 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001137 * Activity Action: Send a message to someone specified by the data.
1138 * <p>Input: {@link #getData} is URI describing the target.
1139 * <p>Output: nothing.
1140 */
1141 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1142 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1143 /**
1144 * Activity Action: Deliver some data to someone else. Who the data is
1145 * being delivered to is not specified; it is up to the receiver of this
1146 * action to ask the user where the data should be sent.
1147 * <p>
1148 * When launching a SEND intent, you should usually wrap it in a chooser
1149 * (through {@link #createChooser}), which will give the proper interface
1150 * for the user to pick how to send your data and allow you to specify
1151 * a prompt indicating what they are doing.
1152 * <p>
1153 * Input: {@link #getType} is the MIME type of the data being sent.
1154 * get*Extra can have either a {@link #EXTRA_TEXT}
1155 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1156 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1157 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1158 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001159 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1160 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1161 * your text with HTML formatting.
1162 * <p>
1163 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1164 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1165 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1166 * content: URIs and other advanced features of {@link ClipData}. If
1167 * using this approach, you still must supply the same data through the
1168 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1169 * for compatibility with old applications. If you don't set a ClipData,
1170 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001171 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001172 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1173 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1174 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1175 * be openable only as asset typed files using
1176 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1177 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001178 * Optional standard extras, which may be interpreted by some recipients as
1179 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1180 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1181 * <p>
1182 * Output: nothing.
1183 */
1184 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1185 public static final String ACTION_SEND = "android.intent.action.SEND";
1186 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001187 * Activity Action: Deliver multiple data to someone else.
1188 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001189 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001190 * <p>
1191 * Input: {@link #getType} is the MIME type of the data being sent.
1192 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001193 * #EXTRA_STREAM} field, containing the data to be sent. If using
1194 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1195 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001196 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001197 * Multiple types are supported, and receivers should handle mixed types
1198 * whenever possible. The right way for the receiver to check them is to
1199 * use the content resolver on each URI. The intent sender should try to
1200 * put the most concrete mime type in the intent type, but it can fall
1201 * back to {@literal <type>/*} or {@literal *}/* as needed.
1202 * <p>
1203 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1204 * be image/jpg, but if you are sending image/jpg and image/png, then the
1205 * intent's type should be image/*.
1206 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001207 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1208 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1209 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1210 * content: URIs and other advanced features of {@link ClipData}. If
1211 * using this approach, you still must supply the same data through the
1212 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1213 * for compatibility with old applications. If you don't set a ClipData,
1214 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1215 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001216 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1217 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1218 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1219 * be openable only as asset typed files using
1220 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1221 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001222 * Optional standard extras, which may be interpreted by some recipients as
1223 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1224 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1225 * <p>
1226 * Output: nothing.
1227 */
1228 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1229 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1230 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001231 * Activity Action: Handle an incoming phone call.
1232 * <p>Input: nothing.
1233 * <p>Output: nothing.
1234 */
1235 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1236 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1237 /**
1238 * Activity Action: Insert an empty item into the given container.
1239 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1240 * in which to place the data.
1241 * <p>Output: URI of the new data that was created.
1242 */
1243 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1244 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1245 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001246 * Activity Action: Create a new item in the given container, initializing it
1247 * from the current contents of the clipboard.
1248 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1249 * in which to place the data.
1250 * <p>Output: URI of the new data that was created.
1251 */
1252 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1253 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1254 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001255 * Activity Action: Delete the given data from its container.
1256 * <p>Input: {@link #getData} is URI of data to be deleted.
1257 * <p>Output: nothing.
1258 */
1259 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1260 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1261 /**
1262 * Activity Action: Run the data, whatever that means.
1263 * <p>Input: ? (Note: this is currently specific to the test harness.)
1264 * <p>Output: nothing.
1265 */
1266 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1267 public static final String ACTION_RUN = "android.intent.action.RUN";
1268 /**
1269 * Activity Action: Perform a data synchronization.
1270 * <p>Input: ?
1271 * <p>Output: ?
1272 */
1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1275 /**
1276 * Activity Action: Pick an activity given an intent, returning the class
1277 * selected.
1278 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1279 * used with {@link PackageManager#queryIntentActivities} to determine the
1280 * set of activities from which to pick.
1281 * <p>Output: Class name of the activity that was selected.
1282 */
1283 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1284 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1285 /**
1286 * Activity Action: Perform a search.
1287 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1288 * is the text to search for. If empty, simply
1289 * enter your search results Activity with the search UI activated.
1290 * <p>Output: nothing.
1291 */
1292 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1293 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1294 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001295 * Activity Action: Start the platform-defined tutorial
1296 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1297 * is the text to search for. If empty, simply
1298 * enter your search results Activity with the search UI activated.
1299 * <p>Output: nothing.
1300 */
1301 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1302 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1303 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001304 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001305 * <p>
1306 * Input: {@link android.app.SearchManager#QUERY
1307 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1308 * a url starts with http or https, the site will be opened. If it is plain
1309 * text, Google search will be applied.
1310 * <p>
1311 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001312 */
1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001315
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001316 /**
Jim Miller07994402012-05-02 14:22:27 -07001317 * Activity Action: Perform assist action.
1318 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001319 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1320 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001321 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1322 * information.
Jim Miller07994402012-05-02 14:22:27 -07001323 * Output: nothing.
1324 */
1325 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1326 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001327
1328 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001329 * Activity Action: Perform voice assist action.
1330 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001331 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1332 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001333 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001334 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001335 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001336 */
Amith Yamasani16452032017-03-03 10:15:57 -08001337 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001338 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1339 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1340
1341 /**
Adam Skory7140a252013-09-11 12:04:58 +01001342 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1343 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001344 */
1345 public static final String EXTRA_ASSIST_PACKAGE
1346 = "android.intent.extra.ASSIST_PACKAGE";
1347
1348 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001349 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1350 * application package at the time the assist was invoked.
1351 */
1352 public static final String EXTRA_ASSIST_UID
1353 = "android.intent.extra.ASSIST_UID";
1354
1355 /**
Adam Skory7140a252013-09-11 12:04:58 +01001356 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1357 * information supplied by the current foreground app at the time of the assist request.
1358 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001359 */
1360 public static final String EXTRA_ASSIST_CONTEXT
1361 = "android.intent.extra.ASSIST_CONTEXT";
1362
Jim Miller07994402012-05-02 14:22:27 -07001363 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001364 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1365 * keyboard as the primary input device for assistance.
1366 */
1367 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1368 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1369
1370 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001371 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1372 * that was used to invoke the assist.
1373 */
1374 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1375 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1376
1377 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001378 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001379 * <p>Input: Nothing.
1380 * <p>Output: nothing.
1381 */
1382 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1383 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1384 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001385 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001386 * <p>Input: Nothing.
1387 * <p>Output: Nothing.
1388 */
1389 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1390 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1391
1392 /**
1393 * Activity Action: Show activity for reporting a bug.
1394 * <p>Input: Nothing.
1395 * <p>Output: Nothing.
1396 */
1397 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1398 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1399
1400 /**
1401 * Activity Action: Main entry point for factory tests. Only used when
1402 * the device is booting in factory test node. The implementing package
1403 * must be installed in the system image.
1404 * <p>Input: nothing
1405 * <p>Output: nothing
1406 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001407 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001408 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1409
1410 /**
1411 * Activity Action: The user pressed the "call" button to go to the dialer
1412 * or other appropriate UI for placing a call.
1413 * <p>Input: Nothing.
1414 * <p>Output: Nothing.
1415 */
1416 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1417 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1418
1419 /**
1420 * Activity Action: Start Voice Command.
1421 * <p>Input: Nothing.
1422 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001423 * <p class="note">
1424 * In some cases, a matching Activity may not exist, so ensure you
1425 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001426 */
1427 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1428 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001429
1430 /**
1431 * Activity Action: Start action associated with long pressing on the
1432 * search key.
1433 * <p>Input: Nothing.
1434 * <p>Output: Nothing.
1435 */
1436 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1437 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001438
Jacek Surazski86b6c532009-05-13 14:38:28 +02001439 /**
1440 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1441 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001442 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001443 * <p>Input: No data is specified. The bug report is passed in using
1444 * an {@link #EXTRA_BUG_REPORT} field.
1445 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001446 *
1447 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001448 */
1449 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001451
1452 /**
1453 * Activity Action: Show power usage information to the user.
1454 * <p>Input: Nothing.
1455 * <p>Output: Nothing.
1456 */
1457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1458 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001459
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001460 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001461 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1462 * to run.
1463 * <p>Input: Nothing.
1464 * <p>Output: Nothing.
1465 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1466 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1467 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001468 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001469 */
1470 @Deprecated
1471 @SystemApi
1472 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1473 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1474
1475 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001476 * Activity Action: Setup wizard to launch after a platform update. This
1477 * activity should have a string meta-data field associated with it,
1478 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1479 * the platform for setup. The activity will be launched only if
1480 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1481 * same value.
1482 * <p>Input: Nothing.
1483 * <p>Output: Nothing.
1484 * @hide
1485 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001486 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001487 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1488 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001489
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001490 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001491 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1492 * <p>Input: Nothing.
1493 * <p>Output: Nothing.
1494 * @hide
1495 */
1496 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1497 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001498 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001499
1500 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001501 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1502 * <p>Input: Nothing.
1503 * <p>Output: Nothing.
1504 * @hide
1505 */
1506 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1507 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001508 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001509
1510 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001511 * Activity Action: Show settings for managing network data usage of a
1512 * specific application. Applications should define an activity that offers
1513 * options to control data usage.
1514 */
1515 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1516 public static final String ACTION_MANAGE_NETWORK_USAGE =
1517 "android.intent.action.MANAGE_NETWORK_USAGE";
1518
1519 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001520 * Activity Action: Launch application installer.
1521 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001522 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001523 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1524 * you can also use "package:<package-name>" to install an application for the
1525 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001526 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1527 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1528 * <p>
1529 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1530 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001531 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001532 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001533 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1534 * in order to launch the application installer.
1535 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001536 *
1537 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1538 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1539 * @see #EXTRA_RETURN_RESULT
1540 */
1541 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1542 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1543
1544 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001545 * Activity Action: Activity to handle split installation failures.
1546 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1547 * but the split that contains the application isn't installed. When a split is
1548 * installed in this manner, the containing package usually doesn't know this is
1549 * happening. However, if an error occurs during installation, the containing
1550 * package can define a single activity handling this action to deal with such
1551 * failures.
1552 * <p>The activity handling this action must be in the base package.
1553 * <p>
1554 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1555 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1556 */
1557 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1558 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1559
1560 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001561 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001562 * <p class="note">
1563 * This is a protected intent that can only be sent by the system.
1564 * </p>
1565 *
1566 * @hide
1567 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001568 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001569 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001570 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1571 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001572
1573 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001575 * <p>
1576 * The system will have a persistent connection to this service.
1577 * This is a protected intent that can only be sent by the system.
1578 * </p>
1579 *
1580 * @hide
1581 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001582 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001583 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001584 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1585 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001586
1587 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001588 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001589 *
1590 * <p class="note">
1591 * This is a protected intent that can only be sent by the system.
1592 * </p>
1593 *
1594 * @hide
1595 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001596 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001597 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001598 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1599 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001600
1601 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001602 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1603 * package. Specifies the installer package name; this package will receive the
1604 * {@link #ACTION_APP_ERROR} intent.
1605 */
1606 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1607 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1608
1609 /**
1610 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1611 * package. Specifies that the application being installed should not be
1612 * treated as coming from an unknown source, but as coming from the app
1613 * invoking the Intent. For this to work you must start the installer with
1614 * startActivityForResult().
1615 */
1616 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1617 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1618
1619 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001620 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1621 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001622 * data field originated from.
1623 */
rich cannings706e8ba2012-08-20 13:20:14 -07001624 public static final String EXTRA_ORIGINATING_URI
1625 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001626
1627 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001628 * This extra can be used with any Intent used to launch an activity, supplying information
1629 * about who is launching that activity. This field contains a {@link android.net.Uri}
1630 * object, typically an http: or https: URI of the web site that the referral came from;
1631 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1632 * a native application that it came from.
1633 *
1634 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1635 * instead of directly retrieving the extra. It is also valid for applications to
1636 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1637 * a string, not a Uri; the field here, if supplied, will always take precedence,
1638 * however.</p>
1639 *
1640 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001641 */
1642 public static final String EXTRA_REFERRER
1643 = "android.intent.extra.REFERRER";
1644
1645 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001646 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1647 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1648 * not be created, in particular when Intent extras are supplied through the
1649 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1650 * schemes.
1651 *
1652 * @see #EXTRA_REFERRER
1653 */
1654 public static final String EXTRA_REFERRER_NAME
1655 = "android.intent.extra.REFERRER_NAME";
1656
1657 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001658 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001659 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001660 * Currently only a system app that hosts the provider authority "downloads" or holds the
1661 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001662 * @hide
1663 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001664 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001665 public static final String EXTRA_ORIGINATING_UID
1666 = "android.intent.extra.ORIGINATING_UID";
1667
1668 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001669 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1670 * package. Tells the installer UI to skip the confirmation with the user
1671 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001672 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1673 * will no longer show an interstitial message about updating existing
1674 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001675 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001676 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001677 public static final String EXTRA_ALLOW_REPLACE
1678 = "android.intent.extra.ALLOW_REPLACE";
1679
1680 /**
1681 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1682 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1683 * return to the application the result code of the install/uninstall. The returned result
1684 * code will be {@link android.app.Activity#RESULT_OK} on success or
1685 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1686 */
1687 public static final String EXTRA_RETURN_RESULT
1688 = "android.intent.extra.RETURN_RESULT";
1689
1690 /**
1691 * Package manager install result code. @hide because result codes are not
1692 * yet ready to be exposed.
1693 */
1694 public static final String EXTRA_INSTALL_RESULT
1695 = "android.intent.extra.INSTALL_RESULT";
1696
1697 /**
1698 * Activity Action: Launch application uninstaller.
1699 * <p>
1700 * Input: The data must be a package: URI whose scheme specific part is
1701 * the package name of the current installed package to be uninstalled.
1702 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1703 * <p>
1704 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1705 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001706 * <p>
1707 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1708 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001709 */
1710 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1711 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1712
1713 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001714 * Specify whether the package should be uninstalled for all users.
1715 * @hide because these should not be part of normal application flow.
1716 */
1717 public static final String EXTRA_UNINSTALL_ALL_USERS
1718 = "android.intent.extra.UNINSTALL_ALL_USERS";
1719
1720 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001721 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1722 * describing the last run version of the platform that was setup.
1723 * @hide
1724 */
1725 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1726
Svet Ganov3695b8a2015-03-24 16:30:25 -07001727 /**
1728 * Activity action: Launch UI to manage the permissions of an app.
1729 * <p>
1730 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1731 * will be managed by the launched UI.
1732 * </p>
1733 * <p>
1734 * Output: Nothing.
1735 * </p>
1736 *
1737 * @see #EXTRA_PACKAGE_NAME
1738 *
1739 * @hide
1740 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001741 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1743 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1744 "android.intent.action.MANAGE_APP_PERMISSIONS";
1745
1746 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001747 * Activity action: Launch UI to manage permissions.
1748 * <p>
1749 * Input: Nothing.
1750 * </p>
1751 * <p>
1752 * Output: Nothing.
1753 * </p>
1754 *
1755 * @hide
1756 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001757 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001758 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1759 public static final String ACTION_MANAGE_PERMISSIONS =
1760 "android.intent.action.MANAGE_PERMISSIONS";
1761
1762 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001763 * Activity action: Launch UI to review permissions for an app.
1764 * The system uses this intent if permission review for apps not
1765 * supporting the new runtime permissions model is enabled. In
1766 * this mode a permission review is required before any of the
1767 * app components can run.
1768 * <p>
1769 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1770 * permissions will be reviewed (mandatory).
1771 * </p>
1772 * <p>
1773 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1774 * be fired after the permission review (optional).
1775 * </p>
1776 * <p>
1777 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1778 * be invoked after the permission review (optional).
1779 * </p>
1780 * <p>
1781 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1782 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1783 * </p>
1784 * <p>
1785 * Output: Nothing.
1786 * </p>
1787 *
1788 * @see #EXTRA_PACKAGE_NAME
1789 * @see #EXTRA_INTENT
1790 * @see #EXTRA_REMOTE_CALLBACK
1791 * @see #EXTRA_RESULT_NEEDED
1792 *
1793 * @hide
1794 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001795 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001796 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1797 public static final String ACTION_REVIEW_PERMISSIONS =
1798 "android.intent.action.REVIEW_PERMISSIONS";
1799
1800 /**
1801 * Intent extra: A callback for reporting remote result as a bundle.
1802 * <p>
1803 * Type: IRemoteCallback
1804 * </p>
1805 *
1806 * @hide
1807 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001808 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001809 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1810
1811 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001812 * Intent extra: An app package name.
1813 * <p>
1814 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001815 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001816 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001817 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001818 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1819
1820 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001821 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1822 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1823 *
1824 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1825 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1826 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001827 *
1828 * @see #ACTION_MY_PACKAGE_SUSPENDED
1829 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1830 * @see PackageManager#isPackageSuspended()
1831 * @see PackageManager#getSuspendedPackageAppExtras()
1832 */
1833 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1834
1835 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001836 * Intent extra: An app split name.
1837 * <p>
1838 * Type: String
1839 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001840 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001841 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1842
1843 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001844 * Intent extra: A {@link ComponentName} value.
1845 * <p>
1846 * Type: String
1847 * </p>
1848 */
1849 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1850
1851 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001852 * Intent extra: An extra for specifying whether a result is needed.
1853 * <p>
1854 * Type: boolean
1855 * </p>
1856 *
1857 * @hide
1858 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001859 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001860 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1861
1862 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001863 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1864 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1865 *
1866 * @see PackageManager#isPackageSuspended()
1867 * @see #ACTION_PACKAGES_SUSPENDED
1868 *
1869 * @hide
1870 */
1871 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1872
1873 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001874 * Activity action: Launch UI to manage which apps have a given permission.
1875 * <p>
1876 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1877 * to which will be managed by the launched UI.
1878 * </p>
1879 * <p>
1880 * Output: Nothing.
1881 * </p>
1882 *
1883 * @see #EXTRA_PERMISSION_NAME
1884 *
1885 * @hide
1886 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001887 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001888 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1889 public static final String ACTION_MANAGE_PERMISSION_APPS =
1890 "android.intent.action.MANAGE_PERMISSION_APPS";
1891
1892 /**
1893 * Intent extra: The name of a permission.
1894 * <p>
1895 * Type: String
1896 * </p>
1897 *
1898 * @hide
1899 */
1900 @SystemApi
1901 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1902
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001903 // ---------------------------------------------------------------------
1904 // ---------------------------------------------------------------------
1905 // Standard intent broadcast actions (see action variable).
1906
1907 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001908 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1909 * <p>
1910 * For historical reasons, the name of this broadcast action refers to the power
1911 * state of the screen but it is actually sent in response to changes in the
1912 * overall interactive state of the device.
1913 * </p><p>
1914 * This broadcast is sent when the device becomes non-interactive which may have
1915 * nothing to do with the screen turning off. To determine the
1916 * actual state of the screen, use {@link android.view.Display#getState}.
1917 * </p><p>
1918 * See {@link android.os.PowerManager#isInteractive} for details.
1919 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001920 * You <em>cannot</em> receive this through components declared in
1921 * manifests, only by explicitly registering for it with
1922 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1923 * Context.registerReceiver()}.
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_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001930
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001931 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001932 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1933 * <p>
1934 * For historical reasons, the name of this broadcast action refers to the power
1935 * state of the screen but it is actually sent in response to changes in the
1936 * overall interactive state of the device.
1937 * </p><p>
1938 * This broadcast is sent when the device becomes interactive which may have
1939 * nothing to do with the screen turning on. To determine the
1940 * actual state of the screen, use {@link android.view.Display#getState}.
1941 * </p><p>
1942 * See {@link android.os.PowerManager#isInteractive} for details.
1943 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001944 * You <em>cannot</em> receive this through components declared in
1945 * manifests, only by explicitly registering for it with
1946 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1947 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001948 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001949 * <p class="note">This is a protected intent that can only be sent
1950 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001951 */
1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001954
1955 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001956 * Broadcast Action: Sent after the system stops dreaming.
1957 *
1958 * <p class="note">This is a protected intent that can only be sent by the system.
1959 * It is only sent to registered receivers.</p>
1960 */
1961 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1962 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1963
1964 /**
1965 * Broadcast Action: Sent after the system starts dreaming.
1966 *
1967 * <p class="note">This is a protected intent that can only be sent by the system.
1968 * It is only sent to registered receivers.</p>
1969 */
1970 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1971 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1972
1973 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001974 * 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 -07001975 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001976 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001977 * <p class="note">This is a protected intent that can only be sent
1978 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001979 */
1980 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001981 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001982
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001983 /**
1984 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001985 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001986 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001987 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1988 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001989 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001990 * <p class="note">This is a protected intent that can only be sent
1991 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001992 */
1993 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1994 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1995 /**
1996 * Broadcast Action: The time was set.
1997 */
1998 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1999 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2000 /**
2001 * Broadcast Action: The date has changed.
2002 */
2003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2004 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2005 /**
2006 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2007 * <ul>
2008 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2009 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002010 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002011 * <p class="note">This is a protected intent that can only be sent
2012 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002013 */
2014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2015 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2016 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002017 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2018 * DNS entries should be tossed.
2019 * @hide
2020 */
2021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2022 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2023 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002024 * Alarm Changed Action: This is broadcast when the AlarmClock
2025 * application's alarm is set or unset. It is used by the
2026 * AlarmClock application and the StatusBar service.
2027 * @hide
2028 */
2029 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2030 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002031
2032 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002033 * Broadcast Action: This is broadcast once, after the user has finished
2034 * booting, but while still in the "locked" state. It can be used to perform
2035 * application-specific initialization, such as installing alarms. You must
2036 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2037 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002038 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002039 * This broadcast is sent immediately at boot by all devices (regardless of
2040 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2041 * higher. Upon receipt of this broadcast, the user is still locked and only
2042 * device-protected storage can be accessed safely. If you want to access
2043 * credential-protected storage, you need to wait for the user to be
2044 * unlocked (typically by entering their lock pattern or PIN for the first
2045 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2046 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2047 * <p>
2048 * To receive this broadcast, your receiver component must be marked as
2049 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002050 * <p class="note">
2051 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002052 *
2053 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002054 */
2055 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2056 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2057
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002058 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002059 * Broadcast Action: This is broadcast once, after the user has finished
2060 * booting. It can be used to perform application-specific initialization,
2061 * such as installing alarms. You must hold the
2062 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2063 * order to receive this broadcast.
2064 * <p>
2065 * This broadcast is sent at boot by all devices (both with and without
2066 * direct boot support). Upon receipt of this broadcast, the user is
2067 * unlocked and both device-protected and credential-protected storage can
2068 * accessed safely.
2069 * <p>
2070 * If you need to run while the user is still locked (before they've entered
2071 * their lock pattern or PIN for the first time), you can listen for the
2072 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2073 * <p class="note">
2074 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002075 */
2076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002077 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002078 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002079
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002080 /**
2081 * Broadcast Action: This is broadcast when a user action should request a
2082 * temporary system dialog to dismiss. Some examples of temporary system
2083 * dialogs are the notification window-shade and the recent tasks dialog.
2084 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002085 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002086 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2087 /**
2088 * Broadcast Action: Trigger the download and eventual installation
2089 * of a package.
2090 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002091 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002092 * <p class="note">This is a protected intent that can only be sent
2093 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002094 *
2095 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002096 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002097 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002098 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2099 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2100 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002101 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002102 * device. The data contains the name of the package. Note that the
2103 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002104 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002105 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002106 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2107 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002108 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2109 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002110 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002111 * <p class="note">This is a protected intent that can only be sent
2112 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002113 */
2114 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2115 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2116 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002117 * Broadcast Action: A new version of an application package has been
2118 * installed, replacing an existing version that was previously installed.
2119 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002120 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002121 * <ul>
2122 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2123 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002124 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002125 * <p class="note">This is a protected intent that can only be sent
2126 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002127 */
2128 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2129 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2130 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002131 * Broadcast Action: A new version of your application has been installed
2132 * over an existing one. This is only sent to the application that was
2133 * replaced. It does not contain any additional data; to receive it, just
2134 * use an intent filter for this action.
2135 *
2136 * <p class="note">This is a protected intent that can only be sent
2137 * by the system.
2138 */
2139 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2140 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2141 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002142 * Broadcast Action: An existing application package has been removed from
2143 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002144 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002145 * <ul>
2146 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2147 * to the package.
2148 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2149 * application -- data and code -- is being removed.
2150 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2151 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2152 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002153 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002154 * <p class="note">This is a protected intent that can only be sent
2155 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002156 */
2157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2158 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2159 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002160 * Broadcast Action: An existing application package has been completely
2161 * removed from the device. The data contains the name of the package.
2162 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2163 * {@link #EXTRA_DATA_REMOVED} is true and
2164 * {@link #EXTRA_REPLACING} is false of that broadcast.
2165 *
2166 * <ul>
2167 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2168 * to the package.
2169 * </ul>
2170 *
2171 * <p class="note">This is a protected intent that can only be sent
2172 * by the system.
2173 */
2174 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2175 public static final String ACTION_PACKAGE_FULLY_REMOVED
2176 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2177 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002178 * Broadcast Action: An existing application package has been changed (for
2179 * example, a component has been enabled or disabled). The data contains
2180 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002181 * <ul>
2182 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002183 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002184 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002185 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2186 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002187 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002188 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002189 * <p class="note">This is a protected intent that can only be sent
2190 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002191 */
2192 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2193 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2194 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002195 * @hide
2196 * Broadcast Action: Ask system services if there is any reason to
2197 * restart the given package. The data contains the name of the
2198 * package.
2199 * <ul>
2200 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2201 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2202 * </ul>
2203 *
2204 * <p class="note">This is a protected intent that can only be sent
2205 * by the system.
2206 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002207 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002208 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2209 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2210 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002211 * Broadcast Action: The user has restarted a package, and all of its
2212 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002213 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002214 * be removed. Note that the restarted package does <em>not</em>
2215 * receive this broadcast.
2216 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002217 * <ul>
2218 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2219 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002220 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002221 * <p class="note">This is a protected intent that can only be sent
2222 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002223 */
2224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2225 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2226 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002227 * Broadcast Action: The user has cleared the data of a package. This should
2228 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002229 * its persistent data is erased and this broadcast sent.
2230 * Note that the cleared package does <em>not</em>
2231 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002232 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002233 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2234 * package whose data was cleared is an uninstalled instant app, then the UID
2235 * will be -1. The platform keeps some meta-data associated with instant apps
2236 * after they are uninstalled.
2237 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2238 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002239 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002240 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002241 * <p class="note">This is a protected intent that can only be sent
2242 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002243 */
2244 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2245 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2246 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002247 * Broadcast Action: Packages have been suspended.
2248 * <p>Includes the following extras:
2249 * <ul>
2250 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2251 * </ul>
2252 *
2253 * <p class="note">This is a protected intent that can only be sent
2254 * by the system. It is only sent to registered receivers.
2255 */
2256 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2257 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2258 /**
2259 * Broadcast Action: Packages have been unsuspended.
2260 * <p>Includes the following extras:
2261 * <ul>
2262 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2263 * </ul>
2264 *
2265 * <p class="note">This is a protected intent that can only be sent
2266 * by the system. It is only sent to registered receivers.
2267 */
2268 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2269 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002270
2271 /**
2272 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002273 * whenever a package is put into a suspended state or any of its app extras change while in the
2274 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002275 * <p> Optionally includes the following extras:
2276 * <ul>
2277 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2278 * useful information for the app being suspended.
2279 * </ul>
2280 * <p class="note">This is a protected intent that can only be sent
2281 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2282 * the manifest.</em>
2283 *
2284 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2285 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2286 * @see PackageManager#isPackageSuspended()
2287 * @see PackageManager#getSuspendedPackageAppExtras()
2288 */
2289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2290 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2291
2292 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002293 * Activity Action: Started to show more details about why an application was suspended.
2294 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002295 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2296 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002297 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002298 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2299 * handling this intent and protect it with
2300 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2301 *
2302 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2303 *
2304 * <p class="note">This is a protected intent that can only be sent
2305 * by the system.
2306 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002307 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2308 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002309 * @see PackageManager#isPackageSuspended()
2310 * @see #ACTION_PACKAGES_SUSPENDED
2311 *
2312 * @hide
2313 */
2314 @SystemApi
2315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2316 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2317 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2318
2319 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002320 * Broadcast Action: Sent to a package that has been unsuspended.
2321 *
2322 * <p class="note">This is a protected intent that can only be sent
2323 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2324 * the manifest.</em>
2325 *
2326 * @see #ACTION_MY_PACKAGE_SUSPENDED
2327 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2328 * @see PackageManager#isPackageSuspended()
2329 * @see PackageManager#getSuspendedPackageAppExtras()
2330 */
2331 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2332 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2333
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002334 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002335 * Broadcast Action: A user ID has been removed from the system. The user
2336 * ID number is stored in the extra data under {@link #EXTRA_UID}.
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_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002343
2344 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002345 * Broadcast Action: Sent to the installer package of an application when
2346 * that application is first launched (that is the first time it is moved
2347 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002348 *
2349 * <p class="note">This is a protected intent that can only be sent
2350 * by the system.
2351 */
2352 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2353 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2354
2355 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002356 * Broadcast Action: Sent to the system package verifier when a package
2357 * needs to be verified. The data contains the package URI.
2358 * <p class="note">
2359 * This is a protected intent that can only be sent by the system.
2360 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002361 */
2362 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2363 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2364
2365 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002366 * Broadcast Action: Sent to the system package verifier when a package is
2367 * verified. The data contains the package URI.
2368 * <p class="note">
2369 * This is a protected intent that can only be sent by the system.
2370 */
2371 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2372 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2373
2374 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002375 * Broadcast Action: Sent to the system intent filter verifier when an
2376 * intent filter needs to be verified. The data contains the filter data
2377 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002378 * <p class="note">
2379 * This is a protected intent that can only be sent by the system.
2380 * </p>
2381 *
2382 * @hide
2383 */
2384 @SystemApi
2385 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2386 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2387
2388 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002389 * Broadcast Action: Resources for a set of packages (which were
2390 * previously unavailable) are currently
2391 * available since the media on which they exist is available.
2392 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2393 * list of packages whose availability changed.
2394 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2395 * list of uids of packages whose availability changed.
2396 * Note that the
2397 * packages in this list do <em>not</em> receive this broadcast.
2398 * The specified set of packages are now available on the system.
2399 * <p>Includes the following extras:
2400 * <ul>
2401 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2402 * whose resources(were previously unavailable) are currently available.
2403 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2404 * packages whose resources(were previously unavailable)
2405 * are currently available.
2406 * </ul>
2407 *
2408 * <p class="note">This is a protected intent that can only be sent
2409 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002410 */
2411 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002412 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2413 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002414
2415 /**
2416 * Broadcast Action: Resources for a set of packages are currently
2417 * unavailable since the media on which they exist is unavailable.
2418 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2419 * list of packages whose availability changed.
2420 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2421 * list of uids of packages whose availability changed.
2422 * The specified set of packages can no longer be
2423 * launched and are practically unavailable on the system.
2424 * <p>Inclues the following extras:
2425 * <ul>
2426 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2427 * whose resources are no longer available.
2428 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2429 * whose resources are no longer available.
2430 * </ul>
2431 *
2432 * <p class="note">This is a protected intent that can only be sent
2433 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002434 */
2435 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002436 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002437 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002438
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002439 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002440 * Broadcast Action: preferred activities have changed *explicitly*.
2441 *
2442 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2443 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2444 * be sent.
2445 *
2446 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2447 *
2448 * @hide
2449 */
2450 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2451 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2452 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2453
2454
2455 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002456 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002457 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002458 * This should <em>only</em> be used to determine when the wallpaper
2459 * has changed to show the new wallpaper to the user. You should certainly
2460 * never, in response to this, change the wallpaper or other attributes of
2461 * it such as the suggested size. That would be crazy, right? You'd cause
2462 * all kinds of loops, especially if other apps are doing similar things,
2463 * right? Of course. So please don't do this.
2464 *
2465 * @deprecated Modern applications should use
2466 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2467 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2468 * shown behind their UI, rather than watching for this broadcast and
2469 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002470 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002471 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002472 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2473 /**
2474 * Broadcast Action: The current device {@link android.content.res.Configuration}
2475 * (orientation, locale, etc) has changed. When such a change happens, the
2476 * UIs (view hierarchy) will need to be rebuilt based on this new
2477 * information; for the most part, applications don't need to worry about
2478 * this, because the system will take care of stopping and restarting the
2479 * application to make sure it sees the new changes. Some system code that
2480 * can not be restarted will need to watch for this action and handle it
2481 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002482 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002483 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002484 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002485 * in manifests, only by explicitly registering for it with
2486 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2487 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002488 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002489 * <p class="note">This is a protected intent that can only be sent
2490 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002491 *
2492 * @see android.content.res.Configuration
2493 */
2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2495 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002496
2497 /**
2498 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2499 * such that the device may be eligible for the installation of additional configuration splits.
2500 * Configuration properties that can trigger this broadcast include locale and display density.
2501 *
2502 * <p class="note">
2503 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2504 * components declared in manifests. However, the receiver <em>must</em> hold the
2505 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2506 *
2507 * <p class="note">
2508 * This is a protected intent that can only be sent by the system.
2509 *
2510 * @hide
2511 */
2512 @SystemApi
2513 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2514 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2515 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002516 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002517 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002518 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002519 * <p class="note">This is a protected intent that can only be sent
2520 * by the system.
2521 */
2522 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2523 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2524 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002525 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2526 * charging state, level, and other information about the battery.
2527 * See {@link android.os.BatteryManager} for documentation on the
2528 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002529 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002530 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002531 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002532 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002534 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2535 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2536 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2537 * broadcasts that are sent and can be received through manifest
2538 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002539 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002540 * <p class="note">This is a protected intent that can only be sent
2541 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002542 */
2543 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2544 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002545
2546
2547 /**
2548 * Broadcast Action: Sent when the current battery level changes.
2549 *
2550 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2551 * instances representing individual battery level changes with associated
2552 * extras from {@link #ACTION_BATTERY_CHANGED}.
2553 *
2554 * <p class="note">
2555 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2556 *
2557 * @hide
2558 */
2559 @SystemApi
2560 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2561 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002562 /**
2563 * Broadcast Action: Indicates low battery condition on the device.
2564 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002565 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002566 * <p class="note">This is a protected intent that can only be sent
2567 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002568 */
2569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2570 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2571 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002572 * Broadcast Action: Indicates the battery is now okay after being low.
2573 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2574 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002575 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002576 * <p class="note">This is a protected intent that can only be sent
2577 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002578 */
2579 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2580 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2581 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002582 * Broadcast Action: External power has been connected to the device.
2583 * This is intended for applications that wish to register specifically to this notification.
2584 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2585 * stay active to receive this notification. This action can be used to implement actions
2586 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002587 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002588 * <p class="note">This is a protected intent that can only be sent
2589 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002590 */
2591 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002592 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002593 /**
2594 * Broadcast Action: External power has been removed from the device.
2595 * This is intended for applications that wish to register specifically to this notification.
2596 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2597 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002598 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002599 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002600 * <p class="note">This is a protected intent that can only be sent
2601 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002604 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002605 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002606 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002607 * Broadcast Action: Device is shutting down.
2608 * This is broadcast when the device is being shut down (completely turned
2609 * off, not sleeping). Once the broadcast is complete, the final shutdown
2610 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002611 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002612 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2613 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2614 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002615 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002616 * <p class="note">This is a protected intent that can only be sent
2617 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002618 * <p>May include the following extras:
2619 * <ul>
2620 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2621 * shutdown is only for userspace processes. If not set, assumed to be false.
2622 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002623 */
2624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002625 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002626 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002627 * Activity Action: Start this activity to request system shutdown.
2628 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002629 * to request confirmation from the user before shutting down. The optional boolean
2630 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2631 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002632 *
2633 * <p class="note">This is a protected intent that can only be sent
2634 * by the system.
2635 *
2636 * {@hide}
2637 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002638 public static final String ACTION_REQUEST_SHUTDOWN
2639 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002640 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002641 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002642 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002643 * <p class="note">
2644 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002645 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002646 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2647 * or above, this broadcast will no longer be delivered to any
2648 * {@link BroadcastReceiver} defined in your manifest. Instead,
2649 * apps are strongly encouraged to use the improved
2650 * {@link Context#getCacheDir()} behavior so the system can
2651 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002652 */
2653 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002654 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002655 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2656 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002657 * Broadcast Action: Indicates low storage space condition on the device no
2658 * longer exists
2659 * <p class="note">
2660 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002661 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002662 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2663 * or above, this broadcast will no longer be delivered to any
2664 * {@link BroadcastReceiver} defined in your manifest. Instead,
2665 * apps are strongly encouraged to use the improved
2666 * {@link Context#getCacheDir()} behavior so the system can
2667 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002668 */
2669 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002670 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002671 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2672 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002673 * Broadcast Action: A sticky broadcast that indicates a storage space full
2674 * condition on the device. This is intended for activities that want to be
2675 * able to fill the data partition completely, leaving only enough free
2676 * space to prevent system-wide SQLite failures.
2677 * <p class="note">
2678 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002679 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002680 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2681 * or above, this broadcast will no longer be delivered to any
2682 * {@link BroadcastReceiver} defined in your manifest. Instead,
2683 * apps are strongly encouraged to use the improved
2684 * {@link Context#getCacheDir()} behavior so the system can
2685 * automatically free up storage when needed.
2686 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002687 */
2688 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002689 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002690 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2691 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002692 * Broadcast Action: Indicates storage space full condition on the device no
2693 * longer exists.
2694 * <p class="note">
2695 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002696 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002697 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2698 * or above, this broadcast will no longer be delivered to any
2699 * {@link BroadcastReceiver} defined in your manifest. Instead,
2700 * apps are strongly encouraged to use the improved
2701 * {@link Context#getCacheDir()} behavior so the system can
2702 * automatically free up storage when needed.
2703 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002704 */
2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002706 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002707 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2708 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002709 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2710 * and package management should be started.
2711 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2712 * notification.
2713 */
2714 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2715 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2716 /**
2717 * Broadcast Action: The device has entered USB Mass Storage mode.
2718 * This is used mainly for the USB Settings panel.
2719 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2720 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002721 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002723 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002724 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002725 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2726
2727 /**
2728 * Broadcast Action: The device has exited USB Mass Storage mode.
2729 * This is used mainly for the USB Settings panel.
2730 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2731 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002732 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002734 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002735 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2737
2738 /**
2739 * Broadcast Action: External media has been removed.
2740 * The path to the mount point for the removed media is contained in the Intent.mData field.
2741 */
2742 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2743 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2744
2745 /**
2746 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002747 * 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 -07002748 */
2749 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2750 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2751
2752 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002753 * Broadcast Action: External media is present, and being disk-checked
2754 * 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 -08002755 */
2756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2757 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2758
2759 /**
2760 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2761 * 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 -08002762 */
2763 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2764 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2765
2766 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002767 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002768 * 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 -07002769 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2770 * media was mounted read only.
2771 */
2772 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2773 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2774
2775 /**
2776 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002777 * 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 -07002778 */
2779 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2781
2782 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002783 * Broadcast Action: External media is no longer being shared via USB mass storage.
2784 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2785 *
2786 * @hide
2787 */
2788 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2789
2790 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002791 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2792 * The path to the mount point for the removed media is contained in the Intent.mData field.
2793 */
2794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2795 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2796
2797 /**
2798 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002799 * 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 -07002800 */
2801 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2802 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2803
2804 /**
2805 * Broadcast Action: User has expressed the desire to remove the external storage media.
2806 * Applications should close all files they have open within the mount point when they receive this intent.
2807 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2808 */
2809 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2810 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2811
2812 /**
2813 * Broadcast Action: The media scanner has started scanning a directory.
2814 * The path to the directory being scanned is contained in the Intent.mData field.
2815 */
2816 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2817 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2818
2819 /**
2820 * Broadcast Action: The media scanner has finished scanning a directory.
2821 * The path to the scanned directory is contained in the Intent.mData field.
2822 */
2823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2824 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2825
2826 /**
2827 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2828 * The path to the file is contained in the Intent.mData field.
2829 */
2830 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2831 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2832
2833 /**
2834 * Broadcast Action: The "Media Button" was pressed. Includes a single
2835 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2836 * caused the broadcast.
2837 */
2838 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2840
2841 /**
2842 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2843 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2844 * caused the broadcast.
2845 */
2846 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2847 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2848
2849 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2850 // location; they are not general-purpose actions.
2851
2852 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002853 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002854 */
2855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2856 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2857 "android.intent.action.GTALK_CONNECTED";
2858
2859 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002860 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002861 */
2862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2863 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2864 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002865
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002866 /**
2867 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002868 */
2869 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2870 public static final String ACTION_INPUT_METHOD_CHANGED =
2871 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002872
2873 /**
2874 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2875 * more radios have been turned off or on. The intent will have the following extra value:</p>
2876 * <ul>
2877 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2878 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2879 * turned off</li>
2880 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002881 *
Peng Xua35b5532016-01-20 00:05:45 -08002882 * <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 -07002883 */
2884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2885 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2886
2887 /**
2888 * Broadcast Action: Some content providers have parts of their namespace
2889 * where they publish new events or items that the user may be especially
2890 * interested in. For these things, they may broadcast this action when the
2891 * set of interesting items change.
2892 *
2893 * For example, GmailProvider sends this notification when the set of unread
2894 * mail in the inbox changes.
2895 *
2896 * <p>The data of the intent identifies which part of which provider
2897 * changed. When queried through the content resolver, the data URI will
2898 * return the data set in question.
2899 *
2900 * <p>The intent will have the following extra values:
2901 * <ul>
2902 * <li><em>count</em> - The number of items in the data set. This is the
2903 * same as the number of items in the cursor returned by querying the
2904 * data URI. </li>
2905 * </ul>
2906 *
2907 * This intent will be sent at boot (if the count is non-zero) and when the
2908 * data set changes. It is possible for the data set to change without the
2909 * count changing (for example, if a new unread message arrives in the same
2910 * sync operation in which a message is archived). The phone should still
2911 * ring/vibrate/etc as normal in this case.
2912 */
2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914 public static final String ACTION_PROVIDER_CHANGED =
2915 "android.intent.action.PROVIDER_CHANGED";
2916
2917 /**
2918 * Broadcast Action: Wired Headset plugged in or unplugged.
2919 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002920 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2921 * and documentation.
2922 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002923 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002924 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002925 */
2926 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002927 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002928
2929 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002930 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2931 * <ul>
2932 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2933 * </ul>
2934 *
2935 * <p class="note">This is a protected intent that can only be sent
2936 * by the system.
2937 *
2938 * @hide
2939 */
2940 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2941 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2942 = "android.intent.action.ADVANCED_SETTINGS";
2943
2944 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002945 * Broadcast Action: Sent after application restrictions are changed.
2946 *
2947 * <p class="note">This is a protected intent that can only be sent
2948 * by the system.</p>
2949 */
2950 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2951 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2952 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2953
2954 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002955 * Broadcast Action: An outgoing call is about to be placed.
2956 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002957 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002958 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002959 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002960 * the phone number originally intended to be dialed.</li>
2961 * </ul>
2962 * <p>Once the broadcast is finished, the resultData is used as the actual
2963 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002964 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002965 * outgoing call in turn: for example, a parental control application
2966 * might verify that the user is authorized to place the call at that
2967 * time, then a number-rewriting application might add an area code if
2968 * one was not specified.</p>
2969 * <p>For consistency, any receiver whose purpose is to prohibit phone
2970 * calls should have a priority of 0, to ensure it will see the final
2971 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002972 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002973 * should have a positive priority.
2974 * Negative priorities are reserved for the system for this broadcast;
2975 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002976 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2977 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002978 * <p>Emergency calls cannot be intercepted using this mechanism, and
2979 * other calls cannot be modified to call emergency numbers using this
2980 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002981 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2982 * call to use their own service instead. Those apps should first prevent
2983 * the call from being placed by setting resultData to <code>null</code>
2984 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002985 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002986 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2987 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002988 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002989 * <p class="note">This is a protected intent that can only be sent
2990 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002991 */
2992 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2993 public static final String ACTION_NEW_OUTGOING_CALL =
2994 "android.intent.action.NEW_OUTGOING_CALL";
2995
2996 /**
2997 * Broadcast Action: Have the device reboot. This is only for use by
2998 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002999 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003000 * <p class="note">This is a protected intent that can only be sent
3001 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003002 */
3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3004 public static final String ACTION_REBOOT =
3005 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003006
Wei Huang97ecc9c2009-05-11 17:44:20 -07003007 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003008 * Broadcast Action: A sticky broadcast for changes in the physical
3009 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003010 *
3011 * <p>The intent will have the following extra values:
3012 * <ul>
3013 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003014 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003015 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003016 * <p>This is intended for monitoring the current physical dock state.
3017 * See {@link android.app.UiModeManager} for the normal API dealing with
3018 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003019 */
3020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3021 public static final String ACTION_DOCK_EVENT =
3022 "android.intent.action.DOCK_EVENT";
3023
3024 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003025 * Broadcast Action: A broadcast when idle maintenance can be started.
3026 * This means that the user is not interacting with the device and is
3027 * not expected to do so soon. Typical use of the idle maintenance is
3028 * to perform somehow expensive tasks that can be postponed at a moment
3029 * when they will not degrade user experience.
3030 * <p>
3031 * <p class="note">In order to keep the device responsive in case of an
3032 * unexpected user interaction, implementations of a maintenance task
3033 * should be interruptible. In such a scenario a broadcast with action
3034 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3035 * should not do the maintenance work in
3036 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3037 * maintenance service by {@link Context#startService(Intent)}. Also
3038 * you should hold a wake lock while your maintenance service is running
3039 * to prevent the device going to sleep.
3040 * </p>
3041 * <p>
3042 * <p class="note">This is a protected intent that can only be sent by
3043 * the system.
3044 * </p>
3045 *
3046 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003047 *
3048 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003049 */
3050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3051 public static final String ACTION_IDLE_MAINTENANCE_START =
3052 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3053
3054 /**
3055 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3056 * This means that the user was not interacting with the device as a result
3057 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3058 * was sent and now the user started interacting with the device. Typical
3059 * use of the idle maintenance is to perform somehow expensive tasks that
3060 * can be postponed at a moment when they will not degrade user experience.
3061 * <p>
3062 * <p class="note">In order to keep the device responsive in case of an
3063 * unexpected user interaction, implementations of a maintenance task
3064 * should be interruptible. Hence, on receiving a broadcast with this
3065 * action, the maintenance task should be interrupted as soon as possible.
3066 * In other words, you should not do the maintenance work in
3067 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3068 * maintenance service that was started on receiving of
3069 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3070 * lock you acquired when your maintenance service started.
3071 * </p>
3072 * <p class="note">This is a protected intent that can only be sent
3073 * by the system.
3074 *
3075 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003076 *
3077 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003078 */
3079 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3080 public static final String ACTION_IDLE_MAINTENANCE_END =
3081 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3082
3083 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003084 * Broadcast Action: a remote intent is to be broadcasted.
3085 *
3086 * A remote intent is used for remote RPC between devices. The remote intent
3087 * is serialized and sent from one device to another device. The receiving
3088 * device parses the remote intent and broadcasts it. Note that anyone can
3089 * broadcast a remote intent. However, if the intent receiver of the remote intent
3090 * does not trust intent broadcasts from arbitrary intent senders, it should require
3091 * the sender to hold certain permissions so only trusted sender's broadcast will be
3092 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003093 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003094 */
3095 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003096 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003097
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003098 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003099 * Broadcast Action: This is broadcast once when the user is booting after a
3100 * system update. It can be used to perform cleanup or upgrades after a
3101 * system update.
3102 * <p>
3103 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3104 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3105 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3106 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003107 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003108 * @hide
3109 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003110 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003111 public static final String ACTION_PRE_BOOT_COMPLETED =
3112 "android.intent.action.PRE_BOOT_COMPLETED";
3113
Amith Yamasani13593602012-03-22 16:16:17 -07003114 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003115 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003116 * on restricted users. The broadcast intent contains an extra
3117 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3118 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3119 * String[] depending on the restriction type.<p/>
3120 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003121 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3122 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3123 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003124 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3125 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003126 * @see RestrictionEntry
3127 */
3128 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3129 "android.intent.action.GET_RESTRICTION_ENTRIES";
3130
3131 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003132 * Sent the first time a user is starting, to allow system apps to
3133 * perform one time initialization. (This will not be seen by third
3134 * party applications because a newly initialized user does not have any
3135 * third party applications installed for it.) This is sent early in
3136 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003137 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3138 * broadcast, since it is part of a visible user interaction; be as quick
3139 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003140 */
3141 public static final String ACTION_USER_INITIALIZE =
3142 "android.intent.action.USER_INITIALIZE";
3143
3144 /**
3145 * Sent when a user switch is happening, causing the process's user to be
3146 * brought to the foreground. This is only sent to receivers registered
3147 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3148 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003149 * foreground. This is sent as a foreground
3150 * broadcast, since it is part of a visible user interaction; be as quick
3151 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003152 */
3153 public static final String ACTION_USER_FOREGROUND =
3154 "android.intent.action.USER_FOREGROUND";
3155
3156 /**
3157 * Sent when a user switch is happening, causing the process's user to be
3158 * sent to the background. This is only sent to receivers registered
3159 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3160 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003161 * background. This is sent as a foreground
3162 * broadcast, since it is part of a visible user interaction; be as quick
3163 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003164 */
3165 public static final String ACTION_USER_BACKGROUND =
3166 "android.intent.action.USER_BACKGROUND";
3167
3168 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003169 * Broadcast sent to the system when a user is added. Carries an extra
3170 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3171 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003172 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003173 * @hide
3174 */
3175 public static final String ACTION_USER_ADDED =
3176 "android.intent.action.USER_ADDED";
3177
3178 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003179 * Broadcast sent by the system when a user is started. Carries an extra
3180 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003181 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003182 * that has been started. This is sent as a foreground
3183 * broadcast, since it is part of a visible user interaction; be as quick
3184 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003185 * @hide
3186 */
3187 public static final String ACTION_USER_STARTED =
3188 "android.intent.action.USER_STARTED";
3189
3190 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003191 * Broadcast sent when a user is in the process of starting. Carries an extra
3192 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3193 * sent to registered receivers, not manifest receivers. It is sent to all
3194 * users (including the one that is being started). You must hold
3195 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3196 * this broadcast. This is sent as a background broadcast, since
3197 * its result is not part of the primary UX flow; to safely keep track of
3198 * started/stopped state of a user you can use this in conjunction with
3199 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3200 * other user state broadcasts since those are foreground broadcasts so can
3201 * execute in a different order.
3202 * @hide
3203 */
3204 public static final String ACTION_USER_STARTING =
3205 "android.intent.action.USER_STARTING";
3206
3207 /**
3208 * Broadcast sent when a user is going to be stopped. Carries an extra
3209 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3210 * sent to registered receivers, not manifest receivers. It is sent to all
3211 * users (including the one that is being stopped). You must hold
3212 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3213 * this broadcast. The user will not stop until all receivers have
3214 * handled the broadcast. This is sent as a background broadcast, since
3215 * its result is not part of the primary UX flow; to safely keep track of
3216 * started/stopped state of a user you can use this in conjunction with
3217 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3218 * other user state broadcasts since those are foreground broadcasts so can
3219 * execute in a different order.
3220 * @hide
3221 */
3222 public static final String ACTION_USER_STOPPING =
3223 "android.intent.action.USER_STOPPING";
3224
3225 /**
3226 * Broadcast sent to the system when a user is stopped. Carries an extra
3227 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3228 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3229 * specific package. This is only sent to registered receivers, not manifest
3230 * receivers. It is sent to all running users <em>except</em> the one that
3231 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003232 * @hide
3233 */
3234 public static final String ACTION_USER_STOPPED =
3235 "android.intent.action.USER_STOPPED";
3236
3237 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003238 * 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 -07003239 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003240 * one that has been removed. The user will not be completely removed until all receivers have
3241 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003242 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003243 * @hide
3244 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003245 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003246 public static final String ACTION_USER_REMOVED =
3247 "android.intent.action.USER_REMOVED";
3248
3249 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003250 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003251 * the userHandle of the user to become the current one. This is only sent to
3252 * registered receivers, not manifest receivers. It is sent to all running users.
3253 * You must hold
3254 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003255 * @hide
3256 */
3257 public static final String ACTION_USER_SWITCHED =
3258 "android.intent.action.USER_SWITCHED";
3259
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003260 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003261 * Broadcast Action: Sent when the credential-encrypted private storage has
3262 * become unlocked for the target user. This is only sent to registered
3263 * receivers, not manifest receivers.
3264 */
3265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3266 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3267
3268 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003269 * Broadcast sent to the system when a user's information changes. Carries an extra
3270 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003271 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003272 * @hide
3273 */
3274 public static final String ACTION_USER_INFO_CHANGED =
3275 "android.intent.action.USER_INFO_CHANGED";
3276
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003277 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003278 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3279 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003280 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3281 * that need to display merged content across both primary and managed profiles need to
3282 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003283 * not manifest receivers.
3284 */
3285 public static final String ACTION_MANAGED_PROFILE_ADDED =
3286 "android.intent.action.MANAGED_PROFILE_ADDED";
3287
3288 /**
3289 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003290 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3291 * Only applications (for example Launchers) that need to display merged content across both
3292 * primary and managed profiles need to worry about this broadcast. This is only sent to
3293 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003294 */
3295 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3296 "android.intent.action.MANAGED_PROFILE_REMOVED";
3297
3298 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003299 * Broadcast sent to the primary user when the credential-encrypted private storage for
3300 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3301 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3302 * Launchers) that need to display merged content across both primary and managed profiles
3303 * need to worry about this broadcast. This is only sent to registered receivers,
3304 * not manifest receivers.
3305 */
3306 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3307 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3308
3309 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003310 * Broadcast sent to the primary user when an associated managed profile has become available.
3311 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003312 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3313 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3314 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003315 */
Rubin Xue95057a2016-04-01 16:49:25 +01003316 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3317 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3318
3319 /**
3320 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3321 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3322 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3323 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3324 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3325 */
3326 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3327 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003328
3329 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003330 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3331 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3332 * the device was locked or unlocked.
3333 *
3334 * This is only sent to registered receivers.
3335 *
3336 * @hide
3337 */
3338 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3339 "android.intent.action.DEVICE_LOCKED_CHANGED";
3340
3341 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003342 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3343 */
3344 public static final String ACTION_QUICK_CLOCK =
3345 "android.intent.action.QUICK_CLOCK";
3346
Michael Wright0087a142013-02-05 16:29:39 -08003347 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003348 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003349 * @hide
3350 */
3351 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003352 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003353
Justin Kohd378ad72013-04-01 12:18:26 -07003354 /**
3355 * Broadcast Action: A global button was pressed. Includes a single
3356 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3357 * caused the broadcast.
3358 * @hide
3359 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003360 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003361 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3362
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003363 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003364 * Broadcast Action: Sent when media resource is granted.
3365 * <p>
3366 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3367 * granted.
3368 * </p>
3369 * <p class="note">
3370 * This is a protected intent that can only be sent by the system.
3371 * </p>
3372 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003373 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003374 * </p>
3375 *
3376 * @hide
3377 */
3378 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3379 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3380
3381 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003382 * Broadcast Action: An overlay package has changed. The data contains the
3383 * name of the overlay package which has changed. This is broadcast on all
3384 * changes to the OverlayInfo returned by {@link
3385 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3386 * most common change is a state change that will change whether the
3387 * overlay is enabled or not.
3388 * @hide
3389 */
3390 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3391
3392 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003393 * Activity Action: Allow the user to select and return one or more existing
3394 * documents. When invoked, the system will display the various
3395 * {@link DocumentsProvider} instances installed on the device, letting the
3396 * user interactively navigate through them. These documents include local
3397 * media, such as photos and video, and documents provided by installed
3398 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003399 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003400 * Each document is represented as a {@code content://} URI backed by a
3401 * {@link DocumentsProvider}, which can be opened as a stream with
3402 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3403 * {@link android.provider.DocumentsContract.Document} metadata.
3404 * <p>
3405 * All selected documents are returned to the calling application with
3406 * persistable read and write permission grants. If you want to maintain
3407 * access to the documents across device reboots, you need to explicitly
3408 * take the persistable permissions using
3409 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3410 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003411 * Callers must indicate the acceptable document MIME types through
3412 * {@link #setType(String)}. For example, to select photos, use
3413 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3414 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3415 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003416 * <p>
3417 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003418 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3419 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003420 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003421 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3422 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003423 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003424 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003425 * Callers can set a document URI through
3426 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3427 * location of documents navigator. System will do its best to launch the
3428 * navigator in the specified document if it's a folder, or the folder that
3429 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003430 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003431 * Output: The URI of the item that was picked, returned in
3432 * {@link #getData()}. This must be a {@code content://} URI so that any
3433 * receiver can access it. If multiple documents were selected, they are
3434 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003435 *
3436 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003437 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003438 * @see #ACTION_CREATE_DOCUMENT
3439 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003440 */
3441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3442 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3443
3444 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003445 * Activity Action: Allow the user to create a new document. When invoked,
3446 * the system will display the various {@link DocumentsProvider} instances
3447 * installed on the device, letting the user navigate through them. The
3448 * returned document may be a newly created document with no content, or it
3449 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003450 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003451 * Each document is represented as a {@code content://} URI backed by a
3452 * {@link DocumentsProvider}, which can be opened as a stream with
3453 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3454 * {@link android.provider.DocumentsContract.Document} metadata.
3455 * <p>
3456 * Callers must indicate the concrete MIME type of the document being
3457 * created by setting {@link #setType(String)}. This MIME type cannot be
3458 * changed after the document is created.
3459 * <p>
3460 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3461 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003462 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003463 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3464 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003465 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003466 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003467 * Callers can set a document URI through
3468 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3469 * location of documents navigator. System will do its best to launch the
3470 * navigator in the specified document if it's a folder, or the folder that
3471 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003472 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003473 * Output: The URI of the item that was created. This must be a
3474 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003475 *
3476 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003477 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003478 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003479 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003480 */
3481 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3482 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3483
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003484 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003485 * Activity Action: Allow the user to pick a directory subtree. When
3486 * invoked, the system will display the various {@link DocumentsProvider}
3487 * instances installed on the device, letting the user navigate through
3488 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003489 * <p>
3490 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003491 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3492 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3493 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003494 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003495 * Callers can set a document URI through
3496 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3497 * location of documents navigator. System will do its best to launch the
3498 * navigator in the specified document if it's a folder, or the folder that
3499 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003500 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003501 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003502 *
3503 * @see DocumentsContract
3504 */
3505 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003506 public static final String
3507 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003508
Felipe Lemec7b1f892016-01-15 15:02:31 -08003509 /**
Peng Xua35b5532016-01-20 00:05:45 -08003510 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3511 * exisiting sensor being disconnected.
3512 *
3513 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3514 *
3515 * {@hide}
3516 */
3517 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3518 public static final String
3519 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3520
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003521 /**
Sam Line707f832017-04-13 17:00:55 -07003522 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003523 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003524 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003525 */
3526 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003527 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003528 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3529
Christopher Tate6597e342015-02-17 12:15:25 -08003530 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003531 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3532 * is about to be performed.
3533 * @hide
3534 */
3535 @SystemApi
3536 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3537 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3538 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3539
3540 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003541 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3542 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3543 *
3544 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3545 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003546 * @hide
3547 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003548 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003549 public static final String EXTRA_FORCE_MASTER_CLEAR =
3550 "android.intent.extra.FORCE_MASTER_CLEAR";
3551
3552 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003553 * A broadcast action to trigger a factory reset.
3554 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003555 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3556 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003557 *
3558 * <p>Not for use by third-party applications.
3559 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003560 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003561 *
3562 * {@hide}
3563 */
3564 @SystemApi
3565 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3566 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3567
3568 /**
3569 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3570 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3571 *
3572 * <p>Not for use by third-party applications.
3573 *
3574 * @hide
3575 */
3576 @SystemApi
3577 public static final String EXTRA_FORCE_FACTORY_RESET =
3578 "android.intent.extra.FORCE_FACTORY_RESET";
3579
3580 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003581 * Broadcast action: report that a settings element is being restored from backup. The intent
3582 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3583 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3584 * is the value of that settings entry prior to the restore operation, and
3585 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3586 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3587 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003588 *
3589 * <p>This broadcast is sent only for settings provider entries known to require special handling
3590 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3591 * the provider's backup agent implementation.
3592 *
3593 * @see #EXTRA_SETTING_NAME
3594 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3595 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003596 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003597 * {@hide}
3598 */
3599 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3600
3601 /** {@hide} */
3602 public static final String EXTRA_SETTING_NAME = "setting_name";
3603 /** {@hide} */
3604 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3605 /** {@hide} */
3606 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003607 /** {@hide} */
3608 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003609
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003610 /**
3611 * Activity Action: Process a piece of text.
3612 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3613 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3614 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3615 */
3616 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3617 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003618
3619 /**
3620 * Broadcast Action: The sim card state has changed.
3621 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3622 * because TelephonyIntents is an internal class.
3623 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003624 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3625 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003626 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003627 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003628 @SystemApi
3629 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3630 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3631
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003632 /**
fionaxu90fee272017-03-31 12:45:12 -07003633 * Broadcast Action: indicate that the phone service state has changed.
3634 * The intent will have the following extra values:</p>
3635 * <p>
3636 * @see #EXTRA_VOICE_REG_STATE
3637 * @see #EXTRA_DATA_REG_STATE
3638 * @see #EXTRA_VOICE_ROAMING_TYPE
3639 * @see #EXTRA_DATA_ROAMING_TYPE
3640 * @see #EXTRA_OPERATOR_ALPHA_LONG
3641 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3642 * @see #EXTRA_OPERATOR_NUMERIC
3643 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3644 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3645 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3646 * @see #EXTRA_MANUAL
3647 * @see #EXTRA_VOICE_RADIO_TECH
3648 * @see #EXTRA_DATA_RADIO_TECH
3649 * @see #EXTRA_CSS_INDICATOR
3650 * @see #EXTRA_NETWORK_ID
3651 * @see #EXTRA_SYSTEM_ID
3652 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3653 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3654 * @see #EXTRA_EMERGENCY_ONLY
3655 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3656 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3657 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3658 *
3659 * <p class="note">
3660 * Requires the READ_PHONE_STATE permission.
3661 *
3662 * <p class="note">This is a protected intent that can only be sent by the system.
3663 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003664 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003665 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3666 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3667 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3668 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003669 */
3670 @Deprecated
3671 @SystemApi
3672 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3673 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3674
3675 /**
3676 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3677 * state.
3678 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3679 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3680 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3681 * @see android.telephony.ServiceState#STATE_POWER_OFF
3682 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003683 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003684 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003685 */
3686 @Deprecated
3687 @SystemApi
3688 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3689
3690 /**
3691 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3692 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3693 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3694 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3695 * @see android.telephony.ServiceState#STATE_POWER_OFF
3696 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003697 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003698 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003699 */
3700 @Deprecated
3701 @SystemApi
3702 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3703
3704 /**
3705 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3706 * type.
3707 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003708 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003709 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003710 */
3711 @Deprecated
3712 @SystemApi
3713 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3714
3715 /**
3716 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3717 * type.
3718 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003719 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003720 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003721 */
3722 @Deprecated
3723 @SystemApi
3724 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3725
3726 /**
3727 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3728 * registered voice operator name in long alphanumeric format.
3729 * {@code null} if the operator name is not known or unregistered.
3730 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003731 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003732 * @deprecated Use
3733 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003734 */
3735 @Deprecated
3736 @SystemApi
3737 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3738
3739 /**
3740 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3741 * registered voice operator name in short alphanumeric format.
3742 * {@code null} if the operator name is not known or unregistered.
3743 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003744 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003745 * @deprecated Use
3746 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003747 */
3748 @Deprecated
3749 @SystemApi
3750 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3751
3752 /**
3753 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3754 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3755 * network.
3756 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003757 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003758 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003759 */
3760 @Deprecated
3761 @SystemApi
3762 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3763
3764 /**
3765 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3766 * registered data operator name in long alphanumeric format.
3767 * {@code null} if the operator name is not known or unregistered.
3768 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003769 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003770 * @deprecated Use
3771 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003772 */
3773 @Deprecated
3774 @SystemApi
3775 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3776
3777 /**
3778 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3779 * registered data operator name in short alphanumeric format.
3780 * {@code null} if the operator name is not known or unregistered.
3781 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003782 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003783 * @deprecated Use
3784 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003785 */
3786 @Deprecated
3787 @SystemApi
3788 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3789
3790 /**
3791 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3792 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3793 * data operator.
3794 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003795 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003796 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003797 */
3798 @Deprecated
3799 @SystemApi
3800 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3801
3802 /**
3803 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3804 * network selection mode is manual.
3805 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3806 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003807 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003808 * @deprecated Use
3809 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003810 */
3811 @Deprecated
3812 @SystemApi
3813 public static final String EXTRA_MANUAL = "manual";
3814
3815 /**
3816 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3817 * radio technology.
3818 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003819 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003820 * @deprecated Use
3821 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003822 */
3823 @Deprecated
3824 @SystemApi
3825 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3826
3827 /**
3828 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3829 * radio technology.
3830 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003831 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003832 * @deprecated Use
3833 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003834 */
3835 @Deprecated
3836 @SystemApi
3837 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3838
3839 /**
3840 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3841 * support on CDMA network.
3842 * Will be {@code true} if support, {@code false} otherwise.
3843 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003844 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003845 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003846 */
3847 @Deprecated
3848 @SystemApi
3849 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3850
3851 /**
3852 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3853 * id. {@code Integer.MAX_VALUE} if unknown.
3854 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003855 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003856 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003857 */
3858 @Deprecated
3859 @SystemApi
3860 public static final String EXTRA_NETWORK_ID = "networkId";
3861
3862 /**
3863 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3864 * {@code Integer.MAX_VALUE} if unknown.
3865 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003866 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003867 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003868 */
3869 @Deprecated
3870 @SystemApi
3871 public static final String EXTRA_SYSTEM_ID = "systemId";
3872
3873 /**
3874 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3875 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3876 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003877 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003878 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003879 */
3880 @Deprecated
3881 @SystemApi
3882 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3883
3884 /**
3885 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3886 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3887 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003888 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003889 * @deprecated Use
3890 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003891 */
3892 @Deprecated
3893 @SystemApi
3894 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3895
3896 /**
3897 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3898 * only mode.
3899 * {@code true} if in emergency only mode, {@code false} otherwise.
3900 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003901 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003902 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003903 */
3904 @Deprecated
3905 @SystemApi
3906 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3907
3908 /**
3909 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3910 * registration state is roaming.
3911 * {@code true} if registration indicates roaming, {@code false} otherwise
3912 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003913 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003914 * @deprecated Use
3915 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003916 */
3917 @Deprecated
3918 @SystemApi
3919 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3920 "isDataRoamingFromRegistration";
3921
3922 /**
3923 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3924 * aggregation is in use.
3925 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3926 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003927 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003928 * @deprecated Use
3929 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003930 */
3931 @Deprecated
3932 @SystemApi
3933 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3934
3935 /**
3936 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3937 * is reduced from the rsrp threshold while calculating signal strength level.
3938 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003939 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003940 */
3941 @Deprecated
3942 @SystemApi
3943 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3944
3945 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003946 * The name of the extra used to define the text to be processed, as a
3947 * CharSequence. Note that this may be a styled CharSequence, so you must use
3948 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003949 */
3950 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3951 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003952 * 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 +00003953 */
3954 public static final String EXTRA_PROCESS_TEXT_READONLY =
3955 "android.intent.extra.PROCESS_TEXT_READONLY";
3956
Bryce Leebc58f592015-09-25 16:43:01 -07003957 /**
3958 * Broadcast action: reports when a new thermal event has been reached. When the device
3959 * is reaching its maximum temperatue, the thermal level reported
3960 * {@hide}
3961 */
3962 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3963 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3964
3965 /** {@hide} */
3966 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3967
3968 /**
3969 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003970 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003971 * {@hide}
3972 */
3973 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3974
3975 /**
3976 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003977 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003978 * {@hide}
3979 */
3980 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3981
3982 /**
3983 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003984 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003985 * {@hide}
3986 */
3987 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3988
3989
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003990 // ---------------------------------------------------------------------
3991 // ---------------------------------------------------------------------
3992 // Standard intent categories (see addCategory()).
3993
3994 /**
3995 * Set if the activity should be an option for the default action
3996 * (center press) to perform on a piece of data. Setting this will
3997 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003998 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003999 * Intent when initiating an action -- it is for use in intent filters
4000 * specified in packages.
4001 */
4002 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4003 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4004 /**
4005 * Activities that can be safely invoked from a browser must support this
4006 * category. For example, if the user is viewing a web page or an e-mail
4007 * and clicks on a link in the text, the Intent generated execute that
4008 * link will require the BROWSABLE category, so that only activities
4009 * supporting this category will be considered as possible actions. By
4010 * supporting this category, you are promising that there is nothing
4011 * damaging (without user intervention) that can happen by invoking any
4012 * matching Intent.
4013 */
4014 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4015 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4016 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004017 * Categories for activities that can participate in voice interaction.
4018 * An activity that supports this category must be prepared to run with
4019 * no UI shown at all (though in some case it may have a UI shown), and
4020 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4021 */
4022 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4023 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4024 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004025 * Set if the activity should be considered as an alternative action to
4026 * the data the user is currently viewing. See also
4027 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4028 * applies to the selection in a list of items.
4029 *
4030 * <p>Supporting this category means that you would like your activity to be
4031 * displayed in the set of alternative things the user can do, usually as
4032 * part of the current activity's options menu. You will usually want to
4033 * include a specific label in the &lt;intent-filter&gt; of this action
4034 * describing to the user what it does.
4035 *
4036 * <p>The action of IntentFilter with this category is important in that it
4037 * describes the specific action the target will perform. This generally
4038 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4039 * a specific name such as "com.android.camera.action.CROP. Only one
4040 * alternative of any particular action will be shown to the user, so using
4041 * a specific action like this makes sure that your alternative will be
4042 * displayed while also allowing other applications to provide their own
4043 * overrides of that particular action.
4044 */
4045 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4046 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4047 /**
4048 * Set if the activity should be considered as an alternative selection
4049 * action to the data the user has currently selected. This is like
4050 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4051 * of items from which the user can select, giving them alternatives to the
4052 * default action that will be performed on it.
4053 */
4054 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4055 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4056 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004057 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004058 */
4059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4060 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4061 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004062 * Should be displayed in the top-level launcher.
4063 */
4064 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4065 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4066 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004067 * Indicates an activity optimized for Leanback mode, and that should
4068 * be displayed in the Leanback launcher.
4069 */
4070 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4071 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4072 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004073 * Indicates the preferred entry-point activity when an application is launched from a Car
4074 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4075 * fallback, or exclude the application entirely.
4076 * @hide
4077 */
4078 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4079 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4080 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004081 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4082 * @hide
4083 */
4084 @SystemApi
4085 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4086 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004087 * Provides information about the package it is in; typically used if
4088 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4089 * a front-door to the user without having to be shown in the all apps list.
4090 */
4091 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4092 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4093 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004094 * This is the home activity, that is the first activity that is displayed
4095 * when the device boots.
4096 */
4097 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4098 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4099 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004100 * This is the home activity that is displayed when the device is finished setting up and ready
4101 * for use.
4102 * @hide
4103 */
4104 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4105 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4106 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004107 * This is the setup wizard activity, that is the first activity that is displayed
4108 * when the user sets up the device for the first time.
4109 * @hide
4110 */
4111 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4112 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4113 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004114 * This is the home activity, that is the activity that serves as the launcher app
4115 * from there the user can start other apps. Often components with lower/higher
4116 * priority intent filters handle the home intent, for example SetupWizard, to
4117 * setup the device and we need to be able to distinguish the home app from these
4118 * setup helpers.
4119 * @hide
4120 */
4121 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4122 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4123 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004124 * This activity is a preference panel.
4125 */
4126 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4127 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4128 /**
4129 * This activity is a development preference panel.
4130 */
4131 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4132 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4133 /**
4134 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004135 */
4136 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4137 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4138 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004139 * This activity allows the user to browse and download new applications.
4140 */
4141 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4142 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4143 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004144 * This activity may be exercised by the monkey or other automated test tools.
4145 */
4146 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4147 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4148 /**
4149 * To be used as a test (not part of the normal user experience).
4150 */
4151 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4152 /**
4153 * To be used as a unit test (run through the Test Harness).
4154 */
4155 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4156 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004157 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004158 * experience).
4159 */
4160 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004161
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004162 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004163 * Used to indicate that an intent only wants URIs that can be opened with
4164 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4165 * must support at least the columns defined in {@link OpenableColumns} when
4166 * queried.
4167 *
4168 * @see #ACTION_GET_CONTENT
4169 * @see #ACTION_OPEN_DOCUMENT
4170 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004171 */
4172 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4173 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4174
4175 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004176 * Used to indicate that an intent filter can accept files which are not necessarily
4177 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4178 * at least streamable via
4179 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4180 * using one of the stream types exposed via
4181 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4182 *
4183 * @see #ACTION_SEND
4184 * @see #ACTION_SEND_MULTIPLE
4185 */
4186 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4187 public static final String CATEGORY_TYPED_OPENABLE =
4188 "android.intent.category.TYPED_OPENABLE";
4189
4190 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004191 * To be used as code under test for framework instrumentation tests.
4192 */
4193 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4194 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004195 /**
4196 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004197 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4198 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004199 */
4200 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4201 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4202 /**
4203 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004204 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4205 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004206 */
4207 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4208 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004209 /**
4210 * An activity to run when device is inserted into a analog (low end) dock.
4211 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4212 * information, see {@link android.app.UiModeManager}.
4213 */
4214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4215 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4216
4217 /**
4218 * An activity to run when device is inserted into a digital (high end) dock.
4219 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4220 * information, see {@link android.app.UiModeManager}.
4221 */
4222 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4223 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004224
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004225 /**
4226 * Used to indicate that the activity can be used in a car environment.
4227 */
4228 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4229 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4230
Zak Cohendb6ca492017-01-26 14:09:00 -08004231 /**
4232 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4233 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4234 * information, see {@link android.app.UiModeManager}.
4235 */
4236 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4237 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004238 // ---------------------------------------------------------------------
4239 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004240 // Application launch intent categories (see addCategory()).
4241
4242 /**
4243 * Used with {@link #ACTION_MAIN} to launch the browser application.
4244 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004245 * <p>NOTE: This should not be used as the primary key of an Intent,
4246 * since it will not result in the app launching with the correct
4247 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004248 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004249 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004250 */
4251 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4252 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4253
4254 /**
4255 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4256 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004257 * <p>NOTE: This should not be used as the primary key of an Intent,
4258 * since it will not result in the app launching with the correct
4259 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004260 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004261 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004262 */
4263 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4264 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4265
4266 /**
4267 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4268 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004269 * <p>NOTE: This should not be used as the primary key of an Intent,
4270 * since it will not result in the app launching with the correct
4271 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004272 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004273 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004274 */
4275 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4276 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4277
4278 /**
4279 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4280 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004281 * <p>NOTE: This should not be used as the primary key of an Intent,
4282 * since it will not result in the app launching with the correct
4283 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004284 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004285 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004286 */
4287 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4288 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4289
4290 /**
4291 * Used with {@link #ACTION_MAIN} to launch the email application.
4292 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004293 * <p>NOTE: This should not be used as the primary key of an Intent,
4294 * since it will not result in the app launching with the correct
4295 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004296 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004297 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004298 */
4299 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4300 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4301
4302 /**
4303 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4304 * The activity should be able to view and manipulate image and video files
4305 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004306 * <p>NOTE: This should not be used as the primary key of an Intent,
4307 * since it will not result in the app launching with the correct
4308 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004309 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004310 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004311 */
4312 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4313 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4314
4315 /**
4316 * Used with {@link #ACTION_MAIN} to launch the maps application.
4317 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004318 * <p>NOTE: This should not be used as the primary key of an Intent,
4319 * since it will not result in the app launching with the correct
4320 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004321 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004322 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004323 */
4324 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4325 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4326
4327 /**
4328 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4329 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004330 * <p>NOTE: This should not be used as the primary key of an Intent,
4331 * since it will not result in the app launching with the correct
4332 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004333 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004334 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004335 */
4336 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4337 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4338
4339 /**
4340 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004341 * The activity should be able to play, browse, or manipulate music files
4342 * stored on the device.
4343 * <p>NOTE: This should not be used as the primary key of an Intent,
4344 * since it will not result in the app launching with the correct
4345 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004346 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004347 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004348 */
4349 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4350 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4351
4352 // ---------------------------------------------------------------------
4353 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004354 // Standard extra data keys.
4355
4356 /**
4357 * The initial data to place in a newly created record. Use with
4358 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4359 * fields as would be given to the underlying ContentProvider.insert()
4360 * call.
4361 */
4362 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4363
4364 /**
4365 * A constant CharSequence that is associated with the Intent, used with
4366 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4367 * this may be a styled CharSequence, so you must use
4368 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4369 * retrieve it.
4370 */
4371 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4372
4373 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004374 * A constant String that is associated with the Intent, used with
4375 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4376 * as HTML formatted text. Note that you <em>must</em> also supply
4377 * {@link #EXTRA_TEXT}.
4378 */
4379 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4380
4381 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004382 * A content: URI holding a stream of data associated with the Intent,
4383 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004384 */
4385 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4386
4387 /**
4388 * A String[] holding e-mail addresses that should be delivered to.
4389 */
4390 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4391
4392 /**
4393 * A String[] holding e-mail addresses that should be carbon copied.
4394 */
4395 public static final String EXTRA_CC = "android.intent.extra.CC";
4396
4397 /**
4398 * A String[] holding e-mail addresses that should be blind carbon copied.
4399 */
4400 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4401
4402 /**
4403 * A constant string holding the desired subject line of a message.
4404 */
4405 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4406
4407 /**
4408 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004409 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004410 */
4411 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4412
4413 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004414 * An int representing the user id to be used.
4415 *
4416 * @hide
4417 */
4418 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4419
4420 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004421 * An int representing the task id to be retrieved. This is used when a launch from recents is
4422 * intercepted by another action such as credentials confirmation to remember which task should
4423 * be resumed when complete.
4424 *
4425 * @hide
4426 */
4427 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4428
4429 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004430 * An Intent[] describing additional, alternate choices you would like shown with
4431 * {@link #ACTION_CHOOSER}.
4432 *
4433 * <p>An app may be capable of providing several different payload types to complete a
4434 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4435 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4436 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4437 * photo data or a hosted link where the photos can be viewed.</p>
4438 *
4439 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4440 * first/primary/preferred intent in the set. Additional intents specified in
4441 * this extra are ordered; by default intents that appear earlier in the array will be
4442 * preferred over intents that appear later in the array as matches for the same
4443 * target component. To alter this preference, a calling app may also supply
4444 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4445 */
4446 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4447
4448 /**
Adam Powell52c39212016-04-07 15:14:18 -07004449 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4450 * and omitted from a list of components presented to the user.
4451 *
4452 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4453 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4454 * from your own package or other apps from your organization if the idea of sending to those
4455 * targets would be redundant with other app functionality. Filtered components will not
4456 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4457 */
4458 public static final String EXTRA_EXCLUDE_COMPONENTS
4459 = "android.intent.extra.EXCLUDE_COMPONENTS";
4460
4461 /**
4462 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4463 * describing additional high-priority deep-link targets for the chooser to present to the user.
4464 *
4465 * <p>Targets provided in this way will be presented inline with all other targets provided
4466 * by services from other apps. They will be prioritized before other service targets, but
4467 * after those targets provided by sources that the user has manually pinned to the front.</p>
4468 *
4469 * @see #ACTION_CHOOSER
4470 */
4471 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4472
4473 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004474 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4475 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4476 *
4477 * <p>An app preparing an action for another app to complete may wish to allow the user to
4478 * disambiguate between several options for completing the action based on the chosen target
4479 * or otherwise refine the action before it is invoked.
4480 * </p>
4481 *
4482 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4483 * <ul>
4484 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4485 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4486 * chosen target beyond the first</li>
4487 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4488 * should fill in and send once the disambiguation is complete</li>
4489 * </ul>
4490 */
4491 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4492 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4493
4494 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004495 * An {@code ArrayList} of {@code String} annotations describing content for
4496 * {@link #ACTION_CHOOSER}.
4497 *
4498 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4499 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4500 *
4501 * <p>Annotations should describe the major components or topics of the content. It is up to
4502 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4503 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004504 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4505 * character. Performance on customized annotations can suffer, if they are rarely used for
4506 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4507 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004508 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004509 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004510 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004511 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004512 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004513 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004514 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004515 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004516 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004517 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4518 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4519 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4520 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4521 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004522 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004523 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4524 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004525 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004526 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004527 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004528 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004529 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004530 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004531 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004532 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004533 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004534 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004535 * Christmas and Thanksgiving.</li>
4536 * </ul>
4537 */
4538 public static final String EXTRA_CONTENT_ANNOTATIONS
4539 = "android.intent.extra.CONTENT_ANNOTATIONS";
4540
4541 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004542 * A {@link ResultReceiver} used to return data back to the sender.
4543 *
4544 * <p>Used to complete an app-specific
4545 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4546 *
4547 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4548 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4549 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4550 * when the user selects a target component from the chooser. It is up to the recipient
4551 * to send a result to this ResultReceiver to signal that disambiguation is complete
4552 * and that the chooser should invoke the user's choice.</p>
4553 *
4554 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4555 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4556 * to match and fill in the final Intent or ChooserTarget before starting it.
4557 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4558 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4559 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4560 *
4561 * <p>The result code passed to the ResultReceiver should be
4562 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4563 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4564 * the chooser should finish without starting a target.</p>
4565 */
4566 public static final String EXTRA_RESULT_RECEIVER
4567 = "android.intent.extra.RESULT_RECEIVER";
4568
4569 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004570 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004571 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004572 */
4573 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4574
4575 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004576 * A Parcelable[] of {@link Intent} or
4577 * {@link android.content.pm.LabeledIntent} objects as set with
4578 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4579 * a the front of the list of choices, when shown to the user with a
4580 * {@link #ACTION_CHOOSER}.
4581 */
4582 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4583
4584 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004585 * A {@link IntentSender} to start after ephemeral installation success.
Patrick Baumann159cd022018-01-11 13:25:05 -08004586 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
4587 * @removed
Todd Kennedy7440f172015-12-09 14:31:22 -08004588 * @hide
4589 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004590 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004591 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4592
4593 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004594 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004595 * @hide
4596 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004597 @SystemApi
4598 public static final String EXTRA_INSTANT_APP_SUCCESS =
4599 "android.intent.extra.INSTANT_APP_SUCCESS";
4600
4601 /**
4602 * A {@link IntentSender} to start after ephemeral installation failure.
4603 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
4604 * @removed
4605 * @hide
4606 */
4607 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004608 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4609
4610 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004611 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004612 * @hide
4613 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004614 @SystemApi
4615 public static final String EXTRA_INSTANT_APP_FAILURE =
4616 "android.intent.extra.INSTANT_APP_FAILURE";
4617
4618 /**
4619 * The host name that triggered an ephemeral resolution.
4620 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
4621 * @removed
4622 * @hide
4623 */
4624 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004625 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4626
4627 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004628 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004629 * @hide
4630 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004631 @SystemApi
4632 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4633 "android.intent.extra.INSTANT_APP_HOSTNAME";
4634
4635 /**
4636 * An opaque token to track ephemeral resolution.
4637 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
4638 * @removed
4639 * @hide
4640 */
4641 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004642 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4643
4644 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004645 * An opaque token to track instant app resolution.
4646 * @hide
4647 */
4648 @SystemApi
4649 public static final String EXTRA_INSTANT_APP_TOKEN =
4650 "android.intent.extra.INSTANT_APP_TOKEN";
4651
4652 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004653 * The action that triggered an instant application resolution.
4654 * @hide
4655 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004656 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004657 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4658
4659 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004660 * An array of {@link Bundle}s containing details about resolved instant apps..
4661 * @hide
4662 */
4663 @SystemApi
4664 public static final String EXTRA_INSTANT_APP_BUNDLES =
4665 "android.intent.extra.INSTANT_APP_BUNDLES";
4666
4667 /**
4668 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004669 * installed. This data is populated from the response to
4670 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4671 * instant application resolver.
4672 * @hide
4673 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004674 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004675 public static final String EXTRA_INSTANT_APP_EXTRAS =
4676 "android.intent.extra.INSTANT_APP_EXTRAS";
4677
4678 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004679 * A boolean value indicating that the instant app resolver was unable to state with certainty
4680 * that it did or did not have an app for the sanitized {@link Intent} defined at
4681 * {@link #EXTRA_INTENT}.
4682 * @hide
4683 */
4684 @SystemApi
4685 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4686 "android.intent.extra.UNKNOWN_INSTANT_APP";
4687
4688 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004689 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004690 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004691 * @hide
4692 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004693 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004694 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4695
4696 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004697 * The version code of the app to install components from.
4698 * @hide
4699 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004700 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004701 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4702
4703 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004704 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004705 * @hide
4706 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004707 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004708 public static final String EXTRA_CALLING_PACKAGE
4709 = "android.intent.extra.CALLING_PACKAGE";
4710
4711 /**
4712 * Optional calling app provided bundle containing additional launch information the
4713 * installer may use.
4714 * @hide
4715 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004716 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004717 public static final String EXTRA_VERIFICATION_BUNDLE
4718 = "android.intent.extra.VERIFICATION_BUNDLE";
4719
4720 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004721 * A Bundle forming a mapping of potential target package names to different extras Bundles
4722 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4723 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4724 * be currently installed on the device.
4725 *
4726 * <p>An application may choose to provide alternate extras for the case where a user
4727 * selects an activity from a predetermined set of target packages. If the activity
4728 * the user selects from the chooser belongs to a package with its package name as
4729 * a key in this bundle, the corresponding extras for that package will be merged with
4730 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4731 * extra has the same key as an extra already present in the intent it will overwrite
4732 * the extra from the intent.</p>
4733 *
4734 * <p><em>Examples:</em>
4735 * <ul>
4736 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4737 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4738 * parameters for that target.</li>
4739 * <li>An application may offer additional metadata for known targets of a given intent
4740 * to pass along information only relevant to that target such as account or content
4741 * identifiers already known to that application.</li>
4742 * </ul></p>
4743 */
4744 public static final String EXTRA_REPLACEMENT_EXTRAS =
4745 "android.intent.extra.REPLACEMENT_EXTRAS";
4746
4747 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004748 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4749 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4750 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4751 * {@link ComponentName} of the chosen component.
4752 *
4753 * <p>In some situations this callback may never come, for example if the user abandons
4754 * the chooser, switches to another task or any number of other reasons. Apps should not
4755 * be written assuming that this callback will always occur.</p>
4756 */
4757 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4758 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4759
4760 /**
4761 * The {@link ComponentName} chosen by the user to complete an action.
4762 *
4763 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4764 */
4765 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4766
4767 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004768 * A {@link android.view.KeyEvent} object containing the event that
4769 * triggered the creation of the Intent it is in.
4770 */
4771 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4772
4773 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004774 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4775 * before shutting down.
4776 *
4777 * {@hide}
4778 */
4779 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4780
4781 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004782 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4783 * requested by the user.
4784 *
4785 * {@hide}
4786 */
4787 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4788 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4789
4790 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004791 * 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 -07004792 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4793 * of restarting the application.
4794 */
4795 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4796
4797 /**
4798 * A String holding the phone number originally entered in
4799 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4800 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4801 */
4802 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004803
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004804 /**
4805 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4806 * intents to supply the uid the package had been assigned. Also an optional
4807 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4808 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4809 * purpose.
4810 */
4811 public static final String EXTRA_UID = "android.intent.extra.UID";
4812
4813 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004814 * @hide String array of package names.
4815 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004816 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004817 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4818
4819 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004820 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4821 * intents to indicate whether this represents a full uninstall (removing
4822 * both the code and its data) or a partial uninstall (leaving its data,
4823 * implying that this is an update).
4824 */
4825 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004826
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004827 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004828 * @hide
4829 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4830 * intents to indicate that at this point the package has been removed for
4831 * all users on the device.
4832 */
4833 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4834 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4835
4836 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004837 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4838 * intents to indicate that this is a replacement of the package, so this
4839 * broadcast will immediately be followed by an add broadcast for a
4840 * different version of the same package.
4841 */
4842 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004843
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004844 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004845 * Used as an int extra field in {@link android.app.AlarmManager} intents
4846 * to tell the application being invoked how many pending alarms are being
4847 * delievered with the intent. For one-shot alarms this will always be 1.
4848 * For recurring alarms, this might be greater than 1 if the device was
4849 * asleep or powered off at the time an earlier alarm would have been
4850 * delivered.
4851 */
4852 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004853
Jacek Surazski86b6c532009-05-13 14:38:28 +02004854 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004855 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4856 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004857 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4858 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004859 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4860 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4861 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004862 */
4863 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4864
4865 /**
4866 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4867 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004868 */
4869 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4870
4871 /**
4872 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4873 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004874 */
4875 public static final int EXTRA_DOCK_STATE_DESK = 1;
4876
4877 /**
4878 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4879 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004880 */
4881 public static final int EXTRA_DOCK_STATE_CAR = 2;
4882
4883 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004884 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4885 * to represent that the phone is in a analog (low end) dock.
4886 */
4887 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4888
4889 /**
4890 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4891 * to represent that the phone is in a digital (high end) dock.
4892 */
4893 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4894
4895 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004896 * Boolean that can be supplied as meta-data with a dock activity, to
4897 * indicate that the dock should take over the home key when it is active.
4898 */
4899 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004900
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004901 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004902 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4903 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004904 */
4905 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4906
4907 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004908 * Used in the extra field in the remote intent. It's astring token passed with the
4909 * remote intent.
4910 */
4911 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4912 "android.intent.extra.remote_intent_token";
4913
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004914 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004915 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004916 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004917 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004918 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004919 "android.intent.extra.changed_component_name";
4920
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004921 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004922 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004923 * and contains a string array of all of the components that have changed. If
4924 * the state of the overall package has changed, then it will contain an entry
4925 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004926 */
4927 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4928 "android.intent.extra.changed_component_name_list";
4929
4930 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004931 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004932 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004933 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4934 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4935 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004936 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004937 */
4938 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4939 "android.intent.extra.changed_package_list";
4940
4941 /**
4942 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004943 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4944 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004945 * and contains an integer array of uids of all of the components
4946 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004947 */
4948 public static final String EXTRA_CHANGED_UID_LIST =
4949 "android.intent.extra.changed_uid_list";
4950
4951 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004952 * @hide
4953 * Magic extra system code can use when binding, to give a label for
4954 * who it is that has bound to a service. This is an integer giving
4955 * a framework string resource that can be displayed to the user.
4956 */
4957 public static final String EXTRA_CLIENT_LABEL =
4958 "android.intent.extra.client_label";
4959
4960 /**
4961 * @hide
4962 * Magic extra system code can use when binding, to give a PendingIntent object
4963 * that can be launched for the user to disable the system's use of this
4964 * service.
4965 */
4966 public static final String EXTRA_CLIENT_INTENT =
4967 "android.intent.extra.client_intent";
4968
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004969 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004970 * Extra used to indicate that an intent should only return data that is on
4971 * the local device. This is a boolean extra; the default is false. If true,
4972 * an implementation should only allow the user to select data that is
4973 * already on the device, not requiring it be downloaded from a remote
4974 * service when opened.
4975 *
4976 * @see #ACTION_GET_CONTENT
4977 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004978 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004979 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004980 */
4981 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004982 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004983
Amith Yamasani13593602012-03-22 16:16:17 -07004984 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004985 * Extra used to indicate that an intent can allow the user to select and
4986 * return multiple items. This is a boolean extra; the default is false. If
4987 * true, an implementation is allowed to present the user with a UI where
4988 * they can pick multiple items that are all returned to the caller. When
4989 * this happens, they should be returned as the {@link #getClipData()} part
4990 * of the result Intent.
4991 *
4992 * @see #ACTION_GET_CONTENT
4993 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004994 */
4995 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004996 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004997
4998 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004999 * The integer userHandle carried with broadcast intents related to addition, removal and
5000 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5001 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5002 *
Amith Yamasani13593602012-03-22 16:16:17 -07005003 * @hide
5004 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005005 public static final String EXTRA_USER_HANDLE =
5006 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005007
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005008 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005009 * The UserHandle carried with broadcasts intents related to addition and removal of managed
5010 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
5011 */
5012 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005013 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005014
5015 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005016 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005017 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5018 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005019 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005020 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5021
5022 /**
5023 * Extra sent in the intent to the BroadcastReceiver that handles
5024 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5025 * the restrictions as key/value pairs.
5026 */
5027 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5028 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005029
Amith Yamasani86118ba2013-03-28 14:33:16 -07005030 /**
5031 * Extra used in the response from a BroadcastReceiver that handles
5032 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5033 */
5034 public static final String EXTRA_RESTRICTIONS_INTENT =
5035 "android.intent.extra.restrictions_intent";
5036
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005037 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005038 * Extra used to communicate a set of acceptable MIME types. The type of the
5039 * extra is {@code String[]}. Values may be a combination of concrete MIME
5040 * types (such as "image/png") and/or partial MIME types (such as
5041 * "audio/*").
5042 *
5043 * @see #ACTION_GET_CONTENT
5044 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005045 */
5046 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5047
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005048 /**
5049 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5050 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005051 * When this is true, hardware devices can use this information to determine that
5052 * they shouldn't do a complete shutdown of their device since this is not a
5053 * complete shutdown down to the kernel, but only user space restarting.
5054 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005055 */
5056 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5057 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5058
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005059 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005060 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5061 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5062 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5063 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005064 *
5065 * @hide for internal use only.
5066 */
5067 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5068 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005069 /** @hide */
5070 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5071 /** @hide */
5072 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5073 /** @hide */
5074 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005075
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005076 /**
5077 * Intent extra: the reason that the operation associated with this intent is being performed.
5078 *
5079 * <p>Type: String
5080 * @hide
5081 */
5082 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005083 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5084
qingxi240c2bb2017-04-12 17:31:18 -07005085 /**
5086 * {@hide}
5087 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5088 */
Rubin Xue8490f12015-06-25 12:17:48 +01005089 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5090
Santos Cordon15a13782015-03-31 18:32:31 -07005091 /**
qingxi240c2bb2017-04-12 17:31:18 -07005092 * {@hide}
5093 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5094 * reset for the device with eSIM. This extra will be sent together with
5095 * {@link #ACTION_FACTORY_RESET}
5096 */
5097 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5098
5099 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005100 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5101 * activation request.
5102 * TODO: Add information about the structure and response data used with the pending intent.
5103 * @hide
5104 */
5105 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5106 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5107
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005108 /**
5109 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005110 *
5111 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005112 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005113 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005114 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5115
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005116 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005117 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5118 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5119 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005120 *
5121 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005122 * @see #ACTION_QUICK_VIEW
5123 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005124 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005125 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005126 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5127 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005128
5129 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005130 * An optional extra of {@code String[]} indicating which quick view features should be made
5131 * available to the user in the quick view UI while handing a
5132 * {@link Intent#ACTION_QUICK_VIEW} intent.
5133 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5134 * Quick viewer can implement features not listed below.
5135 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005136 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5137 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5138 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005139 * <p>
5140 * Requirements:
5141 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5142 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5143 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5144 * internal policies.
5145 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5146 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5147 * disable or hide features.
5148 *
5149 * @see #ACTION_QUICK_VIEW
5150 */
5151 public static final String EXTRA_QUICK_VIEW_FEATURES =
5152 "android.intent.extra.QUICK_VIEW_FEATURES";
5153
5154 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005155 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005156 * When a profile goes into quiet mode, all apps in the profile are killed and the
5157 * profile user is stopped. Widgets originating from the profile are masked, and app
5158 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005159 */
5160 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005161
5162 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005163 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005164 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005165 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5166 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005167 *
5168 * @hide
5169 */
5170 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5171 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5172
5173 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005174 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5175 * whether to show the chooser or not when there is only one application available
5176 * to choose from.
5177 *
5178 * @hide
5179 */
5180 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5181 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5182
5183 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005184 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005185 * to represent that a video codec is allowed to use.
5186 *
5187 * @hide
5188 */
5189 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5190
5191 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005192 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005193 * to represent that a audio codec is allowed to use.
5194 *
5195 * @hide
5196 */
5197 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5198
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005199 // ---------------------------------------------------------------------
5200 // ---------------------------------------------------------------------
5201 // Intent flags (see mFlags variable).
5202
Tor Norbyed9273d62013-05-30 15:59:53 -07005203 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005204 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005205 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5206 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005207 @Retention(RetentionPolicy.SOURCE)
5208 public @interface GrantUriMode {}
5209
Jeff Sharkey846318a2014-04-04 12:12:41 -07005210 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005211 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005212 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5213 @Retention(RetentionPolicy.SOURCE)
5214 public @interface AccessUriMode {}
5215
5216 /**
5217 * Test if given mode flags specify an access mode, which must be at least
5218 * read and/or write.
5219 *
5220 * @hide
5221 */
5222 public static boolean isAccessUriMode(int modeFlags) {
5223 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5224 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5225 }
5226
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005227 /** @hide */
5228 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5229 FLAG_GRANT_READ_URI_PERMISSION,
5230 FLAG_GRANT_WRITE_URI_PERMISSION,
5231 FLAG_FROM_BACKGROUND,
5232 FLAG_DEBUG_LOG_RESOLUTION,
5233 FLAG_EXCLUDE_STOPPED_PACKAGES,
5234 FLAG_INCLUDE_STOPPED_PACKAGES,
5235 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5236 FLAG_GRANT_PREFIX_URI_PERMISSION,
5237 FLAG_DEBUG_TRIAGED_MISSING,
5238 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005239 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005240 FLAG_ACTIVITY_NO_HISTORY,
5241 FLAG_ACTIVITY_SINGLE_TOP,
5242 FLAG_ACTIVITY_NEW_TASK,
5243 FLAG_ACTIVITY_MULTIPLE_TASK,
5244 FLAG_ACTIVITY_CLEAR_TOP,
5245 FLAG_ACTIVITY_FORWARD_RESULT,
5246 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5247 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5248 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5249 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5250 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5251 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5252 FLAG_ACTIVITY_NEW_DOCUMENT,
5253 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5254 FLAG_ACTIVITY_NO_USER_ACTION,
5255 FLAG_ACTIVITY_REORDER_TO_FRONT,
5256 FLAG_ACTIVITY_NO_ANIMATION,
5257 FLAG_ACTIVITY_CLEAR_TASK,
5258 FLAG_ACTIVITY_TASK_ON_HOME,
5259 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5260 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5261 FLAG_RECEIVER_REGISTERED_ONLY,
5262 FLAG_RECEIVER_REPLACE_PENDING,
5263 FLAG_RECEIVER_FOREGROUND,
5264 FLAG_RECEIVER_NO_ABORT,
5265 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5266 FLAG_RECEIVER_BOOT_UPGRADE,
5267 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5268 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5269 FLAG_RECEIVER_FROM_SHELL,
5270 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5271 })
5272 @Retention(RetentionPolicy.SOURCE)
5273 public @interface Flags {}
5274
5275 /** @hide */
5276 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5277 FLAG_FROM_BACKGROUND,
5278 FLAG_DEBUG_LOG_RESOLUTION,
5279 FLAG_EXCLUDE_STOPPED_PACKAGES,
5280 FLAG_INCLUDE_STOPPED_PACKAGES,
5281 FLAG_DEBUG_TRIAGED_MISSING,
5282 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005283 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005284 FLAG_ACTIVITY_NO_HISTORY,
5285 FLAG_ACTIVITY_SINGLE_TOP,
5286 FLAG_ACTIVITY_NEW_TASK,
5287 FLAG_ACTIVITY_MULTIPLE_TASK,
5288 FLAG_ACTIVITY_CLEAR_TOP,
5289 FLAG_ACTIVITY_FORWARD_RESULT,
5290 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5291 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5292 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5293 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5294 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5295 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5296 FLAG_ACTIVITY_NEW_DOCUMENT,
5297 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5298 FLAG_ACTIVITY_NO_USER_ACTION,
5299 FLAG_ACTIVITY_REORDER_TO_FRONT,
5300 FLAG_ACTIVITY_NO_ANIMATION,
5301 FLAG_ACTIVITY_CLEAR_TASK,
5302 FLAG_ACTIVITY_TASK_ON_HOME,
5303 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5304 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5305 FLAG_RECEIVER_REGISTERED_ONLY,
5306 FLAG_RECEIVER_REPLACE_PENDING,
5307 FLAG_RECEIVER_FOREGROUND,
5308 FLAG_RECEIVER_NO_ABORT,
5309 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5310 FLAG_RECEIVER_BOOT_UPGRADE,
5311 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5312 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5313 FLAG_RECEIVER_FROM_SHELL,
5314 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5315 })
5316 @Retention(RetentionPolicy.SOURCE)
5317 public @interface MutableFlags {}
5318
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005319 /**
5320 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005321 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005322 * specified in its ClipData. When applying to an Intent's ClipData,
5323 * all URIs as well as recursive traversals through data or other ClipData
5324 * in Intent items will be granted; only the grant flags of the top-level
5325 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005326 */
5327 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5328 /**
5329 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005330 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005331 * specified in its ClipData. When applying to an Intent's ClipData,
5332 * all URIs as well as recursive traversals through data or other ClipData
5333 * in Intent items will be granted; only the grant flags of the top-level
5334 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005335 */
5336 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5337 /**
5338 * Can be set by the caller to indicate that this Intent is coming from
5339 * a background operation, not from direct user interaction.
5340 */
5341 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5342 /**
5343 * A flag you can enable for debugging: when set, log messages will be
5344 * printed during the resolution of this intent to show you what has
5345 * been found to create the final resolved list.
5346 */
5347 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005348 /**
5349 * If set, this intent will not match any components in packages that
5350 * are currently stopped. If this is not set, then the default behavior
5351 * is to include such applications in the result.
5352 */
5353 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5354 /**
5355 * If set, this intent will always match any components in packages that
5356 * are currently stopped. This is the default behavior when
5357 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5358 * flags are set, this one wins (it allows overriding of exclude for
5359 * places where the framework may automatically set the exclude flag).
5360 */
5361 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005362
5363 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005364 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005365 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005366 * persisted across device reboots until explicitly revoked with
5367 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5368 * grant for possible persisting; the receiving application must call
5369 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5370 * actually persist.
5371 *
5372 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5373 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5374 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005375 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005376 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005377 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005378
5379 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005380 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5381 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5382 * applies to any URI that is a prefix match against the original granted
5383 * URI. (Without this flag, the URI must match exactly for access to be
5384 * granted.) Another URI is considered a prefix match only when scheme,
5385 * authority, and all path segments defined by the prefix are an exact
5386 * match.
5387 */
5388 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5389
5390 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005391 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005392 * homework and verified that they correctly handle packages and components
5393 * that come and go over time. In particular:
5394 * <ul>
5395 * <li>Apps installed on external storage, which will appear to be
5396 * uninstalled while the the device is ejected.
5397 * <li>Apps with encryption unaware components, which will appear to not
5398 * exist while the device is locked.
5399 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005400 *
5401 * @hide
5402 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005403 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005404
5405 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005406 * Internal flag used to indicate ephemeral applications should not be
5407 * considered when resolving the intent.
5408 *
5409 * @hide
5410 */
5411 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5412
5413 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005414 * If set, the new activity is not kept in the history stack. As soon as
5415 * the user navigates away from it, the activity is finished. This may also
5416 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5417 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005418 *
5419 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5420 * is never invoked when the current activity starts a new activity which
5421 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005422 */
5423 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5424 /**
5425 * If set, the activity will not be launched if it is already running
5426 * at the top of the history stack.
5427 */
5428 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5429 /**
5430 * If set, this activity will become the start of a new task on this
5431 * history stack. A task (from the activity that started it to the
5432 * next task activity) defines an atomic group of activities that the
5433 * user can move to. Tasks can be moved to the foreground and background;
5434 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005435 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005436 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5437 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005438 *
5439 * <p>This flag is generally used by activities that want
5440 * to present a "launcher" style behavior: they give the user a list of
5441 * separate things that can be done, which otherwise run completely
5442 * independently of the activity launching them.
5443 *
5444 * <p>When using this flag, if a task is already running for the activity
5445 * you are now starting, then a new activity will not be started; instead,
5446 * the current task will simply be brought to the front of the screen with
5447 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5448 * to disable this behavior.
5449 *
5450 * <p>This flag can not be used when the caller is requesting a result from
5451 * the activity being launched.
5452 */
5453 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5454 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005455 * This flag is used to create a new task and launch an activity into it.
5456 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5457 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5458 * search through existing tasks for ones matching this Intent. Only if no such
5459 * task is found would a new task be created. When paired with
5460 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5461 * the search for a matching task and unconditionally start a new task.
5462 *
5463 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5464 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005465 * top-level application launcher.</strong> Used in conjunction with
5466 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5467 * behavior of bringing an existing task to the foreground. When set,
5468 * a new task is <em>always</em> started to host the Activity for the
5469 * Intent, regardless of whether there is already an existing task running
5470 * the same thing.
5471 *
5472 * <p><strong>Because the default system does not include graphical task management,
5473 * you should not use this flag unless you provide some way for a user to
5474 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005475 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005476 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5477 * creating new document tasks.
5478 *
5479 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005480 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005481 *
Scott Main7aee61f2011-02-08 11:25:01 -08005482 * <p>See
5483 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5484 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005485 *
5486 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5487 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005488 */
5489 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5490 /**
5491 * If set, and the activity being launched is already running in the
5492 * current task, then instead of launching a new instance of that activity,
5493 * all of the other activities on top of it will be closed and this Intent
5494 * will be delivered to the (now on top) old activity as a new Intent.
5495 *
5496 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5497 * If D calls startActivity() with an Intent that resolves to the component
5498 * of activity B, then C and D will be finished and B receive the given
5499 * Intent, resulting in the stack now being: A, B.
5500 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005501 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005502 * either receive the new intent you are starting here in its
5503 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005504 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005505 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5506 * the same intent, then it will be finished and re-created; for all other
5507 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5508 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509 *
5510 * <p>This launch mode can also be used to good effect in conjunction with
5511 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5512 * of a task, it will bring any currently running instance of that task
5513 * to the foreground, and then clear it to its root state. This is
5514 * especially useful, for example, when launching an activity from the
5515 * notification manager.
5516 *
Scott Main7aee61f2011-02-08 11:25:01 -08005517 * <p>See
5518 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5519 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005520 */
5521 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5522 /**
5523 * If set and this intent is being used to launch a new activity from an
5524 * existing one, then the reply target of the existing activity will be
5525 * transfered to the new activity. This way the new activity can call
5526 * {@link android.app.Activity#setResult} and have that result sent back to
5527 * the reply target of the original activity.
5528 */
5529 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5530 /**
5531 * If set and this intent is being used to launch a new activity from an
5532 * existing one, the current activity will not be counted as the top
5533 * activity for deciding whether the new intent should be delivered to
5534 * the top instead of starting a new one. The previous activity will
5535 * be used as the top, with the assumption being that the current activity
5536 * will finish itself immediately.
5537 */
5538 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5539 /**
5540 * If set, the new activity is not kept in the list of recently launched
5541 * activities.
5542 */
5543 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5544 /**
5545 * This flag is not normally set by application code, but set for you by
5546 * the system as described in the
5547 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5548 * launchMode} documentation for the singleTask mode.
5549 */
5550 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5551 /**
5552 * If set, and this activity is either being started in a new task or
5553 * bringing to the top an existing task, then it will be launched as
5554 * the front door of the task. This will result in the application of
5555 * any affinities needed to have that task in the proper state (either
5556 * moving activities to or from it), or simply resetting that task to
5557 * its initial state if needed.
5558 */
5559 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5560 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005561 * This flag is not normally set by application code, but set for you by
5562 * the system if this activity is being launched from history
5563 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005564 */
5565 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005566 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005567 * @deprecated As of API 21 this performs identically to
5568 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005569 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005570 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005571 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005572 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005573 * This flag is used to open a document into a new task rooted at the activity launched
5574 * by this Intent. Through the use of this flag, or its equivalent attribute,
5575 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005576 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005577 *
Craig Mautner026596b2014-05-21 15:35:44 -07005578 * <p>The use of the activity attribute form of this,
5579 * {@link android.R.attr#documentLaunchMode}, is
5580 * preferred over the Intent flag described here. The attribute form allows the
5581 * Activity to specify multiple document behavior for all launchers of the Activity
5582 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005583 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005584 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5585 * it is kept after the activity is finished is different than the use of
5586 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5587 * this flag is being used to create a new recents entry, then by default that entry
5588 * will be removed once the activity is finished. You can modify this behavior with
5589 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5590 *
Craig Mautner026596b2014-05-21 15:35:44 -07005591 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5592 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5593 * equivalent of the Activity manifest specifying {@link
5594 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5595 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5596 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005597 *
Craig Mautner026596b2014-05-21 15:35:44 -07005598 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005599 *
Craig Mautner026596b2014-05-21 15:35:44 -07005600 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005601 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5602 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005603 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005604 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005605 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005606 * callback from occurring on the current frontmost activity before it is
5607 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005608 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005609 * <p>Typically, an activity can rely on that callback to indicate that an
5610 * explicit user action has caused their activity to be moved out of the
5611 * foreground. The callback marks an appropriate point in the activity's
5612 * lifecycle for it to dismiss any notifications that it intends to display
5613 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005614 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005615 * <p>If an activity is ever started via any non-user-driven events such as
5616 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5617 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005618 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005619 */
5620 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005621 /**
5622 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5623 * this flag will cause the launched activity to be brought to the front of its
5624 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005625 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005626 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5627 * If D calls startActivity() with an Intent that resolves to the component
5628 * of activity B, then B will be brought to the front of the history stack,
5629 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005630 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005631 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005632 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005633 */
5634 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005635 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005636 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5637 * this flag will prevent the system from applying an activity transition
5638 * animation to go to the next activity state. This doesn't mean an
5639 * animation will never run -- if another activity change happens that doesn't
5640 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005641 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005642 * when you are going to do a series of activity operations but the
5643 * animation seen by the user shouldn't be driven by the first activity
5644 * change but rather a later one.
5645 */
5646 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5647 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005648 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5649 * this flag will cause any existing task that would be associated with the
5650 * activity to be cleared before the activity is started. That is, the activity
5651 * becomes the new root of an otherwise empty task, and any old activities
5652 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5653 */
5654 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5655 /**
5656 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5657 * this flag will cause a newly launching task to be placed on top of the current
5658 * home activity task (if there is one). That is, pressing back from the task
5659 * will always return the user to home even if that was not the last activity they
5660 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5661 */
5662 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5663 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005664 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5665 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005666 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005667 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005668 * this flag. When set and the task's activity is finished, the recents
5669 * entry will remain in the interface for the user to re-launch it, like a
5670 * recents entry for a top-level application.
5671 * <p>
5672 * The receiving activity can override this request with
5673 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5674 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005675 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005676 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005677 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005678
5679 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005680 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5681 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005682 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5683 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005684 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005685 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005686
Patrick Baumann577d4022018-01-31 16:55:10 +00005687
5688 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005689 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5690 * this flag will attempt to launch an instant app if no full app on the device can already
5691 * handle the intent.
5692 * <p>
5693 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5694 * are supported:
5695 * <ul>
5696 * <li>{@link Intent#setAction(String)}</li>
5697 * <li>{@link Intent#addCategory(String)}</li>
5698 * <li>{@link Intent#setData(Uri)}</li>
5699 * <li>{@link Intent#setType(String)}</li>
5700 * <li>{@link Intent#setPackage(String)}</li>
5701 * <li>{@link Intent#addFlags(int)}</li>
5702 * </ul>
5703 * <p>
5704 * In the case that no instant app can be found, the installer will be launched to notify the
5705 * user that the intent could not be resolved. On devices that do not support instant apps,
5706 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005707 */
5708 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5709
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005710 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005711 * If set, when sending a broadcast only registered receivers will be
5712 * called -- no BroadcastReceiver components will be launched.
5713 */
5714 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005715 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005716 * If set, when sending a broadcast the new broadcast will replace
5717 * any existing pending broadcast that matches it. Matching is defined
5718 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5719 * true for the intents of the two broadcasts. When a match is found,
5720 * the new broadcast (and receivers associated with it) will replace the
5721 * existing one in the pending broadcast list, remaining at the same
5722 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005723 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005724 * <p>This flag is most typically used with sticky broadcasts, which
5725 * only care about delivering the most recent values of the broadcast
5726 * to their receivers.
5727 */
5728 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5729 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005730 * If set, when sending a broadcast the recipient is allowed to run at
5731 * foreground priority, with a shorter timeout interval. During normal
5732 * broadcasts the receivers are not automatically hoisted out of the
5733 * background priority class.
5734 */
5735 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5736 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005737 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5738 * They can still propagate results through to later receivers, but they can not prevent
5739 * later receivers from seeing the broadcast.
5740 */
5741 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5742 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005743 * If set, when sending a broadcast <i>before boot has completed</i> only
5744 * registered receivers will be called -- no BroadcastReceiver components
5745 * will be launched. Sticky intent state will be recorded properly even
5746 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5747 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005748 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005749 * <p>This flag is only for use by system sevices as a convenience to
5750 * avoid having to implement a more complex mechanism around detection
5751 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005752 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005753 * @hide
5754 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005755 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005756 /**
5757 * Set when this broadcast is for a boot upgrade, a special mode that
5758 * allows the broadcast to be sent before the system is ready and launches
5759 * the app process with no providers running in it.
5760 * @hide
5761 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005762 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005763 /**
5764 * If set, the broadcast will always go to manifest receivers in background (cached
5765 * or not running) apps, regardless of whether that would be done by default. By
5766 * default they will only receive broadcasts if the broadcast has specified an
5767 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005768 *
5769 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5770 * the broadcast code there must also be changed to match.
5771 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005772 * @hide
5773 */
5774 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5775 /**
5776 * If set, the broadcast will never go to manifest receivers in background (cached
5777 * or not running) apps, regardless of whether that would be done by default. By
5778 * default they will receive broadcasts if the broadcast has specified an
5779 * explicit component or package name.
5780 * @hide
5781 */
5782 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005783 /**
5784 * If set, this broadcast is being sent from the shell.
5785 * @hide
5786 */
5787 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005788
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005789 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005790 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5791 * will not receive broadcasts.
5792 *
5793 * <em>This flag has no effect when used by an Instant App.</em>
5794 */
5795 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5796
5797 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005798 * @hide Flags that can't be changed with PendingIntent.
5799 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005800 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5801 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5802 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005803
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005804 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005805 // ---------------------------------------------------------------------
5806 // toUri() and parseUri() options.
5807
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005808 /** @hide */
5809 @IntDef(flag = true, prefix = { "URI_" }, value = {
5810 URI_ALLOW_UNSAFE,
5811 URI_ANDROID_APP_SCHEME,
5812 URI_INTENT_SCHEME,
5813 })
5814 @Retention(RetentionPolicy.SOURCE)
5815 public @interface UriFlags {}
5816
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005817 /**
5818 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5819 * always has the "intent:" scheme. This syntax can be used when you want
5820 * to later disambiguate between URIs that are intended to describe an
5821 * Intent vs. all others that should be treated as raw URIs. When used
5822 * with {@link #parseUri}, any other scheme will result in a generic
5823 * VIEW action for that raw URI.
5824 */
5825 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005826
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005827 /**
5828 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5829 * always has the "android-app:" scheme. This is a variation of
5830 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5831 * http/https URI being delivered to a specific package name. The format
5832 * is:
5833 *
5834 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005835 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005836 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005837 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5838 * you must also include a scheme; including a path also requires both a host and a scheme.
5839 * The final #Intent; fragment can be used without a scheme, host, or path.
5840 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005841 * used with intents that have a {@link #setSelector}, since the base intent
5842 * will always have an explicit package name.</p>
5843 *
5844 * <p>Some examples of how this scheme maps to Intent objects:</p>
5845 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5846 * <colgroup align="left" />
5847 * <colgroup align="left" />
5848 * <thead>
5849 * <tr><th>URI</th> <th>Intent</th></tr>
5850 * </thead>
5851 *
5852 * <tbody>
5853 * <tr><td><code>android-app://com.example.app</code></td>
5854 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5855 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5856 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5857 * </table></td>
5858 * </tr>
5859 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5860 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5861 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5862 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5863 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5864 * </table></td>
5865 * </tr>
5866 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5867 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5868 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5869 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5870 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5871 * </table></td>
5872 * </tr>
5873 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5874 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5875 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5876 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5877 * </table></td>
5878 * </tr>
5879 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5880 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5881 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5882 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5883 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5884 * </table></td>
5885 * </tr>
5886 * <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>
5887 * <td><table border="" style="margin:0" >
5888 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5889 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5890 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5891 * </table></td>
5892 * </tr>
5893 * </tbody>
5894 * </table>
5895 */
5896 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5897
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005898 /**
5899 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5900 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5901 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5902 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5903 * generated Intent can not cause unexpected data access to happen.
5904 *
5905 * <p>If you do not trust the source of the URI being parsed, you should still do further
5906 * processing to protect yourself from it. In particular, when using it to start an
5907 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5908 * that can handle it.</p>
5909 */
5910 public static final int URI_ALLOW_UNSAFE = 1<<2;
5911
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005912 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005913
5914 private String mAction;
5915 private Uri mData;
5916 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005917 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005918 private ComponentName mComponent;
5919 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005920 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005921 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005922 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005923 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005924 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005925 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005926 /** Token to track instant app launches. Local only; do not copy cross-process. */
5927 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005928
5929 // ---------------------------------------------------------------------
5930
Makoto Onuki97f82f22017-05-31 16:20:21 -07005931 private static final int COPY_MODE_ALL = 0;
5932 private static final int COPY_MODE_FILTER = 1;
5933 private static final int COPY_MODE_HISTORY = 2;
5934
5935 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005936 @IntDef(prefix = { "COPY_MODE_" }, value = {
5937 COPY_MODE_ALL,
5938 COPY_MODE_FILTER,
5939 COPY_MODE_HISTORY
5940 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005941 @Retention(RetentionPolicy.SOURCE)
5942 public @interface CopyMode {}
5943
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005944 /**
5945 * Create an empty intent.
5946 */
5947 public Intent() {
5948 }
5949
5950 /**
5951 * Copy constructor.
5952 */
5953 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005954 this(o, COPY_MODE_ALL);
5955 }
5956
5957 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005958 this.mAction = o.mAction;
5959 this.mData = o.mData;
5960 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005961 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005962 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005963
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005964 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005965 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005966 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005967
5968 if (copyMode != COPY_MODE_FILTER) {
5969 this.mFlags = o.mFlags;
5970 this.mContentUserHint = o.mContentUserHint;
5971 this.mLaunchToken = o.mLaunchToken;
5972 if (o.mSourceBounds != null) {
5973 this.mSourceBounds = new Rect(o.mSourceBounds);
5974 }
5975 if (o.mSelector != null) {
5976 this.mSelector = new Intent(o.mSelector);
5977 }
5978
5979 if (copyMode != COPY_MODE_HISTORY) {
5980 if (o.mExtras != null) {
5981 this.mExtras = new Bundle(o.mExtras);
5982 }
5983 if (o.mClipData != null) {
5984 this.mClipData = new ClipData(o.mClipData);
5985 }
5986 } else {
5987 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5988 this.mExtras = Bundle.STRIPPED;
5989 }
5990
5991 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5992 // history.
5993 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005994 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005995 }
5996
5997 @Override
5998 public Object clone() {
5999 return new Intent(this);
6000 }
6001
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006002 /**
6003 * Make a clone of only the parts of the Intent that are relevant for
6004 * filter matching: the action, data, type, component, and categories.
6005 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006006 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006007 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 }
6009
6010 /**
6011 * Create an intent with a given action. All other fields (data, type,
6012 * class) are null. Note that the action <em>must</em> be in a
6013 * namespace because Intents are used globally in the system -- for
6014 * example the system VIEW action is android.intent.action.VIEW; an
6015 * application's custom action would be something like
6016 * com.google.app.myapp.CUSTOM_ACTION.
6017 *
6018 * @param action The Intent action, such as ACTION_VIEW.
6019 */
6020 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006021 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006022 }
6023
6024 /**
6025 * Create an intent with a given action and for a given data url. Note
6026 * that the action <em>must</em> be in a namespace because Intents are
6027 * used globally in the system -- for example the system VIEW action is
6028 * android.intent.action.VIEW; an application's custom action would be
6029 * something like com.google.app.myapp.CUSTOM_ACTION.
6030 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006031 * <p><em>Note: scheme and host name matching in the Android framework is
6032 * case-sensitive, unlike the formal RFC. As a result,
6033 * you should always ensure that you write your Uri with these elements
6034 * using lower case letters, and normalize any Uris you receive from
6035 * outside of Android to ensure the scheme and host is lower case.</em></p>
6036 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006037 * @param action The Intent action, such as ACTION_VIEW.
6038 * @param uri The Intent data URI.
6039 */
6040 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006041 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006042 mData = uri;
6043 }
6044
6045 /**
6046 * Create an intent for a specific component. All other fields (action, data,
6047 * type, class) are null, though they can be modified later with explicit
6048 * calls. This provides a convenient way to create an intent that is
6049 * intended to execute a hard-coded class name, rather than relying on the
6050 * system to find an appropriate class for you; see {@link #setComponent}
6051 * for more information on the repercussions of this.
6052 *
6053 * @param packageContext A Context of the application package implementing
6054 * this class.
6055 * @param cls The component class that is to be used for the intent.
6056 *
6057 * @see #setClass
6058 * @see #setComponent
6059 * @see #Intent(String, android.net.Uri , Context, Class)
6060 */
6061 public Intent(Context packageContext, Class<?> cls) {
6062 mComponent = new ComponentName(packageContext, cls);
6063 }
6064
6065 /**
6066 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006067 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006068 * construct the Intent and then calling {@link #setClass} to set its
6069 * class.
6070 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006071 * <p><em>Note: scheme and host name matching in the Android framework is
6072 * case-sensitive, unlike the formal RFC. As a result,
6073 * you should always ensure that you write your Uri with these elements
6074 * using lower case letters, and normalize any Uris you receive from
6075 * outside of Android to ensure the scheme and host is lower case.</em></p>
6076 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006077 * @param action The Intent action, such as ACTION_VIEW.
6078 * @param uri The Intent data URI.
6079 * @param packageContext A Context of the application package implementing
6080 * this class.
6081 * @param cls The component class that is to be used for the intent.
6082 *
6083 * @see #Intent(String, android.net.Uri)
6084 * @see #Intent(Context, Class)
6085 * @see #setClass
6086 * @see #setComponent
6087 */
6088 public Intent(String action, Uri uri,
6089 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006090 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006091 mData = uri;
6092 mComponent = new ComponentName(packageContext, cls);
6093 }
6094
6095 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006096 * Create an intent to launch the main (root) activity of a task. This
6097 * is the Intent that is started when the application's is launched from
6098 * Home. For anything else that wants to launch an application in the
6099 * same way, it is important that they use an Intent structured the same
6100 * way, and can use this function to ensure this is the case.
6101 *
6102 * <p>The returned Intent has the given Activity component as its explicit
6103 * component, {@link #ACTION_MAIN} as its action, and includes the
6104 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6105 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6106 * to do that through {@link #addFlags(int)} on the returned Intent.
6107 *
6108 * @param mainActivity The main activity component that this Intent will
6109 * launch.
6110 * @return Returns a newly created Intent that can be used to launch the
6111 * activity as a main application entry.
6112 *
6113 * @see #setClass
6114 * @see #setComponent
6115 */
6116 public static Intent makeMainActivity(ComponentName mainActivity) {
6117 Intent intent = new Intent(ACTION_MAIN);
6118 intent.setComponent(mainActivity);
6119 intent.addCategory(CATEGORY_LAUNCHER);
6120 return intent;
6121 }
6122
6123 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006124 * Make an Intent for the main activity of an application, without
6125 * specifying a specific activity to run but giving a selector to find
6126 * the activity. This results in a final Intent that is structured
6127 * the same as when the application is launched from
6128 * Home. For anything else that wants to launch an application in the
6129 * same way, it is important that they use an Intent structured the same
6130 * way, and can use this function to ensure this is the case.
6131 *
6132 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6133 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6134 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6135 * to do that through {@link #addFlags(int)} on the returned Intent.
6136 *
6137 * @param selectorAction The action name of the Intent's selector.
6138 * @param selectorCategory The name of a category to add to the Intent's
6139 * selector.
6140 * @return Returns a newly created Intent that can be used to launch the
6141 * activity as a main application entry.
6142 *
6143 * @see #setSelector(Intent)
6144 */
6145 public static Intent makeMainSelectorActivity(String selectorAction,
6146 String selectorCategory) {
6147 Intent intent = new Intent(ACTION_MAIN);
6148 intent.addCategory(CATEGORY_LAUNCHER);
6149 Intent selector = new Intent();
6150 selector.setAction(selectorAction);
6151 selector.addCategory(selectorCategory);
6152 intent.setSelector(selector);
6153 return intent;
6154 }
6155
6156 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006157 * Make an Intent that can be used to re-launch an application's task
6158 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6159 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6160 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6161 *
6162 * @param mainActivity The activity component that is the root of the
6163 * task; this is the activity that has been published in the application's
6164 * manifest as the main launcher icon.
6165 *
6166 * @return Returns a newly created Intent that can be used to relaunch the
6167 * activity's task in its root state.
6168 */
6169 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6170 Intent intent = makeMainActivity(mainActivity);
6171 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6172 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6173 return intent;
6174 }
6175
6176 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006177 * Call {@link #parseUri} with 0 flags.
6178 * @deprecated Use {@link #parseUri} instead.
6179 */
6180 @Deprecated
6181 public static Intent getIntent(String uri) throws URISyntaxException {
6182 return parseUri(uri, 0);
6183 }
Tom Taylord4a47292009-12-21 13:59:18 -08006184
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006185 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006186 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006187 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006188 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006189 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006190 *
6191 * <p>The URI given here must not be relative -- that is, it must include
6192 * the scheme and full path.
6193 *
6194 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006195 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006196 *
6197 * @return Intent The newly created Intent object.
6198 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006199 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6200 * it bad (as parsed by the Uri class) or the Intent data within the
6201 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006202 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006203 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006204 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006205 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006206 int i = 0;
6207 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006208 final boolean androidApp = uri.startsWith("android-app:");
6209
6210 // Validate intent scheme if requested.
6211 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6212 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006213 Intent intent = new Intent(ACTION_VIEW);
6214 try {
6215 intent.setData(Uri.parse(uri));
6216 } catch (IllegalArgumentException e) {
6217 throw new URISyntaxException(uri, e.getMessage());
6218 }
6219 return intent;
6220 }
6221 }
Tom Taylord4a47292009-12-21 13:59:18 -08006222
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006223 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006224 // simple case
6225 if (i == -1) {
6226 if (!androidApp) {
6227 return new Intent(ACTION_VIEW, Uri.parse(uri));
6228 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006229
6230 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006231 } else if (!uri.startsWith("#Intent;", i)) {
6232 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006233 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006234 } else {
6235 i = -1;
6236 }
6237 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006238
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006239 // new format
6240 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006241 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006242 boolean explicitAction = false;
6243 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006244
6245 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006246 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006247 String data;
6248 if (i >= 0) {
6249 data = uri.substring(0, i);
6250 i += 8; // length of "#Intent;"
6251 } else {
6252 data = uri;
6253 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006254
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006255 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006256 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006257 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006258 if (eq < 0) eq = i-1;
6259 int semi = uri.indexOf(';', i);
6260 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006261
6262 // action
6263 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006264 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006265 if (!inSelector) {
6266 explicitAction = true;
6267 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006268 }
6269
6270 // categories
6271 else if (uri.startsWith("category=", i)) {
6272 intent.addCategory(value);
6273 }
6274
6275 // type
6276 else if (uri.startsWith("type=", i)) {
6277 intent.mType = value;
6278 }
6279
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006280 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006281 else if (uri.startsWith("launchFlags=", i)) {
6282 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006283 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6284 intent.mFlags &= ~IMMUTABLE_FLAGS;
6285 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006286 }
6287
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006288 // package
6289 else if (uri.startsWith("package=", i)) {
6290 intent.mPackage = value;
6291 }
6292
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006293 // component
6294 else if (uri.startsWith("component=", i)) {
6295 intent.mComponent = ComponentName.unflattenFromString(value);
6296 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006297
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006298 // scheme
6299 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006300 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006301 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006302 } else {
6303 scheme = value;
6304 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006305 }
6306
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006307 // source bounds
6308 else if (uri.startsWith("sourceBounds=", i)) {
6309 intent.mSourceBounds = Rect.unflattenFromString(value);
6310 }
6311
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006312 // selector
6313 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6314 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006315 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006316 }
6317
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006318 // extra
6319 else {
6320 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006321 // create Bundle if it doesn't already exist
6322 if (intent.mExtras == null) intent.mExtras = new Bundle();
6323 Bundle b = intent.mExtras;
6324 // add EXTRA
6325 if (uri.startsWith("S.", i)) b.putString(key, value);
6326 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6327 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6328 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6329 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6330 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6331 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6332 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6333 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6334 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6335 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006336
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006337 // move to the next item
6338 i = semi + 1;
6339 }
6340
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006341 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006342 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006343 if (baseIntent.mPackage == null) {
6344 baseIntent.setSelector(intent);
6345 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006346 intent = baseIntent;
6347 }
6348
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006349 if (data != null) {
6350 if (data.startsWith("intent:")) {
6351 data = data.substring(7);
6352 if (scheme != null) {
6353 data = scheme + ':' + data;
6354 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006355 } else if (data.startsWith("android-app:")) {
6356 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6357 // Correctly formed android-app, first part is package name.
6358 int end = data.indexOf('/', 14);
6359 if (end < 0) {
6360 // All we have is a package name.
6361 intent.mPackage = data.substring(14);
6362 if (!explicitAction) {
6363 intent.setAction(ACTION_MAIN);
6364 }
6365 data = "";
6366 } else {
6367 // Target the Intent at the given package name always.
6368 String authority = null;
6369 intent.mPackage = data.substring(14, end);
6370 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006371 if ((end+1) < data.length()) {
6372 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6373 // Found a scheme, remember it.
6374 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006375 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006376 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6377 // Found a authority, remember it.
6378 authority = data.substring(end+1, newEnd);
6379 end = newEnd;
6380 }
6381 } else {
6382 // All we have is a scheme.
6383 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006384 }
6385 }
6386 if (scheme == null) {
6387 // If there was no scheme, then this just targets the package.
6388 if (!explicitAction) {
6389 intent.setAction(ACTION_MAIN);
6390 }
6391 data = "";
6392 } else if (authority == null) {
6393 data = scheme + ":";
6394 } else {
6395 data = scheme + "://" + authority + data.substring(end);
6396 }
6397 }
6398 } else {
6399 data = "";
6400 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006401 }
Tom Taylord4a47292009-12-21 13:59:18 -08006402
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006403 if (data.length() > 0) {
6404 try {
6405 intent.mData = Uri.parse(data);
6406 } catch (IllegalArgumentException e) {
6407 throw new URISyntaxException(uri, e.getMessage());
6408 }
6409 }
6410 }
Tom Taylord4a47292009-12-21 13:59:18 -08006411
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006412 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006413
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006414 } catch (IndexOutOfBoundsException e) {
6415 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6416 }
6417 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006418
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006419 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006420 return getIntentOld(uri, 0);
6421 }
6422
6423 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006424 Intent intent;
6425
6426 int i = uri.lastIndexOf('#');
6427 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006428 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006429 final int intentFragmentStart = i;
6430 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006431
6432 i++;
6433
6434 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006435 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006436 i += 7;
6437 int j = uri.indexOf(')', i);
6438 action = uri.substring(i, j);
6439 i = j + 1;
6440 }
6441
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006442 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006443
6444 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006445 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006446 i += 11;
6447 int j = uri.indexOf(')', i);
6448 while (i < j) {
6449 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006450 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006451 if (i < sep) {
6452 intent.addCategory(uri.substring(i, sep));
6453 }
6454 i = sep + 1;
6455 }
6456 i = j + 1;
6457 }
6458
6459 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006460 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006461 i += 5;
6462 int j = uri.indexOf(')', i);
6463 intent.mType = uri.substring(i, j);
6464 i = j + 1;
6465 }
6466
6467 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006468 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006469 i += 12;
6470 int j = uri.indexOf(')', i);
6471 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006472 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6473 intent.mFlags &= ~IMMUTABLE_FLAGS;
6474 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006475 i = j + 1;
6476 }
6477
6478 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006479 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006480 i += 10;
6481 int j = uri.indexOf(')', i);
6482 int sep = uri.indexOf('!', i);
6483 if (sep >= 0 && sep < j) {
6484 String pkg = uri.substring(i, sep);
6485 String cls = uri.substring(sep + 1, j);
6486 intent.mComponent = new ComponentName(pkg, cls);
6487 }
6488 i = j + 1;
6489 }
6490
6491 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006492 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006493 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006494
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006495 final int closeParen = uri.indexOf(')', i);
6496 if (closeParen == -1) throw new URISyntaxException(uri,
6497 "EXTRA missing trailing ')'", i);
6498
6499 while (i < closeParen) {
6500 // fetch the key value
6501 int j = uri.indexOf('=', i);
6502 if (j <= i + 1 || i >= closeParen) {
6503 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6504 }
6505 char type = uri.charAt(i);
6506 i++;
6507 String key = uri.substring(i, j);
6508 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006509
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006510 // get type-value
6511 j = uri.indexOf('!', i);
6512 if (j == -1 || j >= closeParen) j = closeParen;
6513 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6514 String value = uri.substring(i, j);
6515 i = j;
6516
6517 // create Bundle if it doesn't already exist
6518 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006519
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006520 // add item to bundle
6521 try {
6522 switch (type) {
6523 case 'S':
6524 intent.mExtras.putString(key, Uri.decode(value));
6525 break;
6526 case 'B':
6527 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6528 break;
6529 case 'b':
6530 intent.mExtras.putByte(key, Byte.parseByte(value));
6531 break;
6532 case 'c':
6533 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6534 break;
6535 case 'd':
6536 intent.mExtras.putDouble(key, Double.parseDouble(value));
6537 break;
6538 case 'f':
6539 intent.mExtras.putFloat(key, Float.parseFloat(value));
6540 break;
6541 case 'i':
6542 intent.mExtras.putInt(key, Integer.parseInt(value));
6543 break;
6544 case 'l':
6545 intent.mExtras.putLong(key, Long.parseLong(value));
6546 break;
6547 case 's':
6548 intent.mExtras.putShort(key, Short.parseShort(value));
6549 break;
6550 default:
6551 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6552 }
6553 } catch (NumberFormatException e) {
6554 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6555 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006556
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006557 char ch = uri.charAt(i);
6558 if (ch == ')') break;
6559 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6560 i++;
6561 }
6562 }
6563
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006564 if (isIntentFragment) {
6565 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6566 } else {
6567 intent.mData = Uri.parse(uri);
6568 }
Tom Taylord4a47292009-12-21 13:59:18 -08006569
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006570 if (intent.mAction == null) {
6571 // By default, if no action is specified, then use VIEW.
6572 intent.mAction = ACTION_VIEW;
6573 }
6574
6575 } else {
6576 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6577 }
6578
6579 return intent;
6580 }
6581
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006582 /** @hide */
6583 public interface CommandOptionHandler {
6584 boolean handleOption(String opt, ShellCommand cmd);
6585 }
6586
6587 /** @hide */
6588 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6589 throws URISyntaxException {
6590 Intent intent = new Intent();
6591 Intent baseIntent = intent;
6592 boolean hasIntentInfo = false;
6593
6594 Uri data = null;
6595 String type = null;
6596
6597 String opt;
6598 while ((opt=cmd.getNextOption()) != null) {
6599 switch (opt) {
6600 case "-a":
6601 intent.setAction(cmd.getNextArgRequired());
6602 if (intent == baseIntent) {
6603 hasIntentInfo = true;
6604 }
6605 break;
6606 case "-d":
6607 data = Uri.parse(cmd.getNextArgRequired());
6608 if (intent == baseIntent) {
6609 hasIntentInfo = true;
6610 }
6611 break;
6612 case "-t":
6613 type = cmd.getNextArgRequired();
6614 if (intent == baseIntent) {
6615 hasIntentInfo = true;
6616 }
6617 break;
6618 case "-c":
6619 intent.addCategory(cmd.getNextArgRequired());
6620 if (intent == baseIntent) {
6621 hasIntentInfo = true;
6622 }
6623 break;
6624 case "-e":
6625 case "--es": {
6626 String key = cmd.getNextArgRequired();
6627 String value = cmd.getNextArgRequired();
6628 intent.putExtra(key, value);
6629 }
6630 break;
6631 case "--esn": {
6632 String key = cmd.getNextArgRequired();
6633 intent.putExtra(key, (String) null);
6634 }
6635 break;
6636 case "--ei": {
6637 String key = cmd.getNextArgRequired();
6638 String value = cmd.getNextArgRequired();
6639 intent.putExtra(key, Integer.decode(value));
6640 }
6641 break;
6642 case "--eu": {
6643 String key = cmd.getNextArgRequired();
6644 String value = cmd.getNextArgRequired();
6645 intent.putExtra(key, Uri.parse(value));
6646 }
6647 break;
6648 case "--ecn": {
6649 String key = cmd.getNextArgRequired();
6650 String value = cmd.getNextArgRequired();
6651 ComponentName cn = ComponentName.unflattenFromString(value);
6652 if (cn == null)
6653 throw new IllegalArgumentException("Bad component name: " + value);
6654 intent.putExtra(key, cn);
6655 }
6656 break;
6657 case "--eia": {
6658 String key = cmd.getNextArgRequired();
6659 String value = cmd.getNextArgRequired();
6660 String[] strings = value.split(",");
6661 int[] list = new int[strings.length];
6662 for (int i = 0; i < strings.length; i++) {
6663 list[i] = Integer.decode(strings[i]);
6664 }
6665 intent.putExtra(key, list);
6666 }
6667 break;
6668 case "--eial": {
6669 String key = cmd.getNextArgRequired();
6670 String value = cmd.getNextArgRequired();
6671 String[] strings = value.split(",");
6672 ArrayList<Integer> list = new ArrayList<>(strings.length);
6673 for (int i = 0; i < strings.length; i++) {
6674 list.add(Integer.decode(strings[i]));
6675 }
6676 intent.putExtra(key, list);
6677 }
6678 break;
6679 case "--el": {
6680 String key = cmd.getNextArgRequired();
6681 String value = cmd.getNextArgRequired();
6682 intent.putExtra(key, Long.valueOf(value));
6683 }
6684 break;
6685 case "--ela": {
6686 String key = cmd.getNextArgRequired();
6687 String value = cmd.getNextArgRequired();
6688 String[] strings = value.split(",");
6689 long[] list = new long[strings.length];
6690 for (int i = 0; i < strings.length; i++) {
6691 list[i] = Long.valueOf(strings[i]);
6692 }
6693 intent.putExtra(key, list);
6694 hasIntentInfo = true;
6695 }
6696 break;
6697 case "--elal": {
6698 String key = cmd.getNextArgRequired();
6699 String value = cmd.getNextArgRequired();
6700 String[] strings = value.split(",");
6701 ArrayList<Long> list = new ArrayList<>(strings.length);
6702 for (int i = 0; i < strings.length; i++) {
6703 list.add(Long.valueOf(strings[i]));
6704 }
6705 intent.putExtra(key, list);
6706 hasIntentInfo = true;
6707 }
6708 break;
6709 case "--ef": {
6710 String key = cmd.getNextArgRequired();
6711 String value = cmd.getNextArgRequired();
6712 intent.putExtra(key, Float.valueOf(value));
6713 hasIntentInfo = true;
6714 }
6715 break;
6716 case "--efa": {
6717 String key = cmd.getNextArgRequired();
6718 String value = cmd.getNextArgRequired();
6719 String[] strings = value.split(",");
6720 float[] list = new float[strings.length];
6721 for (int i = 0; i < strings.length; i++) {
6722 list[i] = Float.valueOf(strings[i]);
6723 }
6724 intent.putExtra(key, list);
6725 hasIntentInfo = true;
6726 }
6727 break;
6728 case "--efal": {
6729 String key = cmd.getNextArgRequired();
6730 String value = cmd.getNextArgRequired();
6731 String[] strings = value.split(",");
6732 ArrayList<Float> list = new ArrayList<>(strings.length);
6733 for (int i = 0; i < strings.length; i++) {
6734 list.add(Float.valueOf(strings[i]));
6735 }
6736 intent.putExtra(key, list);
6737 hasIntentInfo = true;
6738 }
6739 break;
6740 case "--esa": {
6741 String key = cmd.getNextArgRequired();
6742 String value = cmd.getNextArgRequired();
6743 // Split on commas unless they are preceeded by an escape.
6744 // The escape character must be escaped for the string and
6745 // again for the regex, thus four escape characters become one.
6746 String[] strings = value.split("(?<!\\\\),");
6747 intent.putExtra(key, strings);
6748 hasIntentInfo = true;
6749 }
6750 break;
6751 case "--esal": {
6752 String key = cmd.getNextArgRequired();
6753 String value = cmd.getNextArgRequired();
6754 // Split on commas unless they are preceeded by an escape.
6755 // The escape character must be escaped for the string and
6756 // again for the regex, thus four escape characters become one.
6757 String[] strings = value.split("(?<!\\\\),");
6758 ArrayList<String> list = new ArrayList<>(strings.length);
6759 for (int i = 0; i < strings.length; i++) {
6760 list.add(strings[i]);
6761 }
6762 intent.putExtra(key, list);
6763 hasIntentInfo = true;
6764 }
6765 break;
6766 case "--ez": {
6767 String key = cmd.getNextArgRequired();
6768 String value = cmd.getNextArgRequired().toLowerCase();
6769 // Boolean.valueOf() results in false for anything that is not "true", which is
6770 // error-prone in shell commands
6771 boolean arg;
6772 if ("true".equals(value) || "t".equals(value)) {
6773 arg = true;
6774 } else if ("false".equals(value) || "f".equals(value)) {
6775 arg = false;
6776 } else {
6777 try {
6778 arg = Integer.decode(value) != 0;
6779 } catch (NumberFormatException ex) {
6780 throw new IllegalArgumentException("Invalid boolean value: " + value);
6781 }
6782 }
6783
6784 intent.putExtra(key, arg);
6785 }
6786 break;
6787 case "-n": {
6788 String str = cmd.getNextArgRequired();
6789 ComponentName cn = ComponentName.unflattenFromString(str);
6790 if (cn == null)
6791 throw new IllegalArgumentException("Bad component name: " + str);
6792 intent.setComponent(cn);
6793 if (intent == baseIntent) {
6794 hasIntentInfo = true;
6795 }
6796 }
6797 break;
6798 case "-p": {
6799 String str = cmd.getNextArgRequired();
6800 intent.setPackage(str);
6801 if (intent == baseIntent) {
6802 hasIntentInfo = true;
6803 }
6804 }
6805 break;
6806 case "-f":
6807 String str = cmd.getNextArgRequired();
6808 intent.setFlags(Integer.decode(str).intValue());
6809 break;
6810 case "--grant-read-uri-permission":
6811 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6812 break;
6813 case "--grant-write-uri-permission":
6814 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6815 break;
6816 case "--grant-persistable-uri-permission":
6817 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6818 break;
6819 case "--grant-prefix-uri-permission":
6820 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6821 break;
6822 case "--exclude-stopped-packages":
6823 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6824 break;
6825 case "--include-stopped-packages":
6826 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6827 break;
6828 case "--debug-log-resolution":
6829 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6830 break;
6831 case "--activity-brought-to-front":
6832 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6833 break;
6834 case "--activity-clear-top":
6835 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6836 break;
6837 case "--activity-clear-when-task-reset":
6838 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6839 break;
6840 case "--activity-exclude-from-recents":
6841 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6842 break;
6843 case "--activity-launched-from-history":
6844 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6845 break;
6846 case "--activity-multiple-task":
6847 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6848 break;
6849 case "--activity-no-animation":
6850 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6851 break;
6852 case "--activity-no-history":
6853 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6854 break;
6855 case "--activity-no-user-action":
6856 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6857 break;
6858 case "--activity-previous-is-top":
6859 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6860 break;
6861 case "--activity-reorder-to-front":
6862 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6863 break;
6864 case "--activity-reset-task-if-needed":
6865 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6866 break;
6867 case "--activity-single-top":
6868 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6869 break;
6870 case "--activity-clear-task":
6871 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6872 break;
6873 case "--activity-task-on-home":
6874 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6875 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006876 case "--activity-match-external":
6877 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6878 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006879 case "--receiver-registered-only":
6880 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6881 break;
6882 case "--receiver-replace-pending":
6883 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6884 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006885 case "--receiver-foreground":
6886 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6887 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006888 case "--receiver-no-abort":
6889 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6890 break;
6891 case "--receiver-include-background":
6892 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6893 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006894 case "--selector":
6895 intent.setDataAndType(data, type);
6896 intent = new Intent();
6897 break;
6898 default:
6899 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6900 // Okay, caller handled this option.
6901 } else {
6902 throw new IllegalArgumentException("Unknown option: " + opt);
6903 }
6904 break;
6905 }
6906 }
6907 intent.setDataAndType(data, type);
6908
6909 final boolean hasSelector = intent != baseIntent;
6910 if (hasSelector) {
6911 // A selector was specified; fix up.
6912 baseIntent.setSelector(intent);
6913 intent = baseIntent;
6914 }
6915
6916 String arg = cmd.getNextArg();
6917 baseIntent = null;
6918 if (arg == null) {
6919 if (hasSelector) {
6920 // If a selector has been specified, and no arguments
6921 // have been supplied for the main Intent, then we can
6922 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6923 // need to have a component name specified yet, the
6924 // selector will take care of that.
6925 baseIntent = new Intent(Intent.ACTION_MAIN);
6926 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6927 }
6928 } else if (arg.indexOf(':') >= 0) {
6929 // The argument is a URI. Fully parse it, and use that result
6930 // to fill in any data not specified so far.
6931 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6932 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6933 } else if (arg.indexOf('/') >= 0) {
6934 // The argument is a component name. Build an Intent to launch
6935 // it.
6936 baseIntent = new Intent(Intent.ACTION_MAIN);
6937 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6938 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6939 } else {
6940 // Assume the argument is a package name.
6941 baseIntent = new Intent(Intent.ACTION_MAIN);
6942 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6943 baseIntent.setPackage(arg);
6944 }
6945 if (baseIntent != null) {
6946 Bundle extras = intent.getExtras();
6947 intent.replaceExtras((Bundle)null);
6948 Bundle uriExtras = baseIntent.getExtras();
6949 baseIntent.replaceExtras((Bundle)null);
6950 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6951 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6952 for (String c : cats) {
6953 baseIntent.removeCategory(c);
6954 }
6955 }
6956 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6957 if (extras == null) {
6958 extras = uriExtras;
6959 } else if (uriExtras != null) {
6960 uriExtras.putAll(extras);
6961 extras = uriExtras;
6962 }
6963 intent.replaceExtras(extras);
6964 hasIntentInfo = true;
6965 }
6966
6967 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6968 return intent;
6969 }
6970
6971 /** @hide */
6972 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6973 final String[] lines = new String[] {
6974 "<INTENT> specifications include these flags and arguments:",
6975 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6976 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6977 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6978 " [--esn <EXTRA_KEY> ...]",
6979 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6980 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6981 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6982 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6983 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6984 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6985 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6986 " (mutiple extras passed as Integer[])",
6987 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6988 " (mutiple extras passed as List<Integer>)",
6989 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6990 " (mutiple extras passed as Long[])",
6991 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6992 " (mutiple extras passed as List<Long>)",
6993 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6994 " (mutiple extras passed as Float[])",
6995 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6996 " (mutiple extras passed as List<Float>)",
6997 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6998 " (mutiple extras passed as String[]; to embed a comma into a string,",
6999 " escape it using \"\\,\")",
7000 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7001 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7002 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007003 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007004 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7005 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7006 " [--debug-log-resolution] [--exclude-stopped-packages]",
7007 " [--include-stopped-packages]",
7008 " [--activity-brought-to-front] [--activity-clear-top]",
7009 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7010 " [--activity-launched-from-history] [--activity-multiple-task]",
7011 " [--activity-no-animation] [--activity-no-history]",
7012 " [--activity-no-user-action] [--activity-previous-is-top]",
7013 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7014 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007015 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007016 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007017 " [--receiver-foreground] [--receiver-no-abort]",
7018 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007019 " [--selector]",
7020 " [<URI> | <PACKAGE> | <COMPONENT>]"
7021 };
7022 for (String line : lines) {
7023 pw.print(prefix);
7024 pw.println(line);
7025 }
7026 }
7027
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007028 /**
7029 * Retrieve the general action to be performed, such as
7030 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7031 * the information in the intent should be interpreted -- most importantly,
7032 * what to do with the data returned by {@link #getData}.
7033 *
7034 * @return The action of this intent or null if none is specified.
7035 *
7036 * @see #setAction
7037 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007038 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007039 return mAction;
7040 }
7041
7042 /**
7043 * Retrieve data this intent is operating on. This URI specifies the name
7044 * of the data; often it uses the content: scheme, specifying data in a
7045 * content provider. Other schemes may be handled by specific activities,
7046 * such as http: by the web browser.
7047 *
7048 * @return The URI of the data this intent is targeting or null.
7049 *
7050 * @see #getScheme
7051 * @see #setData
7052 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007053 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007054 return mData;
7055 }
7056
7057 /**
7058 * The same as {@link #getData()}, but returns the URI as an encoded
7059 * String.
7060 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007061 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007062 return mData != null ? mData.toString() : null;
7063 }
7064
7065 /**
7066 * Return the scheme portion of the intent's data. If the data is null or
7067 * does not include a scheme, null is returned. Otherwise, the scheme
7068 * prefix without the final ':' is returned, i.e. "http".
7069 *
7070 * <p>This is the same as calling getData().getScheme() (and checking for
7071 * null data).
7072 *
7073 * @return The scheme of this intent.
7074 *
7075 * @see #getData
7076 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007077 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007078 return mData != null ? mData.getScheme() : null;
7079 }
7080
7081 /**
7082 * Retrieve any explicit MIME type included in the intent. This is usually
7083 * null, as the type is determined by the intent data.
7084 *
7085 * @return If a type was manually set, it is returned; else null is
7086 * returned.
7087 *
7088 * @see #resolveType(ContentResolver)
7089 * @see #setType
7090 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007091 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007092 return mType;
7093 }
7094
7095 /**
7096 * Return the MIME data type of this intent. If the type field is
7097 * explicitly set, that is simply returned. Otherwise, if the data is set,
7098 * the type of that data is returned. If neither fields are set, a null is
7099 * returned.
7100 *
7101 * @return The MIME type of this intent.
7102 *
7103 * @see #getType
7104 * @see #resolveType(ContentResolver)
7105 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007106 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007107 return resolveType(context.getContentResolver());
7108 }
7109
7110 /**
7111 * Return the MIME data type of this intent. If the type field is
7112 * explicitly set, that is simply returned. Otherwise, if the data is set,
7113 * the type of that data is returned. If neither fields are set, a null is
7114 * returned.
7115 *
7116 * @param resolver A ContentResolver that can be used to determine the MIME
7117 * type of the intent's data.
7118 *
7119 * @return The MIME type of this intent.
7120 *
7121 * @see #getType
7122 * @see #resolveType(Context)
7123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007124 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007125 if (mType != null) {
7126 return mType;
7127 }
7128 if (mData != null) {
7129 if ("content".equals(mData.getScheme())) {
7130 return resolver.getType(mData);
7131 }
7132 }
7133 return null;
7134 }
7135
7136 /**
7137 * Return the MIME data type of this intent, only if it will be needed for
7138 * intent resolution. This is not generally useful for application code;
7139 * it is used by the frameworks for communicating with back-end system
7140 * services.
7141 *
7142 * @param resolver A ContentResolver that can be used to determine the MIME
7143 * type of the intent's data.
7144 *
7145 * @return The MIME type of this intent, or null if it is unknown or not
7146 * needed.
7147 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007148 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007149 if (mComponent != null) {
7150 return mType;
7151 }
7152 return resolveType(resolver);
7153 }
7154
7155 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007156 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007157 *
7158 * @param category The category to check.
7159 *
7160 * @return boolean True if the intent contains the category, else false.
7161 *
7162 * @see #getCategories
7163 * @see #addCategory
7164 */
7165 public boolean hasCategory(String category) {
7166 return mCategories != null && mCategories.contains(category);
7167 }
7168
7169 /**
7170 * Return the set of all categories in the intent. If there are no categories,
7171 * returns NULL.
7172 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007173 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007174 *
7175 * @see #hasCategory
7176 * @see #addCategory
7177 */
7178 public Set<String> getCategories() {
7179 return mCategories;
7180 }
7181
7182 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007183 * Return the specific selector associated with this Intent. If there is
7184 * none, returns null. See {@link #setSelector} for more information.
7185 *
7186 * @see #setSelector
7187 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007188 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007189 return mSelector;
7190 }
7191
7192 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007193 * Return the {@link ClipData} associated with this Intent. If there is
7194 * none, returns null. See {@link #setClipData} for more information.
7195 *
John Spurlock125d1332013-11-25 11:58:37 -05007196 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007197 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007198 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007199 return mClipData;
7200 }
7201
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007202 /** @hide */
7203 public int getContentUserHint() {
7204 return mContentUserHint;
7205 }
7206
Todd Kennedyb3b431302017-03-20 16:05:48 -07007207 /** @hide */
7208 public String getLaunchToken() {
7209 return mLaunchToken;
7210 }
7211
7212 /** @hide */
7213 public void setLaunchToken(String launchToken) {
7214 mLaunchToken = launchToken;
7215 }
7216
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007217 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007218 * Sets the ClassLoader that will be used when unmarshalling
7219 * any Parcelable values from the extras of this Intent.
7220 *
7221 * @param loader a ClassLoader, or null to use the default loader
7222 * at the time of unmarshalling.
7223 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007224 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007225 if (mExtras != null) {
7226 mExtras.setClassLoader(loader);
7227 }
7228 }
7229
7230 /**
7231 * Returns true if an extra value is associated with the given name.
7232 * @param name the extra's name
7233 * @return true if the given extra is present.
7234 */
7235 public boolean hasExtra(String name) {
7236 return mExtras != null && mExtras.containsKey(name);
7237 }
7238
7239 /**
7240 * Returns true if the Intent's extras contain a parcelled file descriptor.
7241 * @return true if the Intent contains a parcelled file descriptor.
7242 */
7243 public boolean hasFileDescriptors() {
7244 return mExtras != null && mExtras.hasFileDescriptors();
7245 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007246
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007247 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007248 public void setAllowFds(boolean allowFds) {
7249 if (mExtras != null) {
7250 mExtras.setAllowFds(allowFds);
7251 }
7252 }
7253
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007254 /** {@hide} */
7255 public void setDefusable(boolean defusable) {
7256 if (mExtras != null) {
7257 mExtras.setDefusable(defusable);
7258 }
7259 }
7260
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007261 /**
7262 * Retrieve extended data from the intent.
7263 *
7264 * @param name The name of the desired item.
7265 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007266 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007267 * or null if none was found.
7268 *
7269 * @deprecated
7270 * @hide
7271 */
7272 @Deprecated
7273 public Object getExtra(String name) {
7274 return getExtra(name, null);
7275 }
7276
7277 /**
7278 * Retrieve extended data from the intent.
7279 *
7280 * @param name The name of the desired item.
7281 * @param defaultValue the value to be returned if no value of the desired
7282 * type is stored with the given name.
7283 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007284 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007285 * or the default value if none was found.
7286 *
7287 * @see #putExtra(String, boolean)
7288 */
7289 public boolean getBooleanExtra(String name, boolean defaultValue) {
7290 return mExtras == null ? defaultValue :
7291 mExtras.getBoolean(name, defaultValue);
7292 }
7293
7294 /**
7295 * Retrieve extended data from the intent.
7296 *
7297 * @param name The name of the desired item.
7298 * @param defaultValue the value to be returned if no value of the desired
7299 * type is stored with the given name.
7300 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007301 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007302 * or the default value if none was found.
7303 *
7304 * @see #putExtra(String, byte)
7305 */
7306 public byte getByteExtra(String name, byte defaultValue) {
7307 return mExtras == null ? defaultValue :
7308 mExtras.getByte(name, defaultValue);
7309 }
7310
7311 /**
7312 * Retrieve extended data from the intent.
7313 *
7314 * @param name The name of the desired item.
7315 * @param defaultValue the value to be returned if no value of the desired
7316 * type is stored with the given name.
7317 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007318 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007319 * or the default value if none was found.
7320 *
7321 * @see #putExtra(String, short)
7322 */
7323 public short getShortExtra(String name, short defaultValue) {
7324 return mExtras == null ? defaultValue :
7325 mExtras.getShort(name, defaultValue);
7326 }
7327
7328 /**
7329 * Retrieve extended data from the intent.
7330 *
7331 * @param name The name of the desired item.
7332 * @param defaultValue the value to be returned if no value of the desired
7333 * type is stored with the given name.
7334 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007335 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007336 * or the default value if none was found.
7337 *
7338 * @see #putExtra(String, char)
7339 */
7340 public char getCharExtra(String name, char defaultValue) {
7341 return mExtras == null ? defaultValue :
7342 mExtras.getChar(name, defaultValue);
7343 }
7344
7345 /**
7346 * Retrieve extended data from the intent.
7347 *
7348 * @param name The name of the desired item.
7349 * @param defaultValue the value to be returned if no value of the desired
7350 * type is stored with the given name.
7351 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007352 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007353 * or the default value if none was found.
7354 *
7355 * @see #putExtra(String, int)
7356 */
7357 public int getIntExtra(String name, int defaultValue) {
7358 return mExtras == null ? defaultValue :
7359 mExtras.getInt(name, defaultValue);
7360 }
7361
7362 /**
7363 * Retrieve extended data from the intent.
7364 *
7365 * @param name The name of the desired item.
7366 * @param defaultValue the value to be returned if no value of the desired
7367 * type is stored with the given name.
7368 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007369 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007370 * or the default value if none was found.
7371 *
7372 * @see #putExtra(String, long)
7373 */
7374 public long getLongExtra(String name, long defaultValue) {
7375 return mExtras == null ? defaultValue :
7376 mExtras.getLong(name, defaultValue);
7377 }
7378
7379 /**
7380 * Retrieve extended data from the intent.
7381 *
7382 * @param name The name of the desired item.
7383 * @param defaultValue the value to be returned if no value of the desired
7384 * type is stored with the given name.
7385 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007386 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007387 * or the default value if no such item is present
7388 *
7389 * @see #putExtra(String, float)
7390 */
7391 public float getFloatExtra(String name, float defaultValue) {
7392 return mExtras == null ? defaultValue :
7393 mExtras.getFloat(name, defaultValue);
7394 }
7395
7396 /**
7397 * Retrieve extended data from the intent.
7398 *
7399 * @param name The name of the desired item.
7400 * @param defaultValue the value to be returned if no value of the desired
7401 * type is stored with the given name.
7402 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007403 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007404 * or the default value if none was found.
7405 *
7406 * @see #putExtra(String, double)
7407 */
7408 public double getDoubleExtra(String name, double defaultValue) {
7409 return mExtras == null ? defaultValue :
7410 mExtras.getDouble(name, defaultValue);
7411 }
7412
7413 /**
7414 * Retrieve extended data from the intent.
7415 *
7416 * @param name The name of the desired item.
7417 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007418 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007419 * or null if no String value was found.
7420 *
7421 * @see #putExtra(String, String)
7422 */
7423 public String getStringExtra(String name) {
7424 return mExtras == null ? null : mExtras.getString(name);
7425 }
7426
7427 /**
7428 * Retrieve extended data from the intent.
7429 *
7430 * @param name The name of the desired item.
7431 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007432 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007433 * or null if no CharSequence value was found.
7434 *
7435 * @see #putExtra(String, CharSequence)
7436 */
7437 public CharSequence getCharSequenceExtra(String name) {
7438 return mExtras == null ? null : mExtras.getCharSequence(name);
7439 }
7440
7441 /**
7442 * Retrieve extended data from the intent.
7443 *
7444 * @param name The name of the desired item.
7445 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007446 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007447 * or null if no Parcelable value was found.
7448 *
7449 * @see #putExtra(String, Parcelable)
7450 */
7451 public <T extends Parcelable> T getParcelableExtra(String name) {
7452 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7453 }
7454
7455 /**
7456 * Retrieve extended data from the intent.
7457 *
7458 * @param name The name of the desired item.
7459 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007460 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007461 * or null if no Parcelable[] value was found.
7462 *
7463 * @see #putExtra(String, Parcelable[])
7464 */
7465 public Parcelable[] getParcelableArrayExtra(String name) {
7466 return mExtras == null ? null : mExtras.getParcelableArray(name);
7467 }
7468
7469 /**
7470 * Retrieve extended data from the intent.
7471 *
7472 * @param name The name of the desired item.
7473 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007474 * @return the value of an item previously added with
7475 * putParcelableArrayListExtra(), or null if no
7476 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007477 *
7478 * @see #putParcelableArrayListExtra(String, ArrayList)
7479 */
7480 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7481 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7482 }
7483
7484 /**
7485 * Retrieve extended data from the intent.
7486 *
7487 * @param name The name of the desired item.
7488 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007489 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007490 * or null if no Serializable value was found.
7491 *
7492 * @see #putExtra(String, Serializable)
7493 */
7494 public Serializable getSerializableExtra(String name) {
7495 return mExtras == null ? null : mExtras.getSerializable(name);
7496 }
7497
7498 /**
7499 * Retrieve extended data from the intent.
7500 *
7501 * @param name The name of the desired item.
7502 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007503 * @return the value of an item previously added with
7504 * putIntegerArrayListExtra(), or null if no
7505 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007506 *
7507 * @see #putIntegerArrayListExtra(String, ArrayList)
7508 */
7509 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7510 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7511 }
7512
7513 /**
7514 * Retrieve extended data from the intent.
7515 *
7516 * @param name The name of the desired item.
7517 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007518 * @return the value of an item previously added with
7519 * putStringArrayListExtra(), or null if no
7520 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007521 *
7522 * @see #putStringArrayListExtra(String, ArrayList)
7523 */
7524 public ArrayList<String> getStringArrayListExtra(String name) {
7525 return mExtras == null ? null : mExtras.getStringArrayList(name);
7526 }
7527
7528 /**
7529 * Retrieve extended data from the intent.
7530 *
7531 * @param name The name of the desired item.
7532 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007533 * @return the value of an item previously added with
7534 * putCharSequenceArrayListExtra, or null if no
7535 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007536 *
7537 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7538 */
7539 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7540 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7541 }
7542
7543 /**
7544 * Retrieve extended data from the intent.
7545 *
7546 * @param name The name of the desired item.
7547 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007548 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007549 * or null if no boolean array value was found.
7550 *
7551 * @see #putExtra(String, boolean[])
7552 */
7553 public boolean[] getBooleanArrayExtra(String name) {
7554 return mExtras == null ? null : mExtras.getBooleanArray(name);
7555 }
7556
7557 /**
7558 * Retrieve extended data from the intent.
7559 *
7560 * @param name The name of the desired item.
7561 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007562 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007563 * or null if no byte array value was found.
7564 *
7565 * @see #putExtra(String, byte[])
7566 */
7567 public byte[] getByteArrayExtra(String name) {
7568 return mExtras == null ? null : mExtras.getByteArray(name);
7569 }
7570
7571 /**
7572 * Retrieve extended data from the intent.
7573 *
7574 * @param name The name of the desired item.
7575 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007576 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007577 * or null if no short array value was found.
7578 *
7579 * @see #putExtra(String, short[])
7580 */
7581 public short[] getShortArrayExtra(String name) {
7582 return mExtras == null ? null : mExtras.getShortArray(name);
7583 }
7584
7585 /**
7586 * Retrieve extended data from the intent.
7587 *
7588 * @param name The name of the desired item.
7589 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007590 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007591 * or null if no char array value was found.
7592 *
7593 * @see #putExtra(String, char[])
7594 */
7595 public char[] getCharArrayExtra(String name) {
7596 return mExtras == null ? null : mExtras.getCharArray(name);
7597 }
7598
7599 /**
7600 * Retrieve extended data from the intent.
7601 *
7602 * @param name The name of the desired item.
7603 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007604 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007605 * or null if no int array value was found.
7606 *
7607 * @see #putExtra(String, int[])
7608 */
7609 public int[] getIntArrayExtra(String name) {
7610 return mExtras == null ? null : mExtras.getIntArray(name);
7611 }
7612
7613 /**
7614 * Retrieve extended data from the intent.
7615 *
7616 * @param name The name of the desired item.
7617 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007618 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007619 * or null if no long array value was found.
7620 *
7621 * @see #putExtra(String, long[])
7622 */
7623 public long[] getLongArrayExtra(String name) {
7624 return mExtras == null ? null : mExtras.getLongArray(name);
7625 }
7626
7627 /**
7628 * Retrieve extended data from the intent.
7629 *
7630 * @param name The name of the desired item.
7631 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007632 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007633 * or null if no float array value was found.
7634 *
7635 * @see #putExtra(String, float[])
7636 */
7637 public float[] getFloatArrayExtra(String name) {
7638 return mExtras == null ? null : mExtras.getFloatArray(name);
7639 }
7640
7641 /**
7642 * Retrieve extended data from the intent.
7643 *
7644 * @param name The name of the desired item.
7645 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007646 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007647 * or null if no double array value was found.
7648 *
7649 * @see #putExtra(String, double[])
7650 */
7651 public double[] getDoubleArrayExtra(String name) {
7652 return mExtras == null ? null : mExtras.getDoubleArray(name);
7653 }
7654
7655 /**
7656 * Retrieve extended data from the intent.
7657 *
7658 * @param name The name of the desired item.
7659 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007660 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007661 * or null if no String array value was found.
7662 *
7663 * @see #putExtra(String, String[])
7664 */
7665 public String[] getStringArrayExtra(String name) {
7666 return mExtras == null ? null : mExtras.getStringArray(name);
7667 }
7668
7669 /**
7670 * Retrieve extended data from the intent.
7671 *
7672 * @param name The name of the desired item.
7673 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007674 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007675 * or null if no CharSequence array value was found.
7676 *
7677 * @see #putExtra(String, CharSequence[])
7678 */
7679 public CharSequence[] getCharSequenceArrayExtra(String name) {
7680 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7681 }
7682
7683 /**
7684 * Retrieve extended data from the intent.
7685 *
7686 * @param name The name of the desired item.
7687 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007688 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007689 * or null if no Bundle value was found.
7690 *
7691 * @see #putExtra(String, Bundle)
7692 */
7693 public Bundle getBundleExtra(String name) {
7694 return mExtras == null ? null : mExtras.getBundle(name);
7695 }
7696
7697 /**
7698 * Retrieve extended data from the intent.
7699 *
7700 * @param name The name of the desired item.
7701 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007702 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007703 * or null if no IBinder value was found.
7704 *
7705 * @see #putExtra(String, IBinder)
7706 *
7707 * @deprecated
7708 * @hide
7709 */
7710 @Deprecated
7711 public IBinder getIBinderExtra(String name) {
7712 return mExtras == null ? null : mExtras.getIBinder(name);
7713 }
7714
7715 /**
7716 * Retrieve extended data from the intent.
7717 *
7718 * @param name The name of the desired item.
7719 * @param defaultValue The default value to return in case no item is
7720 * associated with the key 'name'
7721 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007722 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007723 * or defaultValue if none was found.
7724 *
7725 * @see #putExtra
7726 *
7727 * @deprecated
7728 * @hide
7729 */
7730 @Deprecated
7731 public Object getExtra(String name, Object defaultValue) {
7732 Object result = defaultValue;
7733 if (mExtras != null) {
7734 Object result2 = mExtras.get(name);
7735 if (result2 != null) {
7736 result = result2;
7737 }
7738 }
7739
7740 return result;
7741 }
7742
7743 /**
7744 * Retrieves a map of extended data from the intent.
7745 *
7746 * @return the map of all extras previously added with putExtra(),
7747 * or null if none have been added.
7748 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007749 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007750 return (mExtras != null)
7751 ? new Bundle(mExtras)
7752 : null;
7753 }
7754
7755 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007756 * Filter extras to only basic types.
7757 * @hide
7758 */
7759 public void removeUnsafeExtras() {
7760 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007761 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007762 }
7763 }
7764
7765 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007766 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7767 * return itself as-is.
7768 * @hide
7769 */
7770 public boolean canStripForHistory() {
7771 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7772 }
7773
7774 /**
7775 * Call it when the system needs to keep an intent for logging purposes to remove fields
7776 * that are not needed for logging.
7777 * @hide
7778 */
7779 public Intent maybeStripForHistory() {
7780 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7781
7782 if (!canStripForHistory()) {
7783 return this;
7784 }
7785 return new Intent(this, COPY_MODE_HISTORY);
7786 }
7787
7788 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007789 * Retrieve any special flags associated with this intent. You will
7790 * normally just set them with {@link #setFlags} and let the system
7791 * take the appropriate action with them.
7792 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007793 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007794 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007795 * @see #addFlags
7796 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007797 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007798 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007799 return mFlags;
7800 }
7801
Dianne Hackborne7f97212011-02-24 14:40:20 -08007802 /** @hide */
7803 public boolean isExcludingStopped() {
7804 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7805 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7806 }
7807
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007808 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007809 * Retrieve the application package name this Intent is limited to. When
7810 * resolving an Intent, if non-null this limits the resolution to only
7811 * components in the given application package.
7812 *
7813 * @return The name of the application package for the Intent.
7814 *
7815 * @see #resolveActivity
7816 * @see #setPackage
7817 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007818 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007819 return mPackage;
7820 }
7821
7822 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007823 * Retrieve the concrete component associated with the intent. When receiving
7824 * an intent, this is the component that was found to best handle it (that is,
7825 * yourself) and will always be non-null; in all other cases it will be
7826 * null unless explicitly set.
7827 *
7828 * @return The name of the application component to handle the intent.
7829 *
7830 * @see #resolveActivity
7831 * @see #setComponent
7832 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007833 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007834 return mComponent;
7835 }
7836
7837 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007838 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7839 * used as a hint to the receiver for animations and the like. Null means that there
7840 * is no source bounds.
7841 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007842 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007843 return mSourceBounds;
7844 }
7845
7846 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 * Return the Activity component that should be used to handle this intent.
7848 * The appropriate component is determined based on the information in the
7849 * intent, evaluated as follows:
7850 *
7851 * <p>If {@link #getComponent} returns an explicit class, that is returned
7852 * without any further consideration.
7853 *
7854 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7855 * category to be considered.
7856 *
7857 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7858 * action.
7859 *
7860 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7861 * this type.
7862 *
7863 * <p>If {@link #addCategory} has added any categories, the activity must
7864 * handle ALL of the categories specified.
7865 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007866 * <p>If {@link #getPackage} is non-NULL, only activity components in
7867 * that application package will be considered.
7868 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007869 * <p>If there are no activities that satisfy all of these conditions, a
7870 * null string is returned.
7871 *
7872 * <p>If multiple activities are found to satisfy the intent, the one with
7873 * the highest priority will be used. If there are multiple activities
7874 * with the same priority, the system will either pick the best activity
7875 * based on user preference, or resolve to a system class that will allow
7876 * the user to pick an activity and forward from there.
7877 *
7878 * <p>This method is implemented simply by calling
7879 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7880 * true.</p>
7881 * <p> This API is called for you as part of starting an activity from an
7882 * intent. You do not normally need to call it yourself.</p>
7883 *
7884 * @param pm The package manager with which to resolve the Intent.
7885 *
7886 * @return Name of the component implementing an activity that can
7887 * display the intent.
7888 *
7889 * @see #setComponent
7890 * @see #getComponent
7891 * @see #resolveActivityInfo
7892 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007893 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007894 if (mComponent != null) {
7895 return mComponent;
7896 }
7897
7898 ResolveInfo info = pm.resolveActivity(
7899 this, PackageManager.MATCH_DEFAULT_ONLY);
7900 if (info != null) {
7901 return new ComponentName(
7902 info.activityInfo.applicationInfo.packageName,
7903 info.activityInfo.name);
7904 }
7905
7906 return null;
7907 }
7908
7909 /**
7910 * Resolve the Intent into an {@link ActivityInfo}
7911 * describing the activity that should execute the intent. Resolution
7912 * follows the same rules as described for {@link #resolveActivity}, but
7913 * you get back the completely information about the resolved activity
7914 * instead of just its class name.
7915 *
7916 * @param pm The package manager with which to resolve the Intent.
7917 * @param flags Addition information to retrieve as per
7918 * {@link PackageManager#getActivityInfo(ComponentName, int)
7919 * PackageManager.getActivityInfo()}.
7920 *
7921 * @return PackageManager.ActivityInfo
7922 *
7923 * @see #resolveActivity
7924 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007925 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7926 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007927 ActivityInfo ai = null;
7928 if (mComponent != null) {
7929 try {
7930 ai = pm.getActivityInfo(mComponent, flags);
7931 } catch (PackageManager.NameNotFoundException e) {
7932 // ignore
7933 }
7934 } else {
7935 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007936 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007937 if (info != null) {
7938 ai = info.activityInfo;
7939 }
7940 }
7941
7942 return ai;
7943 }
7944
7945 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007946 * Special function for use by the system to resolve service
7947 * intents to system apps. Throws an exception if there are
7948 * multiple potential matches to the Intent. Returns null if
7949 * there are no matches.
7950 * @hide
7951 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007952 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7953 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007954 if (mComponent != null) {
7955 return mComponent;
7956 }
7957
7958 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7959 if (results == null) {
7960 return null;
7961 }
7962 ComponentName comp = null;
7963 for (int i=0; i<results.size(); i++) {
7964 ResolveInfo ri = results.get(i);
7965 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7966 continue;
7967 }
7968 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7969 ri.serviceInfo.name);
7970 if (comp != null) {
7971 throw new IllegalStateException("Multiple system services handle " + this
7972 + ": " + comp + ", " + foundComp);
7973 }
7974 comp = foundComp;
7975 }
7976 return comp;
7977 }
7978
7979 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007980 * Set the general action to be performed.
7981 *
7982 * @param action An action name, such as ACTION_VIEW. Application-specific
7983 * actions should be prefixed with the vendor's package name.
7984 *
7985 * @return Returns the same Intent object, for chaining multiple calls
7986 * into a single statement.
7987 *
7988 * @see #getAction
7989 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007990 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007991 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007992 return this;
7993 }
7994
7995 /**
7996 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007997 * clears any type that was previously set by {@link #setType} or
7998 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007999 *
Nick Pellyccae4122012-01-09 14:12:58 -08008000 * <p><em>Note: scheme matching in the Android framework is
8001 * case-sensitive, unlike the formal RFC. As a result,
8002 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008003 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008004 * {@link #setDataAndNormalize}
8005 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008006 *
Nick Pellyccae4122012-01-09 14:12:58 -08008007 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008008 *
8009 * @return Returns the same Intent object, for chaining multiple calls
8010 * into a single statement.
8011 *
8012 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008013 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008014 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008015 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008016 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008017 mData = data;
8018 mType = null;
8019 return this;
8020 }
8021
8022 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008023 * Normalize and set the data this intent is operating on.
8024 *
8025 * <p>This method automatically clears any type that was
8026 * previously set (for example, by {@link #setType}).
8027 *
8028 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008029 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008030 * so really this is just a convenience method for
8031 * <pre>
8032 * setData(data.normalize())
8033 * </pre>
8034 *
8035 * @param data The Uri of the data this intent is now targeting.
8036 *
8037 * @return Returns the same Intent object, for chaining multiple calls
8038 * into a single statement.
8039 *
8040 * @see #getData
8041 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008042 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008043 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008044 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008045 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008046 }
8047
8048 /**
8049 * Set an explicit MIME data type.
8050 *
8051 * <p>This is used to create intents that only specify a type and not data,
8052 * for example to indicate the type of data to return.
8053 *
8054 * <p>This method automatically clears any data that was
8055 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008056 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008057 * <p><em>Note: MIME type matching in the Android framework is
8058 * case-sensitive, unlike formal RFC MIME types. As a result,
8059 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008060 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8061 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008062 *
8063 * @param type The MIME type of the data being handled by this intent.
8064 *
8065 * @return Returns the same Intent object, for chaining multiple calls
8066 * into a single statement.
8067 *
8068 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008069 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008071 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008072 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008073 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008074 mData = null;
8075 mType = type;
8076 return this;
8077 }
8078
8079 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008080 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008081 *
Nick Pellyccae4122012-01-09 14:12:58 -08008082 * <p>This is used to create intents that only specify a type and not data,
8083 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008084 *
Nick Pellyccae4122012-01-09 14:12:58 -08008085 * <p>This method automatically clears any data that was
8086 * previously set (for example by {@link #setData}).
8087 *
8088 * <p>The MIME type is normalized using
8089 * {@link #normalizeMimeType} before it is set,
8090 * so really this is just a convenience method for
8091 * <pre>
8092 * setType(Intent.normalizeMimeType(type))
8093 * </pre>
8094 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008095 * @param type The MIME type of the data being handled by this intent.
8096 *
8097 * @return Returns the same Intent object, for chaining multiple calls
8098 * into a single statement.
8099 *
Nick Pellyccae4122012-01-09 14:12:58 -08008100 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008101 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008102 * @see #normalizeMimeType
8103 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008104 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008105 return setType(normalizeMimeType(type));
8106 }
8107
8108 /**
8109 * (Usually optional) Set the data for the intent along with an explicit
8110 * MIME data type. This method should very rarely be used -- it allows you
8111 * to override the MIME type that would ordinarily be inferred from the
8112 * data with your own type given here.
8113 *
8114 * <p><em>Note: MIME type and Uri scheme matching in the
8115 * Android framework is case-sensitive, unlike the formal RFC definitions.
8116 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008117 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008118 * {@link #setDataAndTypeAndNormalize}
8119 * to ensure that they are converted to lower case.</em>
8120 *
8121 * @param data The Uri of the data this intent is now targeting.
8122 * @param type The MIME type of the data being handled by this intent.
8123 *
8124 * @return Returns the same Intent object, for chaining multiple calls
8125 * into a single statement.
8126 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008127 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008128 * @see #setData
8129 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008130 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008131 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008132 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008133 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008134 mData = data;
8135 mType = type;
8136 return this;
8137 }
8138
8139 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008140 * (Usually optional) Normalize and set both the data Uri and an explicit
8141 * MIME data type. This method should very rarely be used -- it allows you
8142 * to override the MIME type that would ordinarily be inferred from the
8143 * data with your own type given here.
8144 *
8145 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008146 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008147 * before they are set, so really this is just a convenience method for
8148 * <pre>
8149 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8150 * </pre>
8151 *
8152 * @param data The Uri of the data this intent is now targeting.
8153 * @param type The MIME type of the data being handled by this intent.
8154 *
8155 * @return Returns the same Intent object, for chaining multiple calls
8156 * into a single statement.
8157 *
8158 * @see #setType
8159 * @see #setData
8160 * @see #setDataAndType
8161 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008162 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008163 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008164 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008165 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008166 }
8167
8168 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008169 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008170 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008171 * activities that provide <em>all</em> of the requested categories will be
8172 * used.
8173 *
8174 * @param category The desired category. This can be either one of the
8175 * predefined Intent categories, or a custom category in your own
8176 * namespace.
8177 *
8178 * @return Returns the same Intent object, for chaining multiple calls
8179 * into a single statement.
8180 *
8181 * @see #hasCategory
8182 * @see #removeCategory
8183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008184 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008185 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008186 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008187 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008188 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008189 return this;
8190 }
8191
8192 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008193 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008194 *
8195 * @param category The category to remove.
8196 *
8197 * @see #addCategory
8198 */
8199 public void removeCategory(String category) {
8200 if (mCategories != null) {
8201 mCategories.remove(category);
8202 if (mCategories.size() == 0) {
8203 mCategories = null;
8204 }
8205 }
8206 }
8207
8208 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008209 * Set a selector for this Intent. This is a modification to the kinds of
8210 * things the Intent will match. If the selector is set, it will be used
8211 * when trying to find entities that can handle the Intent, instead of the
8212 * main contents of the Intent. This allows you build an Intent containing
8213 * a generic protocol while targeting it more specifically.
8214 *
8215 * <p>An example of where this may be used is with things like
8216 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8217 * Intent that will launch the Browser application. However, the correct
8218 * main entry point of an application is actually {@link #ACTION_MAIN}
8219 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8220 * used to specify the actual Activity to launch. If you launch the browser
8221 * with something different, undesired behavior may happen if the user has
8222 * previously or later launches it the normal way, since they do not match.
8223 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8224 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8225 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8226 *
8227 * <p>Setting a selector does not impact the behavior of
8228 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8229 * desired behavior of a selector -- it does not impact the base meaning
8230 * of the Intent, just what kinds of things will be matched against it
8231 * when determining who can handle it.</p>
8232 *
8233 * <p>You can not use both a selector and {@link #setPackage(String)} on
8234 * the same base Intent.</p>
8235 *
8236 * @param selector The desired selector Intent; set to null to not use
8237 * a special selector.
8238 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008239 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008240 if (selector == this) {
8241 throw new IllegalArgumentException(
8242 "Intent being set as a selector of itself");
8243 }
8244 if (selector != null && mPackage != null) {
8245 throw new IllegalArgumentException(
8246 "Can't set selector when package name is already set");
8247 }
8248 mSelector = selector;
8249 }
8250
8251 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008252 * Set a {@link ClipData} associated with this Intent. This replaces any
8253 * previously set ClipData.
8254 *
8255 * <p>The ClipData in an intent is not used for Intent matching or other
8256 * such operations. Semantically it is like extras, used to transmit
8257 * additional data with the Intent. The main feature of using this over
8258 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8259 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8260 * items included in the clip data. This is useful, in particular, if
8261 * you want to transmit an Intent containing multiple <code>content:</code>
8262 * URIs for which the recipient may not have global permission to access the
8263 * content provider.
8264 *
8265 * <p>If the ClipData contains items that are themselves Intents, any
8266 * grant flags in those Intents will be ignored. Only the top-level flags
8267 * of the main Intent are respected, and will be applied to all Uri or
8268 * Intent items in the clip (or sub-items of the clip).
8269 *
8270 * <p>The MIME type, label, and icon in the ClipData object are not
8271 * directly used by Intent. Applications should generally rely on the
8272 * MIME type of the Intent itself, not what it may find in the ClipData.
8273 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008274 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008275 *
8276 * @param clip The new clip to set. May be null to clear the current clip.
8277 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008278 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008279 mClipData = clip;
8280 }
8281
8282 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008283 * This is NOT a secure mechanism to identify the user who sent the intent.
8284 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8285 * who sent the intent.
8286 * @hide
8287 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008288 public void prepareToLeaveUser(int userId) {
8289 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8290 // We want mContentUserHint to refer to the original user, so don't do anything.
8291 if (mContentUserHint == UserHandle.USER_CURRENT) {
8292 mContentUserHint = userId;
8293 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008294 }
8295
8296 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008297 * Add extended data to the intent. The name must include a package
8298 * prefix, for example the app com.android.contacts would use names
8299 * like "com.android.contacts.ShowAll".
8300 *
8301 * @param name The name of the extra data, with package prefix.
8302 * @param value The boolean data value.
8303 *
8304 * @return Returns the same Intent object, for chaining multiple calls
8305 * into a single statement.
8306 *
8307 * @see #putExtras
8308 * @see #removeExtra
8309 * @see #getBooleanExtra(String, boolean)
8310 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008311 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008312 if (mExtras == null) {
8313 mExtras = new Bundle();
8314 }
8315 mExtras.putBoolean(name, value);
8316 return this;
8317 }
8318
8319 /**
8320 * Add extended data to the intent. The name must include a package
8321 * prefix, for example the app com.android.contacts would use names
8322 * like "com.android.contacts.ShowAll".
8323 *
8324 * @param name The name of the extra data, with package prefix.
8325 * @param value The byte data value.
8326 *
8327 * @return Returns the same Intent object, for chaining multiple calls
8328 * into a single statement.
8329 *
8330 * @see #putExtras
8331 * @see #removeExtra
8332 * @see #getByteExtra(String, byte)
8333 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008334 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008335 if (mExtras == null) {
8336 mExtras = new Bundle();
8337 }
8338 mExtras.putByte(name, value);
8339 return this;
8340 }
8341
8342 /**
8343 * Add extended data to the intent. The name must include a package
8344 * prefix, for example the app com.android.contacts would use names
8345 * like "com.android.contacts.ShowAll".
8346 *
8347 * @param name The name of the extra data, with package prefix.
8348 * @param value The char data value.
8349 *
8350 * @return Returns the same Intent object, for chaining multiple calls
8351 * into a single statement.
8352 *
8353 * @see #putExtras
8354 * @see #removeExtra
8355 * @see #getCharExtra(String, char)
8356 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008357 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008358 if (mExtras == null) {
8359 mExtras = new Bundle();
8360 }
8361 mExtras.putChar(name, value);
8362 return this;
8363 }
8364
8365 /**
8366 * Add extended data to the intent. The name must include a package
8367 * prefix, for example the app com.android.contacts would use names
8368 * like "com.android.contacts.ShowAll".
8369 *
8370 * @param name The name of the extra data, with package prefix.
8371 * @param value The short data value.
8372 *
8373 * @return Returns the same Intent object, for chaining multiple calls
8374 * into a single statement.
8375 *
8376 * @see #putExtras
8377 * @see #removeExtra
8378 * @see #getShortExtra(String, short)
8379 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008380 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008381 if (mExtras == null) {
8382 mExtras = new Bundle();
8383 }
8384 mExtras.putShort(name, value);
8385 return this;
8386 }
8387
8388 /**
8389 * Add extended data to the intent. The name must include a package
8390 * prefix, for example the app com.android.contacts would use names
8391 * like "com.android.contacts.ShowAll".
8392 *
8393 * @param name The name of the extra data, with package prefix.
8394 * @param value The integer data value.
8395 *
8396 * @return Returns the same Intent object, for chaining multiple calls
8397 * into a single statement.
8398 *
8399 * @see #putExtras
8400 * @see #removeExtra
8401 * @see #getIntExtra(String, int)
8402 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008403 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008404 if (mExtras == null) {
8405 mExtras = new Bundle();
8406 }
8407 mExtras.putInt(name, value);
8408 return this;
8409 }
8410
8411 /**
8412 * Add extended data to the intent. The name must include a package
8413 * prefix, for example the app com.android.contacts would use names
8414 * like "com.android.contacts.ShowAll".
8415 *
8416 * @param name The name of the extra data, with package prefix.
8417 * @param value The long data value.
8418 *
8419 * @return Returns the same Intent object, for chaining multiple calls
8420 * into a single statement.
8421 *
8422 * @see #putExtras
8423 * @see #removeExtra
8424 * @see #getLongExtra(String, long)
8425 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008426 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008427 if (mExtras == null) {
8428 mExtras = new Bundle();
8429 }
8430 mExtras.putLong(name, value);
8431 return this;
8432 }
8433
8434 /**
8435 * Add extended data to the intent. The name must include a package
8436 * prefix, for example the app com.android.contacts would use names
8437 * like "com.android.contacts.ShowAll".
8438 *
8439 * @param name The name of the extra data, with package prefix.
8440 * @param value The float data value.
8441 *
8442 * @return Returns the same Intent object, for chaining multiple calls
8443 * into a single statement.
8444 *
8445 * @see #putExtras
8446 * @see #removeExtra
8447 * @see #getFloatExtra(String, float)
8448 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008449 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008450 if (mExtras == null) {
8451 mExtras = new Bundle();
8452 }
8453 mExtras.putFloat(name, value);
8454 return this;
8455 }
8456
8457 /**
8458 * Add extended data to the intent. The name must include a package
8459 * prefix, for example the app com.android.contacts would use names
8460 * like "com.android.contacts.ShowAll".
8461 *
8462 * @param name The name of the extra data, with package prefix.
8463 * @param value The double data value.
8464 *
8465 * @return Returns the same Intent object, for chaining multiple calls
8466 * into a single statement.
8467 *
8468 * @see #putExtras
8469 * @see #removeExtra
8470 * @see #getDoubleExtra(String, double)
8471 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008472 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008473 if (mExtras == null) {
8474 mExtras = new Bundle();
8475 }
8476 mExtras.putDouble(name, value);
8477 return this;
8478 }
8479
8480 /**
8481 * Add extended data to the intent. The name must include a package
8482 * prefix, for example the app com.android.contacts would use names
8483 * like "com.android.contacts.ShowAll".
8484 *
8485 * @param name The name of the extra data, with package prefix.
8486 * @param value The String data value.
8487 *
8488 * @return Returns the same Intent object, for chaining multiple calls
8489 * into a single statement.
8490 *
8491 * @see #putExtras
8492 * @see #removeExtra
8493 * @see #getStringExtra(String)
8494 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008495 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008496 if (mExtras == null) {
8497 mExtras = new Bundle();
8498 }
8499 mExtras.putString(name, value);
8500 return this;
8501 }
8502
8503 /**
8504 * Add extended data to the intent. The name must include a package
8505 * prefix, for example the app com.android.contacts would use names
8506 * like "com.android.contacts.ShowAll".
8507 *
8508 * @param name The name of the extra data, with package prefix.
8509 * @param value The CharSequence data value.
8510 *
8511 * @return Returns the same Intent object, for chaining multiple calls
8512 * into a single statement.
8513 *
8514 * @see #putExtras
8515 * @see #removeExtra
8516 * @see #getCharSequenceExtra(String)
8517 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008518 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008519 if (mExtras == null) {
8520 mExtras = new Bundle();
8521 }
8522 mExtras.putCharSequence(name, value);
8523 return this;
8524 }
8525
8526 /**
8527 * Add extended data to the intent. The name must include a package
8528 * prefix, for example the app com.android.contacts would use names
8529 * like "com.android.contacts.ShowAll".
8530 *
8531 * @param name The name of the extra data, with package prefix.
8532 * @param value The Parcelable data value.
8533 *
8534 * @return Returns the same Intent object, for chaining multiple calls
8535 * into a single statement.
8536 *
8537 * @see #putExtras
8538 * @see #removeExtra
8539 * @see #getParcelableExtra(String)
8540 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008541 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008542 if (mExtras == null) {
8543 mExtras = new Bundle();
8544 }
8545 mExtras.putParcelable(name, value);
8546 return this;
8547 }
8548
8549 /**
8550 * Add extended data to the intent. The name must include a package
8551 * prefix, for example the app com.android.contacts would use names
8552 * like "com.android.contacts.ShowAll".
8553 *
8554 * @param name The name of the extra data, with package prefix.
8555 * @param value The Parcelable[] data value.
8556 *
8557 * @return Returns the same Intent object, for chaining multiple calls
8558 * into a single statement.
8559 *
8560 * @see #putExtras
8561 * @see #removeExtra
8562 * @see #getParcelableArrayExtra(String)
8563 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008564 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008565 if (mExtras == null) {
8566 mExtras = new Bundle();
8567 }
8568 mExtras.putParcelableArray(name, value);
8569 return this;
8570 }
8571
8572 /**
8573 * Add extended data to the intent. The name must include a package
8574 * prefix, for example the app com.android.contacts would use names
8575 * like "com.android.contacts.ShowAll".
8576 *
8577 * @param name The name of the extra data, with package prefix.
8578 * @param value The ArrayList<Parcelable> data value.
8579 *
8580 * @return Returns the same Intent object, for chaining multiple calls
8581 * into a single statement.
8582 *
8583 * @see #putExtras
8584 * @see #removeExtra
8585 * @see #getParcelableArrayListExtra(String)
8586 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008587 public @NonNull Intent putParcelableArrayListExtra(String name,
8588 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008589 if (mExtras == null) {
8590 mExtras = new Bundle();
8591 }
8592 mExtras.putParcelableArrayList(name, value);
8593 return this;
8594 }
8595
8596 /**
8597 * Add extended data to the intent. The name must include a package
8598 * prefix, for example the app com.android.contacts would use names
8599 * like "com.android.contacts.ShowAll".
8600 *
8601 * @param name The name of the extra data, with package prefix.
8602 * @param value The ArrayList<Integer> data value.
8603 *
8604 * @return Returns the same Intent object, for chaining multiple calls
8605 * into a single statement.
8606 *
8607 * @see #putExtras
8608 * @see #removeExtra
8609 * @see #getIntegerArrayListExtra(String)
8610 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008611 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008612 if (mExtras == null) {
8613 mExtras = new Bundle();
8614 }
8615 mExtras.putIntegerArrayList(name, value);
8616 return this;
8617 }
8618
8619 /**
8620 * Add extended data to the intent. The name must include a package
8621 * prefix, for example the app com.android.contacts would use names
8622 * like "com.android.contacts.ShowAll".
8623 *
8624 * @param name The name of the extra data, with package prefix.
8625 * @param value The ArrayList<String> data value.
8626 *
8627 * @return Returns the same Intent object, for chaining multiple calls
8628 * into a single statement.
8629 *
8630 * @see #putExtras
8631 * @see #removeExtra
8632 * @see #getStringArrayListExtra(String)
8633 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008634 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008635 if (mExtras == null) {
8636 mExtras = new Bundle();
8637 }
8638 mExtras.putStringArrayList(name, value);
8639 return this;
8640 }
8641
8642 /**
8643 * Add extended data to the intent. The name must include a package
8644 * prefix, for example the app com.android.contacts would use names
8645 * like "com.android.contacts.ShowAll".
8646 *
8647 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008648 * @param value The ArrayList<CharSequence> data value.
8649 *
8650 * @return Returns the same Intent object, for chaining multiple calls
8651 * into a single statement.
8652 *
8653 * @see #putExtras
8654 * @see #removeExtra
8655 * @see #getCharSequenceArrayListExtra(String)
8656 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008657 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8658 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008659 if (mExtras == null) {
8660 mExtras = new Bundle();
8661 }
8662 mExtras.putCharSequenceArrayList(name, value);
8663 return this;
8664 }
8665
8666 /**
8667 * Add extended data to the intent. The name must include a package
8668 * prefix, for example the app com.android.contacts would use names
8669 * like "com.android.contacts.ShowAll".
8670 *
8671 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008672 * @param value The Serializable data value.
8673 *
8674 * @return Returns the same Intent object, for chaining multiple calls
8675 * into a single statement.
8676 *
8677 * @see #putExtras
8678 * @see #removeExtra
8679 * @see #getSerializableExtra(String)
8680 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008681 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008682 if (mExtras == null) {
8683 mExtras = new Bundle();
8684 }
8685 mExtras.putSerializable(name, value);
8686 return this;
8687 }
8688
8689 /**
8690 * Add extended data to the intent. The name must include a package
8691 * prefix, for example the app com.android.contacts would use names
8692 * like "com.android.contacts.ShowAll".
8693 *
8694 * @param name The name of the extra data, with package prefix.
8695 * @param value The boolean array data value.
8696 *
8697 * @return Returns the same Intent object, for chaining multiple calls
8698 * into a single statement.
8699 *
8700 * @see #putExtras
8701 * @see #removeExtra
8702 * @see #getBooleanArrayExtra(String)
8703 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008704 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008705 if (mExtras == null) {
8706 mExtras = new Bundle();
8707 }
8708 mExtras.putBooleanArray(name, value);
8709 return this;
8710 }
8711
8712 /**
8713 * Add extended data to the intent. The name must include a package
8714 * prefix, for example the app com.android.contacts would use names
8715 * like "com.android.contacts.ShowAll".
8716 *
8717 * @param name The name of the extra data, with package prefix.
8718 * @param value The byte array data value.
8719 *
8720 * @return Returns the same Intent object, for chaining multiple calls
8721 * into a single statement.
8722 *
8723 * @see #putExtras
8724 * @see #removeExtra
8725 * @see #getByteArrayExtra(String)
8726 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008727 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008728 if (mExtras == null) {
8729 mExtras = new Bundle();
8730 }
8731 mExtras.putByteArray(name, value);
8732 return this;
8733 }
8734
8735 /**
8736 * Add extended data to the intent. The name must include a package
8737 * prefix, for example the app com.android.contacts would use names
8738 * like "com.android.contacts.ShowAll".
8739 *
8740 * @param name The name of the extra data, with package prefix.
8741 * @param value The short array data value.
8742 *
8743 * @return Returns the same Intent object, for chaining multiple calls
8744 * into a single statement.
8745 *
8746 * @see #putExtras
8747 * @see #removeExtra
8748 * @see #getShortArrayExtra(String)
8749 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008750 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008751 if (mExtras == null) {
8752 mExtras = new Bundle();
8753 }
8754 mExtras.putShortArray(name, value);
8755 return this;
8756 }
8757
8758 /**
8759 * Add extended data to the intent. The name must include a package
8760 * prefix, for example the app com.android.contacts would use names
8761 * like "com.android.contacts.ShowAll".
8762 *
8763 * @param name The name of the extra data, with package prefix.
8764 * @param value The char array data value.
8765 *
8766 * @return Returns the same Intent object, for chaining multiple calls
8767 * into a single statement.
8768 *
8769 * @see #putExtras
8770 * @see #removeExtra
8771 * @see #getCharArrayExtra(String)
8772 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008773 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008774 if (mExtras == null) {
8775 mExtras = new Bundle();
8776 }
8777 mExtras.putCharArray(name, value);
8778 return this;
8779 }
8780
8781 /**
8782 * Add extended data to the intent. The name must include a package
8783 * prefix, for example the app com.android.contacts would use names
8784 * like "com.android.contacts.ShowAll".
8785 *
8786 * @param name The name of the extra data, with package prefix.
8787 * @param value The int array data value.
8788 *
8789 * @return Returns the same Intent object, for chaining multiple calls
8790 * into a single statement.
8791 *
8792 * @see #putExtras
8793 * @see #removeExtra
8794 * @see #getIntArrayExtra(String)
8795 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008796 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008797 if (mExtras == null) {
8798 mExtras = new Bundle();
8799 }
8800 mExtras.putIntArray(name, value);
8801 return this;
8802 }
8803
8804 /**
8805 * Add extended data to the intent. The name must include a package
8806 * prefix, for example the app com.android.contacts would use names
8807 * like "com.android.contacts.ShowAll".
8808 *
8809 * @param name The name of the extra data, with package prefix.
8810 * @param value The byte array data value.
8811 *
8812 * @return Returns the same Intent object, for chaining multiple calls
8813 * into a single statement.
8814 *
8815 * @see #putExtras
8816 * @see #removeExtra
8817 * @see #getLongArrayExtra(String)
8818 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008819 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008820 if (mExtras == null) {
8821 mExtras = new Bundle();
8822 }
8823 mExtras.putLongArray(name, value);
8824 return this;
8825 }
8826
8827 /**
8828 * Add extended data to the intent. The name must include a package
8829 * prefix, for example the app com.android.contacts would use names
8830 * like "com.android.contacts.ShowAll".
8831 *
8832 * @param name The name of the extra data, with package prefix.
8833 * @param value The float array data value.
8834 *
8835 * @return Returns the same Intent object, for chaining multiple calls
8836 * into a single statement.
8837 *
8838 * @see #putExtras
8839 * @see #removeExtra
8840 * @see #getFloatArrayExtra(String)
8841 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008842 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008843 if (mExtras == null) {
8844 mExtras = new Bundle();
8845 }
8846 mExtras.putFloatArray(name, value);
8847 return this;
8848 }
8849
8850 /**
8851 * Add extended data to the intent. The name must include a package
8852 * prefix, for example the app com.android.contacts would use names
8853 * like "com.android.contacts.ShowAll".
8854 *
8855 * @param name The name of the extra data, with package prefix.
8856 * @param value The double array data value.
8857 *
8858 * @return Returns the same Intent object, for chaining multiple calls
8859 * into a single statement.
8860 *
8861 * @see #putExtras
8862 * @see #removeExtra
8863 * @see #getDoubleArrayExtra(String)
8864 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008865 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008866 if (mExtras == null) {
8867 mExtras = new Bundle();
8868 }
8869 mExtras.putDoubleArray(name, value);
8870 return this;
8871 }
8872
8873 /**
8874 * Add extended data to the intent. The name must include a package
8875 * prefix, for example the app com.android.contacts would use names
8876 * like "com.android.contacts.ShowAll".
8877 *
8878 * @param name The name of the extra data, with package prefix.
8879 * @param value The String array data value.
8880 *
8881 * @return Returns the same Intent object, for chaining multiple calls
8882 * into a single statement.
8883 *
8884 * @see #putExtras
8885 * @see #removeExtra
8886 * @see #getStringArrayExtra(String)
8887 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008888 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008889 if (mExtras == null) {
8890 mExtras = new Bundle();
8891 }
8892 mExtras.putStringArray(name, value);
8893 return this;
8894 }
8895
8896 /**
8897 * Add extended data to the intent. The name must include a package
8898 * prefix, for example the app com.android.contacts would use names
8899 * like "com.android.contacts.ShowAll".
8900 *
8901 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008902 * @param value The CharSequence array data value.
8903 *
8904 * @return Returns the same Intent object, for chaining multiple calls
8905 * into a single statement.
8906 *
8907 * @see #putExtras
8908 * @see #removeExtra
8909 * @see #getCharSequenceArrayExtra(String)
8910 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008911 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008912 if (mExtras == null) {
8913 mExtras = new Bundle();
8914 }
8915 mExtras.putCharSequenceArray(name, value);
8916 return this;
8917 }
8918
8919 /**
8920 * Add extended data to the intent. The name must include a package
8921 * prefix, for example the app com.android.contacts would use names
8922 * like "com.android.contacts.ShowAll".
8923 *
8924 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008925 * @param value The Bundle data value.
8926 *
8927 * @return Returns the same Intent object, for chaining multiple calls
8928 * into a single statement.
8929 *
8930 * @see #putExtras
8931 * @see #removeExtra
8932 * @see #getBundleExtra(String)
8933 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008934 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008935 if (mExtras == null) {
8936 mExtras = new Bundle();
8937 }
8938 mExtras.putBundle(name, value);
8939 return this;
8940 }
8941
8942 /**
8943 * Add extended data to the intent. The name must include a package
8944 * prefix, for example the app com.android.contacts would use names
8945 * like "com.android.contacts.ShowAll".
8946 *
8947 * @param name The name of the extra data, with package prefix.
8948 * @param value The IBinder data value.
8949 *
8950 * @return Returns the same Intent object, for chaining multiple calls
8951 * into a single statement.
8952 *
8953 * @see #putExtras
8954 * @see #removeExtra
8955 * @see #getIBinderExtra(String)
8956 *
8957 * @deprecated
8958 * @hide
8959 */
8960 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008961 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008962 if (mExtras == null) {
8963 mExtras = new Bundle();
8964 }
8965 mExtras.putIBinder(name, value);
8966 return this;
8967 }
8968
8969 /**
8970 * Copy all extras in 'src' in to this intent.
8971 *
8972 * @param src Contains the extras to copy.
8973 *
8974 * @see #putExtra
8975 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008976 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008977 if (src.mExtras != null) {
8978 if (mExtras == null) {
8979 mExtras = new Bundle(src.mExtras);
8980 } else {
8981 mExtras.putAll(src.mExtras);
8982 }
8983 }
8984 return this;
8985 }
8986
8987 /**
8988 * Add a set of extended data to the intent. The keys must include a package
8989 * prefix, for example the app com.android.contacts would use names
8990 * like "com.android.contacts.ShowAll".
8991 *
8992 * @param extras The Bundle of extras to add to this intent.
8993 *
8994 * @see #putExtra
8995 * @see #removeExtra
8996 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008997 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008998 if (mExtras == null) {
8999 mExtras = new Bundle();
9000 }
9001 mExtras.putAll(extras);
9002 return this;
9003 }
9004
9005 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009006 * Completely replace the extras in the Intent with the extras in the
9007 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009008 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009009 * @param src The exact extras contained in this Intent are copied
9010 * into the target intent, replacing any that were previously there.
9011 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009012 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009013 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9014 return this;
9015 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009016
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009017 /**
9018 * Completely replace the extras in the Intent with the given Bundle of
9019 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009020 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009021 * @param extras The new set of extras in the Intent, or null to erase
9022 * all extras.
9023 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009024 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009025 mExtras = extras != null ? new Bundle(extras) : null;
9026 return this;
9027 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009028
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009029 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009030 * Remove extended data from the intent.
9031 *
9032 * @see #putExtra
9033 */
9034 public void removeExtra(String name) {
9035 if (mExtras != null) {
9036 mExtras.remove(name);
9037 if (mExtras.size() == 0) {
9038 mExtras = null;
9039 }
9040 }
9041 }
9042
9043 /**
9044 * Set special flags controlling how this intent is handled. Most values
9045 * here depend on the type of component being executed by the Intent,
9046 * specifically the FLAG_ACTIVITY_* flags are all for use with
9047 * {@link Context#startActivity Context.startActivity()} and the
9048 * FLAG_RECEIVER_* flags are all for use with
9049 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9050 *
Scott Main7aee61f2011-02-08 11:25:01 -08009051 * <p>See the
9052 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9053 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009054 * the behavior of your application.
9055 *
9056 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009057 * @return Returns the same Intent object, for chaining multiple calls
9058 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009059 * @see #getFlags
9060 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009061 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009062 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009063 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009064 mFlags = flags;
9065 return this;
9066 }
9067
9068 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009069 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009070 *
9071 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009072 * @return Returns the same Intent object, for chaining multiple calls into
9073 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009074 * @see #setFlags
9075 * @see #getFlags
9076 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009077 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009078 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009079 mFlags |= flags;
9080 return this;
9081 }
9082
9083 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009084 * Remove these flags from the intent.
9085 *
9086 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009087 * @see #setFlags
9088 * @see #getFlags
9089 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009090 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009091 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009092 mFlags &= ~flags;
9093 }
9094
9095 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009096 * (Usually optional) Set an explicit application package name that limits
9097 * the components this Intent will resolve to. If left to the default
9098 * value of null, all components in all applications will considered.
9099 * If non-null, the Intent can only match the components in the given
9100 * application package.
9101 *
9102 * @param packageName The name of the application package to handle the
9103 * intent, or null to allow any application package.
9104 *
9105 * @return Returns the same Intent object, for chaining multiple calls
9106 * into a single statement.
9107 *
9108 * @see #getPackage
9109 * @see #resolveActivity
9110 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009111 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009112 if (packageName != null && mSelector != null) {
9113 throw new IllegalArgumentException(
9114 "Can't set package name when selector is already set");
9115 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009116 mPackage = packageName;
9117 return this;
9118 }
9119
9120 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009121 * (Usually optional) Explicitly set the component to handle the intent.
9122 * If left with the default value of null, the system will determine the
9123 * appropriate class to use based on the other fields (action, data,
9124 * type, categories) in the Intent. If this class is defined, the
9125 * specified class will always be used regardless of the other fields. You
9126 * should only set this value when you know you absolutely want a specific
9127 * class to be used; otherwise it is better to let the system find the
9128 * appropriate class so that you will respect the installed applications
9129 * and user preferences.
9130 *
9131 * @param component The name of the application component to handle the
9132 * intent, or null to let the system find one for you.
9133 *
9134 * @return Returns the same Intent object, for chaining multiple calls
9135 * into a single statement.
9136 *
9137 * @see #setClass
9138 * @see #setClassName(Context, String)
9139 * @see #setClassName(String, String)
9140 * @see #getComponent
9141 * @see #resolveActivity
9142 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009143 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009144 mComponent = component;
9145 return this;
9146 }
9147
9148 /**
9149 * Convenience for calling {@link #setComponent} with an
9150 * explicit class name.
9151 *
9152 * @param packageContext A Context of the application package implementing
9153 * this class.
9154 * @param className The name of a class inside of the application package
9155 * that will be used as the component for this Intent.
9156 *
9157 * @return Returns the same Intent object, for chaining multiple calls
9158 * into a single statement.
9159 *
9160 * @see #setComponent
9161 * @see #setClass
9162 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009163 public @NonNull Intent setClassName(@NonNull Context packageContext,
9164 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009165 mComponent = new ComponentName(packageContext, className);
9166 return this;
9167 }
9168
9169 /**
9170 * Convenience for calling {@link #setComponent} with an
9171 * explicit application package name and class name.
9172 *
9173 * @param packageName The name of the package implementing the desired
9174 * component.
9175 * @param className The name of a class inside of the application package
9176 * that will be used as the component for this Intent.
9177 *
9178 * @return Returns the same Intent object, for chaining multiple calls
9179 * into a single statement.
9180 *
9181 * @see #setComponent
9182 * @see #setClass
9183 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009184 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009185 mComponent = new ComponentName(packageName, className);
9186 return this;
9187 }
9188
9189 /**
9190 * Convenience for calling {@link #setComponent(ComponentName)} with the
9191 * name returned by a {@link Class} object.
9192 *
9193 * @param packageContext A Context of the application package implementing
9194 * this class.
9195 * @param cls The class name to set, equivalent to
9196 * <code>setClassName(context, cls.getName())</code>.
9197 *
9198 * @return Returns the same Intent object, for chaining multiple calls
9199 * into a single statement.
9200 *
9201 * @see #setComponent
9202 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009203 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009204 mComponent = new ComponentName(packageContext, cls);
9205 return this;
9206 }
9207
9208 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009209 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9210 * used as a hint to the receiver for animations and the like. Null means that there
9211 * is no source bounds.
9212 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009213 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009214 if (r != null) {
9215 mSourceBounds = new Rect(r);
9216 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009217 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009218 }
9219 }
9220
Tor Norbyed9273d62013-05-30 15:59:53 -07009221 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009222 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9223 FILL_IN_ACTION,
9224 FILL_IN_DATA,
9225 FILL_IN_CATEGORIES,
9226 FILL_IN_COMPONENT,
9227 FILL_IN_PACKAGE,
9228 FILL_IN_SOURCE_BOUNDS,
9229 FILL_IN_SELECTOR,
9230 FILL_IN_CLIP_DATA
9231 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009232 @Retention(RetentionPolicy.SOURCE)
9233 public @interface FillInFlags {}
9234
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009235 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009236 * Use with {@link #fillIn} to allow the current action value to be
9237 * overwritten, even if it is already set.
9238 */
9239 public static final int FILL_IN_ACTION = 1<<0;
9240
9241 /**
9242 * Use with {@link #fillIn} to allow the current data or type value
9243 * overwritten, even if it is already set.
9244 */
9245 public static final int FILL_IN_DATA = 1<<1;
9246
9247 /**
9248 * Use with {@link #fillIn} to allow the current categories to be
9249 * overwritten, even if they are already set.
9250 */
9251 public static final int FILL_IN_CATEGORIES = 1<<2;
9252
9253 /**
9254 * Use with {@link #fillIn} to allow the current component value to be
9255 * overwritten, even if it is already set.
9256 */
9257 public static final int FILL_IN_COMPONENT = 1<<3;
9258
9259 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009260 * Use with {@link #fillIn} to allow the current package value to be
9261 * overwritten, even if it is already set.
9262 */
9263 public static final int FILL_IN_PACKAGE = 1<<4;
9264
9265 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009266 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009267 * overwritten, even if it is already set.
9268 */
9269 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9270
9271 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009272 * Use with {@link #fillIn} to allow the current selector to be
9273 * overwritten, even if it is already set.
9274 */
9275 public static final int FILL_IN_SELECTOR = 1<<6;
9276
9277 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009278 * Use with {@link #fillIn} to allow the current ClipData to be
9279 * overwritten, even if it is already set.
9280 */
9281 public static final int FILL_IN_CLIP_DATA = 1<<7;
9282
9283 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009284 * Copy the contents of <var>other</var> in to this object, but only
9285 * where fields are not defined by this object. For purposes of a field
9286 * being defined, the following pieces of data in the Intent are
9287 * considered to be separate fields:
9288 *
9289 * <ul>
9290 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009291 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009292 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9293 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009294 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009295 * <li> component, as set by {@link #setComponent(ComponentName)} or
9296 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009297 * <li> source bounds, as set by {@link #setSourceBounds}.
9298 * <li> selector, as set by {@link #setSelector(Intent)}.
9299 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009300 * <li> each top-level name in the associated extras.
9301 * </ul>
9302 *
9303 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009304 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009305 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9306 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9307 * the restriction where the corresponding field will not be replaced if
9308 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009309 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009310 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9311 * is explicitly specified. The selector will only be copied if
9312 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009313 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009314 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9315 * and Intent B with {action="gotit", data-type="some/thing",
9316 * categories="one","two"}.
9317 *
9318 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9319 * containing: {action="gotit", data-type="some/thing",
9320 * categories="bar"}.
9321 *
9322 * @param other Another Intent whose values are to be used to fill in
9323 * the current one.
9324 * @param flags Options to control which fields can be filled in.
9325 *
9326 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009327 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009328 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009329 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009330 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009331 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009332 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009333 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009334 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009335 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009336 if (other.mAction != null
9337 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009338 mAction = other.mAction;
9339 changes |= FILL_IN_ACTION;
9340 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009341 if ((other.mData != null || other.mType != null)
9342 && ((mData == null && mType == null)
9343 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009344 mData = other.mData;
9345 mType = other.mType;
9346 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009347 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009348 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009349 if (other.mCategories != null
9350 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009351 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009352 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009353 }
9354 changes |= FILL_IN_CATEGORIES;
9355 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009356 if (other.mPackage != null
9357 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009358 // Only do this if mSelector is not set.
9359 if (mSelector == null) {
9360 mPackage = other.mPackage;
9361 changes |= FILL_IN_PACKAGE;
9362 }
9363 }
9364 // Selector is special: it can only be set if explicitly allowed,
9365 // for the same reason as the component name.
9366 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9367 if (mPackage == null) {
9368 mSelector = new Intent(other.mSelector);
9369 mPackage = null;
9370 changes |= FILL_IN_SELECTOR;
9371 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009372 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009373 if (other.mClipData != null
9374 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9375 mClipData = other.mClipData;
9376 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009377 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009378 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009379 // Component is special: it can -only- be set if explicitly allowed,
9380 // since otherwise the sender could force the intent somewhere the
9381 // originator didn't intend.
9382 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009383 mComponent = other.mComponent;
9384 changes |= FILL_IN_COMPONENT;
9385 }
9386 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009387 if (other.mSourceBounds != null
9388 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9389 mSourceBounds = new Rect(other.mSourceBounds);
9390 changes |= FILL_IN_SOURCE_BOUNDS;
9391 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009392 if (mExtras == null) {
9393 if (other.mExtras != null) {
9394 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009395 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009396 }
9397 } else if (other.mExtras != null) {
9398 try {
9399 Bundle newb = new Bundle(other.mExtras);
9400 newb.putAll(mExtras);
9401 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009402 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009403 } catch (RuntimeException e) {
9404 // Modifying the extras can cause us to unparcel the contents
9405 // of the bundle, and if we do this in the system process that
9406 // may fail. We really should handle this (i.e., the Bundle
9407 // impl shouldn't be on top of a plain map), but for now just
9408 // ignore it and keep the original contents. :(
9409 Log.w("Intent", "Failure filling in extras", e);
9410 }
9411 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009412 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9413 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9414 mContentUserHint = other.mContentUserHint;
9415 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009416 return changes;
9417 }
9418
9419 /**
9420 * Wrapper class holding an Intent and implementing comparisons on it for
9421 * the purpose of filtering. The class implements its
9422 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9423 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9424 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9425 * on the wrapped Intent.
9426 */
9427 public static final class FilterComparison {
9428 private final Intent mIntent;
9429 private final int mHashCode;
9430
9431 public FilterComparison(Intent intent) {
9432 mIntent = intent;
9433 mHashCode = intent.filterHashCode();
9434 }
9435
9436 /**
9437 * Return the Intent that this FilterComparison represents.
9438 * @return Returns the Intent held by the FilterComparison. Do
9439 * not modify!
9440 */
9441 public Intent getIntent() {
9442 return mIntent;
9443 }
9444
9445 @Override
9446 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009447 if (obj instanceof FilterComparison) {
9448 Intent other = ((FilterComparison)obj).mIntent;
9449 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009450 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009451 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009452 }
9453
9454 @Override
9455 public int hashCode() {
9456 return mHashCode;
9457 }
9458 }
9459
9460 /**
9461 * Determine if two intents are the same for the purposes of intent
9462 * resolution (filtering). That is, if their action, data, type,
9463 * class, and categories are the same. This does <em>not</em> compare
9464 * any extra data included in the intents.
9465 *
9466 * @param other The other Intent to compare against.
9467 *
9468 * @return Returns true if action, data, type, class, and categories
9469 * are the same.
9470 */
9471 public boolean filterEquals(Intent other) {
9472 if (other == null) {
9473 return false;
9474 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009475 if (!Objects.equals(this.mAction, other.mAction)) return false;
9476 if (!Objects.equals(this.mData, other.mData)) return false;
9477 if (!Objects.equals(this.mType, other.mType)) return false;
9478 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9479 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9480 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009481
9482 return true;
9483 }
9484
9485 /**
9486 * Generate hash code that matches semantics of filterEquals().
9487 *
9488 * @return Returns the hash value of the action, data, type, class, and
9489 * categories.
9490 *
9491 * @see #filterEquals
9492 */
9493 public int filterHashCode() {
9494 int code = 0;
9495 if (mAction != null) {
9496 code += mAction.hashCode();
9497 }
9498 if (mData != null) {
9499 code += mData.hashCode();
9500 }
9501 if (mType != null) {
9502 code += mType.hashCode();
9503 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009504 if (mPackage != null) {
9505 code += mPackage.hashCode();
9506 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009507 if (mComponent != null) {
9508 code += mComponent.hashCode();
9509 }
9510 if (mCategories != null) {
9511 code += mCategories.hashCode();
9512 }
9513 return code;
9514 }
9515
9516 @Override
9517 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009518 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009519
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009520 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009521 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009522 b.append(" }");
9523
9524 return b.toString();
9525 }
9526
9527 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009528 public String toInsecureString() {
9529 StringBuilder b = new StringBuilder(128);
9530
9531 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009532 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009533 b.append(" }");
9534
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009535 return b.toString();
9536 }
Romain Guy4969af72009-06-17 10:53:19 -07009537
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009538 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009539 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009540 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009541
9542 b.append("Intent { ");
9543 toShortString(b, false, true, true, true);
9544 b.append(" }");
9545
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009546 return b.toString();
9547 }
9548
9549 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009550 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9551 StringBuilder b = new StringBuilder(128);
9552 toShortString(b, secure, comp, extras, clip);
9553 return b.toString();
9554 }
9555
9556 /** @hide */
9557 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9558 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009559 boolean first = true;
9560 if (mAction != null) {
9561 b.append("act=").append(mAction);
9562 first = false;
9563 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009564 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009565 if (!first) {
9566 b.append(' ');
9567 }
9568 first = false;
9569 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009570 for (int i=0; i<mCategories.size(); i++) {
9571 if (i > 0) b.append(',');
9572 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009573 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009574 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009575 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009576 if (mData != null) {
9577 if (!first) {
9578 b.append(' ');
9579 }
9580 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009581 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009582 if (secure) {
9583 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009584 } else {
9585 b.append(mData);
9586 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009587 }
9588 if (mType != null) {
9589 if (!first) {
9590 b.append(' ');
9591 }
9592 first = false;
9593 b.append("typ=").append(mType);
9594 }
9595 if (mFlags != 0) {
9596 if (!first) {
9597 b.append(' ');
9598 }
9599 first = false;
9600 b.append("flg=0x").append(Integer.toHexString(mFlags));
9601 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009602 if (mPackage != null) {
9603 if (!first) {
9604 b.append(' ');
9605 }
9606 first = false;
9607 b.append("pkg=").append(mPackage);
9608 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009609 if (comp && mComponent != null) {
9610 if (!first) {
9611 b.append(' ');
9612 }
9613 first = false;
9614 b.append("cmp=").append(mComponent.flattenToShortString());
9615 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009616 if (mSourceBounds != null) {
9617 if (!first) {
9618 b.append(' ');
9619 }
9620 first = false;
9621 b.append("bnds=").append(mSourceBounds.toShortString());
9622 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009623 if (mClipData != null) {
9624 if (!first) {
9625 b.append(' ');
9626 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009627 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009628 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009629 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009630 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009631 if (mClipData.getDescription() != null) {
9632 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9633 } else {
9634 first = true;
9635 }
9636 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009637 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009638 first = false;
9639 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009640 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009641 if (extras && mExtras != null) {
9642 if (!first) {
9643 b.append(' ');
9644 }
9645 first = false;
9646 b.append("(has extras)");
9647 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009648 if (mContentUserHint != UserHandle.USER_CURRENT) {
9649 if (!first) {
9650 b.append(' ');
9651 }
9652 first = false;
9653 b.append("u=").append(mContentUserHint);
9654 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009655 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009656 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009657 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009658 b.append("}");
9659 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009660 }
9661
Yi Jin129fc6c2017-09-28 15:48:38 -07009662 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009663 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9664 // Same input parameters that toString() gives to toShortString().
9665 writeToProto(proto, fieldId, true, true, true, false);
9666 }
9667
9668 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009669 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9670 boolean extras, boolean clip) {
9671 long token = proto.start(fieldId);
9672 if (mAction != null) {
9673 proto.write(IntentProto.ACTION, mAction);
9674 }
9675 if (mCategories != null) {
9676 for (String category : mCategories) {
9677 proto.write(IntentProto.CATEGORIES, category);
9678 }
9679 }
9680 if (mData != null) {
9681 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9682 }
9683 if (mType != null) {
9684 proto.write(IntentProto.TYPE, mType);
9685 }
9686 if (mFlags != 0) {
9687 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9688 }
9689 if (mPackage != null) {
9690 proto.write(IntentProto.PACKAGE, mPackage);
9691 }
9692 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009693 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009694 }
9695 if (mSourceBounds != null) {
9696 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9697 }
9698 if (mClipData != null) {
9699 StringBuilder b = new StringBuilder();
9700 if (clip) {
9701 mClipData.toShortString(b);
9702 } else {
9703 mClipData.toShortStringShortItems(b, false);
9704 }
9705 proto.write(IntentProto.CLIP_DATA, b.toString());
9706 }
9707 if (extras && mExtras != null) {
9708 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9709 }
9710 if (mContentUserHint != 0) {
9711 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9712 }
9713 if (mSelector != null) {
9714 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9715 }
9716 proto.end(token);
9717 }
9718
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009719 /**
9720 * Call {@link #toUri} with 0 flags.
9721 * @deprecated Use {@link #toUri} instead.
9722 */
9723 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009724 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009725 return toUri(0);
9726 }
9727
9728 /**
9729 * Convert this Intent into a String holding a URI representation of it.
9730 * The returned URI string has been properly URI encoded, so it can be
9731 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9732 * Intent's data as the base URI, with an additional fragment describing
9733 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009734 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009735 * <p>You can convert the returned string back to an Intent with
9736 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009737 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009738 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009739 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009740 * @return Returns a URI encoding URI string describing the entire contents
9741 * of the Intent.
9742 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009743 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009744 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009745 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9746 if (mPackage == null) {
9747 throw new IllegalArgumentException(
9748 "Intent must include an explicit package name to build an android-app: "
9749 + this);
9750 }
9751 uri.append("android-app://");
9752 uri.append(mPackage);
9753 String scheme = null;
9754 if (mData != null) {
9755 scheme = mData.getScheme();
9756 if (scheme != null) {
9757 uri.append('/');
9758 uri.append(scheme);
9759 String authority = mData.getEncodedAuthority();
9760 if (authority != null) {
9761 uri.append('/');
9762 uri.append(authority);
9763 String path = mData.getEncodedPath();
9764 if (path != null) {
9765 uri.append(path);
9766 }
9767 String queryParams = mData.getEncodedQuery();
9768 if (queryParams != null) {
9769 uri.append('?');
9770 uri.append(queryParams);
9771 }
9772 String fragment = mData.getEncodedFragment();
9773 if (fragment != null) {
9774 uri.append('#');
9775 uri.append(fragment);
9776 }
9777 }
9778 }
9779 }
9780 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9781 mPackage, flags);
9782 return uri.toString();
9783 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009784 String scheme = null;
9785 if (mData != null) {
9786 String data = mData.toString();
9787 if ((flags&URI_INTENT_SCHEME) != 0) {
9788 final int N = data.length();
9789 for (int i=0; i<N; i++) {
9790 char c = data.charAt(i);
9791 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009792 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009793 continue;
9794 }
9795 if (c == ':' && i > 0) {
9796 // Valid scheme.
9797 scheme = data.substring(0, i);
9798 uri.append("intent:");
9799 data = data.substring(i+1);
9800 break;
9801 }
Tom Taylord4a47292009-12-21 13:59:18 -08009802
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009803 // No scheme.
9804 break;
9805 }
9806 }
9807 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009808
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009809 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9810 uri.append("intent:");
9811 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009812
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009813 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009814
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009815 return uri.toString();
9816 }
9817
9818 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9819 String defPackage, int flags) {
9820 StringBuilder frag = new StringBuilder(128);
9821
9822 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009823 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009824 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009825 // Note that for now we are not going to try to handle the
9826 // data part; not clear how to represent this as a URI, and
9827 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009828 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9829 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009830 }
9831
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009832 if (frag.length() > 0) {
9833 uri.append("#Intent;");
9834 uri.append(frag);
9835 uri.append("end");
9836 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009837 }
9838
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009839 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9840 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009841 if (scheme != null) {
9842 uri.append("scheme=").append(scheme).append(';');
9843 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009844 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009845 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009846 }
9847 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009848 for (int i=0; i<mCategories.size(); i++) {
9849 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009850 }
9851 }
9852 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009853 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009854 }
9855 if (mFlags != 0) {
9856 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9857 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009858 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009859 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9860 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009861 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009862 uri.append("component=").append(Uri.encode(
9863 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009864 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009865 if (mSourceBounds != null) {
9866 uri.append("sourceBounds=")
9867 .append(Uri.encode(mSourceBounds.flattenToString()))
9868 .append(';');
9869 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009870 if (mExtras != null) {
9871 for (String key : mExtras.keySet()) {
9872 final Object value = mExtras.get(key);
9873 char entryType =
9874 value instanceof String ? 'S' :
9875 value instanceof Boolean ? 'B' :
9876 value instanceof Byte ? 'b' :
9877 value instanceof Character ? 'c' :
9878 value instanceof Double ? 'd' :
9879 value instanceof Float ? 'f' :
9880 value instanceof Integer ? 'i' :
9881 value instanceof Long ? 'l' :
9882 value instanceof Short ? 's' :
9883 '\0';
9884
9885 if (entryType != '\0') {
9886 uri.append(entryType);
9887 uri.append('.');
9888 uri.append(Uri.encode(key));
9889 uri.append('=');
9890 uri.append(Uri.encode(value.toString()));
9891 uri.append(';');
9892 }
9893 }
9894 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009895 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009896
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009897 public int describeContents() {
9898 return (mExtras != null) ? mExtras.describeContents() : 0;
9899 }
9900
9901 public void writeToParcel(Parcel out, int flags) {
9902 out.writeString(mAction);
9903 Uri.writeToParcel(out, mData);
9904 out.writeString(mType);
9905 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009906 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009907 ComponentName.writeToParcel(mComponent, out);
9908
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009909 if (mSourceBounds != null) {
9910 out.writeInt(1);
9911 mSourceBounds.writeToParcel(out, flags);
9912 } else {
9913 out.writeInt(0);
9914 }
9915
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009916 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009917 final int N = mCategories.size();
9918 out.writeInt(N);
9919 for (int i=0; i<N; i++) {
9920 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009921 }
9922 } else {
9923 out.writeInt(0);
9924 }
9925
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009926 if (mSelector != null) {
9927 out.writeInt(1);
9928 mSelector.writeToParcel(out, flags);
9929 } else {
9930 out.writeInt(0);
9931 }
9932
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009933 if (mClipData != null) {
9934 out.writeInt(1);
9935 mClipData.writeToParcel(out, flags);
9936 } else {
9937 out.writeInt(0);
9938 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009939 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009940 out.writeBundle(mExtras);
9941 }
9942
9943 public static final Parcelable.Creator<Intent> CREATOR
9944 = new Parcelable.Creator<Intent>() {
9945 public Intent createFromParcel(Parcel in) {
9946 return new Intent(in);
9947 }
9948 public Intent[] newArray(int size) {
9949 return new Intent[size];
9950 }
9951 };
9952
Dianne Hackborneb034652009-09-07 00:49:58 -07009953 /** @hide */
9954 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009955 readFromParcel(in);
9956 }
9957
9958 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009959 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009960 mData = Uri.CREATOR.createFromParcel(in);
9961 mType = in.readString();
9962 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009963 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009964 mComponent = ComponentName.readFromParcel(in);
9965
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009966 if (in.readInt() != 0) {
9967 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9968 }
9969
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009970 int N = in.readInt();
9971 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009972 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009973 int i;
9974 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009975 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009976 }
9977 } else {
9978 mCategories = null;
9979 }
9980
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009981 if (in.readInt() != 0) {
9982 mSelector = new Intent(in);
9983 }
9984
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009985 if (in.readInt() != 0) {
9986 mClipData = new ClipData(in);
9987 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009988 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009989 mExtras = in.readBundle();
9990 }
9991
9992 /**
9993 * Parses the "intent" element (and its children) from XML and instantiates
9994 * an Intent object. The given XML parser should be located at the tag
9995 * where parsing should start (often named "intent"), from which the
9996 * basic action, data, type, and package and class name will be
9997 * retrieved. The function will then parse in to any child elements,
9998 * looking for <category android:name="xxx"> tags to add categories and
9999 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10000 * to the intent.
10001 *
10002 * @param resources The Resources to use when inflating resources.
10003 * @param parser The XML parser pointing at an "intent" tag.
10004 * @param attrs The AttributeSet interface for retrieving extended
10005 * attribute data at the current <var>parser</var> location.
10006 * @return An Intent object matching the XML data.
10007 * @throws XmlPullParserException If there was an XML parsing error.
10008 * @throws IOException If there was an I/O error.
10009 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010010 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10011 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010012 throws XmlPullParserException, IOException {
10013 Intent intent = new Intent();
10014
10015 TypedArray sa = resources.obtainAttributes(attrs,
10016 com.android.internal.R.styleable.Intent);
10017
10018 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10019
10020 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10021 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10022 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10023
10024 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10025 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10026 if (packageName != null && className != null) {
10027 intent.setComponent(new ComponentName(packageName, className));
10028 }
10029
10030 sa.recycle();
10031
10032 int outerDepth = parser.getDepth();
10033 int type;
10034 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10035 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10036 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10037 continue;
10038 }
10039
10040 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010041 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010042 sa = resources.obtainAttributes(attrs,
10043 com.android.internal.R.styleable.IntentCategory);
10044 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10045 sa.recycle();
10046
10047 if (cat != null) {
10048 intent.addCategory(cat);
10049 }
10050 XmlUtils.skipCurrentTag(parser);
10051
Craig Mautner21d24a22014-04-23 11:45:37 -070010052 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010053 if (intent.mExtras == null) {
10054 intent.mExtras = new Bundle();
10055 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010056 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010057 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010058
10059 } else {
10060 XmlUtils.skipCurrentTag(parser);
10061 }
10062 }
10063
10064 return intent;
10065 }
Nick Pellyccae4122012-01-09 14:12:58 -080010066
Craig Mautner21d24a22014-04-23 11:45:37 -070010067 /** @hide */
10068 public void saveToXml(XmlSerializer out) throws IOException {
10069 if (mAction != null) {
10070 out.attribute(null, ATTR_ACTION, mAction);
10071 }
10072 if (mData != null) {
10073 out.attribute(null, ATTR_DATA, mData.toString());
10074 }
10075 if (mType != null) {
10076 out.attribute(null, ATTR_TYPE, mType);
10077 }
10078 if (mComponent != null) {
10079 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10080 }
10081 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10082
10083 if (mCategories != null) {
10084 out.startTag(null, TAG_CATEGORIES);
10085 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10086 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10087 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010088 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010089 }
10090 }
10091
10092 /** @hide */
10093 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10094 XmlPullParserException {
10095 Intent intent = new Intent();
10096 final int outerDepth = in.getDepth();
10097
10098 int attrCount = in.getAttributeCount();
10099 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10100 final String attrName = in.getAttributeName(attrNdx);
10101 final String attrValue = in.getAttributeValue(attrNdx);
10102 if (ATTR_ACTION.equals(attrName)) {
10103 intent.setAction(attrValue);
10104 } else if (ATTR_DATA.equals(attrName)) {
10105 intent.setData(Uri.parse(attrValue));
10106 } else if (ATTR_TYPE.equals(attrName)) {
10107 intent.setType(attrValue);
10108 } else if (ATTR_COMPONENT.equals(attrName)) {
10109 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10110 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010111 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010112 } else {
10113 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10114 }
10115 }
10116
10117 int event;
10118 String name;
10119 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10120 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10121 if (event == XmlPullParser.START_TAG) {
10122 name = in.getName();
10123 if (TAG_CATEGORIES.equals(name)) {
10124 attrCount = in.getAttributeCount();
10125 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10126 intent.addCategory(in.getAttributeValue(attrNdx));
10127 }
10128 } else {
10129 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10130 XmlUtils.skipCurrentTag(in);
10131 }
10132 }
10133 }
10134
10135 return intent;
10136 }
10137
Nick Pellyccae4122012-01-09 14:12:58 -080010138 /**
10139 * Normalize a MIME data type.
10140 *
10141 * <p>A normalized MIME type has white-space trimmed,
10142 * content-type parameters removed, and is lower-case.
10143 * This aligns the type with Android best practices for
10144 * intent filtering.
10145 *
10146 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10147 * "text/x-vCard" becomes "text/x-vcard".
10148 *
10149 * <p>All MIME types received from outside Android (such as user input,
10150 * or external sources like Bluetooth, NFC, or the Internet) should
10151 * be normalized before they are used to create an Intent.
10152 *
10153 * @param type MIME data type to normalize
10154 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010155 * @see #setType
10156 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010157 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010158 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010159 if (type == null) {
10160 return null;
10161 }
10162
Elliott Hughescb64d432013-08-02 10:00:44 -070010163 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010164
10165 final int semicolonIndex = type.indexOf(';');
10166 if (semicolonIndex != -1) {
10167 type = type.substring(0, semicolonIndex);
10168 }
10169 return type;
10170 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010171
10172 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010173 * Prepare this {@link Intent} to leave an app process.
10174 *
10175 * @hide
10176 */
Jeff Sharkey344744b2016-01-28 19:03:30 -070010177 public void prepareToLeaveProcess(Context context) {
10178 final boolean leavingPackage = (mComponent == null)
10179 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10180 prepareToLeaveProcess(leavingPackage);
10181 }
10182
10183 /**
10184 * Prepare this {@link Intent} to leave an app process.
10185 *
10186 * @hide
10187 */
10188 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010189 setAllowFds(false);
10190
10191 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010192 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010193 }
10194 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010195 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010196 }
10197
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010198 if (mExtras != null && !mExtras.isParcelled()) {
10199 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10200 if (intent instanceof Intent) {
10201 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10202 }
10203 }
10204
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010205 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10206 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010207 switch (mAction) {
10208 case ACTION_MEDIA_REMOVED:
10209 case ACTION_MEDIA_UNMOUNTED:
10210 case ACTION_MEDIA_CHECKING:
10211 case ACTION_MEDIA_NOFS:
10212 case ACTION_MEDIA_MOUNTED:
10213 case ACTION_MEDIA_SHARED:
10214 case ACTION_MEDIA_UNSHARED:
10215 case ACTION_MEDIA_BAD_REMOVAL:
10216 case ACTION_MEDIA_UNMOUNTABLE:
10217 case ACTION_MEDIA_EJECT:
10218 case ACTION_MEDIA_SCANNER_STARTED:
10219 case ACTION_MEDIA_SCANNER_FINISHED:
10220 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010221 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10222 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010223 // Ignore legacy actions
10224 break;
10225 default:
10226 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010227 }
10228 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010229
10230 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10231 && leavingPackage) {
10232 switch (mAction) {
10233 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010234 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010235 // Ignore actions that don't need to grant
10236 break;
10237 default:
10238 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10239 }
10240 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010241 }
10242
10243 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010244 * @hide
10245 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010246 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010247 // We just entered destination process, so we should be able to read all
10248 // parcelables inside.
10249 setDefusable(true);
10250
10251 if (mSelector != null) {
10252 mSelector.prepareToEnterProcess();
10253 }
10254 if (mClipData != null) {
10255 mClipData.prepareToEnterProcess();
10256 }
10257
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010258 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010259 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10260 fixUris(mContentUserHint);
10261 mContentUserHint = UserHandle.USER_CURRENT;
10262 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010263 }
10264 }
10265
Patrick Baumann577d4022018-01-31 16:55:10 +000010266 /** @hide */
10267 public boolean hasWebURI() {
10268 if (getData() == null) {
10269 return false;
10270 }
10271 final String scheme = getScheme();
10272 if (TextUtils.isEmpty(scheme)) {
10273 return false;
10274 }
10275 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10276 }
10277
10278 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010279 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010280 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010281 && hasWebURI();
10282 }
10283
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010284 /**
10285 * @hide
10286 */
10287 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010288 Uri data = getData();
10289 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010290 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010291 }
10292 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010293 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010294 }
10295 String action = getAction();
10296 if (ACTION_SEND.equals(action)) {
10297 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10298 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010299 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010300 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010301 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010302 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10303 if (streams != null) {
10304 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10305 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010306 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010307 }
10308 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10309 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010310 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10311 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10312 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10313 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10314 if (output != null) {
10315 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10316 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010317 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010318 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010319
10320 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010321 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010322 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10323 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010324 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010325 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010326 * @hide
10327 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010328 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010329 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010330 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010331
10332 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010333 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010334
10335 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010336 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010337 // Inspect contained intents to see if we need to migrate extras. We
10338 // don't promote ClipData to the parent, since ChooserActivity will
10339 // already start the picked item as the caller, and we can't combine
10340 // the flags in a safe way.
10341
10342 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010343 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010344 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10345 if (intent != null) {
10346 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010347 }
10348 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010349 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010350 try {
10351 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10352 if (intents != null) {
10353 for (int i = 0; i < intents.length; i++) {
10354 final Intent intent = (Intent) intents[i];
10355 if (intent != null) {
10356 migrated |= intent.migrateExtraStreamToClipData();
10357 }
10358 }
10359 }
10360 } catch (ClassCastException e) {
10361 }
10362 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010363
10364 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010365 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010366 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10367 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10368 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10369 if (stream != null || text != null || htmlText != null) {
10370 final ClipData clipData = new ClipData(
10371 null, new String[] { getType() },
10372 new ClipData.Item(text, htmlText, null, stream));
10373 setClipData(clipData);
10374 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010375 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010376 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010377 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010378 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010379
10380 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010381 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010382 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10383 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10384 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10385 int num = -1;
10386 if (streams != null) {
10387 num = streams.size();
10388 }
10389 if (texts != null) {
10390 if (num >= 0 && num != texts.size()) {
10391 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010392 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010393 }
10394 num = texts.size();
10395 }
10396 if (htmlTexts != null) {
10397 if (num >= 0 && num != htmlTexts.size()) {
10398 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010399 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010400 }
10401 num = htmlTexts.size();
10402 }
10403 if (num > 0) {
10404 final ClipData clipData = new ClipData(
10405 null, new String[] { getType() },
10406 makeClipItem(streams, texts, htmlTexts, 0));
10407
10408 for (int i = 1; i < num; i++) {
10409 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10410 }
10411
10412 setClipData(clipData);
10413 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010414 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010415 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010416 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010417 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010418 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10419 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10420 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10421 final Uri output;
10422 try {
10423 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10424 } catch (ClassCastException e) {
10425 return false;
10426 }
10427 if (output != null) {
10428 setClipData(ClipData.newRawUri("", output));
10429 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10430 return true;
10431 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010432 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010433
10434 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010435 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010436
Michael Wright19859762017-09-18 20:57:58 +010010437 /**
10438 * Convert the dock state to a human readable format.
10439 * @hide
10440 */
10441 public static String dockStateToString(int dock) {
10442 switch (dock) {
10443 case EXTRA_DOCK_STATE_HE_DESK:
10444 return "EXTRA_DOCK_STATE_HE_DESK";
10445 case EXTRA_DOCK_STATE_LE_DESK:
10446 return "EXTRA_DOCK_STATE_LE_DESK";
10447 case EXTRA_DOCK_STATE_CAR:
10448 return "EXTRA_DOCK_STATE_CAR";
10449 case EXTRA_DOCK_STATE_DESK:
10450 return "EXTRA_DOCK_STATE_DESK";
10451 case EXTRA_DOCK_STATE_UNDOCKED:
10452 return "EXTRA_DOCK_STATE_UNDOCKED";
10453 default:
10454 return Integer.toString(dock);
10455 }
10456 }
10457
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010458 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10459 ArrayList<String> htmlTexts, int which) {
10460 Uri uri = streams != null ? streams.get(which) : null;
10461 CharSequence text = texts != null ? texts.get(which) : null;
10462 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10463 return new ClipData.Item(text, htmlText, null, uri);
10464 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010465
10466 /** @hide */
10467 public boolean isDocument() {
10468 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10469 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010470}