blob: 206ed719a55b99bc2232416ea4a3a1378ff9a426 [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.
1423 */
1424 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1425 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001426
1427 /**
1428 * Activity Action: Start action associated with long pressing on the
1429 * search key.
1430 * <p>Input: Nothing.
1431 * <p>Output: Nothing.
1432 */
1433 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1434 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001435
Jacek Surazski86b6c532009-05-13 14:38:28 +02001436 /**
1437 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1438 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001439 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001440 * <p>Input: No data is specified. The bug report is passed in using
1441 * an {@link #EXTRA_BUG_REPORT} field.
1442 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001443 *
1444 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001445 */
1446 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1447 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001448
1449 /**
1450 * Activity Action: Show power usage information to the user.
1451 * <p>Input: Nothing.
1452 * <p>Output: Nothing.
1453 */
1454 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1455 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001456
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001457 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001458 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1459 * to run.
1460 * <p>Input: Nothing.
1461 * <p>Output: Nothing.
1462 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1463 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1464 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001465 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001466 */
1467 @Deprecated
1468 @SystemApi
1469 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1470 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1471
1472 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001473 * Activity Action: Setup wizard to launch after a platform update. This
1474 * activity should have a string meta-data field associated with it,
1475 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1476 * the platform for setup. The activity will be launched only if
1477 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1478 * same value.
1479 * <p>Input: Nothing.
1480 * <p>Output: Nothing.
1481 * @hide
1482 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001483 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001484 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1485 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001486
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001487 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001488 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1489 * <p>Input: Nothing.
1490 * <p>Output: Nothing.
1491 * @hide
1492 */
1493 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1494 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001495 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001496
1497 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001498 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1499 * <p>Input: Nothing.
1500 * <p>Output: Nothing.
1501 * @hide
1502 */
1503 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1504 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001505 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001506
1507 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001508 * Activity Action: Show settings for managing network data usage of a
1509 * specific application. Applications should define an activity that offers
1510 * options to control data usage.
1511 */
1512 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1513 public static final String ACTION_MANAGE_NETWORK_USAGE =
1514 "android.intent.action.MANAGE_NETWORK_USAGE";
1515
1516 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001517 * Activity Action: Launch application installer.
1518 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001519 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001520 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1521 * you can also use "package:<package-name>" to install an application for the
1522 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001523 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1524 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1525 * <p>
1526 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1527 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001528 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001529 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001530 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1531 * in order to launch the application installer.
1532 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001533 *
1534 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1535 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1536 * @see #EXTRA_RETURN_RESULT
1537 */
1538 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1539 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1540
1541 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001542 * Activity Action: Activity to handle split installation failures.
1543 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1544 * but the split that contains the application isn't installed. When a split is
1545 * installed in this manner, the containing package usually doesn't know this is
1546 * happening. However, if an error occurs during installation, the containing
1547 * package can define a single activity handling this action to deal with such
1548 * failures.
1549 * <p>The activity handling this action must be in the base package.
1550 * <p>
1551 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1552 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1553 */
1554 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1555 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1556
1557 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001558 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001559 * <p class="note">
1560 * This is a protected intent that can only be sent by the system.
1561 * </p>
1562 *
1563 * @hide
1564 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001565 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001566 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001567 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1568 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001569
1570 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001571 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001572 * <p>
1573 * The system will have a persistent connection to this service.
1574 * This is a protected intent that can only be sent by the system.
1575 * </p>
1576 *
1577 * @hide
1578 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001579 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001580 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001581 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1582 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001583
1584 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001585 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001586 *
1587 * <p class="note">
1588 * This is a protected intent that can only be sent by the system.
1589 * </p>
1590 *
1591 * @hide
1592 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001593 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001594 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001595 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1596 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001597
1598 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001599 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1600 * package. Specifies the installer package name; this package will receive the
1601 * {@link #ACTION_APP_ERROR} intent.
1602 */
1603 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1604 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1605
1606 /**
1607 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1608 * package. Specifies that the application being installed should not be
1609 * treated as coming from an unknown source, but as coming from the app
1610 * invoking the Intent. For this to work you must start the installer with
1611 * startActivityForResult().
1612 */
1613 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1614 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1615
1616 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001617 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1618 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001619 * data field originated from.
1620 */
rich cannings706e8ba2012-08-20 13:20:14 -07001621 public static final String EXTRA_ORIGINATING_URI
1622 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001623
1624 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001625 * This extra can be used with any Intent used to launch an activity, supplying information
1626 * about who is launching that activity. This field contains a {@link android.net.Uri}
1627 * object, typically an http: or https: URI of the web site that the referral came from;
1628 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1629 * a native application that it came from.
1630 *
1631 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1632 * instead of directly retrieving the extra. It is also valid for applications to
1633 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1634 * a string, not a Uri; the field here, if supplied, will always take precedence,
1635 * however.</p>
1636 *
1637 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001638 */
1639 public static final String EXTRA_REFERRER
1640 = "android.intent.extra.REFERRER";
1641
1642 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001643 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1644 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1645 * not be created, in particular when Intent extras are supplied through the
1646 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1647 * schemes.
1648 *
1649 * @see #EXTRA_REFERRER
1650 */
1651 public static final String EXTRA_REFERRER_NAME
1652 = "android.intent.extra.REFERRER_NAME";
1653
1654 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001655 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001656 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001657 * Currently only a system app that hosts the provider authority "downloads" or holds the
1658 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001659 * @hide
1660 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001661 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001662 public static final String EXTRA_ORIGINATING_UID
1663 = "android.intent.extra.ORIGINATING_UID";
1664
1665 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001666 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1667 * package. Tells the installer UI to skip the confirmation with the user
1668 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001669 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1670 * will no longer show an interstitial message about updating existing
1671 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001672 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001673 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001674 public static final String EXTRA_ALLOW_REPLACE
1675 = "android.intent.extra.ALLOW_REPLACE";
1676
1677 /**
1678 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1679 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1680 * return to the application the result code of the install/uninstall. The returned result
1681 * code will be {@link android.app.Activity#RESULT_OK} on success or
1682 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1683 */
1684 public static final String EXTRA_RETURN_RESULT
1685 = "android.intent.extra.RETURN_RESULT";
1686
1687 /**
1688 * Package manager install result code. @hide because result codes are not
1689 * yet ready to be exposed.
1690 */
1691 public static final String EXTRA_INSTALL_RESULT
1692 = "android.intent.extra.INSTALL_RESULT";
1693
1694 /**
1695 * Activity Action: Launch application uninstaller.
1696 * <p>
1697 * Input: The data must be a package: URI whose scheme specific part is
1698 * the package name of the current installed package to be uninstalled.
1699 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1700 * <p>
1701 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1702 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001703 * <p>
1704 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1705 * since {@link Build.VERSION_CODES#P}.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001706 */
1707 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1708 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1709
1710 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001711 * Specify whether the package should be uninstalled for all users.
1712 * @hide because these should not be part of normal application flow.
1713 */
1714 public static final String EXTRA_UNINSTALL_ALL_USERS
1715 = "android.intent.extra.UNINSTALL_ALL_USERS";
1716
1717 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001718 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1719 * describing the last run version of the platform that was setup.
1720 * @hide
1721 */
1722 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1723
Svet Ganov3695b8a2015-03-24 16:30:25 -07001724 /**
1725 * Activity action: Launch UI to manage the permissions of an app.
1726 * <p>
1727 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1728 * will be managed by the launched UI.
1729 * </p>
1730 * <p>
1731 * Output: Nothing.
1732 * </p>
1733 *
1734 * @see #EXTRA_PACKAGE_NAME
1735 *
1736 * @hide
1737 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001738 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001739 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1740 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1741 "android.intent.action.MANAGE_APP_PERMISSIONS";
1742
1743 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001744 * Activity action: Launch UI to manage permissions.
1745 * <p>
1746 * Input: Nothing.
1747 * </p>
1748 * <p>
1749 * Output: Nothing.
1750 * </p>
1751 *
1752 * @hide
1753 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001754 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001755 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1756 public static final String ACTION_MANAGE_PERMISSIONS =
1757 "android.intent.action.MANAGE_PERMISSIONS";
1758
1759 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001760 * Activity action: Launch UI to review permissions for an app.
1761 * The system uses this intent if permission review for apps not
1762 * supporting the new runtime permissions model is enabled. In
1763 * this mode a permission review is required before any of the
1764 * app components can run.
1765 * <p>
1766 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1767 * permissions will be reviewed (mandatory).
1768 * </p>
1769 * <p>
1770 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1771 * be fired after the permission review (optional).
1772 * </p>
1773 * <p>
1774 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1775 * be invoked after the permission review (optional).
1776 * </p>
1777 * <p>
1778 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1779 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1780 * </p>
1781 * <p>
1782 * Output: Nothing.
1783 * </p>
1784 *
1785 * @see #EXTRA_PACKAGE_NAME
1786 * @see #EXTRA_INTENT
1787 * @see #EXTRA_REMOTE_CALLBACK
1788 * @see #EXTRA_RESULT_NEEDED
1789 *
1790 * @hide
1791 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001792 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001793 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1794 public static final String ACTION_REVIEW_PERMISSIONS =
1795 "android.intent.action.REVIEW_PERMISSIONS";
1796
1797 /**
1798 * Intent extra: A callback for reporting remote result as a bundle.
1799 * <p>
1800 * Type: IRemoteCallback
1801 * </p>
1802 *
1803 * @hide
1804 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001805 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001806 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1807
1808 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001809 * Intent extra: An app package name.
1810 * <p>
1811 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001812 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001813 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001814 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001815 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1816
1817 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001818 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1819 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1820 *
1821 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1822 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1823 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001824 *
1825 * @see #ACTION_MY_PACKAGE_SUSPENDED
1826 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1827 * @see PackageManager#isPackageSuspended()
1828 * @see PackageManager#getSuspendedPackageAppExtras()
1829 */
1830 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1831
1832 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001833 * Intent extra: An app split name.
1834 * <p>
1835 * Type: String
1836 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001837 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001838 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1839
1840 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001841 * Intent extra: A {@link ComponentName} value.
1842 * <p>
1843 * Type: String
1844 * </p>
1845 */
1846 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1847
1848 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001849 * Intent extra: An extra for specifying whether a result is needed.
1850 * <p>
1851 * Type: boolean
1852 * </p>
1853 *
1854 * @hide
1855 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001856 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001857 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1858
1859 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001860 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1861 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1862 *
1863 * @see PackageManager#isPackageSuspended()
1864 * @see #ACTION_PACKAGES_SUSPENDED
1865 *
1866 * @hide
1867 */
1868 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1869
1870 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001871 * Activity action: Launch UI to manage which apps have a given permission.
1872 * <p>
1873 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1874 * to which will be managed by the launched UI.
1875 * </p>
1876 * <p>
1877 * Output: Nothing.
1878 * </p>
1879 *
1880 * @see #EXTRA_PERMISSION_NAME
1881 *
1882 * @hide
1883 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001884 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001885 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1886 public static final String ACTION_MANAGE_PERMISSION_APPS =
1887 "android.intent.action.MANAGE_PERMISSION_APPS";
1888
1889 /**
1890 * Intent extra: The name of a permission.
1891 * <p>
1892 * Type: String
1893 * </p>
1894 *
1895 * @hide
1896 */
1897 @SystemApi
1898 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1899
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001900 // ---------------------------------------------------------------------
1901 // ---------------------------------------------------------------------
1902 // Standard intent broadcast actions (see action variable).
1903
1904 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001905 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1906 * <p>
1907 * For historical reasons, the name of this broadcast action refers to the power
1908 * state of the screen but it is actually sent in response to changes in the
1909 * overall interactive state of the device.
1910 * </p><p>
1911 * This broadcast is sent when the device becomes non-interactive which may have
1912 * nothing to do with the screen turning off. To determine the
1913 * actual state of the screen, use {@link android.view.Display#getState}.
1914 * </p><p>
1915 * See {@link android.os.PowerManager#isInteractive} for details.
1916 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001917 * You <em>cannot</em> receive this through components declared in
1918 * manifests, only by explicitly registering for it with
1919 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1920 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001921 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001922 * <p class="note">This is a protected intent that can only be sent
1923 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001924 */
1925 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1926 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001927
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001928 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001929 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1930 * <p>
1931 * For historical reasons, the name of this broadcast action refers to the power
1932 * state of the screen but it is actually sent in response to changes in the
1933 * overall interactive state of the device.
1934 * </p><p>
1935 * This broadcast is sent when the device becomes interactive which may have
1936 * nothing to do with the screen turning on. To determine the
1937 * actual state of the screen, use {@link android.view.Display#getState}.
1938 * </p><p>
1939 * See {@link android.os.PowerManager#isInteractive} for details.
1940 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001941 * You <em>cannot</em> receive this through components declared in
1942 * manifests, only by explicitly registering for it with
1943 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1944 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001945 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001946 * <p class="note">This is a protected intent that can only be sent
1947 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001948 */
1949 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1950 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001951
1952 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001953 * Broadcast Action: Sent after the system stops dreaming.
1954 *
1955 * <p class="note">This is a protected intent that can only be sent by the system.
1956 * It is only sent to registered receivers.</p>
1957 */
1958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1959 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1960
1961 /**
1962 * Broadcast Action: Sent after the system starts dreaming.
1963 *
1964 * <p class="note">This is a protected intent that can only be sent by the system.
1965 * It is only sent to registered receivers.</p>
1966 */
1967 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1968 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1969
1970 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001971 * 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 -07001972 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08001973 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001974 * <p class="note">This is a protected intent that can only be sent
1975 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001976 */
1977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001978 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001979
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001980 /**
1981 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07001982 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04001983 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001984 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1985 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001986 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001987 * <p class="note">This is a protected intent that can only be sent
1988 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001989 */
1990 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1991 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
1992 /**
1993 * Broadcast Action: The time was set.
1994 */
1995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1996 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
1997 /**
1998 * Broadcast Action: The date has changed.
1999 */
2000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2001 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2002 /**
2003 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2004 * <ul>
2005 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2006 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002007 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002008 * <p class="note">This is a protected intent that can only be sent
2009 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002010 */
2011 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2012 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2013 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002014 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2015 * DNS entries should be tossed.
2016 * @hide
2017 */
2018 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2019 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2020 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002021 * Alarm Changed Action: This is broadcast when the AlarmClock
2022 * application's alarm is set or unset. It is used by the
2023 * AlarmClock application and the StatusBar service.
2024 * @hide
2025 */
2026 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2027 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002028
2029 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002030 * Broadcast Action: This is broadcast once, after the user has finished
2031 * booting, but while still in the "locked" state. It can be used to perform
2032 * application-specific initialization, such as installing alarms. You must
2033 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2034 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002035 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002036 * This broadcast is sent immediately at boot by all devices (regardless of
2037 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2038 * higher. Upon receipt of this broadcast, the user is still locked and only
2039 * device-protected storage can be accessed safely. If you want to access
2040 * credential-protected storage, you need to wait for the user to be
2041 * unlocked (typically by entering their lock pattern or PIN for the first
2042 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2043 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2044 * <p>
2045 * To receive this broadcast, your receiver component must be marked as
2046 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002047 * <p class="note">
2048 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002049 *
2050 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002051 */
2052 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2053 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2054
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002055 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002056 * Broadcast Action: This is broadcast once, after the user has finished
2057 * booting. It can be used to perform application-specific initialization,
2058 * such as installing alarms. You must hold the
2059 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2060 * order to receive this broadcast.
2061 * <p>
2062 * This broadcast is sent at boot by all devices (both with and without
2063 * direct boot support). Upon receipt of this broadcast, the user is
2064 * unlocked and both device-protected and credential-protected storage can
2065 * accessed safely.
2066 * <p>
2067 * If you need to run while the user is still locked (before they've entered
2068 * their lock pattern or PIN for the first time), you can listen for the
2069 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2070 * <p class="note">
2071 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 */
2073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002074 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002075 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002076
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002077 /**
2078 * Broadcast Action: This is broadcast when a user action should request a
2079 * temporary system dialog to dismiss. Some examples of temporary system
2080 * dialogs are the notification window-shade and the recent tasks dialog.
2081 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002082 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002083 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2084 /**
2085 * Broadcast Action: Trigger the download and eventual installation
2086 * of a package.
2087 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002088 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002089 * <p class="note">This is a protected intent that can only be sent
2090 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002091 *
2092 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002093 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002094 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2096 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2097 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002098 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002099 * device. The data contains the name of the package. Note that the
2100 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002101 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002102 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002103 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2104 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002105 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2106 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002107 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002108 * <p class="note">This is a protected intent that can only be sent
2109 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002110 */
2111 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2112 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2113 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002114 * Broadcast Action: A new version of an application package has been
2115 * installed, replacing an existing version that was previously installed.
2116 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002117 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002118 * <ul>
2119 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2120 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002121 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002122 * <p class="note">This is a protected intent that can only be sent
2123 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002124 */
2125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2126 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2127 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002128 * Broadcast Action: A new version of your application has been installed
2129 * over an existing one. This is only sent to the application that was
2130 * replaced. It does not contain any additional data; to receive it, just
2131 * use an intent filter for this action.
2132 *
2133 * <p class="note">This is a protected intent that can only be sent
2134 * by the system.
2135 */
2136 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2137 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2138 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002139 * Broadcast Action: An existing application package has been removed from
2140 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002141 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002142 * <ul>
2143 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2144 * to the package.
2145 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2146 * application -- data and code -- is being removed.
2147 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2148 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2149 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002150 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002151 * <p class="note">This is a protected intent that can only be sent
2152 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002153 */
2154 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2155 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2156 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002157 * Broadcast Action: An existing application package has been completely
2158 * removed from the device. The data contains the name of the package.
2159 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2160 * {@link #EXTRA_DATA_REMOVED} is true and
2161 * {@link #EXTRA_REPLACING} is false of that broadcast.
2162 *
2163 * <ul>
2164 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2165 * to the package.
2166 * </ul>
2167 *
2168 * <p class="note">This is a protected intent that can only be sent
2169 * by the system.
2170 */
2171 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2172 public static final String ACTION_PACKAGE_FULLY_REMOVED
2173 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2174 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002175 * Broadcast Action: An existing application package has been changed (for
2176 * example, a component has been enabled or disabled). The data contains
2177 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002178 * <ul>
2179 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002180 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002181 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002182 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2183 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002184 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002185 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002186 * <p class="note">This is a protected intent that can only be sent
2187 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002188 */
2189 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2190 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2191 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002192 * @hide
2193 * Broadcast Action: Ask system services if there is any reason to
2194 * restart the given package. The data contains the name of the
2195 * package.
2196 * <ul>
2197 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2198 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2199 * </ul>
2200 *
2201 * <p class="note">This is a protected intent that can only be sent
2202 * by the system.
2203 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002204 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2206 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2207 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002208 * Broadcast Action: The user has restarted a package, and all of its
2209 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002210 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002211 * be removed. Note that the restarted package does <em>not</em>
2212 * receive this broadcast.
2213 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002214 * <ul>
2215 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2216 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002217 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002218 * <p class="note">This is a protected intent that can only be sent
2219 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002220 */
2221 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2222 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2223 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002224 * Broadcast Action: The user has cleared the data of a package. This should
2225 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002226 * its persistent data is erased and this broadcast sent.
2227 * Note that the cleared package does <em>not</em>
2228 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002229 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002230 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2231 * package whose data was cleared is an uninstalled instant app, then the UID
2232 * will be -1. The platform keeps some meta-data associated with instant apps
2233 * after they are uninstalled.
2234 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2235 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002236 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002237 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002238 * <p class="note">This is a protected intent that can only be sent
2239 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002240 */
2241 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2242 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2243 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002244 * Broadcast Action: Packages have been suspended.
2245 * <p>Includes the following extras:
2246 * <ul>
2247 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2248 * </ul>
2249 *
2250 * <p class="note">This is a protected intent that can only be sent
2251 * by the system. It is only sent to registered receivers.
2252 */
2253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2254 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2255 /**
2256 * Broadcast Action: Packages have been unsuspended.
2257 * <p>Includes the following extras:
2258 * <ul>
2259 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2260 * </ul>
2261 *
2262 * <p class="note">This is a protected intent that can only be sent
2263 * by the system. It is only sent to registered receivers.
2264 */
2265 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2266 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002267
2268 /**
2269 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002270 * whenever a package is put into a suspended state or any of its app extras change while in the
2271 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002272 * <p> Optionally includes the following extras:
2273 * <ul>
2274 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2275 * useful information for the app being suspended.
2276 * </ul>
2277 * <p class="note">This is a protected intent that can only be sent
2278 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2279 * the manifest.</em>
2280 *
2281 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2282 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2283 * @see PackageManager#isPackageSuspended()
2284 * @see PackageManager#getSuspendedPackageAppExtras()
2285 */
2286 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2287 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2288
2289 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002290 * Activity Action: Started to show more details about why an application was suspended.
2291 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002292 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2293 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002294 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002295 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2296 * handling this intent and protect it with
2297 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2298 *
2299 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2300 *
2301 * <p class="note">This is a protected intent that can only be sent
2302 * by the system.
2303 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002304 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2305 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002306 * @see PackageManager#isPackageSuspended()
2307 * @see #ACTION_PACKAGES_SUSPENDED
2308 *
2309 * @hide
2310 */
2311 @SystemApi
2312 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2313 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2314 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2315
2316 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002317 * Broadcast Action: Sent to a package that has been unsuspended.
2318 *
2319 * <p class="note">This is a protected intent that can only be sent
2320 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2321 * the manifest.</em>
2322 *
2323 * @see #ACTION_MY_PACKAGE_SUSPENDED
2324 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2325 * @see PackageManager#isPackageSuspended()
2326 * @see PackageManager#getSuspendedPackageAppExtras()
2327 */
2328 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2329 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2330
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002331 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002332 * Broadcast Action: A user ID has been removed from the system. The user
2333 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002334 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002335 * <p class="note">This is a protected intent that can only be sent
2336 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002337 */
2338 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2339 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002340
2341 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002342 * Broadcast Action: Sent to the installer package of an application when
2343 * that application is first launched (that is the first time it is moved
2344 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002345 *
2346 * <p class="note">This is a protected intent that can only be sent
2347 * by the system.
2348 */
2349 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2350 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2351
2352 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002353 * Broadcast Action: Sent to the system package verifier when a package
2354 * needs to be verified. The data contains the package URI.
2355 * <p class="note">
2356 * This is a protected intent that can only be sent by the system.
2357 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002358 */
2359 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2360 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2361
2362 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002363 * Broadcast Action: Sent to the system package verifier when a package is
2364 * verified. The data contains the package URI.
2365 * <p class="note">
2366 * This is a protected intent that can only be sent by the system.
2367 */
2368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2369 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2370
2371 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002372 * Broadcast Action: Sent to the system intent filter verifier when an
2373 * intent filter needs to be verified. The data contains the filter data
2374 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002375 * <p class="note">
2376 * This is a protected intent that can only be sent by the system.
2377 * </p>
2378 *
2379 * @hide
2380 */
2381 @SystemApi
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2384
2385 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002386 * Broadcast Action: Resources for a set of packages (which were
2387 * previously unavailable) are currently
2388 * available since the media on which they exist is available.
2389 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2390 * list of packages whose availability changed.
2391 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2392 * list of uids of packages whose availability changed.
2393 * Note that the
2394 * packages in this list do <em>not</em> receive this broadcast.
2395 * The specified set of packages are now available on the system.
2396 * <p>Includes the following extras:
2397 * <ul>
2398 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2399 * whose resources(were previously unavailable) are currently available.
2400 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2401 * packages whose resources(were previously unavailable)
2402 * are currently available.
2403 * </ul>
2404 *
2405 * <p class="note">This is a protected intent that can only be sent
2406 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002407 */
2408 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002409 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2410 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002411
2412 /**
2413 * Broadcast Action: Resources for a set of packages are currently
2414 * unavailable since the media on which they exist is unavailable.
2415 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2416 * list of packages whose availability changed.
2417 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2418 * list of uids of packages whose availability changed.
2419 * The specified set of packages can no longer be
2420 * launched and are practically unavailable on the system.
2421 * <p>Inclues the following extras:
2422 * <ul>
2423 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2424 * whose resources are no longer available.
2425 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2426 * whose resources are no longer available.
2427 * </ul>
2428 *
2429 * <p class="note">This is a protected intent that can only be sent
2430 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002431 */
2432 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002433 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002434 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002435
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002436 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002437 * Broadcast Action: preferred activities have changed *explicitly*.
2438 *
2439 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2440 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2441 * be sent.
2442 *
2443 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2444 *
2445 * @hide
2446 */
2447 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2448 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2449 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2450
2451
2452 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002453 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002454 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002455 * This should <em>only</em> be used to determine when the wallpaper
2456 * has changed to show the new wallpaper to the user. You should certainly
2457 * never, in response to this, change the wallpaper or other attributes of
2458 * it such as the suggested size. That would be crazy, right? You'd cause
2459 * all kinds of loops, especially if other apps are doing similar things,
2460 * right? Of course. So please don't do this.
2461 *
2462 * @deprecated Modern applications should use
2463 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2464 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2465 * shown behind their UI, rather than watching for this broadcast and
2466 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002467 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002468 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002469 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2470 /**
2471 * Broadcast Action: The current device {@link android.content.res.Configuration}
2472 * (orientation, locale, etc) has changed. When such a change happens, the
2473 * UIs (view hierarchy) will need to be rebuilt based on this new
2474 * information; for the most part, applications don't need to worry about
2475 * this, because the system will take care of stopping and restarting the
2476 * application to make sure it sees the new changes. Some system code that
2477 * can not be restarted will need to watch for this action and handle it
2478 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002479 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002480 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002481 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002482 * in manifests, only by explicitly registering for it with
2483 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2484 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002485 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002486 * <p class="note">This is a protected intent that can only be sent
2487 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002488 *
2489 * @see android.content.res.Configuration
2490 */
2491 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2492 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002493
2494 /**
2495 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2496 * such that the device may be eligible for the installation of additional configuration splits.
2497 * Configuration properties that can trigger this broadcast include locale and display density.
2498 *
2499 * <p class="note">
2500 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2501 * components declared in manifests. However, the receiver <em>must</em> hold the
2502 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2503 *
2504 * <p class="note">
2505 * This is a protected intent that can only be sent by the system.
2506 *
2507 * @hide
2508 */
2509 @SystemApi
2510 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2511 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2512 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002513 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002514 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002515 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002516 * <p class="note">This is a protected intent that can only be sent
2517 * by the system.
2518 */
2519 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2520 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2521 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002522 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2523 * charging state, level, and other information about the battery.
2524 * See {@link android.os.BatteryManager} for documentation on the
2525 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002526 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002527 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002528 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002529 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002530 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002531 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2532 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2533 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2534 * broadcasts that are sent and can be received through manifest
2535 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002536 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002537 * <p class="note">This is a protected intent that can only be sent
2538 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002539 */
2540 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2541 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002542
2543
2544 /**
2545 * Broadcast Action: Sent when the current battery level changes.
2546 *
2547 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2548 * instances representing individual battery level changes with associated
2549 * extras from {@link #ACTION_BATTERY_CHANGED}.
2550 *
2551 * <p class="note">
2552 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2553 *
2554 * @hide
2555 */
2556 @SystemApi
2557 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2558 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002559 /**
2560 * Broadcast Action: Indicates low battery condition on the device.
2561 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002562 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002563 * <p class="note">This is a protected intent that can only be sent
2564 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002565 */
2566 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2567 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2568 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002569 * Broadcast Action: Indicates the battery is now okay after being low.
2570 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2571 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002572 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002573 * <p class="note">This is a protected intent that can only be sent
2574 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002575 */
2576 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2577 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2578 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002579 * Broadcast Action: External power has been connected to the device.
2580 * This is intended for applications that wish to register specifically to this notification.
2581 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2582 * stay active to receive this notification. This action can be used to implement actions
2583 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002584 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002585 * <p class="note">This is a protected intent that can only be sent
2586 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002587 */
2588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002589 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002590 /**
2591 * Broadcast Action: External power has been removed from the device.
2592 * This is intended for applications that wish to register specifically to this notification.
2593 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2594 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002595 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002596 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002597 * <p class="note">This is a protected intent that can only be sent
2598 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002599 */
2600 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002601 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002602 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002603 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002604 * Broadcast Action: Device is shutting down.
2605 * This is broadcast when the device is being shut down (completely turned
2606 * off, not sleeping). Once the broadcast is complete, the final shutdown
2607 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002608 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002609 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2610 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2611 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002612 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002613 * <p class="note">This is a protected intent that can only be sent
2614 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002615 * <p>May include the following extras:
2616 * <ul>
2617 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2618 * shutdown is only for userspace processes. If not set, assumed to be false.
2619 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002620 */
2621 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002622 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002623 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002624 * Activity Action: Start this activity to request system shutdown.
2625 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002626 * to request confirmation from the user before shutting down. The optional boolean
2627 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2628 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002629 *
2630 * <p class="note">This is a protected intent that can only be sent
2631 * by the system.
2632 *
2633 * {@hide}
2634 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002635 public static final String ACTION_REQUEST_SHUTDOWN
2636 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002637 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002638 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002639 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002640 * <p class="note">
2641 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002642 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002643 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2644 * or above, this broadcast will no longer be delivered to any
2645 * {@link BroadcastReceiver} defined in your manifest. Instead,
2646 * apps are strongly encouraged to use the improved
2647 * {@link Context#getCacheDir()} behavior so the system can
2648 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002649 */
2650 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002651 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002652 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2653 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002654 * Broadcast Action: Indicates low storage space condition on the device no
2655 * longer exists
2656 * <p class="note">
2657 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002658 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002659 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2660 * or above, this broadcast will no longer be delivered to any
2661 * {@link BroadcastReceiver} defined in your manifest. Instead,
2662 * apps are strongly encouraged to use the improved
2663 * {@link Context#getCacheDir()} behavior so the system can
2664 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002665 */
2666 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002667 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002668 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2669 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002670 * Broadcast Action: A sticky broadcast that indicates a storage space full
2671 * condition on the device. This is intended for activities that want to be
2672 * able to fill the data partition completely, leaving only enough free
2673 * space to prevent system-wide SQLite failures.
2674 * <p class="note">
2675 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002676 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002677 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2678 * or above, this broadcast will no longer be delivered to any
2679 * {@link BroadcastReceiver} defined in your manifest. Instead,
2680 * apps are strongly encouraged to use the improved
2681 * {@link Context#getCacheDir()} behavior so the system can
2682 * automatically free up storage when needed.
2683 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002684 */
2685 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002686 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002687 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2688 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002689 * Broadcast Action: Indicates storage space full condition on the device no
2690 * longer exists.
2691 * <p class="note">
2692 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002693 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002694 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2695 * or above, this broadcast will no longer be delivered to any
2696 * {@link BroadcastReceiver} defined in your manifest. Instead,
2697 * apps are strongly encouraged to use the improved
2698 * {@link Context#getCacheDir()} behavior so the system can
2699 * automatically free up storage when needed.
2700 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002701 */
2702 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002703 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002704 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2705 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002706 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2707 * and package management should be started.
2708 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2709 * notification.
2710 */
2711 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2712 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2713 /**
2714 * Broadcast Action: The device has entered USB Mass Storage mode.
2715 * This is used mainly for the USB Settings panel.
2716 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2717 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002718 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002719 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002720 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2723
2724 /**
2725 * Broadcast Action: The device has exited USB Mass Storage mode.
2726 * This is used mainly for the USB Settings panel.
2727 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2728 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002729 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002730 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002731 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002733 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2734
2735 /**
2736 * Broadcast Action: External media has been removed.
2737 * The path to the mount point for the removed media is contained in the Intent.mData field.
2738 */
2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2741
2742 /**
2743 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002744 * 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 -07002745 */
2746 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2747 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2748
2749 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002750 * Broadcast Action: External media is present, and being disk-checked
2751 * 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 -08002752 */
2753 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2754 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2755
2756 /**
2757 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2758 * 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 -08002759 */
2760 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2761 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2762
2763 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002764 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002765 * 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 -07002766 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2767 * media was mounted read only.
2768 */
2769 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2770 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2771
2772 /**
2773 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002774 * 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 -07002775 */
2776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2777 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2778
2779 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002780 * Broadcast Action: External media is no longer being shared via USB mass storage.
2781 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2782 *
2783 * @hide
2784 */
2785 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2786
2787 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002788 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2789 * The path to the mount point for the removed media is contained in the Intent.mData field.
2790 */
2791 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2792 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2793
2794 /**
2795 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002796 * 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 -07002797 */
2798 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2799 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2800
2801 /**
2802 * Broadcast Action: User has expressed the desire to remove the external storage media.
2803 * Applications should close all files they have open within the mount point when they receive this intent.
2804 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2805 */
2806 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2807 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2808
2809 /**
2810 * Broadcast Action: The media scanner has started scanning a directory.
2811 * The path to the directory being scanned is contained in the Intent.mData field.
2812 */
2813 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2814 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2815
2816 /**
2817 * Broadcast Action: The media scanner has finished scanning a directory.
2818 * The path to the scanned directory is contained in the Intent.mData field.
2819 */
2820 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2821 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2822
2823 /**
2824 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2825 * The path to the file is contained in the Intent.mData field.
2826 */
2827 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2828 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2829
2830 /**
2831 * Broadcast Action: The "Media Button" was pressed. Includes a single
2832 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2833 * caused the broadcast.
2834 */
2835 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2836 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2837
2838 /**
2839 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2840 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2841 * caused the broadcast.
2842 */
2843 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2844 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2845
2846 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2847 // location; they are not general-purpose actions.
2848
2849 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002850 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002851 */
2852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2853 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2854 "android.intent.action.GTALK_CONNECTED";
2855
2856 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002857 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002858 */
2859 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2860 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2861 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002862
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002863 /**
2864 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002865 */
2866 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2867 public static final String ACTION_INPUT_METHOD_CHANGED =
2868 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002869
2870 /**
2871 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2872 * more radios have been turned off or on. The intent will have the following extra value:</p>
2873 * <ul>
2874 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2875 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2876 * turned off</li>
2877 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002878 *
Peng Xua35b5532016-01-20 00:05:45 -08002879 * <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 -07002880 */
2881 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2882 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2883
2884 /**
2885 * Broadcast Action: Some content providers have parts of their namespace
2886 * where they publish new events or items that the user may be especially
2887 * interested in. For these things, they may broadcast this action when the
2888 * set of interesting items change.
2889 *
2890 * For example, GmailProvider sends this notification when the set of unread
2891 * mail in the inbox changes.
2892 *
2893 * <p>The data of the intent identifies which part of which provider
2894 * changed. When queried through the content resolver, the data URI will
2895 * return the data set in question.
2896 *
2897 * <p>The intent will have the following extra values:
2898 * <ul>
2899 * <li><em>count</em> - The number of items in the data set. This is the
2900 * same as the number of items in the cursor returned by querying the
2901 * data URI. </li>
2902 * </ul>
2903 *
2904 * This intent will be sent at boot (if the count is non-zero) and when the
2905 * data set changes. It is possible for the data set to change without the
2906 * count changing (for example, if a new unread message arrives in the same
2907 * sync operation in which a message is archived). The phone should still
2908 * ring/vibrate/etc as normal in this case.
2909 */
2910 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2911 public static final String ACTION_PROVIDER_CHANGED =
2912 "android.intent.action.PROVIDER_CHANGED";
2913
2914 /**
2915 * Broadcast Action: Wired Headset plugged in or unplugged.
2916 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002917 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2918 * and documentation.
2919 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002920 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002921 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002922 */
2923 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002924 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002925
2926 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002927 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2928 * <ul>
2929 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2930 * </ul>
2931 *
2932 * <p class="note">This is a protected intent that can only be sent
2933 * by the system.
2934 *
2935 * @hide
2936 */
2937 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2938 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2939 = "android.intent.action.ADVANCED_SETTINGS";
2940
2941 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002942 * Broadcast Action: Sent after application restrictions are changed.
2943 *
2944 * <p class="note">This is a protected intent that can only be sent
2945 * by the system.</p>
2946 */
2947 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2948 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2949 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2950
2951 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002952 * Broadcast Action: An outgoing call is about to be placed.
2953 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002954 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002955 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002956 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002957 * the phone number originally intended to be dialed.</li>
2958 * </ul>
2959 * <p>Once the broadcast is finished, the resultData is used as the actual
2960 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002961 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002962 * outgoing call in turn: for example, a parental control application
2963 * might verify that the user is authorized to place the call at that
2964 * time, then a number-rewriting application might add an area code if
2965 * one was not specified.</p>
2966 * <p>For consistency, any receiver whose purpose is to prohibit phone
2967 * calls should have a priority of 0, to ensure it will see the final
2968 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002969 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002970 * should have a positive priority.
2971 * Negative priorities are reserved for the system for this broadcast;
2972 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07002973 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
2974 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002975 * <p>Emergency calls cannot be intercepted using this mechanism, and
2976 * other calls cannot be modified to call emergency numbers using this
2977 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07002978 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
2979 * call to use their own service instead. Those apps should first prevent
2980 * the call from being placed by setting resultData to <code>null</code>
2981 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07002982 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002983 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
2984 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08002985 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002986 * <p class="note">This is a protected intent that can only be sent
2987 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002988 */
2989 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2990 public static final String ACTION_NEW_OUTGOING_CALL =
2991 "android.intent.action.NEW_OUTGOING_CALL";
2992
2993 /**
2994 * Broadcast Action: Have the device reboot. This is only for use by
2995 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08002996 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002997 * <p class="note">This is a protected intent that can only be sent
2998 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002999 */
3000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3001 public static final String ACTION_REBOOT =
3002 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003003
Wei Huang97ecc9c2009-05-11 17:44:20 -07003004 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003005 * Broadcast Action: A sticky broadcast for changes in the physical
3006 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003007 *
3008 * <p>The intent will have the following extra values:
3009 * <ul>
3010 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003011 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003012 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003013 * <p>This is intended for monitoring the current physical dock state.
3014 * See {@link android.app.UiModeManager} for the normal API dealing with
3015 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003016 */
3017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3018 public static final String ACTION_DOCK_EVENT =
3019 "android.intent.action.DOCK_EVENT";
3020
3021 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003022 * Broadcast Action: A broadcast when idle maintenance can be started.
3023 * This means that the user is not interacting with the device and is
3024 * not expected to do so soon. Typical use of the idle maintenance is
3025 * to perform somehow expensive tasks that can be postponed at a moment
3026 * when they will not degrade user experience.
3027 * <p>
3028 * <p class="note">In order to keep the device responsive in case of an
3029 * unexpected user interaction, implementations of a maintenance task
3030 * should be interruptible. In such a scenario a broadcast with action
3031 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3032 * should not do the maintenance work in
3033 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3034 * maintenance service by {@link Context#startService(Intent)}. Also
3035 * you should hold a wake lock while your maintenance service is running
3036 * to prevent the device going to sleep.
3037 * </p>
3038 * <p>
3039 * <p class="note">This is a protected intent that can only be sent by
3040 * the system.
3041 * </p>
3042 *
3043 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003044 *
3045 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003046 */
3047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3048 public static final String ACTION_IDLE_MAINTENANCE_START =
3049 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3050
3051 /**
3052 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3053 * This means that the user was not interacting with the device as a result
3054 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3055 * was sent and now the user started interacting with the device. Typical
3056 * use of the idle maintenance is to perform somehow expensive tasks that
3057 * can be postponed at a moment when they will not degrade user experience.
3058 * <p>
3059 * <p class="note">In order to keep the device responsive in case of an
3060 * unexpected user interaction, implementations of a maintenance task
3061 * should be interruptible. Hence, on receiving a broadcast with this
3062 * action, the maintenance task should be interrupted as soon as possible.
3063 * In other words, you should not do the maintenance work in
3064 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3065 * maintenance service that was started on receiving of
3066 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3067 * lock you acquired when your maintenance service started.
3068 * </p>
3069 * <p class="note">This is a protected intent that can only be sent
3070 * by the system.
3071 *
3072 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003073 *
3074 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003075 */
3076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3077 public static final String ACTION_IDLE_MAINTENANCE_END =
3078 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3079
3080 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003081 * Broadcast Action: a remote intent is to be broadcasted.
3082 *
3083 * A remote intent is used for remote RPC between devices. The remote intent
3084 * is serialized and sent from one device to another device. The receiving
3085 * device parses the remote intent and broadcasts it. Note that anyone can
3086 * broadcast a remote intent. However, if the intent receiver of the remote intent
3087 * does not trust intent broadcasts from arbitrary intent senders, it should require
3088 * the sender to hold certain permissions so only trusted sender's broadcast will be
3089 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003090 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003091 */
3092 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003093 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003094
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003095 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003096 * Broadcast Action: This is broadcast once when the user is booting after a
3097 * system update. It can be used to perform cleanup or upgrades after a
3098 * system update.
3099 * <p>
3100 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3101 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3102 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3103 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003104 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003105 * @hide
3106 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003107 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003108 public static final String ACTION_PRE_BOOT_COMPLETED =
3109 "android.intent.action.PRE_BOOT_COMPLETED";
3110
Amith Yamasani13593602012-03-22 16:16:17 -07003111 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003112 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003113 * on restricted users. The broadcast intent contains an extra
3114 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3115 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3116 * String[] depending on the restriction type.<p/>
3117 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003118 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3119 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3120 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003121 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3122 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003123 * @see RestrictionEntry
3124 */
3125 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3126 "android.intent.action.GET_RESTRICTION_ENTRIES";
3127
3128 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003129 * Sent the first time a user is starting, to allow system apps to
3130 * perform one time initialization. (This will not be seen by third
3131 * party applications because a newly initialized user does not have any
3132 * third party applications installed for it.) This is sent early in
3133 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003134 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3135 * broadcast, since it is part of a visible user interaction; be as quick
3136 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003137 */
3138 public static final String ACTION_USER_INITIALIZE =
3139 "android.intent.action.USER_INITIALIZE";
3140
3141 /**
3142 * Sent when a user switch is happening, causing the process's user to be
3143 * brought to the foreground. This is only sent to receivers registered
3144 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3145 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003146 * foreground. This is sent as a foreground
3147 * broadcast, since it is part of a visible user interaction; be as quick
3148 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003149 */
3150 public static final String ACTION_USER_FOREGROUND =
3151 "android.intent.action.USER_FOREGROUND";
3152
3153 /**
3154 * Sent when a user switch is happening, causing the process's user to be
3155 * sent to the background. This is only sent to receivers registered
3156 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3157 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003158 * background. This is sent as a foreground
3159 * broadcast, since it is part of a visible user interaction; be as quick
3160 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003161 */
3162 public static final String ACTION_USER_BACKGROUND =
3163 "android.intent.action.USER_BACKGROUND";
3164
3165 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003166 * Broadcast sent to the system when a user is added. Carries an extra
3167 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3168 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003169 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003170 * @hide
3171 */
3172 public static final String ACTION_USER_ADDED =
3173 "android.intent.action.USER_ADDED";
3174
3175 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003176 * Broadcast sent by the system when a user is started. Carries an extra
3177 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003178 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003179 * that has been started. This is sent as a foreground
3180 * broadcast, since it is part of a visible user interaction; be as quick
3181 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003182 * @hide
3183 */
3184 public static final String ACTION_USER_STARTED =
3185 "android.intent.action.USER_STARTED";
3186
3187 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003188 * Broadcast sent when a user is in the process of starting. Carries an extra
3189 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3190 * sent to registered receivers, not manifest receivers. It is sent to all
3191 * users (including the one that is being started). You must hold
3192 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3193 * this broadcast. This is sent as a background broadcast, since
3194 * its result is not part of the primary UX flow; to safely keep track of
3195 * started/stopped state of a user you can use this in conjunction with
3196 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3197 * other user state broadcasts since those are foreground broadcasts so can
3198 * execute in a different order.
3199 * @hide
3200 */
3201 public static final String ACTION_USER_STARTING =
3202 "android.intent.action.USER_STARTING";
3203
3204 /**
3205 * Broadcast sent when a user is going to be stopped. Carries an extra
3206 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3207 * sent to registered receivers, not manifest receivers. It is sent to all
3208 * users (including the one that is being stopped). You must hold
3209 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3210 * this broadcast. The user will not stop until all receivers have
3211 * handled the broadcast. This is sent as a background broadcast, since
3212 * its result is not part of the primary UX flow; to safely keep track of
3213 * started/stopped state of a user you can use this in conjunction with
3214 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3215 * other user state broadcasts since those are foreground broadcasts so can
3216 * execute in a different order.
3217 * @hide
3218 */
3219 public static final String ACTION_USER_STOPPING =
3220 "android.intent.action.USER_STOPPING";
3221
3222 /**
3223 * Broadcast sent to the system when a user is stopped. Carries an extra
3224 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3225 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3226 * specific package. This is only sent to registered receivers, not manifest
3227 * receivers. It is sent to all running users <em>except</em> the one that
3228 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003229 * @hide
3230 */
3231 public static final String ACTION_USER_STOPPED =
3232 "android.intent.action.USER_STOPPED";
3233
3234 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003235 * 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 -07003236 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003237 * one that has been removed. The user will not be completely removed until all receivers have
3238 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003239 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003240 * @hide
3241 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003242 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003243 public static final String ACTION_USER_REMOVED =
3244 "android.intent.action.USER_REMOVED";
3245
3246 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003247 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003248 * the userHandle of the user to become the current one. This is only sent to
3249 * registered receivers, not manifest receivers. It is sent to all running users.
3250 * You must hold
3251 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003252 * @hide
3253 */
3254 public static final String ACTION_USER_SWITCHED =
3255 "android.intent.action.USER_SWITCHED";
3256
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003257 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003258 * Broadcast Action: Sent when the credential-encrypted private storage has
3259 * become unlocked for the target user. This is only sent to registered
3260 * receivers, not manifest receivers.
3261 */
3262 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3263 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3264
3265 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003266 * Broadcast sent to the system when a user's information changes. Carries an extra
3267 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003268 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003269 * @hide
3270 */
3271 public static final String ACTION_USER_INFO_CHANGED =
3272 "android.intent.action.USER_INFO_CHANGED";
3273
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003274 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003275 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3276 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003277 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3278 * that need to display merged content across both primary and managed profiles need to
3279 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003280 * not manifest receivers.
3281 */
3282 public static final String ACTION_MANAGED_PROFILE_ADDED =
3283 "android.intent.action.MANAGED_PROFILE_ADDED";
3284
3285 /**
3286 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003287 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3288 * Only applications (for example Launchers) that need to display merged content across both
3289 * primary and managed profiles need to worry about this broadcast. This is only sent to
3290 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003291 */
3292 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3293 "android.intent.action.MANAGED_PROFILE_REMOVED";
3294
3295 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003296 * Broadcast sent to the primary user when the credential-encrypted private storage for
3297 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3298 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3299 * Launchers) that need to display merged content across both primary and managed profiles
3300 * need to worry about this broadcast. This is only sent to registered receivers,
3301 * not manifest receivers.
3302 */
3303 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3304 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3305
3306 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003307 * Broadcast sent to the primary user when an associated managed profile has become available.
3308 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003309 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3310 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3311 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003312 */
Rubin Xue95057a2016-04-01 16:49:25 +01003313 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3314 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3315
3316 /**
3317 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3318 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3319 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3320 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3321 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3322 */
3323 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3324 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003325
3326 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003327 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3328 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3329 * the device was locked or unlocked.
3330 *
3331 * This is only sent to registered receivers.
3332 *
3333 * @hide
3334 */
3335 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3336 "android.intent.action.DEVICE_LOCKED_CHANGED";
3337
3338 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003339 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3340 */
3341 public static final String ACTION_QUICK_CLOCK =
3342 "android.intent.action.QUICK_CLOCK";
3343
Michael Wright0087a142013-02-05 16:29:39 -08003344 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003345 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003346 * @hide
3347 */
3348 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003349 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003350
Justin Kohd378ad72013-04-01 12:18:26 -07003351 /**
3352 * Broadcast Action: A global button was pressed. Includes a single
3353 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3354 * caused the broadcast.
3355 * @hide
3356 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003357 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003358 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3359
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003360 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003361 * Broadcast Action: Sent when media resource is granted.
3362 * <p>
3363 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3364 * granted.
3365 * </p>
3366 * <p class="note">
3367 * This is a protected intent that can only be sent by the system.
3368 * </p>
3369 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003370 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003371 * </p>
3372 *
3373 * @hide
3374 */
3375 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3376 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3377
3378 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003379 * Broadcast Action: An overlay package has changed. The data contains the
3380 * name of the overlay package which has changed. This is broadcast on all
3381 * changes to the OverlayInfo returned by {@link
3382 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3383 * most common change is a state change that will change whether the
3384 * overlay is enabled or not.
3385 * @hide
3386 */
3387 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3388
3389 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003390 * Activity Action: Allow the user to select and return one or more existing
3391 * documents. When invoked, the system will display the various
3392 * {@link DocumentsProvider} instances installed on the device, letting the
3393 * user interactively navigate through them. These documents include local
3394 * media, such as photos and video, and documents provided by installed
3395 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003396 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003397 * Each document is represented as a {@code content://} URI backed by a
3398 * {@link DocumentsProvider}, which can be opened as a stream with
3399 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3400 * {@link android.provider.DocumentsContract.Document} metadata.
3401 * <p>
3402 * All selected documents are returned to the calling application with
3403 * persistable read and write permission grants. If you want to maintain
3404 * access to the documents across device reboots, you need to explicitly
3405 * take the persistable permissions using
3406 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3407 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003408 * Callers must indicate the acceptable document MIME types through
3409 * {@link #setType(String)}. For example, to select photos, use
3410 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3411 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3412 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003413 * <p>
3414 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003415 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3416 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003417 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003418 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3419 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003420 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003421 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003422 * Callers can set a document URI through
3423 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3424 * location of documents navigator. System will do its best to launch the
3425 * navigator in the specified document if it's a folder, or the folder that
3426 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003427 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003428 * Output: The URI of the item that was picked, returned in
3429 * {@link #getData()}. This must be a {@code content://} URI so that any
3430 * receiver can access it. If multiple documents were selected, they are
3431 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003432 *
3433 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003434 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003435 * @see #ACTION_CREATE_DOCUMENT
3436 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003437 */
3438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3439 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3440
3441 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003442 * Activity Action: Allow the user to create a new document. When invoked,
3443 * the system will display the various {@link DocumentsProvider} instances
3444 * installed on the device, letting the user navigate through them. The
3445 * returned document may be a newly created document with no content, or it
3446 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003447 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003448 * Each document is represented as a {@code content://} URI backed by a
3449 * {@link DocumentsProvider}, which can be opened as a stream with
3450 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3451 * {@link android.provider.DocumentsContract.Document} metadata.
3452 * <p>
3453 * Callers must indicate the concrete MIME type of the document being
3454 * created by setting {@link #setType(String)}. This MIME type cannot be
3455 * changed after the document is created.
3456 * <p>
3457 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3458 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003459 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003460 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3461 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003462 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003463 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003464 * Callers can set a document URI through
3465 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3466 * location of documents navigator. System will do its best to launch the
3467 * navigator in the specified document if it's a folder, or the folder that
3468 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003469 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003470 * Output: The URI of the item that was created. This must be a
3471 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003472 *
3473 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003474 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003475 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003476 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003477 */
3478 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3479 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3480
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003481 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003482 * Activity Action: Allow the user to pick a directory subtree. When
3483 * invoked, the system will display the various {@link DocumentsProvider}
3484 * instances installed on the device, letting the user navigate through
3485 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003486 * <p>
3487 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003488 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3489 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3490 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003491 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003492 * Callers can set a document URI through
3493 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3494 * location of documents navigator. System will do its best to launch the
3495 * navigator in the specified document if it's a folder, or the folder that
3496 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003497 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003498 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003499 *
3500 * @see DocumentsContract
3501 */
3502 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003503 public static final String
3504 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003505
Felipe Lemec7b1f892016-01-15 15:02:31 -08003506 /**
Peng Xua35b5532016-01-20 00:05:45 -08003507 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3508 * exisiting sensor being disconnected.
3509 *
3510 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3511 *
3512 * {@hide}
3513 */
3514 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3515 public static final String
3516 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3517
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003518 /**
Sam Line707f832017-04-13 17:00:55 -07003519 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003520 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003521 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003522 */
3523 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003524 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003525 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3526
Christopher Tate6597e342015-02-17 12:15:25 -08003527 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003528 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3529 * is about to be performed.
3530 * @hide
3531 */
3532 @SystemApi
3533 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3534 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3535 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3536
3537 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003538 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3539 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3540 *
3541 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3542 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003543 * @hide
3544 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003545 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003546 public static final String EXTRA_FORCE_MASTER_CLEAR =
3547 "android.intent.extra.FORCE_MASTER_CLEAR";
3548
3549 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003550 * A broadcast action to trigger a factory reset.
3551 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003552 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3553 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003554 *
3555 * <p>Not for use by third-party applications.
3556 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003557 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003558 *
3559 * {@hide}
3560 */
3561 @SystemApi
3562 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3563 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3564
3565 /**
3566 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3567 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3568 *
3569 * <p>Not for use by third-party applications.
3570 *
3571 * @hide
3572 */
3573 @SystemApi
3574 public static final String EXTRA_FORCE_FACTORY_RESET =
3575 "android.intent.extra.FORCE_FACTORY_RESET";
3576
3577 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003578 * Broadcast action: report that a settings element is being restored from backup. The intent
3579 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3580 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3581 * is the value of that settings entry prior to the restore operation, and
3582 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3583 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3584 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003585 *
3586 * <p>This broadcast is sent only for settings provider entries known to require special handling
3587 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3588 * the provider's backup agent implementation.
3589 *
3590 * @see #EXTRA_SETTING_NAME
3591 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3592 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003593 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003594 * {@hide}
3595 */
3596 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3597
3598 /** {@hide} */
3599 public static final String EXTRA_SETTING_NAME = "setting_name";
3600 /** {@hide} */
3601 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3602 /** {@hide} */
3603 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003604 /** {@hide} */
3605 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003606
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003607 /**
3608 * Activity Action: Process a piece of text.
3609 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3610 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3611 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3612 */
3613 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3614 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003615
3616 /**
3617 * Broadcast Action: The sim card state has changed.
3618 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3619 * because TelephonyIntents is an internal class.
3620 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003621 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3622 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003623 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003624 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003625 @SystemApi
3626 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3627 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3628
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003629 /**
fionaxu90fee272017-03-31 12:45:12 -07003630 * Broadcast Action: indicate that the phone service state has changed.
3631 * The intent will have the following extra values:</p>
3632 * <p>
3633 * @see #EXTRA_VOICE_REG_STATE
3634 * @see #EXTRA_DATA_REG_STATE
3635 * @see #EXTRA_VOICE_ROAMING_TYPE
3636 * @see #EXTRA_DATA_ROAMING_TYPE
3637 * @see #EXTRA_OPERATOR_ALPHA_LONG
3638 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3639 * @see #EXTRA_OPERATOR_NUMERIC
3640 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3641 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3642 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3643 * @see #EXTRA_MANUAL
3644 * @see #EXTRA_VOICE_RADIO_TECH
3645 * @see #EXTRA_DATA_RADIO_TECH
3646 * @see #EXTRA_CSS_INDICATOR
3647 * @see #EXTRA_NETWORK_ID
3648 * @see #EXTRA_SYSTEM_ID
3649 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3650 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3651 * @see #EXTRA_EMERGENCY_ONLY
3652 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3653 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3654 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3655 *
3656 * <p class="note">
3657 * Requires the READ_PHONE_STATE permission.
3658 *
3659 * <p class="note">This is a protected intent that can only be sent by the system.
3660 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003661 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003662 */
3663 @Deprecated
3664 @SystemApi
3665 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3666 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3667
3668 /**
3669 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3670 * state.
3671 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3672 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3673 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3674 * @see android.telephony.ServiceState#STATE_POWER_OFF
3675 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003676 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003677 */
3678 @Deprecated
3679 @SystemApi
3680 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3681
3682 /**
3683 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3684 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3685 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3686 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3687 * @see android.telephony.ServiceState#STATE_POWER_OFF
3688 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003689 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003690 */
3691 @Deprecated
3692 @SystemApi
3693 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3694
3695 /**
3696 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3697 * type.
3698 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003699 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003700 */
3701 @Deprecated
3702 @SystemApi
3703 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3704
3705 /**
3706 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3707 * type.
3708 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003709 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003710 */
3711 @Deprecated
3712 @SystemApi
3713 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3714
3715 /**
3716 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3717 * registered voice operator name in long alphanumeric format.
3718 * {@code null} if the operator name is not known or unregistered.
3719 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003720 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003721 */
3722 @Deprecated
3723 @SystemApi
3724 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3725
3726 /**
3727 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3728 * registered voice operator name in short 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
fionaxu90fee272017-03-31 12:45:12 -07003732 */
3733 @Deprecated
3734 @SystemApi
3735 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3736
3737 /**
3738 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3739 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3740 * network.
3741 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003742 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003743 */
3744 @Deprecated
3745 @SystemApi
3746 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3747
3748 /**
3749 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3750 * registered data operator name in long alphanumeric format.
3751 * {@code null} if the operator name is not known or unregistered.
3752 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003753 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003754 */
3755 @Deprecated
3756 @SystemApi
3757 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3758
3759 /**
3760 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3761 * registered data operator name in short alphanumeric format.
3762 * {@code null} if the operator name is not known or unregistered.
3763 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003764 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003765 */
3766 @Deprecated
3767 @SystemApi
3768 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3769
3770 /**
3771 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3772 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3773 * data operator.
3774 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003775 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003776 */
3777 @Deprecated
3778 @SystemApi
3779 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3780
3781 /**
3782 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3783 * network selection mode is manual.
3784 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3785 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003786 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003787 */
3788 @Deprecated
3789 @SystemApi
3790 public static final String EXTRA_MANUAL = "manual";
3791
3792 /**
3793 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3794 * radio technology.
3795 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003796 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003797 */
3798 @Deprecated
3799 @SystemApi
3800 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3801
3802 /**
3803 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3804 * radio technology.
3805 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003806 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003807 */
3808 @Deprecated
3809 @SystemApi
3810 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3811
3812 /**
3813 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3814 * support on CDMA network.
3815 * Will be {@code true} if support, {@code false} otherwise.
3816 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003817 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003818 */
3819 @Deprecated
3820 @SystemApi
3821 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3822
3823 /**
3824 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3825 * id. {@code Integer.MAX_VALUE} if unknown.
3826 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003827 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003828 */
3829 @Deprecated
3830 @SystemApi
3831 public static final String EXTRA_NETWORK_ID = "networkId";
3832
3833 /**
3834 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3835 * {@code Integer.MAX_VALUE} if unknown.
3836 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003837 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003838 */
3839 @Deprecated
3840 @SystemApi
3841 public static final String EXTRA_SYSTEM_ID = "systemId";
3842
3843 /**
3844 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3845 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3846 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003847 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003848 */
3849 @Deprecated
3850 @SystemApi
3851 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3852
3853 /**
3854 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3855 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3856 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003857 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003858 */
3859 @Deprecated
3860 @SystemApi
3861 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3862
3863 /**
3864 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3865 * only mode.
3866 * {@code true} if in emergency only mode, {@code false} otherwise.
3867 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003868 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003869 */
3870 @Deprecated
3871 @SystemApi
3872 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3873
3874 /**
3875 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3876 * registration state is roaming.
3877 * {@code true} if registration indicates roaming, {@code false} otherwise
3878 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003879 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003880 */
3881 @Deprecated
3882 @SystemApi
3883 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3884 "isDataRoamingFromRegistration";
3885
3886 /**
3887 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3888 * aggregation is in use.
3889 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3890 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003891 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003892 */
3893 @Deprecated
3894 @SystemApi
3895 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3896
3897 /**
3898 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3899 * is reduced from the rsrp threshold while calculating signal strength level.
3900 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003901 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003902 */
3903 @Deprecated
3904 @SystemApi
3905 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3906
3907 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003908 * The name of the extra used to define the text to be processed, as a
3909 * CharSequence. Note that this may be a styled CharSequence, so you must use
3910 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003911 */
3912 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3913 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003914 * 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 +00003915 */
3916 public static final String EXTRA_PROCESS_TEXT_READONLY =
3917 "android.intent.extra.PROCESS_TEXT_READONLY";
3918
Bryce Leebc58f592015-09-25 16:43:01 -07003919 /**
3920 * Broadcast action: reports when a new thermal event has been reached. When the device
3921 * is reaching its maximum temperatue, the thermal level reported
3922 * {@hide}
3923 */
3924 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3925 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3926
3927 /** {@hide} */
3928 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
3929
3930 /**
3931 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003932 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003933 * {@hide}
3934 */
3935 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
3936
3937 /**
3938 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003939 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003940 * {@hide}
3941 */
3942 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
3943
3944 /**
3945 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08003946 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07003947 * {@hide}
3948 */
3949 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
3950
3951
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003952 // ---------------------------------------------------------------------
3953 // ---------------------------------------------------------------------
3954 // Standard intent categories (see addCategory()).
3955
3956 /**
3957 * Set if the activity should be an option for the default action
3958 * (center press) to perform on a piece of data. Setting this will
3959 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04003960 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003961 * Intent when initiating an action -- it is for use in intent filters
3962 * specified in packages.
3963 */
3964 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3965 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
3966 /**
3967 * Activities that can be safely invoked from a browser must support this
3968 * category. For example, if the user is viewing a web page or an e-mail
3969 * and clicks on a link in the text, the Intent generated execute that
3970 * link will require the BROWSABLE category, so that only activities
3971 * supporting this category will be considered as possible actions. By
3972 * supporting this category, you are promising that there is nothing
3973 * damaging (without user intervention) that can happen by invoking any
3974 * matching Intent.
3975 */
3976 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3977 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
3978 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07003979 * Categories for activities that can participate in voice interaction.
3980 * An activity that supports this category must be prepared to run with
3981 * no UI shown at all (though in some case it may have a UI shown), and
3982 * rely on {@link android.app.VoiceInteractor} to interact with the user.
3983 */
3984 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
3985 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
3986 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003987 * Set if the activity should be considered as an alternative action to
3988 * the data the user is currently viewing. See also
3989 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
3990 * applies to the selection in a list of items.
3991 *
3992 * <p>Supporting this category means that you would like your activity to be
3993 * displayed in the set of alternative things the user can do, usually as
3994 * part of the current activity's options menu. You will usually want to
3995 * include a specific label in the &lt;intent-filter&gt; of this action
3996 * describing to the user what it does.
3997 *
3998 * <p>The action of IntentFilter with this category is important in that it
3999 * describes the specific action the target will perform. This generally
4000 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4001 * a specific name such as "com.android.camera.action.CROP. Only one
4002 * alternative of any particular action will be shown to the user, so using
4003 * a specific action like this makes sure that your alternative will be
4004 * displayed while also allowing other applications to provide their own
4005 * overrides of that particular action.
4006 */
4007 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4008 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4009 /**
4010 * Set if the activity should be considered as an alternative selection
4011 * action to the data the user has currently selected. This is like
4012 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4013 * of items from which the user can select, giving them alternatives to the
4014 * default action that will be performed on it.
4015 */
4016 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4017 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4018 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004019 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004020 */
4021 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4022 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4023 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004024 * Should be displayed in the top-level launcher.
4025 */
4026 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4027 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4028 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004029 * Indicates an activity optimized for Leanback mode, and that should
4030 * be displayed in the Leanback launcher.
4031 */
4032 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4033 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4034 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004035 * Indicates the preferred entry-point activity when an application is launched from a Car
4036 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4037 * fallback, or exclude the application entirely.
4038 * @hide
4039 */
4040 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4041 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4042 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004043 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4044 * @hide
4045 */
4046 @SystemApi
4047 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4048 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004049 * Provides information about the package it is in; typically used if
4050 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4051 * a front-door to the user without having to be shown in the all apps list.
4052 */
4053 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4054 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4055 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004056 * This is the home activity, that is the first activity that is displayed
4057 * when the device boots.
4058 */
4059 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4060 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4061 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004062 * This is the home activity that is displayed when the device is finished setting up and ready
4063 * for use.
4064 * @hide
4065 */
4066 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4067 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4068 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004069 * This is the setup wizard activity, that is the first activity that is displayed
4070 * when the user sets up the device for the first time.
4071 * @hide
4072 */
4073 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4074 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4075 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004076 * This is the home activity, that is the activity that serves as the launcher app
4077 * from there the user can start other apps. Often components with lower/higher
4078 * priority intent filters handle the home intent, for example SetupWizard, to
4079 * setup the device and we need to be able to distinguish the home app from these
4080 * setup helpers.
4081 * @hide
4082 */
4083 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4084 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4085 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004086 * This activity is a preference panel.
4087 */
4088 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4089 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4090 /**
4091 * This activity is a development preference panel.
4092 */
4093 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4094 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4095 /**
4096 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004097 */
4098 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4099 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4100 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004101 * This activity allows the user to browse and download new applications.
4102 */
4103 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4104 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4105 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004106 * This activity may be exercised by the monkey or other automated test tools.
4107 */
4108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4109 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4110 /**
4111 * To be used as a test (not part of the normal user experience).
4112 */
4113 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4114 /**
4115 * To be used as a unit test (run through the Test Harness).
4116 */
4117 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4118 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004119 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004120 * experience).
4121 */
4122 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004123
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004124 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004125 * Used to indicate that an intent only wants URIs that can be opened with
4126 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4127 * must support at least the columns defined in {@link OpenableColumns} when
4128 * queried.
4129 *
4130 * @see #ACTION_GET_CONTENT
4131 * @see #ACTION_OPEN_DOCUMENT
4132 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004133 */
4134 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4135 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4136
4137 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004138 * Used to indicate that an intent filter can accept files which are not necessarily
4139 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4140 * at least streamable via
4141 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4142 * using one of the stream types exposed via
4143 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4144 *
4145 * @see #ACTION_SEND
4146 * @see #ACTION_SEND_MULTIPLE
4147 */
4148 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4149 public static final String CATEGORY_TYPED_OPENABLE =
4150 "android.intent.category.TYPED_OPENABLE";
4151
4152 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004153 * To be used as code under test for framework instrumentation tests.
4154 */
4155 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4156 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004157 /**
4158 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004159 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4160 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004161 */
4162 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4163 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4164 /**
4165 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004166 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4167 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004168 */
4169 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4170 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004171 /**
4172 * An activity to run when device is inserted into a analog (low end) dock.
4173 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4174 * information, see {@link android.app.UiModeManager}.
4175 */
4176 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4177 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4178
4179 /**
4180 * An activity to run when device is inserted into a digital (high end) dock.
4181 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4182 * information, see {@link android.app.UiModeManager}.
4183 */
4184 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4185 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004186
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004187 /**
4188 * Used to indicate that the activity can be used in a car environment.
4189 */
4190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4191 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4192
Zak Cohendb6ca492017-01-26 14:09:00 -08004193 /**
4194 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4195 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4196 * information, see {@link android.app.UiModeManager}.
4197 */
4198 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4199 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004200 // ---------------------------------------------------------------------
4201 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004202 // Application launch intent categories (see addCategory()).
4203
4204 /**
4205 * Used with {@link #ACTION_MAIN} to launch the browser application.
4206 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004207 * <p>NOTE: This should not be used as the primary key of an Intent,
4208 * since it will not result in the app launching with the correct
4209 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004210 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004211 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004212 */
4213 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4214 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4215
4216 /**
4217 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4218 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004219 * <p>NOTE: This should not be used as the primary key of an Intent,
4220 * since it will not result in the app launching with the correct
4221 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004222 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004223 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004224 */
4225 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4226 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4227
4228 /**
4229 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4230 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004231 * <p>NOTE: This should not be used as the primary key of an Intent,
4232 * since it will not result in the app launching with the correct
4233 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004234 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004235 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004236 */
4237 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4238 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4239
4240 /**
4241 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4242 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004243 * <p>NOTE: This should not be used as the primary key of an Intent,
4244 * since it will not result in the app launching with the correct
4245 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004246 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004247 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004248 */
4249 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4250 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4251
4252 /**
4253 * Used with {@link #ACTION_MAIN} to launch the email application.
4254 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004255 * <p>NOTE: This should not be used as the primary key of an Intent,
4256 * since it will not result in the app launching with the correct
4257 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004258 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004259 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004260 */
4261 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4262 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4263
4264 /**
4265 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4266 * The activity should be able to view and manipulate image and video files
4267 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004268 * <p>NOTE: This should not be used as the primary key of an Intent,
4269 * since it will not result in the app launching with the correct
4270 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004271 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004272 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004273 */
4274 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4275 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4276
4277 /**
4278 * Used with {@link #ACTION_MAIN} to launch the maps application.
4279 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004280 * <p>NOTE: This should not be used as the primary key of an Intent,
4281 * since it will not result in the app launching with the correct
4282 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004283 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004284 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004285 */
4286 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4287 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4288
4289 /**
4290 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4291 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004292 * <p>NOTE: This should not be used as the primary key of an Intent,
4293 * since it will not result in the app launching with the correct
4294 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004295 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004296 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004297 */
4298 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4299 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4300
4301 /**
4302 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004303 * The activity should be able to play, browse, or manipulate music files
4304 * stored on the device.
4305 * <p>NOTE: This should not be used as the primary key of an Intent,
4306 * since it will not result in the app launching with the correct
4307 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004308 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004309 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004310 */
4311 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4312 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4313
4314 // ---------------------------------------------------------------------
4315 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004316 // Standard extra data keys.
4317
4318 /**
4319 * The initial data to place in a newly created record. Use with
4320 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4321 * fields as would be given to the underlying ContentProvider.insert()
4322 * call.
4323 */
4324 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4325
4326 /**
4327 * A constant CharSequence that is associated with the Intent, used with
4328 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4329 * this may be a styled CharSequence, so you must use
4330 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4331 * retrieve it.
4332 */
4333 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4334
4335 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004336 * A constant String that is associated with the Intent, used with
4337 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4338 * as HTML formatted text. Note that you <em>must</em> also supply
4339 * {@link #EXTRA_TEXT}.
4340 */
4341 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4342
4343 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004344 * A content: URI holding a stream of data associated with the Intent,
4345 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004346 */
4347 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4348
4349 /**
4350 * A String[] holding e-mail addresses that should be delivered to.
4351 */
4352 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4353
4354 /**
4355 * A String[] holding e-mail addresses that should be carbon copied.
4356 */
4357 public static final String EXTRA_CC = "android.intent.extra.CC";
4358
4359 /**
4360 * A String[] holding e-mail addresses that should be blind carbon copied.
4361 */
4362 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4363
4364 /**
4365 * A constant string holding the desired subject line of a message.
4366 */
4367 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4368
4369 /**
4370 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004371 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004372 */
4373 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4374
4375 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004376 * An int representing the user id to be used.
4377 *
4378 * @hide
4379 */
4380 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4381
4382 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004383 * An int representing the task id to be retrieved. This is used when a launch from recents is
4384 * intercepted by another action such as credentials confirmation to remember which task should
4385 * be resumed when complete.
4386 *
4387 * @hide
4388 */
4389 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4390
4391 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004392 * An Intent[] describing additional, alternate choices you would like shown with
4393 * {@link #ACTION_CHOOSER}.
4394 *
4395 * <p>An app may be capable of providing several different payload types to complete a
4396 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4397 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4398 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4399 * photo data or a hosted link where the photos can be viewed.</p>
4400 *
4401 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4402 * first/primary/preferred intent in the set. Additional intents specified in
4403 * this extra are ordered; by default intents that appear earlier in the array will be
4404 * preferred over intents that appear later in the array as matches for the same
4405 * target component. To alter this preference, a calling app may also supply
4406 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4407 */
4408 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4409
4410 /**
Adam Powell52c39212016-04-07 15:14:18 -07004411 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4412 * and omitted from a list of components presented to the user.
4413 *
4414 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4415 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4416 * from your own package or other apps from your organization if the idea of sending to those
4417 * targets would be redundant with other app functionality. Filtered components will not
4418 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4419 */
4420 public static final String EXTRA_EXCLUDE_COMPONENTS
4421 = "android.intent.extra.EXCLUDE_COMPONENTS";
4422
4423 /**
4424 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4425 * describing additional high-priority deep-link targets for the chooser to present to the user.
4426 *
4427 * <p>Targets provided in this way will be presented inline with all other targets provided
4428 * by services from other apps. They will be prioritized before other service targets, but
4429 * after those targets provided by sources that the user has manually pinned to the front.</p>
4430 *
4431 * @see #ACTION_CHOOSER
4432 */
4433 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4434
4435 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004436 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4437 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4438 *
4439 * <p>An app preparing an action for another app to complete may wish to allow the user to
4440 * disambiguate between several options for completing the action based on the chosen target
4441 * or otherwise refine the action before it is invoked.
4442 * </p>
4443 *
4444 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4445 * <ul>
4446 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4447 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4448 * chosen target beyond the first</li>
4449 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4450 * should fill in and send once the disambiguation is complete</li>
4451 * </ul>
4452 */
4453 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4454 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4455
4456 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004457 * An {@code ArrayList} of {@code String} annotations describing content for
4458 * {@link #ACTION_CHOOSER}.
4459 *
4460 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4461 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4462 *
4463 * <p>Annotations should describe the major components or topics of the content. It is up to
4464 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4465 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004466 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4467 * character. Performance on customized annotations can suffer, if they are rarely used for
4468 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4469 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004470 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004471 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004472 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004473 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004474 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004475 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004476 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004477 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004478 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004479 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4480 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4481 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4482 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4483 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004484 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004485 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4486 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004487 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004488 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004489 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004490 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004491 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004492 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004493 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004494 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004495 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004496 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004497 * Christmas and Thanksgiving.</li>
4498 * </ul>
4499 */
4500 public static final String EXTRA_CONTENT_ANNOTATIONS
4501 = "android.intent.extra.CONTENT_ANNOTATIONS";
4502
4503 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004504 * A {@link ResultReceiver} used to return data back to the sender.
4505 *
4506 * <p>Used to complete an app-specific
4507 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4508 *
4509 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4510 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4511 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4512 * when the user selects a target component from the chooser. It is up to the recipient
4513 * to send a result to this ResultReceiver to signal that disambiguation is complete
4514 * and that the chooser should invoke the user's choice.</p>
4515 *
4516 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4517 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4518 * to match and fill in the final Intent or ChooserTarget before starting it.
4519 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4520 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4521 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4522 *
4523 * <p>The result code passed to the ResultReceiver should be
4524 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4525 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4526 * the chooser should finish without starting a target.</p>
4527 */
4528 public static final String EXTRA_RESULT_RECEIVER
4529 = "android.intent.extra.RESULT_RECEIVER";
4530
4531 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004533 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004534 */
4535 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4536
4537 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004538 * A Parcelable[] of {@link Intent} or
4539 * {@link android.content.pm.LabeledIntent} objects as set with
4540 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4541 * a the front of the list of choices, when shown to the user with a
4542 * {@link #ACTION_CHOOSER}.
4543 */
4544 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4545
4546 /**
Todd Kennedy7440f172015-12-09 14:31:22 -08004547 * A {@link IntentSender} to start after ephemeral installation success.
Patrick Baumann159cd022018-01-11 13:25:05 -08004548 * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
4549 * @removed
Todd Kennedy7440f172015-12-09 14:31:22 -08004550 * @hide
4551 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004552 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004553 public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
4554
4555 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004556 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004557 * @hide
4558 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004559 @SystemApi
4560 public static final String EXTRA_INSTANT_APP_SUCCESS =
4561 "android.intent.extra.INSTANT_APP_SUCCESS";
4562
4563 /**
4564 * A {@link IntentSender} to start after ephemeral installation failure.
4565 * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
4566 * @removed
4567 * @hide
4568 */
4569 @Deprecated
Todd Kennedy7440f172015-12-09 14:31:22 -08004570 public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
4571
4572 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004573 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004574 * @hide
4575 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004576 @SystemApi
4577 public static final String EXTRA_INSTANT_APP_FAILURE =
4578 "android.intent.extra.INSTANT_APP_FAILURE";
4579
4580 /**
4581 * The host name that triggered an ephemeral resolution.
4582 * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
4583 * @removed
4584 * @hide
4585 */
4586 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004587 public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
4588
4589 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004590 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004591 * @hide
4592 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004593 @SystemApi
4594 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4595 "android.intent.extra.INSTANT_APP_HOSTNAME";
4596
4597 /**
4598 * An opaque token to track ephemeral resolution.
4599 * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
4600 * @removed
4601 * @hide
4602 */
4603 @Deprecated
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004604 public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
4605
4606 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004607 * An opaque token to track instant app resolution.
4608 * @hide
4609 */
4610 @SystemApi
4611 public static final String EXTRA_INSTANT_APP_TOKEN =
4612 "android.intent.extra.INSTANT_APP_TOKEN";
4613
4614 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004615 * The action that triggered an instant application resolution.
4616 * @hide
4617 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004618 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004619 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4620
4621 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004622 * An array of {@link Bundle}s containing details about resolved instant apps..
4623 * @hide
4624 */
4625 @SystemApi
4626 public static final String EXTRA_INSTANT_APP_BUNDLES =
4627 "android.intent.extra.INSTANT_APP_BUNDLES";
4628
4629 /**
4630 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004631 * installed. This data is populated from the response to
4632 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4633 * instant application resolver.
4634 * @hide
4635 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004636 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004637 public static final String EXTRA_INSTANT_APP_EXTRAS =
4638 "android.intent.extra.INSTANT_APP_EXTRAS";
4639
4640 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004641 * A boolean value indicating that the instant app resolver was unable to state with certainty
4642 * that it did or did not have an app for the sanitized {@link Intent} defined at
4643 * {@link #EXTRA_INTENT}.
4644 * @hide
4645 */
4646 @SystemApi
4647 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4648 "android.intent.extra.UNKNOWN_INSTANT_APP";
4649
4650 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004651 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004652 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004653 * @hide
4654 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004655 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004656 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4657
4658 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004659 * The version code of the app to install components from.
4660 * @hide
4661 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004662 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004663 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4664
4665 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004666 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004667 * @hide
4668 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004669 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004670 public static final String EXTRA_CALLING_PACKAGE
4671 = "android.intent.extra.CALLING_PACKAGE";
4672
4673 /**
4674 * Optional calling app provided bundle containing additional launch information the
4675 * installer may use.
4676 * @hide
4677 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004678 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004679 public static final String EXTRA_VERIFICATION_BUNDLE
4680 = "android.intent.extra.VERIFICATION_BUNDLE";
4681
4682 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004683 * A Bundle forming a mapping of potential target package names to different extras Bundles
4684 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4685 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4686 * be currently installed on the device.
4687 *
4688 * <p>An application may choose to provide alternate extras for the case where a user
4689 * selects an activity from a predetermined set of target packages. If the activity
4690 * the user selects from the chooser belongs to a package with its package name as
4691 * a key in this bundle, the corresponding extras for that package will be merged with
4692 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4693 * extra has the same key as an extra already present in the intent it will overwrite
4694 * the extra from the intent.</p>
4695 *
4696 * <p><em>Examples:</em>
4697 * <ul>
4698 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4699 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4700 * parameters for that target.</li>
4701 * <li>An application may offer additional metadata for known targets of a given intent
4702 * to pass along information only relevant to that target such as account or content
4703 * identifiers already known to that application.</li>
4704 * </ul></p>
4705 */
4706 public static final String EXTRA_REPLACEMENT_EXTRAS =
4707 "android.intent.extra.REPLACEMENT_EXTRAS";
4708
4709 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004710 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4711 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4712 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4713 * {@link ComponentName} of the chosen component.
4714 *
4715 * <p>In some situations this callback may never come, for example if the user abandons
4716 * the chooser, switches to another task or any number of other reasons. Apps should not
4717 * be written assuming that this callback will always occur.</p>
4718 */
4719 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4720 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4721
4722 /**
4723 * The {@link ComponentName} chosen by the user to complete an action.
4724 *
4725 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4726 */
4727 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4728
4729 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004730 * A {@link android.view.KeyEvent} object containing the event that
4731 * triggered the creation of the Intent it is in.
4732 */
4733 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4734
4735 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004736 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4737 * before shutting down.
4738 *
4739 * {@hide}
4740 */
4741 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4742
4743 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004744 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4745 * requested by the user.
4746 *
4747 * {@hide}
4748 */
4749 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4750 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4751
4752 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004753 * 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 -07004754 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4755 * of restarting the application.
4756 */
4757 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4758
4759 /**
4760 * A String holding the phone number originally entered in
4761 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4762 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4763 */
4764 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004765
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004766 /**
4767 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4768 * intents to supply the uid the package had been assigned. Also an optional
4769 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4770 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4771 * purpose.
4772 */
4773 public static final String EXTRA_UID = "android.intent.extra.UID";
4774
4775 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004776 * @hide String array of package names.
4777 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004778 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004779 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4780
4781 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004782 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4783 * intents to indicate whether this represents a full uninstall (removing
4784 * both the code and its data) or a partial uninstall (leaving its data,
4785 * implying that this is an update).
4786 */
4787 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004788
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004789 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004790 * @hide
4791 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4792 * intents to indicate that at this point the package has been removed for
4793 * all users on the device.
4794 */
4795 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4796 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4797
4798 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004799 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4800 * intents to indicate that this is a replacement of the package, so this
4801 * broadcast will immediately be followed by an add broadcast for a
4802 * different version of the same package.
4803 */
4804 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004805
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004806 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004807 * Used as an int extra field in {@link android.app.AlarmManager} intents
4808 * to tell the application being invoked how many pending alarms are being
4809 * delievered with the intent. For one-shot alarms this will always be 1.
4810 * For recurring alarms, this might be greater than 1 if the device was
4811 * asleep or powered off at the time an earlier alarm would have been
4812 * delivered.
4813 */
4814 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004815
Jacek Surazski86b6c532009-05-13 14:38:28 +02004816 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004817 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4818 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004819 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4820 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004821 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4822 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4823 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004824 */
4825 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4826
4827 /**
4828 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4829 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004830 */
4831 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4832
4833 /**
4834 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4835 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004836 */
4837 public static final int EXTRA_DOCK_STATE_DESK = 1;
4838
4839 /**
4840 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4841 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004842 */
4843 public static final int EXTRA_DOCK_STATE_CAR = 2;
4844
4845 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004846 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4847 * to represent that the phone is in a analog (low end) dock.
4848 */
4849 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4850
4851 /**
4852 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4853 * to represent that the phone is in a digital (high end) dock.
4854 */
4855 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4856
4857 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004858 * Boolean that can be supplied as meta-data with a dock activity, to
4859 * indicate that the dock should take over the home key when it is active.
4860 */
4861 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004862
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004863 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004864 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4865 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004866 */
4867 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4868
4869 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004870 * Used in the extra field in the remote intent. It's astring token passed with the
4871 * remote intent.
4872 */
4873 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4874 "android.intent.extra.remote_intent_token";
4875
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004876 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004877 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004878 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004879 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004880 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004881 "android.intent.extra.changed_component_name";
4882
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004883 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004884 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004885 * and contains a string array of all of the components that have changed. If
4886 * the state of the overall package has changed, then it will contain an entry
4887 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004888 */
4889 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4890 "android.intent.extra.changed_component_name_list";
4891
4892 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004893 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004894 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004895 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4896 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4897 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004898 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004899 */
4900 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4901 "android.intent.extra.changed_package_list";
4902
4903 /**
4904 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004905 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4906 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004907 * and contains an integer array of uids of all of the components
4908 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004909 */
4910 public static final String EXTRA_CHANGED_UID_LIST =
4911 "android.intent.extra.changed_uid_list";
4912
4913 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004914 * @hide
4915 * Magic extra system code can use when binding, to give a label for
4916 * who it is that has bound to a service. This is an integer giving
4917 * a framework string resource that can be displayed to the user.
4918 */
4919 public static final String EXTRA_CLIENT_LABEL =
4920 "android.intent.extra.client_label";
4921
4922 /**
4923 * @hide
4924 * Magic extra system code can use when binding, to give a PendingIntent object
4925 * that can be launched for the user to disable the system's use of this
4926 * service.
4927 */
4928 public static final String EXTRA_CLIENT_INTENT =
4929 "android.intent.extra.client_intent";
4930
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004931 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004932 * Extra used to indicate that an intent should only return data that is on
4933 * the local device. This is a boolean extra; the default is false. If true,
4934 * an implementation should only allow the user to select data that is
4935 * already on the device, not requiring it be downloaded from a remote
4936 * service when opened.
4937 *
4938 * @see #ACTION_GET_CONTENT
4939 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004940 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004941 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004942 */
4943 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004944 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07004945
Amith Yamasani13593602012-03-22 16:16:17 -07004946 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004947 * Extra used to indicate that an intent can allow the user to select and
4948 * return multiple items. This is a boolean extra; the default is false. If
4949 * true, an implementation is allowed to present the user with a UI where
4950 * they can pick multiple items that are all returned to the caller. When
4951 * this happens, they should be returned as the {@link #getClipData()} part
4952 * of the result Intent.
4953 *
4954 * @see #ACTION_GET_CONTENT
4955 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004956 */
4957 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004958 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08004959
4960 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004961 * The integer userHandle carried with broadcast intents related to addition, removal and
4962 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
4963 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
4964 *
Amith Yamasani13593602012-03-22 16:16:17 -07004965 * @hide
4966 */
Amith Yamasani2a003292012-08-14 18:25:45 -07004967 public static final String EXTRA_USER_HANDLE =
4968 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07004969
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004970 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004971 * The UserHandle carried with broadcasts intents related to addition and removal of managed
4972 * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
4973 */
4974 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01004975 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01004976
4977 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004978 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004979 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
4980 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004981 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07004982 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
4983
4984 /**
4985 * Extra sent in the intent to the BroadcastReceiver that handles
4986 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
4987 * the restrictions as key/value pairs.
4988 */
4989 public static final String EXTRA_RESTRICTIONS_BUNDLE =
4990 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08004991
Amith Yamasani86118ba2013-03-28 14:33:16 -07004992 /**
4993 * Extra used in the response from a BroadcastReceiver that handles
4994 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
4995 */
4996 public static final String EXTRA_RESTRICTIONS_INTENT =
4997 "android.intent.extra.restrictions_intent";
4998
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07004999 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005000 * Extra used to communicate a set of acceptable MIME types. The type of the
5001 * extra is {@code String[]}. Values may be a combination of concrete MIME
5002 * types (such as "image/png") and/or partial MIME types (such as
5003 * "audio/*").
5004 *
5005 * @see #ACTION_GET_CONTENT
5006 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005007 */
5008 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5009
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005010 /**
5011 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5012 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005013 * When this is true, hardware devices can use this information to determine that
5014 * they shouldn't do a complete shutdown of their device since this is not a
5015 * complete shutdown down to the kernel, but only user space restarting.
5016 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005017 */
5018 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5019 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5020
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005021 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005022 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5023 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5024 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5025 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005026 *
5027 * @hide for internal use only.
5028 */
5029 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5030 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005031 /** @hide */
5032 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5033 /** @hide */
5034 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5035 /** @hide */
5036 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005037
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005038 /**
5039 * Intent extra: the reason that the operation associated with this intent is being performed.
5040 *
5041 * <p>Type: String
5042 * @hide
5043 */
5044 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005045 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5046
qingxi240c2bb2017-04-12 17:31:18 -07005047 /**
5048 * {@hide}
5049 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5050 */
Rubin Xue8490f12015-06-25 12:17:48 +01005051 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5052
Santos Cordon15a13782015-03-31 18:32:31 -07005053 /**
qingxi240c2bb2017-04-12 17:31:18 -07005054 * {@hide}
5055 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5056 * reset for the device with eSIM. This extra will be sent together with
5057 * {@link #ACTION_FACTORY_RESET}
5058 */
5059 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5060
5061 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005062 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5063 * activation request.
5064 * TODO: Add information about the structure and response data used with the pending intent.
5065 * @hide
5066 */
5067 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5068 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5069
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005070 /**
5071 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005072 *
5073 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005074 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005075 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005076 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5077
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005078 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005079 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5080 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5081 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005082 *
5083 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005084 * @see #ACTION_QUICK_VIEW
5085 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005086 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005087 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005088 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5089 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005090
5091 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005092 * An optional extra of {@code String[]} indicating which quick view features should be made
5093 * available to the user in the quick view UI while handing a
5094 * {@link Intent#ACTION_QUICK_VIEW} intent.
5095 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5096 * Quick viewer can implement features not listed below.
5097 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005098 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5099 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5100 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005101 * <p>
5102 * Requirements:
5103 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5104 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5105 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5106 * internal policies.
5107 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5108 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5109 * disable or hide features.
5110 *
5111 * @see #ACTION_QUICK_VIEW
5112 */
5113 public static final String EXTRA_QUICK_VIEW_FEATURES =
5114 "android.intent.extra.QUICK_VIEW_FEATURES";
5115
5116 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005117 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005118 * When a profile goes into quiet mode, all apps in the profile are killed and the
5119 * profile user is stopped. Widgets originating from the profile are masked, and app
5120 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005121 */
5122 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005123
5124 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005125 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005126 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005127 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5128 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005129 *
5130 * @hide
5131 */
5132 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5133 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5134
5135 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005136 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5137 * whether to show the chooser or not when there is only one application available
5138 * to choose from.
5139 *
5140 * @hide
5141 */
5142 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5143 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5144
5145 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005146 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005147 * to represent that a video codec is allowed to use.
5148 *
5149 * @hide
5150 */
5151 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5152
5153 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005154 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005155 * to represent that a audio codec is allowed to use.
5156 *
5157 * @hide
5158 */
5159 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5160
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005161 // ---------------------------------------------------------------------
5162 // ---------------------------------------------------------------------
5163 // Intent flags (see mFlags variable).
5164
Tor Norbyed9273d62013-05-30 15:59:53 -07005165 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005166 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005167 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5168 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005169 @Retention(RetentionPolicy.SOURCE)
5170 public @interface GrantUriMode {}
5171
Jeff Sharkey846318a2014-04-04 12:12:41 -07005172 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005173 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005174 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5175 @Retention(RetentionPolicy.SOURCE)
5176 public @interface AccessUriMode {}
5177
5178 /**
5179 * Test if given mode flags specify an access mode, which must be at least
5180 * read and/or write.
5181 *
5182 * @hide
5183 */
5184 public static boolean isAccessUriMode(int modeFlags) {
5185 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5186 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5187 }
5188
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005189 /** @hide */
5190 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5191 FLAG_GRANT_READ_URI_PERMISSION,
5192 FLAG_GRANT_WRITE_URI_PERMISSION,
5193 FLAG_FROM_BACKGROUND,
5194 FLAG_DEBUG_LOG_RESOLUTION,
5195 FLAG_EXCLUDE_STOPPED_PACKAGES,
5196 FLAG_INCLUDE_STOPPED_PACKAGES,
5197 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5198 FLAG_GRANT_PREFIX_URI_PERMISSION,
5199 FLAG_DEBUG_TRIAGED_MISSING,
5200 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005201 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005202 FLAG_ACTIVITY_NO_HISTORY,
5203 FLAG_ACTIVITY_SINGLE_TOP,
5204 FLAG_ACTIVITY_NEW_TASK,
5205 FLAG_ACTIVITY_MULTIPLE_TASK,
5206 FLAG_ACTIVITY_CLEAR_TOP,
5207 FLAG_ACTIVITY_FORWARD_RESULT,
5208 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5209 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5210 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5211 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5212 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5213 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5214 FLAG_ACTIVITY_NEW_DOCUMENT,
5215 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5216 FLAG_ACTIVITY_NO_USER_ACTION,
5217 FLAG_ACTIVITY_REORDER_TO_FRONT,
5218 FLAG_ACTIVITY_NO_ANIMATION,
5219 FLAG_ACTIVITY_CLEAR_TASK,
5220 FLAG_ACTIVITY_TASK_ON_HOME,
5221 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5222 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5223 FLAG_RECEIVER_REGISTERED_ONLY,
5224 FLAG_RECEIVER_REPLACE_PENDING,
5225 FLAG_RECEIVER_FOREGROUND,
5226 FLAG_RECEIVER_NO_ABORT,
5227 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5228 FLAG_RECEIVER_BOOT_UPGRADE,
5229 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5230 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5231 FLAG_RECEIVER_FROM_SHELL,
5232 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5233 })
5234 @Retention(RetentionPolicy.SOURCE)
5235 public @interface Flags {}
5236
5237 /** @hide */
5238 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5239 FLAG_FROM_BACKGROUND,
5240 FLAG_DEBUG_LOG_RESOLUTION,
5241 FLAG_EXCLUDE_STOPPED_PACKAGES,
5242 FLAG_INCLUDE_STOPPED_PACKAGES,
5243 FLAG_DEBUG_TRIAGED_MISSING,
5244 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005245 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005246 FLAG_ACTIVITY_NO_HISTORY,
5247 FLAG_ACTIVITY_SINGLE_TOP,
5248 FLAG_ACTIVITY_NEW_TASK,
5249 FLAG_ACTIVITY_MULTIPLE_TASK,
5250 FLAG_ACTIVITY_CLEAR_TOP,
5251 FLAG_ACTIVITY_FORWARD_RESULT,
5252 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5253 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5254 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5255 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5256 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5257 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5258 FLAG_ACTIVITY_NEW_DOCUMENT,
5259 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5260 FLAG_ACTIVITY_NO_USER_ACTION,
5261 FLAG_ACTIVITY_REORDER_TO_FRONT,
5262 FLAG_ACTIVITY_NO_ANIMATION,
5263 FLAG_ACTIVITY_CLEAR_TASK,
5264 FLAG_ACTIVITY_TASK_ON_HOME,
5265 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5266 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5267 FLAG_RECEIVER_REGISTERED_ONLY,
5268 FLAG_RECEIVER_REPLACE_PENDING,
5269 FLAG_RECEIVER_FOREGROUND,
5270 FLAG_RECEIVER_NO_ABORT,
5271 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5272 FLAG_RECEIVER_BOOT_UPGRADE,
5273 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5274 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5275 FLAG_RECEIVER_FROM_SHELL,
5276 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5277 })
5278 @Retention(RetentionPolicy.SOURCE)
5279 public @interface MutableFlags {}
5280
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005281 /**
5282 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005283 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005284 * specified in its ClipData. When applying to an Intent's ClipData,
5285 * all URIs as well as recursive traversals through data or other ClipData
5286 * in Intent items will be granted; only the grant flags of the top-level
5287 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005288 */
5289 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5290 /**
5291 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005292 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005293 * specified in its ClipData. When applying to an Intent's ClipData,
5294 * all URIs as well as recursive traversals through data or other ClipData
5295 * in Intent items will be granted; only the grant flags of the top-level
5296 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005297 */
5298 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5299 /**
5300 * Can be set by the caller to indicate that this Intent is coming from
5301 * a background operation, not from direct user interaction.
5302 */
5303 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5304 /**
5305 * A flag you can enable for debugging: when set, log messages will be
5306 * printed during the resolution of this intent to show you what has
5307 * been found to create the final resolved list.
5308 */
5309 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005310 /**
5311 * If set, this intent will not match any components in packages that
5312 * are currently stopped. If this is not set, then the default behavior
5313 * is to include such applications in the result.
5314 */
5315 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5316 /**
5317 * If set, this intent will always match any components in packages that
5318 * are currently stopped. This is the default behavior when
5319 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5320 * flags are set, this one wins (it allows overriding of exclude for
5321 * places where the framework may automatically set the exclude flag).
5322 */
5323 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005324
5325 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005326 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005327 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005328 * persisted across device reboots until explicitly revoked with
5329 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5330 * grant for possible persisting; the receiving application must call
5331 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5332 * actually persist.
5333 *
5334 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5335 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5336 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005337 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005338 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005339 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005340
5341 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005342 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5343 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5344 * applies to any URI that is a prefix match against the original granted
5345 * URI. (Without this flag, the URI must match exactly for access to be
5346 * granted.) Another URI is considered a prefix match only when scheme,
5347 * authority, and all path segments defined by the prefix are an exact
5348 * match.
5349 */
5350 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5351
5352 /**
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005353 * Internal flag used to indicate that a system component has done their
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005354 * homework and verified that they correctly handle packages and components
5355 * that come and go over time. In particular:
5356 * <ul>
5357 * <li>Apps installed on external storage, which will appear to be
5358 * uninstalled while the the device is ejected.
5359 * <li>Apps with encryption unaware components, which will appear to not
5360 * exist while the device is locked.
5361 * </ul>
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005362 *
5363 * @hide
5364 */
Jeff Sharkey2f3e3532015-12-21 14:16:43 -07005365 public static final int FLAG_DEBUG_TRIAGED_MISSING = 0x00000100;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005366
5367 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005368 * Internal flag used to indicate ephemeral applications should not be
5369 * considered when resolving the intent.
5370 *
5371 * @hide
5372 */
5373 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5374
5375 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005376 * If set, the new activity is not kept in the history stack. As soon as
5377 * the user navigates away from it, the activity is finished. This may also
5378 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5379 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005380 *
5381 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5382 * is never invoked when the current activity starts a new activity which
5383 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005384 */
5385 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5386 /**
5387 * If set, the activity will not be launched if it is already running
5388 * at the top of the history stack.
5389 */
5390 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5391 /**
5392 * If set, this activity will become the start of a new task on this
5393 * history stack. A task (from the activity that started it to the
5394 * next task activity) defines an atomic group of activities that the
5395 * user can move to. Tasks can be moved to the foreground and background;
5396 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005397 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005398 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5399 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005400 *
5401 * <p>This flag is generally used by activities that want
5402 * to present a "launcher" style behavior: they give the user a list of
5403 * separate things that can be done, which otherwise run completely
5404 * independently of the activity launching them.
5405 *
5406 * <p>When using this flag, if a task is already running for the activity
5407 * you are now starting, then a new activity will not be started; instead,
5408 * the current task will simply be brought to the front of the screen with
5409 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5410 * to disable this behavior.
5411 *
5412 * <p>This flag can not be used when the caller is requesting a result from
5413 * the activity being launched.
5414 */
5415 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5416 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005417 * This flag is used to create a new task and launch an activity into it.
5418 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5419 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5420 * search through existing tasks for ones matching this Intent. Only if no such
5421 * task is found would a new task be created. When paired with
5422 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5423 * the search for a matching task and unconditionally start a new task.
5424 *
5425 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5426 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005427 * top-level application launcher.</strong> Used in conjunction with
5428 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5429 * behavior of bringing an existing task to the foreground. When set,
5430 * a new task is <em>always</em> started to host the Activity for the
5431 * Intent, regardless of whether there is already an existing task running
5432 * the same thing.
5433 *
5434 * <p><strong>Because the default system does not include graphical task management,
5435 * you should not use this flag unless you provide some way for a user to
5436 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005437 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005438 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5439 * creating new document tasks.
5440 *
5441 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005442 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005443 *
Scott Main7aee61f2011-02-08 11:25:01 -08005444 * <p>See
5445 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5446 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005447 *
5448 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5449 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005450 */
5451 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5452 /**
5453 * If set, and the activity being launched is already running in the
5454 * current task, then instead of launching a new instance of that activity,
5455 * all of the other activities on top of it will be closed and this Intent
5456 * will be delivered to the (now on top) old activity as a new Intent.
5457 *
5458 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5459 * If D calls startActivity() with an Intent that resolves to the component
5460 * of activity B, then C and D will be finished and B receive the given
5461 * Intent, resulting in the stack now being: A, B.
5462 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005463 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005464 * either receive the new intent you are starting here in its
5465 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005466 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005467 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5468 * the same intent, then it will be finished and re-created; for all other
5469 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5470 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005471 *
5472 * <p>This launch mode can also be used to good effect in conjunction with
5473 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5474 * of a task, it will bring any currently running instance of that task
5475 * to the foreground, and then clear it to its root state. This is
5476 * especially useful, for example, when launching an activity from the
5477 * notification manager.
5478 *
Scott Main7aee61f2011-02-08 11:25:01 -08005479 * <p>See
5480 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5481 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005482 */
5483 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5484 /**
5485 * If set and this intent is being used to launch a new activity from an
5486 * existing one, then the reply target of the existing activity will be
5487 * transfered to the new activity. This way the new activity can call
5488 * {@link android.app.Activity#setResult} and have that result sent back to
5489 * the reply target of the original activity.
5490 */
5491 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5492 /**
5493 * If set and this intent is being used to launch a new activity from an
5494 * existing one, the current activity will not be counted as the top
5495 * activity for deciding whether the new intent should be delivered to
5496 * the top instead of starting a new one. The previous activity will
5497 * be used as the top, with the assumption being that the current activity
5498 * will finish itself immediately.
5499 */
5500 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5501 /**
5502 * If set, the new activity is not kept in the list of recently launched
5503 * activities.
5504 */
5505 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5506 /**
5507 * This flag is not normally set by application code, but set for you by
5508 * the system as described in the
5509 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5510 * launchMode} documentation for the singleTask mode.
5511 */
5512 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5513 /**
5514 * If set, and this activity is either being started in a new task or
5515 * bringing to the top an existing task, then it will be launched as
5516 * the front door of the task. This will result in the application of
5517 * any affinities needed to have that task in the proper state (either
5518 * moving activities to or from it), or simply resetting that task to
5519 * its initial state if needed.
5520 */
5521 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5522 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005523 * This flag is not normally set by application code, but set for you by
5524 * the system if this activity is being launched from history
5525 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005526 */
5527 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005528 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005529 * @deprecated As of API 21 this performs identically to
5530 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005531 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005532 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005533 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005534 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005535 * This flag is used to open a document into a new task rooted at the activity launched
5536 * by this Intent. Through the use of this flag, or its equivalent attribute,
5537 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005538 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005539 *
Craig Mautner026596b2014-05-21 15:35:44 -07005540 * <p>The use of the activity attribute form of this,
5541 * {@link android.R.attr#documentLaunchMode}, is
5542 * preferred over the Intent flag described here. The attribute form allows the
5543 * Activity to specify multiple document behavior for all launchers of the Activity
5544 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005545 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005546 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5547 * it is kept after the activity is finished is different than the use of
5548 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5549 * this flag is being used to create a new recents entry, then by default that entry
5550 * will be removed once the activity is finished. You can modify this behavior with
5551 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5552 *
Craig Mautner026596b2014-05-21 15:35:44 -07005553 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5554 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5555 * equivalent of the Activity manifest specifying {@link
5556 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5557 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5558 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005559 *
Craig Mautner026596b2014-05-21 15:35:44 -07005560 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005561 *
Craig Mautner026596b2014-05-21 15:35:44 -07005562 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005563 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5564 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005565 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005566 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005567 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005568 * callback from occurring on the current frontmost activity before it is
5569 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005570 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005571 * <p>Typically, an activity can rely on that callback to indicate that an
5572 * explicit user action has caused their activity to be moved out of the
5573 * foreground. The callback marks an appropriate point in the activity's
5574 * lifecycle for it to dismiss any notifications that it intends to display
5575 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005576 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005577 * <p>If an activity is ever started via any non-user-driven events such as
5578 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5579 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005580 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005581 */
5582 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005583 /**
5584 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5585 * this flag will cause the launched activity to be brought to the front of its
5586 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005587 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005588 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5589 * If D calls startActivity() with an Intent that resolves to the component
5590 * of activity B, then B will be brought to the front of the history stack,
5591 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005592 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005593 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005594 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005595 */
5596 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005597 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005598 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5599 * this flag will prevent the system from applying an activity transition
5600 * animation to go to the next activity state. This doesn't mean an
5601 * animation will never run -- if another activity change happens that doesn't
5602 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005603 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005604 * when you are going to do a series of activity operations but the
5605 * animation seen by the user shouldn't be driven by the first activity
5606 * change but rather a later one.
5607 */
5608 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5609 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005610 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5611 * this flag will cause any existing task that would be associated with the
5612 * activity to be cleared before the activity is started. That is, the activity
5613 * becomes the new root of an otherwise empty task, and any old activities
5614 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5615 */
5616 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5617 /**
5618 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5619 * this flag will cause a newly launching task to be placed on top of the current
5620 * home activity task (if there is one). That is, pressing back from the task
5621 * will always return the user to home even if that was not the last activity they
5622 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5623 */
5624 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5625 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005626 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5627 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005628 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005629 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005630 * this flag. When set and the task's activity is finished, the recents
5631 * entry will remain in the interface for the user to re-launch it, like a
5632 * recents entry for a top-level application.
5633 * <p>
5634 * The receiving activity can override this request with
5635 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5636 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005637 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005638 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005639 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005640
5641 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005642 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5643 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005644 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5645 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005646 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005647 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005648
Patrick Baumann577d4022018-01-31 16:55:10 +00005649
5650 /**
5651 * If set, resolution of this intent may take place via an instant app not
5652 * yet on the device if there does not yet exist an app on device to
5653 * resolve it.
5654 */
5655 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5656
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005657 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005658 * If set, when sending a broadcast only registered receivers will be
5659 * called -- no BroadcastReceiver components will be launched.
5660 */
5661 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005662 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005663 * If set, when sending a broadcast the new broadcast will replace
5664 * any existing pending broadcast that matches it. Matching is defined
5665 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5666 * true for the intents of the two broadcasts. When a match is found,
5667 * the new broadcast (and receivers associated with it) will replace the
5668 * existing one in the pending broadcast list, remaining at the same
5669 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005670 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005671 * <p>This flag is most typically used with sticky broadcasts, which
5672 * only care about delivering the most recent values of the broadcast
5673 * to their receivers.
5674 */
5675 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5676 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005677 * If set, when sending a broadcast the recipient is allowed to run at
5678 * foreground priority, with a shorter timeout interval. During normal
5679 * broadcasts the receivers are not automatically hoisted out of the
5680 * background priority class.
5681 */
5682 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5683 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005684 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5685 * They can still propagate results through to later receivers, but they can not prevent
5686 * later receivers from seeing the broadcast.
5687 */
5688 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5689 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005690 * If set, when sending a broadcast <i>before boot has completed</i> only
5691 * registered receivers will be called -- no BroadcastReceiver components
5692 * will be launched. Sticky intent state will be recorded properly even
5693 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5694 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005695 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005696 * <p>This flag is only for use by system sevices as a convenience to
5697 * avoid having to implement a more complex mechanism around detection
5698 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005699 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005700 * @hide
5701 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005702 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005703 /**
5704 * Set when this broadcast is for a boot upgrade, a special mode that
5705 * allows the broadcast to be sent before the system is ready and launches
5706 * the app process with no providers running in it.
5707 * @hide
5708 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005709 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005710 /**
5711 * If set, the broadcast will always go to manifest receivers in background (cached
5712 * or not running) apps, regardless of whether that would be done by default. By
5713 * default they will only receive broadcasts if the broadcast has specified an
5714 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005715 *
5716 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5717 * the broadcast code there must also be changed to match.
5718 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005719 * @hide
5720 */
5721 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5722 /**
5723 * If set, the broadcast will never go to manifest receivers in background (cached
5724 * or not running) apps, regardless of whether that would be done by default. By
5725 * default they will receive broadcasts if the broadcast has specified an
5726 * explicit component or package name.
5727 * @hide
5728 */
5729 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005730 /**
5731 * If set, this broadcast is being sent from the shell.
5732 * @hide
5733 */
5734 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005735
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005736 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005737 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5738 * will not receive broadcasts.
5739 *
5740 * <em>This flag has no effect when used by an Instant App.</em>
5741 */
5742 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5743
5744 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005745 * @hide Flags that can't be changed with PendingIntent.
5746 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005747 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5748 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5749 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005750
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005751 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005752 // ---------------------------------------------------------------------
5753 // toUri() and parseUri() options.
5754
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005755 /** @hide */
5756 @IntDef(flag = true, prefix = { "URI_" }, value = {
5757 URI_ALLOW_UNSAFE,
5758 URI_ANDROID_APP_SCHEME,
5759 URI_INTENT_SCHEME,
5760 })
5761 @Retention(RetentionPolicy.SOURCE)
5762 public @interface UriFlags {}
5763
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005764 /**
5765 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5766 * always has the "intent:" scheme. This syntax can be used when you want
5767 * to later disambiguate between URIs that are intended to describe an
5768 * Intent vs. all others that should be treated as raw URIs. When used
5769 * with {@link #parseUri}, any other scheme will result in a generic
5770 * VIEW action for that raw URI.
5771 */
5772 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005773
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005774 /**
5775 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5776 * always has the "android-app:" scheme. This is a variation of
5777 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5778 * http/https URI being delivered to a specific package name. The format
5779 * is:
5780 *
5781 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005782 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005783 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005784 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5785 * you must also include a scheme; including a path also requires both a host and a scheme.
5786 * The final #Intent; fragment can be used without a scheme, host, or path.
5787 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005788 * used with intents that have a {@link #setSelector}, since the base intent
5789 * will always have an explicit package name.</p>
5790 *
5791 * <p>Some examples of how this scheme maps to Intent objects:</p>
5792 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5793 * <colgroup align="left" />
5794 * <colgroup align="left" />
5795 * <thead>
5796 * <tr><th>URI</th> <th>Intent</th></tr>
5797 * </thead>
5798 *
5799 * <tbody>
5800 * <tr><td><code>android-app://com.example.app</code></td>
5801 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5802 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5803 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5804 * </table></td>
5805 * </tr>
5806 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5807 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5808 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5809 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5810 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5811 * </table></td>
5812 * </tr>
5813 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5814 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5815 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5816 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5817 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5818 * </table></td>
5819 * </tr>
5820 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5821 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5822 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5823 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5824 * </table></td>
5825 * </tr>
5826 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5827 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5828 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5829 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5830 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5831 * </table></td>
5832 * </tr>
5833 * <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>
5834 * <td><table border="" style="margin:0" >
5835 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5836 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5837 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5838 * </table></td>
5839 * </tr>
5840 * </tbody>
5841 * </table>
5842 */
5843 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5844
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005845 /**
5846 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5847 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5848 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5849 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5850 * generated Intent can not cause unexpected data access to happen.
5851 *
5852 * <p>If you do not trust the source of the URI being parsed, you should still do further
5853 * processing to protect yourself from it. In particular, when using it to start an
5854 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5855 * that can handle it.</p>
5856 */
5857 public static final int URI_ALLOW_UNSAFE = 1<<2;
5858
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005859 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005860
5861 private String mAction;
5862 private Uri mData;
5863 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005864 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005865 private ComponentName mComponent;
5866 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005867 private ArraySet<String> mCategories;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005868 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005869 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005870 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005871 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005872 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005873 /** Token to track instant app launches. Local only; do not copy cross-process. */
5874 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005875
5876 // ---------------------------------------------------------------------
5877
Makoto Onuki97f82f22017-05-31 16:20:21 -07005878 private static final int COPY_MODE_ALL = 0;
5879 private static final int COPY_MODE_FILTER = 1;
5880 private static final int COPY_MODE_HISTORY = 2;
5881
5882 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005883 @IntDef(prefix = { "COPY_MODE_" }, value = {
5884 COPY_MODE_ALL,
5885 COPY_MODE_FILTER,
5886 COPY_MODE_HISTORY
5887 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005888 @Retention(RetentionPolicy.SOURCE)
5889 public @interface CopyMode {}
5890
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005891 /**
5892 * Create an empty intent.
5893 */
5894 public Intent() {
5895 }
5896
5897 /**
5898 * Copy constructor.
5899 */
5900 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005901 this(o, COPY_MODE_ALL);
5902 }
5903
5904 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005905 this.mAction = o.mAction;
5906 this.mData = o.mData;
5907 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005908 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005909 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005910
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005911 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005912 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005913 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005914
5915 if (copyMode != COPY_MODE_FILTER) {
5916 this.mFlags = o.mFlags;
5917 this.mContentUserHint = o.mContentUserHint;
5918 this.mLaunchToken = o.mLaunchToken;
5919 if (o.mSourceBounds != null) {
5920 this.mSourceBounds = new Rect(o.mSourceBounds);
5921 }
5922 if (o.mSelector != null) {
5923 this.mSelector = new Intent(o.mSelector);
5924 }
5925
5926 if (copyMode != COPY_MODE_HISTORY) {
5927 if (o.mExtras != null) {
5928 this.mExtras = new Bundle(o.mExtras);
5929 }
5930 if (o.mClipData != null) {
5931 this.mClipData = new ClipData(o.mClipData);
5932 }
5933 } else {
5934 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
5935 this.mExtras = Bundle.STRIPPED;
5936 }
5937
5938 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
5939 // history.
5940 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005941 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005942 }
5943
5944 @Override
5945 public Object clone() {
5946 return new Intent(this);
5947 }
5948
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005949 /**
5950 * Make a clone of only the parts of the Intent that are relevant for
5951 * filter matching: the action, data, type, component, and categories.
5952 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005953 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005954 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005955 }
5956
5957 /**
5958 * Create an intent with a given action. All other fields (data, type,
5959 * class) are null. Note that the action <em>must</em> be in a
5960 * namespace because Intents are used globally in the system -- for
5961 * example the system VIEW action is android.intent.action.VIEW; an
5962 * application's custom action would be something like
5963 * com.google.app.myapp.CUSTOM_ACTION.
5964 *
5965 * @param action The Intent action, such as ACTION_VIEW.
5966 */
5967 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005968 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005969 }
5970
5971 /**
5972 * Create an intent with a given action and for a given data url. Note
5973 * that the action <em>must</em> be in a namespace because Intents are
5974 * used globally in the system -- for example the system VIEW action is
5975 * android.intent.action.VIEW; an application's custom action would be
5976 * something like com.google.app.myapp.CUSTOM_ACTION.
5977 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07005978 * <p><em>Note: scheme and host name matching in the Android framework is
5979 * case-sensitive, unlike the formal RFC. As a result,
5980 * you should always ensure that you write your Uri with these elements
5981 * using lower case letters, and normalize any Uris you receive from
5982 * outside of Android to ensure the scheme and host is lower case.</em></p>
5983 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005984 * @param action The Intent action, such as ACTION_VIEW.
5985 * @param uri The Intent data URI.
5986 */
5987 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08005988 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005989 mData = uri;
5990 }
5991
5992 /**
5993 * Create an intent for a specific component. All other fields (action, data,
5994 * type, class) are null, though they can be modified later with explicit
5995 * calls. This provides a convenient way to create an intent that is
5996 * intended to execute a hard-coded class name, rather than relying on the
5997 * system to find an appropriate class for you; see {@link #setComponent}
5998 * for more information on the repercussions of this.
5999 *
6000 * @param packageContext A Context of the application package implementing
6001 * this class.
6002 * @param cls The component class that is to be used for the intent.
6003 *
6004 * @see #setClass
6005 * @see #setComponent
6006 * @see #Intent(String, android.net.Uri , Context, Class)
6007 */
6008 public Intent(Context packageContext, Class<?> cls) {
6009 mComponent = new ComponentName(packageContext, cls);
6010 }
6011
6012 /**
6013 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006014 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006015 * construct the Intent and then calling {@link #setClass} to set its
6016 * class.
6017 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006018 * <p><em>Note: scheme and host name matching in the Android framework is
6019 * case-sensitive, unlike the formal RFC. As a result,
6020 * you should always ensure that you write your Uri with these elements
6021 * using lower case letters, and normalize any Uris you receive from
6022 * outside of Android to ensure the scheme and host is lower case.</em></p>
6023 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006024 * @param action The Intent action, such as ACTION_VIEW.
6025 * @param uri The Intent data URI.
6026 * @param packageContext A Context of the application package implementing
6027 * this class.
6028 * @param cls The component class that is to be used for the intent.
6029 *
6030 * @see #Intent(String, android.net.Uri)
6031 * @see #Intent(Context, Class)
6032 * @see #setClass
6033 * @see #setComponent
6034 */
6035 public Intent(String action, Uri uri,
6036 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006037 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006038 mData = uri;
6039 mComponent = new ComponentName(packageContext, cls);
6040 }
6041
6042 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006043 * Create an intent to launch the main (root) activity of a task. This
6044 * is the Intent that is started when the application's is launched from
6045 * Home. For anything else that wants to launch an application in the
6046 * same way, it is important that they use an Intent structured the same
6047 * way, and can use this function to ensure this is the case.
6048 *
6049 * <p>The returned Intent has the given Activity component as its explicit
6050 * component, {@link #ACTION_MAIN} as its action, and includes the
6051 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6052 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6053 * to do that through {@link #addFlags(int)} on the returned Intent.
6054 *
6055 * @param mainActivity The main activity component that this Intent will
6056 * launch.
6057 * @return Returns a newly created Intent that can be used to launch the
6058 * activity as a main application entry.
6059 *
6060 * @see #setClass
6061 * @see #setComponent
6062 */
6063 public static Intent makeMainActivity(ComponentName mainActivity) {
6064 Intent intent = new Intent(ACTION_MAIN);
6065 intent.setComponent(mainActivity);
6066 intent.addCategory(CATEGORY_LAUNCHER);
6067 return intent;
6068 }
6069
6070 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006071 * Make an Intent for the main activity of an application, without
6072 * specifying a specific activity to run but giving a selector to find
6073 * the activity. This results in a final Intent that is structured
6074 * the same as when the application is launched from
6075 * Home. For anything else that wants to launch an application in the
6076 * same way, it is important that they use an Intent structured the same
6077 * way, and can use this function to ensure this is the case.
6078 *
6079 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6080 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6081 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6082 * to do that through {@link #addFlags(int)} on the returned Intent.
6083 *
6084 * @param selectorAction The action name of the Intent's selector.
6085 * @param selectorCategory The name of a category to add to the Intent's
6086 * selector.
6087 * @return Returns a newly created Intent that can be used to launch the
6088 * activity as a main application entry.
6089 *
6090 * @see #setSelector(Intent)
6091 */
6092 public static Intent makeMainSelectorActivity(String selectorAction,
6093 String selectorCategory) {
6094 Intent intent = new Intent(ACTION_MAIN);
6095 intent.addCategory(CATEGORY_LAUNCHER);
6096 Intent selector = new Intent();
6097 selector.setAction(selectorAction);
6098 selector.addCategory(selectorCategory);
6099 intent.setSelector(selector);
6100 return intent;
6101 }
6102
6103 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006104 * Make an Intent that can be used to re-launch an application's task
6105 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6106 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6107 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6108 *
6109 * @param mainActivity The activity component that is the root of the
6110 * task; this is the activity that has been published in the application's
6111 * manifest as the main launcher icon.
6112 *
6113 * @return Returns a newly created Intent that can be used to relaunch the
6114 * activity's task in its root state.
6115 */
6116 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6117 Intent intent = makeMainActivity(mainActivity);
6118 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6119 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6120 return intent;
6121 }
6122
6123 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006124 * Call {@link #parseUri} with 0 flags.
6125 * @deprecated Use {@link #parseUri} instead.
6126 */
6127 @Deprecated
6128 public static Intent getIntent(String uri) throws URISyntaxException {
6129 return parseUri(uri, 0);
6130 }
Tom Taylord4a47292009-12-21 13:59:18 -08006131
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006132 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006133 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006134 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006135 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006136 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006137 *
6138 * <p>The URI given here must not be relative -- that is, it must include
6139 * the scheme and full path.
6140 *
6141 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006142 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006143 *
6144 * @return Intent The newly created Intent object.
6145 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006146 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6147 * it bad (as parsed by the Uri class) or the Intent data within the
6148 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006149 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006150 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006151 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006152 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006153 int i = 0;
6154 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006155 final boolean androidApp = uri.startsWith("android-app:");
6156
6157 // Validate intent scheme if requested.
6158 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6159 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006160 Intent intent = new Intent(ACTION_VIEW);
6161 try {
6162 intent.setData(Uri.parse(uri));
6163 } catch (IllegalArgumentException e) {
6164 throw new URISyntaxException(uri, e.getMessage());
6165 }
6166 return intent;
6167 }
6168 }
Tom Taylord4a47292009-12-21 13:59:18 -08006169
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006170 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006171 // simple case
6172 if (i == -1) {
6173 if (!androidApp) {
6174 return new Intent(ACTION_VIEW, Uri.parse(uri));
6175 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006176
6177 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006178 } else if (!uri.startsWith("#Intent;", i)) {
6179 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006180 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006181 } else {
6182 i = -1;
6183 }
6184 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006185
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006186 // new format
6187 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006188 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006189 boolean explicitAction = false;
6190 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006191
6192 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006193 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006194 String data;
6195 if (i >= 0) {
6196 data = uri.substring(0, i);
6197 i += 8; // length of "#Intent;"
6198 } else {
6199 data = uri;
6200 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006201
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006202 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006203 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006204 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006205 if (eq < 0) eq = i-1;
6206 int semi = uri.indexOf(';', i);
6207 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006208
6209 // action
6210 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006211 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006212 if (!inSelector) {
6213 explicitAction = true;
6214 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006215 }
6216
6217 // categories
6218 else if (uri.startsWith("category=", i)) {
6219 intent.addCategory(value);
6220 }
6221
6222 // type
6223 else if (uri.startsWith("type=", i)) {
6224 intent.mType = value;
6225 }
6226
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006227 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006228 else if (uri.startsWith("launchFlags=", i)) {
6229 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006230 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6231 intent.mFlags &= ~IMMUTABLE_FLAGS;
6232 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006233 }
6234
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006235 // package
6236 else if (uri.startsWith("package=", i)) {
6237 intent.mPackage = value;
6238 }
6239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006240 // component
6241 else if (uri.startsWith("component=", i)) {
6242 intent.mComponent = ComponentName.unflattenFromString(value);
6243 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006244
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006245 // scheme
6246 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006247 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006248 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006249 } else {
6250 scheme = value;
6251 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006252 }
6253
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006254 // source bounds
6255 else if (uri.startsWith("sourceBounds=", i)) {
6256 intent.mSourceBounds = Rect.unflattenFromString(value);
6257 }
6258
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006259 // selector
6260 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6261 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006262 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006263 }
6264
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006265 // extra
6266 else {
6267 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006268 // create Bundle if it doesn't already exist
6269 if (intent.mExtras == null) intent.mExtras = new Bundle();
6270 Bundle b = intent.mExtras;
6271 // add EXTRA
6272 if (uri.startsWith("S.", i)) b.putString(key, value);
6273 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6274 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6275 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6276 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6277 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6278 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6279 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6280 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6281 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6282 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006284 // move to the next item
6285 i = semi + 1;
6286 }
6287
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006288 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006289 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006290 if (baseIntent.mPackage == null) {
6291 baseIntent.setSelector(intent);
6292 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006293 intent = baseIntent;
6294 }
6295
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006296 if (data != null) {
6297 if (data.startsWith("intent:")) {
6298 data = data.substring(7);
6299 if (scheme != null) {
6300 data = scheme + ':' + data;
6301 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006302 } else if (data.startsWith("android-app:")) {
6303 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6304 // Correctly formed android-app, first part is package name.
6305 int end = data.indexOf('/', 14);
6306 if (end < 0) {
6307 // All we have is a package name.
6308 intent.mPackage = data.substring(14);
6309 if (!explicitAction) {
6310 intent.setAction(ACTION_MAIN);
6311 }
6312 data = "";
6313 } else {
6314 // Target the Intent at the given package name always.
6315 String authority = null;
6316 intent.mPackage = data.substring(14, end);
6317 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006318 if ((end+1) < data.length()) {
6319 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6320 // Found a scheme, remember it.
6321 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006322 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006323 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6324 // Found a authority, remember it.
6325 authority = data.substring(end+1, newEnd);
6326 end = newEnd;
6327 }
6328 } else {
6329 // All we have is a scheme.
6330 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006331 }
6332 }
6333 if (scheme == null) {
6334 // If there was no scheme, then this just targets the package.
6335 if (!explicitAction) {
6336 intent.setAction(ACTION_MAIN);
6337 }
6338 data = "";
6339 } else if (authority == null) {
6340 data = scheme + ":";
6341 } else {
6342 data = scheme + "://" + authority + data.substring(end);
6343 }
6344 }
6345 } else {
6346 data = "";
6347 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006348 }
Tom Taylord4a47292009-12-21 13:59:18 -08006349
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006350 if (data.length() > 0) {
6351 try {
6352 intent.mData = Uri.parse(data);
6353 } catch (IllegalArgumentException e) {
6354 throw new URISyntaxException(uri, e.getMessage());
6355 }
6356 }
6357 }
Tom Taylord4a47292009-12-21 13:59:18 -08006358
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006359 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006360
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006361 } catch (IndexOutOfBoundsException e) {
6362 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6363 }
6364 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006365
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006366 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006367 return getIntentOld(uri, 0);
6368 }
6369
6370 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006371 Intent intent;
6372
6373 int i = uri.lastIndexOf('#');
6374 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006375 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006376 final int intentFragmentStart = i;
6377 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006378
6379 i++;
6380
6381 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006382 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006383 i += 7;
6384 int j = uri.indexOf(')', i);
6385 action = uri.substring(i, j);
6386 i = j + 1;
6387 }
6388
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006389 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006390
6391 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006392 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006393 i += 11;
6394 int j = uri.indexOf(')', i);
6395 while (i < j) {
6396 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006397 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006398 if (i < sep) {
6399 intent.addCategory(uri.substring(i, sep));
6400 }
6401 i = sep + 1;
6402 }
6403 i = j + 1;
6404 }
6405
6406 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006407 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006408 i += 5;
6409 int j = uri.indexOf(')', i);
6410 intent.mType = uri.substring(i, j);
6411 i = j + 1;
6412 }
6413
6414 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006415 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006416 i += 12;
6417 int j = uri.indexOf(')', i);
6418 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006419 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6420 intent.mFlags &= ~IMMUTABLE_FLAGS;
6421 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006422 i = j + 1;
6423 }
6424
6425 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006426 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006427 i += 10;
6428 int j = uri.indexOf(')', i);
6429 int sep = uri.indexOf('!', i);
6430 if (sep >= 0 && sep < j) {
6431 String pkg = uri.substring(i, sep);
6432 String cls = uri.substring(sep + 1, j);
6433 intent.mComponent = new ComponentName(pkg, cls);
6434 }
6435 i = j + 1;
6436 }
6437
6438 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006439 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006440 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006441
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006442 final int closeParen = uri.indexOf(')', i);
6443 if (closeParen == -1) throw new URISyntaxException(uri,
6444 "EXTRA missing trailing ')'", i);
6445
6446 while (i < closeParen) {
6447 // fetch the key value
6448 int j = uri.indexOf('=', i);
6449 if (j <= i + 1 || i >= closeParen) {
6450 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6451 }
6452 char type = uri.charAt(i);
6453 i++;
6454 String key = uri.substring(i, j);
6455 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006456
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006457 // get type-value
6458 j = uri.indexOf('!', i);
6459 if (j == -1 || j >= closeParen) j = closeParen;
6460 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6461 String value = uri.substring(i, j);
6462 i = j;
6463
6464 // create Bundle if it doesn't already exist
6465 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006466
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006467 // add item to bundle
6468 try {
6469 switch (type) {
6470 case 'S':
6471 intent.mExtras.putString(key, Uri.decode(value));
6472 break;
6473 case 'B':
6474 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6475 break;
6476 case 'b':
6477 intent.mExtras.putByte(key, Byte.parseByte(value));
6478 break;
6479 case 'c':
6480 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6481 break;
6482 case 'd':
6483 intent.mExtras.putDouble(key, Double.parseDouble(value));
6484 break;
6485 case 'f':
6486 intent.mExtras.putFloat(key, Float.parseFloat(value));
6487 break;
6488 case 'i':
6489 intent.mExtras.putInt(key, Integer.parseInt(value));
6490 break;
6491 case 'l':
6492 intent.mExtras.putLong(key, Long.parseLong(value));
6493 break;
6494 case 's':
6495 intent.mExtras.putShort(key, Short.parseShort(value));
6496 break;
6497 default:
6498 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6499 }
6500 } catch (NumberFormatException e) {
6501 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6502 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006503
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006504 char ch = uri.charAt(i);
6505 if (ch == ')') break;
6506 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6507 i++;
6508 }
6509 }
6510
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006511 if (isIntentFragment) {
6512 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6513 } else {
6514 intent.mData = Uri.parse(uri);
6515 }
Tom Taylord4a47292009-12-21 13:59:18 -08006516
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006517 if (intent.mAction == null) {
6518 // By default, if no action is specified, then use VIEW.
6519 intent.mAction = ACTION_VIEW;
6520 }
6521
6522 } else {
6523 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6524 }
6525
6526 return intent;
6527 }
6528
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006529 /** @hide */
6530 public interface CommandOptionHandler {
6531 boolean handleOption(String opt, ShellCommand cmd);
6532 }
6533
6534 /** @hide */
6535 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6536 throws URISyntaxException {
6537 Intent intent = new Intent();
6538 Intent baseIntent = intent;
6539 boolean hasIntentInfo = false;
6540
6541 Uri data = null;
6542 String type = null;
6543
6544 String opt;
6545 while ((opt=cmd.getNextOption()) != null) {
6546 switch (opt) {
6547 case "-a":
6548 intent.setAction(cmd.getNextArgRequired());
6549 if (intent == baseIntent) {
6550 hasIntentInfo = true;
6551 }
6552 break;
6553 case "-d":
6554 data = Uri.parse(cmd.getNextArgRequired());
6555 if (intent == baseIntent) {
6556 hasIntentInfo = true;
6557 }
6558 break;
6559 case "-t":
6560 type = cmd.getNextArgRequired();
6561 if (intent == baseIntent) {
6562 hasIntentInfo = true;
6563 }
6564 break;
6565 case "-c":
6566 intent.addCategory(cmd.getNextArgRequired());
6567 if (intent == baseIntent) {
6568 hasIntentInfo = true;
6569 }
6570 break;
6571 case "-e":
6572 case "--es": {
6573 String key = cmd.getNextArgRequired();
6574 String value = cmd.getNextArgRequired();
6575 intent.putExtra(key, value);
6576 }
6577 break;
6578 case "--esn": {
6579 String key = cmd.getNextArgRequired();
6580 intent.putExtra(key, (String) null);
6581 }
6582 break;
6583 case "--ei": {
6584 String key = cmd.getNextArgRequired();
6585 String value = cmd.getNextArgRequired();
6586 intent.putExtra(key, Integer.decode(value));
6587 }
6588 break;
6589 case "--eu": {
6590 String key = cmd.getNextArgRequired();
6591 String value = cmd.getNextArgRequired();
6592 intent.putExtra(key, Uri.parse(value));
6593 }
6594 break;
6595 case "--ecn": {
6596 String key = cmd.getNextArgRequired();
6597 String value = cmd.getNextArgRequired();
6598 ComponentName cn = ComponentName.unflattenFromString(value);
6599 if (cn == null)
6600 throw new IllegalArgumentException("Bad component name: " + value);
6601 intent.putExtra(key, cn);
6602 }
6603 break;
6604 case "--eia": {
6605 String key = cmd.getNextArgRequired();
6606 String value = cmd.getNextArgRequired();
6607 String[] strings = value.split(",");
6608 int[] list = new int[strings.length];
6609 for (int i = 0; i < strings.length; i++) {
6610 list[i] = Integer.decode(strings[i]);
6611 }
6612 intent.putExtra(key, list);
6613 }
6614 break;
6615 case "--eial": {
6616 String key = cmd.getNextArgRequired();
6617 String value = cmd.getNextArgRequired();
6618 String[] strings = value.split(",");
6619 ArrayList<Integer> list = new ArrayList<>(strings.length);
6620 for (int i = 0; i < strings.length; i++) {
6621 list.add(Integer.decode(strings[i]));
6622 }
6623 intent.putExtra(key, list);
6624 }
6625 break;
6626 case "--el": {
6627 String key = cmd.getNextArgRequired();
6628 String value = cmd.getNextArgRequired();
6629 intent.putExtra(key, Long.valueOf(value));
6630 }
6631 break;
6632 case "--ela": {
6633 String key = cmd.getNextArgRequired();
6634 String value = cmd.getNextArgRequired();
6635 String[] strings = value.split(",");
6636 long[] list = new long[strings.length];
6637 for (int i = 0; i < strings.length; i++) {
6638 list[i] = Long.valueOf(strings[i]);
6639 }
6640 intent.putExtra(key, list);
6641 hasIntentInfo = true;
6642 }
6643 break;
6644 case "--elal": {
6645 String key = cmd.getNextArgRequired();
6646 String value = cmd.getNextArgRequired();
6647 String[] strings = value.split(",");
6648 ArrayList<Long> list = new ArrayList<>(strings.length);
6649 for (int i = 0; i < strings.length; i++) {
6650 list.add(Long.valueOf(strings[i]));
6651 }
6652 intent.putExtra(key, list);
6653 hasIntentInfo = true;
6654 }
6655 break;
6656 case "--ef": {
6657 String key = cmd.getNextArgRequired();
6658 String value = cmd.getNextArgRequired();
6659 intent.putExtra(key, Float.valueOf(value));
6660 hasIntentInfo = true;
6661 }
6662 break;
6663 case "--efa": {
6664 String key = cmd.getNextArgRequired();
6665 String value = cmd.getNextArgRequired();
6666 String[] strings = value.split(",");
6667 float[] list = new float[strings.length];
6668 for (int i = 0; i < strings.length; i++) {
6669 list[i] = Float.valueOf(strings[i]);
6670 }
6671 intent.putExtra(key, list);
6672 hasIntentInfo = true;
6673 }
6674 break;
6675 case "--efal": {
6676 String key = cmd.getNextArgRequired();
6677 String value = cmd.getNextArgRequired();
6678 String[] strings = value.split(",");
6679 ArrayList<Float> list = new ArrayList<>(strings.length);
6680 for (int i = 0; i < strings.length; i++) {
6681 list.add(Float.valueOf(strings[i]));
6682 }
6683 intent.putExtra(key, list);
6684 hasIntentInfo = true;
6685 }
6686 break;
6687 case "--esa": {
6688 String key = cmd.getNextArgRequired();
6689 String value = cmd.getNextArgRequired();
6690 // Split on commas unless they are preceeded by an escape.
6691 // The escape character must be escaped for the string and
6692 // again for the regex, thus four escape characters become one.
6693 String[] strings = value.split("(?<!\\\\),");
6694 intent.putExtra(key, strings);
6695 hasIntentInfo = true;
6696 }
6697 break;
6698 case "--esal": {
6699 String key = cmd.getNextArgRequired();
6700 String value = cmd.getNextArgRequired();
6701 // Split on commas unless they are preceeded by an escape.
6702 // The escape character must be escaped for the string and
6703 // again for the regex, thus four escape characters become one.
6704 String[] strings = value.split("(?<!\\\\),");
6705 ArrayList<String> list = new ArrayList<>(strings.length);
6706 for (int i = 0; i < strings.length; i++) {
6707 list.add(strings[i]);
6708 }
6709 intent.putExtra(key, list);
6710 hasIntentInfo = true;
6711 }
6712 break;
6713 case "--ez": {
6714 String key = cmd.getNextArgRequired();
6715 String value = cmd.getNextArgRequired().toLowerCase();
6716 // Boolean.valueOf() results in false for anything that is not "true", which is
6717 // error-prone in shell commands
6718 boolean arg;
6719 if ("true".equals(value) || "t".equals(value)) {
6720 arg = true;
6721 } else if ("false".equals(value) || "f".equals(value)) {
6722 arg = false;
6723 } else {
6724 try {
6725 arg = Integer.decode(value) != 0;
6726 } catch (NumberFormatException ex) {
6727 throw new IllegalArgumentException("Invalid boolean value: " + value);
6728 }
6729 }
6730
6731 intent.putExtra(key, arg);
6732 }
6733 break;
6734 case "-n": {
6735 String str = cmd.getNextArgRequired();
6736 ComponentName cn = ComponentName.unflattenFromString(str);
6737 if (cn == null)
6738 throw new IllegalArgumentException("Bad component name: " + str);
6739 intent.setComponent(cn);
6740 if (intent == baseIntent) {
6741 hasIntentInfo = true;
6742 }
6743 }
6744 break;
6745 case "-p": {
6746 String str = cmd.getNextArgRequired();
6747 intent.setPackage(str);
6748 if (intent == baseIntent) {
6749 hasIntentInfo = true;
6750 }
6751 }
6752 break;
6753 case "-f":
6754 String str = cmd.getNextArgRequired();
6755 intent.setFlags(Integer.decode(str).intValue());
6756 break;
6757 case "--grant-read-uri-permission":
6758 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6759 break;
6760 case "--grant-write-uri-permission":
6761 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6762 break;
6763 case "--grant-persistable-uri-permission":
6764 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6765 break;
6766 case "--grant-prefix-uri-permission":
6767 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6768 break;
6769 case "--exclude-stopped-packages":
6770 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6771 break;
6772 case "--include-stopped-packages":
6773 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6774 break;
6775 case "--debug-log-resolution":
6776 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6777 break;
6778 case "--activity-brought-to-front":
6779 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6780 break;
6781 case "--activity-clear-top":
6782 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6783 break;
6784 case "--activity-clear-when-task-reset":
6785 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6786 break;
6787 case "--activity-exclude-from-recents":
6788 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6789 break;
6790 case "--activity-launched-from-history":
6791 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6792 break;
6793 case "--activity-multiple-task":
6794 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6795 break;
6796 case "--activity-no-animation":
6797 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6798 break;
6799 case "--activity-no-history":
6800 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6801 break;
6802 case "--activity-no-user-action":
6803 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6804 break;
6805 case "--activity-previous-is-top":
6806 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6807 break;
6808 case "--activity-reorder-to-front":
6809 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6810 break;
6811 case "--activity-reset-task-if-needed":
6812 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6813 break;
6814 case "--activity-single-top":
6815 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6816 break;
6817 case "--activity-clear-task":
6818 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6819 break;
6820 case "--activity-task-on-home":
6821 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6822 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006823 case "--activity-match-external":
6824 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6825 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006826 case "--receiver-registered-only":
6827 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6828 break;
6829 case "--receiver-replace-pending":
6830 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6831 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006832 case "--receiver-foreground":
6833 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6834 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006835 case "--receiver-no-abort":
6836 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6837 break;
6838 case "--receiver-include-background":
6839 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6840 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006841 case "--selector":
6842 intent.setDataAndType(data, type);
6843 intent = new Intent();
6844 break;
6845 default:
6846 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6847 // Okay, caller handled this option.
6848 } else {
6849 throw new IllegalArgumentException("Unknown option: " + opt);
6850 }
6851 break;
6852 }
6853 }
6854 intent.setDataAndType(data, type);
6855
6856 final boolean hasSelector = intent != baseIntent;
6857 if (hasSelector) {
6858 // A selector was specified; fix up.
6859 baseIntent.setSelector(intent);
6860 intent = baseIntent;
6861 }
6862
6863 String arg = cmd.getNextArg();
6864 baseIntent = null;
6865 if (arg == null) {
6866 if (hasSelector) {
6867 // If a selector has been specified, and no arguments
6868 // have been supplied for the main Intent, then we can
6869 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6870 // need to have a component name specified yet, the
6871 // selector will take care of that.
6872 baseIntent = new Intent(Intent.ACTION_MAIN);
6873 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6874 }
6875 } else if (arg.indexOf(':') >= 0) {
6876 // The argument is a URI. Fully parse it, and use that result
6877 // to fill in any data not specified so far.
6878 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6879 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6880 } else if (arg.indexOf('/') >= 0) {
6881 // The argument is a component name. Build an Intent to launch
6882 // it.
6883 baseIntent = new Intent(Intent.ACTION_MAIN);
6884 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6885 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6886 } else {
6887 // Assume the argument is a package name.
6888 baseIntent = new Intent(Intent.ACTION_MAIN);
6889 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6890 baseIntent.setPackage(arg);
6891 }
6892 if (baseIntent != null) {
6893 Bundle extras = intent.getExtras();
6894 intent.replaceExtras((Bundle)null);
6895 Bundle uriExtras = baseIntent.getExtras();
6896 baseIntent.replaceExtras((Bundle)null);
6897 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6898 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6899 for (String c : cats) {
6900 baseIntent.removeCategory(c);
6901 }
6902 }
6903 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6904 if (extras == null) {
6905 extras = uriExtras;
6906 } else if (uriExtras != null) {
6907 uriExtras.putAll(extras);
6908 extras = uriExtras;
6909 }
6910 intent.replaceExtras(extras);
6911 hasIntentInfo = true;
6912 }
6913
6914 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6915 return intent;
6916 }
6917
6918 /** @hide */
6919 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6920 final String[] lines = new String[] {
6921 "<INTENT> specifications include these flags and arguments:",
6922 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
6923 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
6924 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
6925 " [--esn <EXTRA_KEY> ...]",
6926 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
6927 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
6928 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
6929 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
6930 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
6931 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
6932 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6933 " (mutiple extras passed as Integer[])",
6934 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
6935 " (mutiple extras passed as List<Integer>)",
6936 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6937 " (mutiple extras passed as Long[])",
6938 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
6939 " (mutiple extras passed as List<Long>)",
6940 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6941 " (mutiple extras passed as Float[])",
6942 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
6943 " (mutiple extras passed as List<Float>)",
6944 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6945 " (mutiple extras passed as String[]; to embed a comma into a string,",
6946 " escape it using \"\\,\")",
6947 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
6948 " (mutiple extras passed as List<String>; to embed a comma into a string,",
6949 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08006950 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006951 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
6952 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
6953 " [--debug-log-resolution] [--exclude-stopped-packages]",
6954 " [--include-stopped-packages]",
6955 " [--activity-brought-to-front] [--activity-clear-top]",
6956 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
6957 " [--activity-launched-from-history] [--activity-multiple-task]",
6958 " [--activity-no-animation] [--activity-no-history]",
6959 " [--activity-no-user-action] [--activity-previous-is-top]",
6960 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
6961 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07006962 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006963 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08006964 " [--receiver-foreground] [--receiver-no-abort]",
6965 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006966 " [--selector]",
6967 " [<URI> | <PACKAGE> | <COMPONENT>]"
6968 };
6969 for (String line : lines) {
6970 pw.print(prefix);
6971 pw.println(line);
6972 }
6973 }
6974
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006975 /**
6976 * Retrieve the general action to be performed, such as
6977 * {@link #ACTION_VIEW}. The action describes the general way the rest of
6978 * the information in the intent should be interpreted -- most importantly,
6979 * what to do with the data returned by {@link #getData}.
6980 *
6981 * @return The action of this intent or null if none is specified.
6982 *
6983 * @see #setAction
6984 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006985 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006986 return mAction;
6987 }
6988
6989 /**
6990 * Retrieve data this intent is operating on. This URI specifies the name
6991 * of the data; often it uses the content: scheme, specifying data in a
6992 * content provider. Other schemes may be handled by specific activities,
6993 * such as http: by the web browser.
6994 *
6995 * @return The URI of the data this intent is targeting or null.
6996 *
6997 * @see #getScheme
6998 * @see #setData
6999 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007000 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007001 return mData;
7002 }
7003
7004 /**
7005 * The same as {@link #getData()}, but returns the URI as an encoded
7006 * String.
7007 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007008 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007009 return mData != null ? mData.toString() : null;
7010 }
7011
7012 /**
7013 * Return the scheme portion of the intent's data. If the data is null or
7014 * does not include a scheme, null is returned. Otherwise, the scheme
7015 * prefix without the final ':' is returned, i.e. "http".
7016 *
7017 * <p>This is the same as calling getData().getScheme() (and checking for
7018 * null data).
7019 *
7020 * @return The scheme of this intent.
7021 *
7022 * @see #getData
7023 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007024 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007025 return mData != null ? mData.getScheme() : null;
7026 }
7027
7028 /**
7029 * Retrieve any explicit MIME type included in the intent. This is usually
7030 * null, as the type is determined by the intent data.
7031 *
7032 * @return If a type was manually set, it is returned; else null is
7033 * returned.
7034 *
7035 * @see #resolveType(ContentResolver)
7036 * @see #setType
7037 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007038 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007039 return mType;
7040 }
7041
7042 /**
7043 * Return the MIME data type of this intent. If the type field is
7044 * explicitly set, that is simply returned. Otherwise, if the data is set,
7045 * the type of that data is returned. If neither fields are set, a null is
7046 * returned.
7047 *
7048 * @return The MIME type of this intent.
7049 *
7050 * @see #getType
7051 * @see #resolveType(ContentResolver)
7052 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007053 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007054 return resolveType(context.getContentResolver());
7055 }
7056
7057 /**
7058 * Return the MIME data type of this intent. If the type field is
7059 * explicitly set, that is simply returned. Otherwise, if the data is set,
7060 * the type of that data is returned. If neither fields are set, a null is
7061 * returned.
7062 *
7063 * @param resolver A ContentResolver that can be used to determine the MIME
7064 * type of the intent's data.
7065 *
7066 * @return The MIME type of this intent.
7067 *
7068 * @see #getType
7069 * @see #resolveType(Context)
7070 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007071 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007072 if (mType != null) {
7073 return mType;
7074 }
7075 if (mData != null) {
7076 if ("content".equals(mData.getScheme())) {
7077 return resolver.getType(mData);
7078 }
7079 }
7080 return null;
7081 }
7082
7083 /**
7084 * Return the MIME data type of this intent, only if it will be needed for
7085 * intent resolution. This is not generally useful for application code;
7086 * it is used by the frameworks for communicating with back-end system
7087 * services.
7088 *
7089 * @param resolver A ContentResolver that can be used to determine the MIME
7090 * type of the intent's data.
7091 *
7092 * @return The MIME type of this intent, or null if it is unknown or not
7093 * needed.
7094 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007095 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007096 if (mComponent != null) {
7097 return mType;
7098 }
7099 return resolveType(resolver);
7100 }
7101
7102 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007103 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007104 *
7105 * @param category The category to check.
7106 *
7107 * @return boolean True if the intent contains the category, else false.
7108 *
7109 * @see #getCategories
7110 * @see #addCategory
7111 */
7112 public boolean hasCategory(String category) {
7113 return mCategories != null && mCategories.contains(category);
7114 }
7115
7116 /**
7117 * Return the set of all categories in the intent. If there are no categories,
7118 * returns NULL.
7119 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007120 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007121 *
7122 * @see #hasCategory
7123 * @see #addCategory
7124 */
7125 public Set<String> getCategories() {
7126 return mCategories;
7127 }
7128
7129 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007130 * Return the specific selector associated with this Intent. If there is
7131 * none, returns null. See {@link #setSelector} for more information.
7132 *
7133 * @see #setSelector
7134 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007135 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007136 return mSelector;
7137 }
7138
7139 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007140 * Return the {@link ClipData} associated with this Intent. If there is
7141 * none, returns null. See {@link #setClipData} for more information.
7142 *
John Spurlock125d1332013-11-25 11:58:37 -05007143 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007144 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007145 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007146 return mClipData;
7147 }
7148
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007149 /** @hide */
7150 public int getContentUserHint() {
7151 return mContentUserHint;
7152 }
7153
Todd Kennedyb3b431302017-03-20 16:05:48 -07007154 /** @hide */
7155 public String getLaunchToken() {
7156 return mLaunchToken;
7157 }
7158
7159 /** @hide */
7160 public void setLaunchToken(String launchToken) {
7161 mLaunchToken = launchToken;
7162 }
7163
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007164 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007165 * Sets the ClassLoader that will be used when unmarshalling
7166 * any Parcelable values from the extras of this Intent.
7167 *
7168 * @param loader a ClassLoader, or null to use the default loader
7169 * at the time of unmarshalling.
7170 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007171 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007172 if (mExtras != null) {
7173 mExtras.setClassLoader(loader);
7174 }
7175 }
7176
7177 /**
7178 * Returns true if an extra value is associated with the given name.
7179 * @param name the extra's name
7180 * @return true if the given extra is present.
7181 */
7182 public boolean hasExtra(String name) {
7183 return mExtras != null && mExtras.containsKey(name);
7184 }
7185
7186 /**
7187 * Returns true if the Intent's extras contain a parcelled file descriptor.
7188 * @return true if the Intent contains a parcelled file descriptor.
7189 */
7190 public boolean hasFileDescriptors() {
7191 return mExtras != null && mExtras.hasFileDescriptors();
7192 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007193
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007194 /** {@hide} */
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007195 public void setAllowFds(boolean allowFds) {
7196 if (mExtras != null) {
7197 mExtras.setAllowFds(allowFds);
7198 }
7199 }
7200
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007201 /** {@hide} */
7202 public void setDefusable(boolean defusable) {
7203 if (mExtras != null) {
7204 mExtras.setDefusable(defusable);
7205 }
7206 }
7207
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007208 /**
7209 * Retrieve extended data from the intent.
7210 *
7211 * @param name The name of the desired item.
7212 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007213 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007214 * or null if none was found.
7215 *
7216 * @deprecated
7217 * @hide
7218 */
7219 @Deprecated
7220 public Object getExtra(String name) {
7221 return getExtra(name, null);
7222 }
7223
7224 /**
7225 * Retrieve extended data from the intent.
7226 *
7227 * @param name The name of the desired item.
7228 * @param defaultValue the value to be returned if no value of the desired
7229 * type is stored with the given name.
7230 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007231 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007232 * or the default value if none was found.
7233 *
7234 * @see #putExtra(String, boolean)
7235 */
7236 public boolean getBooleanExtra(String name, boolean defaultValue) {
7237 return mExtras == null ? defaultValue :
7238 mExtras.getBoolean(name, defaultValue);
7239 }
7240
7241 /**
7242 * Retrieve extended data from the intent.
7243 *
7244 * @param name The name of the desired item.
7245 * @param defaultValue the value to be returned if no value of the desired
7246 * type is stored with the given name.
7247 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007248 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007249 * or the default value if none was found.
7250 *
7251 * @see #putExtra(String, byte)
7252 */
7253 public byte getByteExtra(String name, byte defaultValue) {
7254 return mExtras == null ? defaultValue :
7255 mExtras.getByte(name, defaultValue);
7256 }
7257
7258 /**
7259 * Retrieve extended data from the intent.
7260 *
7261 * @param name The name of the desired item.
7262 * @param defaultValue the value to be returned if no value of the desired
7263 * type is stored with the given name.
7264 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007265 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007266 * or the default value if none was found.
7267 *
7268 * @see #putExtra(String, short)
7269 */
7270 public short getShortExtra(String name, short defaultValue) {
7271 return mExtras == null ? defaultValue :
7272 mExtras.getShort(name, defaultValue);
7273 }
7274
7275 /**
7276 * Retrieve extended data from the intent.
7277 *
7278 * @param name The name of the desired item.
7279 * @param defaultValue the value to be returned if no value of the desired
7280 * type is stored with the given name.
7281 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007282 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007283 * or the default value if none was found.
7284 *
7285 * @see #putExtra(String, char)
7286 */
7287 public char getCharExtra(String name, char defaultValue) {
7288 return mExtras == null ? defaultValue :
7289 mExtras.getChar(name, defaultValue);
7290 }
7291
7292 /**
7293 * Retrieve extended data from the intent.
7294 *
7295 * @param name The name of the desired item.
7296 * @param defaultValue the value to be returned if no value of the desired
7297 * type is stored with the given name.
7298 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007299 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007300 * or the default value if none was found.
7301 *
7302 * @see #putExtra(String, int)
7303 */
7304 public int getIntExtra(String name, int defaultValue) {
7305 return mExtras == null ? defaultValue :
7306 mExtras.getInt(name, defaultValue);
7307 }
7308
7309 /**
7310 * Retrieve extended data from the intent.
7311 *
7312 * @param name The name of the desired item.
7313 * @param defaultValue the value to be returned if no value of the desired
7314 * type is stored with the given name.
7315 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007316 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007317 * or the default value if none was found.
7318 *
7319 * @see #putExtra(String, long)
7320 */
7321 public long getLongExtra(String name, long defaultValue) {
7322 return mExtras == null ? defaultValue :
7323 mExtras.getLong(name, defaultValue);
7324 }
7325
7326 /**
7327 * Retrieve extended data from the intent.
7328 *
7329 * @param name The name of the desired item.
7330 * @param defaultValue the value to be returned if no value of the desired
7331 * type is stored with the given name.
7332 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007333 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007334 * or the default value if no such item is present
7335 *
7336 * @see #putExtra(String, float)
7337 */
7338 public float getFloatExtra(String name, float defaultValue) {
7339 return mExtras == null ? defaultValue :
7340 mExtras.getFloat(name, defaultValue);
7341 }
7342
7343 /**
7344 * Retrieve extended data from the intent.
7345 *
7346 * @param name The name of the desired item.
7347 * @param defaultValue the value to be returned if no value of the desired
7348 * type is stored with the given name.
7349 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007350 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007351 * or the default value if none was found.
7352 *
7353 * @see #putExtra(String, double)
7354 */
7355 public double getDoubleExtra(String name, double defaultValue) {
7356 return mExtras == null ? defaultValue :
7357 mExtras.getDouble(name, defaultValue);
7358 }
7359
7360 /**
7361 * Retrieve extended data from the intent.
7362 *
7363 * @param name The name of the desired item.
7364 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007365 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007366 * or null if no String value was found.
7367 *
7368 * @see #putExtra(String, String)
7369 */
7370 public String getStringExtra(String name) {
7371 return mExtras == null ? null : mExtras.getString(name);
7372 }
7373
7374 /**
7375 * Retrieve extended data from the intent.
7376 *
7377 * @param name The name of the desired item.
7378 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007379 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007380 * or null if no CharSequence value was found.
7381 *
7382 * @see #putExtra(String, CharSequence)
7383 */
7384 public CharSequence getCharSequenceExtra(String name) {
7385 return mExtras == null ? null : mExtras.getCharSequence(name);
7386 }
7387
7388 /**
7389 * Retrieve extended data from the intent.
7390 *
7391 * @param name The name of the desired item.
7392 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007393 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007394 * or null if no Parcelable value was found.
7395 *
7396 * @see #putExtra(String, Parcelable)
7397 */
7398 public <T extends Parcelable> T getParcelableExtra(String name) {
7399 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7400 }
7401
7402 /**
7403 * Retrieve extended data from the intent.
7404 *
7405 * @param name The name of the desired item.
7406 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007407 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007408 * or null if no Parcelable[] value was found.
7409 *
7410 * @see #putExtra(String, Parcelable[])
7411 */
7412 public Parcelable[] getParcelableArrayExtra(String name) {
7413 return mExtras == null ? null : mExtras.getParcelableArray(name);
7414 }
7415
7416 /**
7417 * Retrieve extended data from the intent.
7418 *
7419 * @param name The name of the desired item.
7420 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007421 * @return the value of an item previously added with
7422 * putParcelableArrayListExtra(), or null if no
7423 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007424 *
7425 * @see #putParcelableArrayListExtra(String, ArrayList)
7426 */
7427 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7428 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7429 }
7430
7431 /**
7432 * Retrieve extended data from the intent.
7433 *
7434 * @param name The name of the desired item.
7435 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007436 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007437 * or null if no Serializable value was found.
7438 *
7439 * @see #putExtra(String, Serializable)
7440 */
7441 public Serializable getSerializableExtra(String name) {
7442 return mExtras == null ? null : mExtras.getSerializable(name);
7443 }
7444
7445 /**
7446 * Retrieve extended data from the intent.
7447 *
7448 * @param name The name of the desired item.
7449 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007450 * @return the value of an item previously added with
7451 * putIntegerArrayListExtra(), or null if no
7452 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007453 *
7454 * @see #putIntegerArrayListExtra(String, ArrayList)
7455 */
7456 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7457 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7458 }
7459
7460 /**
7461 * Retrieve extended data from the intent.
7462 *
7463 * @param name The name of the desired item.
7464 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007465 * @return the value of an item previously added with
7466 * putStringArrayListExtra(), or null if no
7467 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007468 *
7469 * @see #putStringArrayListExtra(String, ArrayList)
7470 */
7471 public ArrayList<String> getStringArrayListExtra(String name) {
7472 return mExtras == null ? null : mExtras.getStringArrayList(name);
7473 }
7474
7475 /**
7476 * Retrieve extended data from the intent.
7477 *
7478 * @param name The name of the desired item.
7479 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007480 * @return the value of an item previously added with
7481 * putCharSequenceArrayListExtra, or null if no
7482 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007483 *
7484 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7485 */
7486 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7487 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7488 }
7489
7490 /**
7491 * Retrieve extended data from the intent.
7492 *
7493 * @param name The name of the desired item.
7494 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007495 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007496 * or null if no boolean array value was found.
7497 *
7498 * @see #putExtra(String, boolean[])
7499 */
7500 public boolean[] getBooleanArrayExtra(String name) {
7501 return mExtras == null ? null : mExtras.getBooleanArray(name);
7502 }
7503
7504 /**
7505 * Retrieve extended data from the intent.
7506 *
7507 * @param name The name of the desired item.
7508 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007509 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007510 * or null if no byte array value was found.
7511 *
7512 * @see #putExtra(String, byte[])
7513 */
7514 public byte[] getByteArrayExtra(String name) {
7515 return mExtras == null ? null : mExtras.getByteArray(name);
7516 }
7517
7518 /**
7519 * Retrieve extended data from the intent.
7520 *
7521 * @param name The name of the desired item.
7522 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007523 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007524 * or null if no short array value was found.
7525 *
7526 * @see #putExtra(String, short[])
7527 */
7528 public short[] getShortArrayExtra(String name) {
7529 return mExtras == null ? null : mExtras.getShortArray(name);
7530 }
7531
7532 /**
7533 * Retrieve extended data from the intent.
7534 *
7535 * @param name The name of the desired item.
7536 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007537 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007538 * or null if no char array value was found.
7539 *
7540 * @see #putExtra(String, char[])
7541 */
7542 public char[] getCharArrayExtra(String name) {
7543 return mExtras == null ? null : mExtras.getCharArray(name);
7544 }
7545
7546 /**
7547 * Retrieve extended data from the intent.
7548 *
7549 * @param name The name of the desired item.
7550 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007551 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007552 * or null if no int array value was found.
7553 *
7554 * @see #putExtra(String, int[])
7555 */
7556 public int[] getIntArrayExtra(String name) {
7557 return mExtras == null ? null : mExtras.getIntArray(name);
7558 }
7559
7560 /**
7561 * Retrieve extended data from the intent.
7562 *
7563 * @param name The name of the desired item.
7564 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007565 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007566 * or null if no long array value was found.
7567 *
7568 * @see #putExtra(String, long[])
7569 */
7570 public long[] getLongArrayExtra(String name) {
7571 return mExtras == null ? null : mExtras.getLongArray(name);
7572 }
7573
7574 /**
7575 * Retrieve extended data from the intent.
7576 *
7577 * @param name The name of the desired item.
7578 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007579 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007580 * or null if no float array value was found.
7581 *
7582 * @see #putExtra(String, float[])
7583 */
7584 public float[] getFloatArrayExtra(String name) {
7585 return mExtras == null ? null : mExtras.getFloatArray(name);
7586 }
7587
7588 /**
7589 * Retrieve extended data from the intent.
7590 *
7591 * @param name The name of the desired item.
7592 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007593 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007594 * or null if no double array value was found.
7595 *
7596 * @see #putExtra(String, double[])
7597 */
7598 public double[] getDoubleArrayExtra(String name) {
7599 return mExtras == null ? null : mExtras.getDoubleArray(name);
7600 }
7601
7602 /**
7603 * Retrieve extended data from the intent.
7604 *
7605 * @param name The name of the desired item.
7606 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007607 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007608 * or null if no String array value was found.
7609 *
7610 * @see #putExtra(String, String[])
7611 */
7612 public String[] getStringArrayExtra(String name) {
7613 return mExtras == null ? null : mExtras.getStringArray(name);
7614 }
7615
7616 /**
7617 * Retrieve extended data from the intent.
7618 *
7619 * @param name The name of the desired item.
7620 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007621 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007622 * or null if no CharSequence array value was found.
7623 *
7624 * @see #putExtra(String, CharSequence[])
7625 */
7626 public CharSequence[] getCharSequenceArrayExtra(String name) {
7627 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7628 }
7629
7630 /**
7631 * Retrieve extended data from the intent.
7632 *
7633 * @param name The name of the desired item.
7634 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007635 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007636 * or null if no Bundle value was found.
7637 *
7638 * @see #putExtra(String, Bundle)
7639 */
7640 public Bundle getBundleExtra(String name) {
7641 return mExtras == null ? null : mExtras.getBundle(name);
7642 }
7643
7644 /**
7645 * Retrieve extended data from the intent.
7646 *
7647 * @param name The name of the desired item.
7648 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007649 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007650 * or null if no IBinder value was found.
7651 *
7652 * @see #putExtra(String, IBinder)
7653 *
7654 * @deprecated
7655 * @hide
7656 */
7657 @Deprecated
7658 public IBinder getIBinderExtra(String name) {
7659 return mExtras == null ? null : mExtras.getIBinder(name);
7660 }
7661
7662 /**
7663 * Retrieve extended data from the intent.
7664 *
7665 * @param name The name of the desired item.
7666 * @param defaultValue The default value to return in case no item is
7667 * associated with the key 'name'
7668 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007669 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007670 * or defaultValue if none was found.
7671 *
7672 * @see #putExtra
7673 *
7674 * @deprecated
7675 * @hide
7676 */
7677 @Deprecated
7678 public Object getExtra(String name, Object defaultValue) {
7679 Object result = defaultValue;
7680 if (mExtras != null) {
7681 Object result2 = mExtras.get(name);
7682 if (result2 != null) {
7683 result = result2;
7684 }
7685 }
7686
7687 return result;
7688 }
7689
7690 /**
7691 * Retrieves a map of extended data from the intent.
7692 *
7693 * @return the map of all extras previously added with putExtra(),
7694 * or null if none have been added.
7695 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007696 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007697 return (mExtras != null)
7698 ? new Bundle(mExtras)
7699 : null;
7700 }
7701
7702 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007703 * Filter extras to only basic types.
7704 * @hide
7705 */
7706 public void removeUnsafeExtras() {
7707 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007708 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007709 }
7710 }
7711
7712 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007713 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7714 * return itself as-is.
7715 * @hide
7716 */
7717 public boolean canStripForHistory() {
7718 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7719 }
7720
7721 /**
7722 * Call it when the system needs to keep an intent for logging purposes to remove fields
7723 * that are not needed for logging.
7724 * @hide
7725 */
7726 public Intent maybeStripForHistory() {
7727 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7728
7729 if (!canStripForHistory()) {
7730 return this;
7731 }
7732 return new Intent(this, COPY_MODE_HISTORY);
7733 }
7734
7735 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007736 * Retrieve any special flags associated with this intent. You will
7737 * normally just set them with {@link #setFlags} and let the system
7738 * take the appropriate action with them.
7739 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007740 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007741 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007742 * @see #addFlags
7743 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007744 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007745 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007746 return mFlags;
7747 }
7748
Dianne Hackborne7f97212011-02-24 14:40:20 -08007749 /** @hide */
7750 public boolean isExcludingStopped() {
7751 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7752 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7753 }
7754
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007755 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007756 * Retrieve the application package name this Intent is limited to. When
7757 * resolving an Intent, if non-null this limits the resolution to only
7758 * components in the given application package.
7759 *
7760 * @return The name of the application package for the Intent.
7761 *
7762 * @see #resolveActivity
7763 * @see #setPackage
7764 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007765 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007766 return mPackage;
7767 }
7768
7769 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007770 * Retrieve the concrete component associated with the intent. When receiving
7771 * an intent, this is the component that was found to best handle it (that is,
7772 * yourself) and will always be non-null; in all other cases it will be
7773 * null unless explicitly set.
7774 *
7775 * @return The name of the application component to handle the intent.
7776 *
7777 * @see #resolveActivity
7778 * @see #setComponent
7779 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007780 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 return mComponent;
7782 }
7783
7784 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007785 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7786 * used as a hint to the receiver for animations and the like. Null means that there
7787 * is no source bounds.
7788 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007789 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007790 return mSourceBounds;
7791 }
7792
7793 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007794 * Return the Activity component that should be used to handle this intent.
7795 * The appropriate component is determined based on the information in the
7796 * intent, evaluated as follows:
7797 *
7798 * <p>If {@link #getComponent} returns an explicit class, that is returned
7799 * without any further consideration.
7800 *
7801 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7802 * category to be considered.
7803 *
7804 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7805 * action.
7806 *
7807 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7808 * this type.
7809 *
7810 * <p>If {@link #addCategory} has added any categories, the activity must
7811 * handle ALL of the categories specified.
7812 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007813 * <p>If {@link #getPackage} is non-NULL, only activity components in
7814 * that application package will be considered.
7815 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007816 * <p>If there are no activities that satisfy all of these conditions, a
7817 * null string is returned.
7818 *
7819 * <p>If multiple activities are found to satisfy the intent, the one with
7820 * the highest priority will be used. If there are multiple activities
7821 * with the same priority, the system will either pick the best activity
7822 * based on user preference, or resolve to a system class that will allow
7823 * the user to pick an activity and forward from there.
7824 *
7825 * <p>This method is implemented simply by calling
7826 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7827 * true.</p>
7828 * <p> This API is called for you as part of starting an activity from an
7829 * intent. You do not normally need to call it yourself.</p>
7830 *
7831 * @param pm The package manager with which to resolve the Intent.
7832 *
7833 * @return Name of the component implementing an activity that can
7834 * display the intent.
7835 *
7836 * @see #setComponent
7837 * @see #getComponent
7838 * @see #resolveActivityInfo
7839 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007840 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007841 if (mComponent != null) {
7842 return mComponent;
7843 }
7844
7845 ResolveInfo info = pm.resolveActivity(
7846 this, PackageManager.MATCH_DEFAULT_ONLY);
7847 if (info != null) {
7848 return new ComponentName(
7849 info.activityInfo.applicationInfo.packageName,
7850 info.activityInfo.name);
7851 }
7852
7853 return null;
7854 }
7855
7856 /**
7857 * Resolve the Intent into an {@link ActivityInfo}
7858 * describing the activity that should execute the intent. Resolution
7859 * follows the same rules as described for {@link #resolveActivity}, but
7860 * you get back the completely information about the resolved activity
7861 * instead of just its class name.
7862 *
7863 * @param pm The package manager with which to resolve the Intent.
7864 * @param flags Addition information to retrieve as per
7865 * {@link PackageManager#getActivityInfo(ComponentName, int)
7866 * PackageManager.getActivityInfo()}.
7867 *
7868 * @return PackageManager.ActivityInfo
7869 *
7870 * @see #resolveActivity
7871 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007872 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7873 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007874 ActivityInfo ai = null;
7875 if (mComponent != null) {
7876 try {
7877 ai = pm.getActivityInfo(mComponent, flags);
7878 } catch (PackageManager.NameNotFoundException e) {
7879 // ignore
7880 }
7881 } else {
7882 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007883 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007884 if (info != null) {
7885 ai = info.activityInfo;
7886 }
7887 }
7888
7889 return ai;
7890 }
7891
7892 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007893 * Special function for use by the system to resolve service
7894 * intents to system apps. Throws an exception if there are
7895 * multiple potential matches to the Intent. Returns null if
7896 * there are no matches.
7897 * @hide
7898 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007899 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7900 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007901 if (mComponent != null) {
7902 return mComponent;
7903 }
7904
7905 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7906 if (results == null) {
7907 return null;
7908 }
7909 ComponentName comp = null;
7910 for (int i=0; i<results.size(); i++) {
7911 ResolveInfo ri = results.get(i);
7912 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7913 continue;
7914 }
7915 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
7916 ri.serviceInfo.name);
7917 if (comp != null) {
7918 throw new IllegalStateException("Multiple system services handle " + this
7919 + ": " + comp + ", " + foundComp);
7920 }
7921 comp = foundComp;
7922 }
7923 return comp;
7924 }
7925
7926 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007927 * Set the general action to be performed.
7928 *
7929 * @param action An action name, such as ACTION_VIEW. Application-specific
7930 * actions should be prefixed with the vendor's package name.
7931 *
7932 * @return Returns the same Intent object, for chaining multiple calls
7933 * into a single statement.
7934 *
7935 * @see #getAction
7936 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007937 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08007938 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007939 return this;
7940 }
7941
7942 /**
7943 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08007944 * clears any type that was previously set by {@link #setType} or
7945 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007946 *
Nick Pellyccae4122012-01-09 14:12:58 -08007947 * <p><em>Note: scheme matching in the Android framework is
7948 * case-sensitive, unlike the formal RFC. As a result,
7949 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007950 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08007951 * {@link #setDataAndNormalize}
7952 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07007953 *
Nick Pellyccae4122012-01-09 14:12:58 -08007954 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007955 *
7956 * @return Returns the same Intent object, for chaining multiple calls
7957 * into a single statement.
7958 *
7959 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08007960 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07007961 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007962 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007963 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007964 mData = data;
7965 mType = null;
7966 return this;
7967 }
7968
7969 /**
Nick Pellyccae4122012-01-09 14:12:58 -08007970 * Normalize and set the data this intent is operating on.
7971 *
7972 * <p>This method automatically clears any type that was
7973 * previously set (for example, by {@link #setType}).
7974 *
7975 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007976 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08007977 * so really this is just a convenience method for
7978 * <pre>
7979 * setData(data.normalize())
7980 * </pre>
7981 *
7982 * @param data The Uri of the data this intent is now targeting.
7983 *
7984 * @return Returns the same Intent object, for chaining multiple calls
7985 * into a single statement.
7986 *
7987 * @see #getData
7988 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007989 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08007990 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007991 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04007992 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08007993 }
7994
7995 /**
7996 * Set an explicit MIME data type.
7997 *
7998 * <p>This is used to create intents that only specify a type and not data,
7999 * for example to indicate the type of data to return.
8000 *
8001 * <p>This method automatically clears any data that was
8002 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008003 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008004 * <p><em>Note: MIME type matching in the Android framework is
8005 * case-sensitive, unlike formal RFC MIME types. As a result,
8006 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008007 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8008 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008009 *
8010 * @param type The MIME type of the data being handled by this intent.
8011 *
8012 * @return Returns the same Intent object, for chaining multiple calls
8013 * into a single statement.
8014 *
8015 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008016 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008017 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008018 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008019 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008020 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008021 mData = null;
8022 mType = type;
8023 return this;
8024 }
8025
8026 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008027 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008028 *
Nick Pellyccae4122012-01-09 14:12:58 -08008029 * <p>This is used to create intents that only specify a type and not data,
8030 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008031 *
Nick Pellyccae4122012-01-09 14:12:58 -08008032 * <p>This method automatically clears any data that was
8033 * previously set (for example by {@link #setData}).
8034 *
8035 * <p>The MIME type is normalized using
8036 * {@link #normalizeMimeType} before it is set,
8037 * so really this is just a convenience method for
8038 * <pre>
8039 * setType(Intent.normalizeMimeType(type))
8040 * </pre>
8041 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008042 * @param type The MIME type of the data being handled by this intent.
8043 *
8044 * @return Returns the same Intent object, for chaining multiple calls
8045 * into a single statement.
8046 *
Nick Pellyccae4122012-01-09 14:12:58 -08008047 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008048 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008049 * @see #normalizeMimeType
8050 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008051 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008052 return setType(normalizeMimeType(type));
8053 }
8054
8055 /**
8056 * (Usually optional) Set the data for the intent along with an explicit
8057 * MIME data type. This method should very rarely be used -- it allows you
8058 * to override the MIME type that would ordinarily be inferred from the
8059 * data with your own type given here.
8060 *
8061 * <p><em>Note: MIME type and Uri scheme matching in the
8062 * Android framework is case-sensitive, unlike the formal RFC definitions.
8063 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008064 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008065 * {@link #setDataAndTypeAndNormalize}
8066 * to ensure that they are converted to lower case.</em>
8067 *
8068 * @param data The Uri of the data this intent is now targeting.
8069 * @param type The MIME type of the data being handled by this intent.
8070 *
8071 * @return Returns the same Intent object, for chaining multiple calls
8072 * into a single statement.
8073 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008074 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008075 * @see #setData
8076 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008077 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008078 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008079 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008080 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008081 mData = data;
8082 mType = type;
8083 return this;
8084 }
8085
8086 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008087 * (Usually optional) Normalize and set both the data Uri and an explicit
8088 * MIME data type. This method should very rarely be used -- it allows you
8089 * to override the MIME type that would ordinarily be inferred from the
8090 * data with your own type given here.
8091 *
8092 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008093 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008094 * before they are set, so really this is just a convenience method for
8095 * <pre>
8096 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8097 * </pre>
8098 *
8099 * @param data The Uri of the data this intent is now targeting.
8100 * @param type The MIME type of the data being handled by this intent.
8101 *
8102 * @return Returns the same Intent object, for chaining multiple calls
8103 * into a single statement.
8104 *
8105 * @see #setType
8106 * @see #setData
8107 * @see #setDataAndType
8108 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008109 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008110 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008111 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008112 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008113 }
8114
8115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008116 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008117 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008118 * activities that provide <em>all</em> of the requested categories will be
8119 * used.
8120 *
8121 * @param category The desired category. This can be either one of the
8122 * predefined Intent categories, or a custom category in your own
8123 * namespace.
8124 *
8125 * @return Returns the same Intent object, for chaining multiple calls
8126 * into a single statement.
8127 *
8128 * @see #hasCategory
8129 * @see #removeCategory
8130 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008131 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008132 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008133 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008134 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008135 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008136 return this;
8137 }
8138
8139 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008140 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008141 *
8142 * @param category The category to remove.
8143 *
8144 * @see #addCategory
8145 */
8146 public void removeCategory(String category) {
8147 if (mCategories != null) {
8148 mCategories.remove(category);
8149 if (mCategories.size() == 0) {
8150 mCategories = null;
8151 }
8152 }
8153 }
8154
8155 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008156 * Set a selector for this Intent. This is a modification to the kinds of
8157 * things the Intent will match. If the selector is set, it will be used
8158 * when trying to find entities that can handle the Intent, instead of the
8159 * main contents of the Intent. This allows you build an Intent containing
8160 * a generic protocol while targeting it more specifically.
8161 *
8162 * <p>An example of where this may be used is with things like
8163 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8164 * Intent that will launch the Browser application. However, the correct
8165 * main entry point of an application is actually {@link #ACTION_MAIN}
8166 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8167 * used to specify the actual Activity to launch. If you launch the browser
8168 * with something different, undesired behavior may happen if the user has
8169 * previously or later launches it the normal way, since they do not match.
8170 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8171 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8172 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8173 *
8174 * <p>Setting a selector does not impact the behavior of
8175 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8176 * desired behavior of a selector -- it does not impact the base meaning
8177 * of the Intent, just what kinds of things will be matched against it
8178 * when determining who can handle it.</p>
8179 *
8180 * <p>You can not use both a selector and {@link #setPackage(String)} on
8181 * the same base Intent.</p>
8182 *
8183 * @param selector The desired selector Intent; set to null to not use
8184 * a special selector.
8185 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008186 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008187 if (selector == this) {
8188 throw new IllegalArgumentException(
8189 "Intent being set as a selector of itself");
8190 }
8191 if (selector != null && mPackage != null) {
8192 throw new IllegalArgumentException(
8193 "Can't set selector when package name is already set");
8194 }
8195 mSelector = selector;
8196 }
8197
8198 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008199 * Set a {@link ClipData} associated with this Intent. This replaces any
8200 * previously set ClipData.
8201 *
8202 * <p>The ClipData in an intent is not used for Intent matching or other
8203 * such operations. Semantically it is like extras, used to transmit
8204 * additional data with the Intent. The main feature of using this over
8205 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8206 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8207 * items included in the clip data. This is useful, in particular, if
8208 * you want to transmit an Intent containing multiple <code>content:</code>
8209 * URIs for which the recipient may not have global permission to access the
8210 * content provider.
8211 *
8212 * <p>If the ClipData contains items that are themselves Intents, any
8213 * grant flags in those Intents will be ignored. Only the top-level flags
8214 * of the main Intent are respected, and will be applied to all Uri or
8215 * Intent items in the clip (or sub-items of the clip).
8216 *
8217 * <p>The MIME type, label, and icon in the ClipData object are not
8218 * directly used by Intent. Applications should generally rely on the
8219 * MIME type of the Intent itself, not what it may find in the ClipData.
8220 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008221 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008222 *
8223 * @param clip The new clip to set. May be null to clear the current clip.
8224 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008225 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008226 mClipData = clip;
8227 }
8228
8229 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008230 * This is NOT a secure mechanism to identify the user who sent the intent.
8231 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8232 * who sent the intent.
8233 * @hide
8234 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008235 public void prepareToLeaveUser(int userId) {
8236 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8237 // We want mContentUserHint to refer to the original user, so don't do anything.
8238 if (mContentUserHint == UserHandle.USER_CURRENT) {
8239 mContentUserHint = userId;
8240 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008241 }
8242
8243 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008244 * Add extended data to the intent. The name must include a package
8245 * prefix, for example the app com.android.contacts would use names
8246 * like "com.android.contacts.ShowAll".
8247 *
8248 * @param name The name of the extra data, with package prefix.
8249 * @param value The boolean data value.
8250 *
8251 * @return Returns the same Intent object, for chaining multiple calls
8252 * into a single statement.
8253 *
8254 * @see #putExtras
8255 * @see #removeExtra
8256 * @see #getBooleanExtra(String, boolean)
8257 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008258 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008259 if (mExtras == null) {
8260 mExtras = new Bundle();
8261 }
8262 mExtras.putBoolean(name, value);
8263 return this;
8264 }
8265
8266 /**
8267 * Add extended data to the intent. The name must include a package
8268 * prefix, for example the app com.android.contacts would use names
8269 * like "com.android.contacts.ShowAll".
8270 *
8271 * @param name The name of the extra data, with package prefix.
8272 * @param value The byte data value.
8273 *
8274 * @return Returns the same Intent object, for chaining multiple calls
8275 * into a single statement.
8276 *
8277 * @see #putExtras
8278 * @see #removeExtra
8279 * @see #getByteExtra(String, byte)
8280 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008281 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008282 if (mExtras == null) {
8283 mExtras = new Bundle();
8284 }
8285 mExtras.putByte(name, value);
8286 return this;
8287 }
8288
8289 /**
8290 * Add extended data to the intent. The name must include a package
8291 * prefix, for example the app com.android.contacts would use names
8292 * like "com.android.contacts.ShowAll".
8293 *
8294 * @param name The name of the extra data, with package prefix.
8295 * @param value The char data value.
8296 *
8297 * @return Returns the same Intent object, for chaining multiple calls
8298 * into a single statement.
8299 *
8300 * @see #putExtras
8301 * @see #removeExtra
8302 * @see #getCharExtra(String, char)
8303 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008304 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305 if (mExtras == null) {
8306 mExtras = new Bundle();
8307 }
8308 mExtras.putChar(name, value);
8309 return this;
8310 }
8311
8312 /**
8313 * Add extended data to the intent. The name must include a package
8314 * prefix, for example the app com.android.contacts would use names
8315 * like "com.android.contacts.ShowAll".
8316 *
8317 * @param name The name of the extra data, with package prefix.
8318 * @param value The short data value.
8319 *
8320 * @return Returns the same Intent object, for chaining multiple calls
8321 * into a single statement.
8322 *
8323 * @see #putExtras
8324 * @see #removeExtra
8325 * @see #getShortExtra(String, short)
8326 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008327 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008328 if (mExtras == null) {
8329 mExtras = new Bundle();
8330 }
8331 mExtras.putShort(name, value);
8332 return this;
8333 }
8334
8335 /**
8336 * Add extended data to the intent. The name must include a package
8337 * prefix, for example the app com.android.contacts would use names
8338 * like "com.android.contacts.ShowAll".
8339 *
8340 * @param name The name of the extra data, with package prefix.
8341 * @param value The integer data value.
8342 *
8343 * @return Returns the same Intent object, for chaining multiple calls
8344 * into a single statement.
8345 *
8346 * @see #putExtras
8347 * @see #removeExtra
8348 * @see #getIntExtra(String, int)
8349 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008350 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008351 if (mExtras == null) {
8352 mExtras = new Bundle();
8353 }
8354 mExtras.putInt(name, value);
8355 return this;
8356 }
8357
8358 /**
8359 * Add extended data to the intent. The name must include a package
8360 * prefix, for example the app com.android.contacts would use names
8361 * like "com.android.contacts.ShowAll".
8362 *
8363 * @param name The name of the extra data, with package prefix.
8364 * @param value The long data value.
8365 *
8366 * @return Returns the same Intent object, for chaining multiple calls
8367 * into a single statement.
8368 *
8369 * @see #putExtras
8370 * @see #removeExtra
8371 * @see #getLongExtra(String, long)
8372 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008373 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008374 if (mExtras == null) {
8375 mExtras = new Bundle();
8376 }
8377 mExtras.putLong(name, value);
8378 return this;
8379 }
8380
8381 /**
8382 * Add extended data to the intent. The name must include a package
8383 * prefix, for example the app com.android.contacts would use names
8384 * like "com.android.contacts.ShowAll".
8385 *
8386 * @param name The name of the extra data, with package prefix.
8387 * @param value The float data value.
8388 *
8389 * @return Returns the same Intent object, for chaining multiple calls
8390 * into a single statement.
8391 *
8392 * @see #putExtras
8393 * @see #removeExtra
8394 * @see #getFloatExtra(String, float)
8395 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008396 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008397 if (mExtras == null) {
8398 mExtras = new Bundle();
8399 }
8400 mExtras.putFloat(name, value);
8401 return this;
8402 }
8403
8404 /**
8405 * Add extended data to the intent. The name must include a package
8406 * prefix, for example the app com.android.contacts would use names
8407 * like "com.android.contacts.ShowAll".
8408 *
8409 * @param name The name of the extra data, with package prefix.
8410 * @param value The double data value.
8411 *
8412 * @return Returns the same Intent object, for chaining multiple calls
8413 * into a single statement.
8414 *
8415 * @see #putExtras
8416 * @see #removeExtra
8417 * @see #getDoubleExtra(String, double)
8418 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008419 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008420 if (mExtras == null) {
8421 mExtras = new Bundle();
8422 }
8423 mExtras.putDouble(name, value);
8424 return this;
8425 }
8426
8427 /**
8428 * Add extended data to the intent. The name must include a package
8429 * prefix, for example the app com.android.contacts would use names
8430 * like "com.android.contacts.ShowAll".
8431 *
8432 * @param name The name of the extra data, with package prefix.
8433 * @param value The String data value.
8434 *
8435 * @return Returns the same Intent object, for chaining multiple calls
8436 * into a single statement.
8437 *
8438 * @see #putExtras
8439 * @see #removeExtra
8440 * @see #getStringExtra(String)
8441 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008442 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008443 if (mExtras == null) {
8444 mExtras = new Bundle();
8445 }
8446 mExtras.putString(name, value);
8447 return this;
8448 }
8449
8450 /**
8451 * Add extended data to the intent. The name must include a package
8452 * prefix, for example the app com.android.contacts would use names
8453 * like "com.android.contacts.ShowAll".
8454 *
8455 * @param name The name of the extra data, with package prefix.
8456 * @param value The CharSequence data value.
8457 *
8458 * @return Returns the same Intent object, for chaining multiple calls
8459 * into a single statement.
8460 *
8461 * @see #putExtras
8462 * @see #removeExtra
8463 * @see #getCharSequenceExtra(String)
8464 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008465 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008466 if (mExtras == null) {
8467 mExtras = new Bundle();
8468 }
8469 mExtras.putCharSequence(name, value);
8470 return this;
8471 }
8472
8473 /**
8474 * Add extended data to the intent. The name must include a package
8475 * prefix, for example the app com.android.contacts would use names
8476 * like "com.android.contacts.ShowAll".
8477 *
8478 * @param name The name of the extra data, with package prefix.
8479 * @param value The Parcelable data value.
8480 *
8481 * @return Returns the same Intent object, for chaining multiple calls
8482 * into a single statement.
8483 *
8484 * @see #putExtras
8485 * @see #removeExtra
8486 * @see #getParcelableExtra(String)
8487 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008488 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008489 if (mExtras == null) {
8490 mExtras = new Bundle();
8491 }
8492 mExtras.putParcelable(name, value);
8493 return this;
8494 }
8495
8496 /**
8497 * Add extended data to the intent. The name must include a package
8498 * prefix, for example the app com.android.contacts would use names
8499 * like "com.android.contacts.ShowAll".
8500 *
8501 * @param name The name of the extra data, with package prefix.
8502 * @param value The Parcelable[] data value.
8503 *
8504 * @return Returns the same Intent object, for chaining multiple calls
8505 * into a single statement.
8506 *
8507 * @see #putExtras
8508 * @see #removeExtra
8509 * @see #getParcelableArrayExtra(String)
8510 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008511 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008512 if (mExtras == null) {
8513 mExtras = new Bundle();
8514 }
8515 mExtras.putParcelableArray(name, value);
8516 return this;
8517 }
8518
8519 /**
8520 * Add extended data to the intent. The name must include a package
8521 * prefix, for example the app com.android.contacts would use names
8522 * like "com.android.contacts.ShowAll".
8523 *
8524 * @param name The name of the extra data, with package prefix.
8525 * @param value The ArrayList<Parcelable> data value.
8526 *
8527 * @return Returns the same Intent object, for chaining multiple calls
8528 * into a single statement.
8529 *
8530 * @see #putExtras
8531 * @see #removeExtra
8532 * @see #getParcelableArrayListExtra(String)
8533 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008534 public @NonNull Intent putParcelableArrayListExtra(String name,
8535 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008536 if (mExtras == null) {
8537 mExtras = new Bundle();
8538 }
8539 mExtras.putParcelableArrayList(name, value);
8540 return this;
8541 }
8542
8543 /**
8544 * Add extended data to the intent. The name must include a package
8545 * prefix, for example the app com.android.contacts would use names
8546 * like "com.android.contacts.ShowAll".
8547 *
8548 * @param name The name of the extra data, with package prefix.
8549 * @param value The ArrayList<Integer> data value.
8550 *
8551 * @return Returns the same Intent object, for chaining multiple calls
8552 * into a single statement.
8553 *
8554 * @see #putExtras
8555 * @see #removeExtra
8556 * @see #getIntegerArrayListExtra(String)
8557 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008558 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008559 if (mExtras == null) {
8560 mExtras = new Bundle();
8561 }
8562 mExtras.putIntegerArrayList(name, value);
8563 return this;
8564 }
8565
8566 /**
8567 * Add extended data to the intent. The name must include a package
8568 * prefix, for example the app com.android.contacts would use names
8569 * like "com.android.contacts.ShowAll".
8570 *
8571 * @param name The name of the extra data, with package prefix.
8572 * @param value The ArrayList<String> data value.
8573 *
8574 * @return Returns the same Intent object, for chaining multiple calls
8575 * into a single statement.
8576 *
8577 * @see #putExtras
8578 * @see #removeExtra
8579 * @see #getStringArrayListExtra(String)
8580 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008581 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008582 if (mExtras == null) {
8583 mExtras = new Bundle();
8584 }
8585 mExtras.putStringArrayList(name, value);
8586 return this;
8587 }
8588
8589 /**
8590 * Add extended data to the intent. The name must include a package
8591 * prefix, for example the app com.android.contacts would use names
8592 * like "com.android.contacts.ShowAll".
8593 *
8594 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008595 * @param value The ArrayList<CharSequence> data value.
8596 *
8597 * @return Returns the same Intent object, for chaining multiple calls
8598 * into a single statement.
8599 *
8600 * @see #putExtras
8601 * @see #removeExtra
8602 * @see #getCharSequenceArrayListExtra(String)
8603 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008604 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8605 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008606 if (mExtras == null) {
8607 mExtras = new Bundle();
8608 }
8609 mExtras.putCharSequenceArrayList(name, value);
8610 return this;
8611 }
8612
8613 /**
8614 * Add extended data to the intent. The name must include a package
8615 * prefix, for example the app com.android.contacts would use names
8616 * like "com.android.contacts.ShowAll".
8617 *
8618 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008619 * @param value The Serializable data value.
8620 *
8621 * @return Returns the same Intent object, for chaining multiple calls
8622 * into a single statement.
8623 *
8624 * @see #putExtras
8625 * @see #removeExtra
8626 * @see #getSerializableExtra(String)
8627 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008628 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008629 if (mExtras == null) {
8630 mExtras = new Bundle();
8631 }
8632 mExtras.putSerializable(name, value);
8633 return this;
8634 }
8635
8636 /**
8637 * Add extended data to the intent. The name must include a package
8638 * prefix, for example the app com.android.contacts would use names
8639 * like "com.android.contacts.ShowAll".
8640 *
8641 * @param name The name of the extra data, with package prefix.
8642 * @param value The boolean array data value.
8643 *
8644 * @return Returns the same Intent object, for chaining multiple calls
8645 * into a single statement.
8646 *
8647 * @see #putExtras
8648 * @see #removeExtra
8649 * @see #getBooleanArrayExtra(String)
8650 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008651 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008652 if (mExtras == null) {
8653 mExtras = new Bundle();
8654 }
8655 mExtras.putBooleanArray(name, value);
8656 return this;
8657 }
8658
8659 /**
8660 * Add extended data to the intent. The name must include a package
8661 * prefix, for example the app com.android.contacts would use names
8662 * like "com.android.contacts.ShowAll".
8663 *
8664 * @param name The name of the extra data, with package prefix.
8665 * @param value The byte array data value.
8666 *
8667 * @return Returns the same Intent object, for chaining multiple calls
8668 * into a single statement.
8669 *
8670 * @see #putExtras
8671 * @see #removeExtra
8672 * @see #getByteArrayExtra(String)
8673 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008674 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008675 if (mExtras == null) {
8676 mExtras = new Bundle();
8677 }
8678 mExtras.putByteArray(name, value);
8679 return this;
8680 }
8681
8682 /**
8683 * Add extended data to the intent. The name must include a package
8684 * prefix, for example the app com.android.contacts would use names
8685 * like "com.android.contacts.ShowAll".
8686 *
8687 * @param name The name of the extra data, with package prefix.
8688 * @param value The short array data value.
8689 *
8690 * @return Returns the same Intent object, for chaining multiple calls
8691 * into a single statement.
8692 *
8693 * @see #putExtras
8694 * @see #removeExtra
8695 * @see #getShortArrayExtra(String)
8696 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008697 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008698 if (mExtras == null) {
8699 mExtras = new Bundle();
8700 }
8701 mExtras.putShortArray(name, value);
8702 return this;
8703 }
8704
8705 /**
8706 * Add extended data to the intent. The name must include a package
8707 * prefix, for example the app com.android.contacts would use names
8708 * like "com.android.contacts.ShowAll".
8709 *
8710 * @param name The name of the extra data, with package prefix.
8711 * @param value The char array data value.
8712 *
8713 * @return Returns the same Intent object, for chaining multiple calls
8714 * into a single statement.
8715 *
8716 * @see #putExtras
8717 * @see #removeExtra
8718 * @see #getCharArrayExtra(String)
8719 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008720 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008721 if (mExtras == null) {
8722 mExtras = new Bundle();
8723 }
8724 mExtras.putCharArray(name, value);
8725 return this;
8726 }
8727
8728 /**
8729 * Add extended data to the intent. The name must include a package
8730 * prefix, for example the app com.android.contacts would use names
8731 * like "com.android.contacts.ShowAll".
8732 *
8733 * @param name The name of the extra data, with package prefix.
8734 * @param value The int array data value.
8735 *
8736 * @return Returns the same Intent object, for chaining multiple calls
8737 * into a single statement.
8738 *
8739 * @see #putExtras
8740 * @see #removeExtra
8741 * @see #getIntArrayExtra(String)
8742 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008743 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008744 if (mExtras == null) {
8745 mExtras = new Bundle();
8746 }
8747 mExtras.putIntArray(name, value);
8748 return this;
8749 }
8750
8751 /**
8752 * Add extended data to the intent. The name must include a package
8753 * prefix, for example the app com.android.contacts would use names
8754 * like "com.android.contacts.ShowAll".
8755 *
8756 * @param name The name of the extra data, with package prefix.
8757 * @param value The byte array data value.
8758 *
8759 * @return Returns the same Intent object, for chaining multiple calls
8760 * into a single statement.
8761 *
8762 * @see #putExtras
8763 * @see #removeExtra
8764 * @see #getLongArrayExtra(String)
8765 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008766 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008767 if (mExtras == null) {
8768 mExtras = new Bundle();
8769 }
8770 mExtras.putLongArray(name, value);
8771 return this;
8772 }
8773
8774 /**
8775 * Add extended data to the intent. The name must include a package
8776 * prefix, for example the app com.android.contacts would use names
8777 * like "com.android.contacts.ShowAll".
8778 *
8779 * @param name The name of the extra data, with package prefix.
8780 * @param value The float array data value.
8781 *
8782 * @return Returns the same Intent object, for chaining multiple calls
8783 * into a single statement.
8784 *
8785 * @see #putExtras
8786 * @see #removeExtra
8787 * @see #getFloatArrayExtra(String)
8788 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008789 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008790 if (mExtras == null) {
8791 mExtras = new Bundle();
8792 }
8793 mExtras.putFloatArray(name, value);
8794 return this;
8795 }
8796
8797 /**
8798 * Add extended data to the intent. The name must include a package
8799 * prefix, for example the app com.android.contacts would use names
8800 * like "com.android.contacts.ShowAll".
8801 *
8802 * @param name The name of the extra data, with package prefix.
8803 * @param value The double array data value.
8804 *
8805 * @return Returns the same Intent object, for chaining multiple calls
8806 * into a single statement.
8807 *
8808 * @see #putExtras
8809 * @see #removeExtra
8810 * @see #getDoubleArrayExtra(String)
8811 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008812 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008813 if (mExtras == null) {
8814 mExtras = new Bundle();
8815 }
8816 mExtras.putDoubleArray(name, value);
8817 return this;
8818 }
8819
8820 /**
8821 * Add extended data to the intent. The name must include a package
8822 * prefix, for example the app com.android.contacts would use names
8823 * like "com.android.contacts.ShowAll".
8824 *
8825 * @param name The name of the extra data, with package prefix.
8826 * @param value The String array data value.
8827 *
8828 * @return Returns the same Intent object, for chaining multiple calls
8829 * into a single statement.
8830 *
8831 * @see #putExtras
8832 * @see #removeExtra
8833 * @see #getStringArrayExtra(String)
8834 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008835 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008836 if (mExtras == null) {
8837 mExtras = new Bundle();
8838 }
8839 mExtras.putStringArray(name, value);
8840 return this;
8841 }
8842
8843 /**
8844 * Add extended data to the intent. The name must include a package
8845 * prefix, for example the app com.android.contacts would use names
8846 * like "com.android.contacts.ShowAll".
8847 *
8848 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008849 * @param value The CharSequence array data value.
8850 *
8851 * @return Returns the same Intent object, for chaining multiple calls
8852 * into a single statement.
8853 *
8854 * @see #putExtras
8855 * @see #removeExtra
8856 * @see #getCharSequenceArrayExtra(String)
8857 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008858 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008859 if (mExtras == null) {
8860 mExtras = new Bundle();
8861 }
8862 mExtras.putCharSequenceArray(name, value);
8863 return this;
8864 }
8865
8866 /**
8867 * Add extended data to the intent. The name must include a package
8868 * prefix, for example the app com.android.contacts would use names
8869 * like "com.android.contacts.ShowAll".
8870 *
8871 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008872 * @param value The Bundle data value.
8873 *
8874 * @return Returns the same Intent object, for chaining multiple calls
8875 * into a single statement.
8876 *
8877 * @see #putExtras
8878 * @see #removeExtra
8879 * @see #getBundleExtra(String)
8880 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008881 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008882 if (mExtras == null) {
8883 mExtras = new Bundle();
8884 }
8885 mExtras.putBundle(name, value);
8886 return this;
8887 }
8888
8889 /**
8890 * Add extended data to the intent. The name must include a package
8891 * prefix, for example the app com.android.contacts would use names
8892 * like "com.android.contacts.ShowAll".
8893 *
8894 * @param name The name of the extra data, with package prefix.
8895 * @param value The IBinder data value.
8896 *
8897 * @return Returns the same Intent object, for chaining multiple calls
8898 * into a single statement.
8899 *
8900 * @see #putExtras
8901 * @see #removeExtra
8902 * @see #getIBinderExtra(String)
8903 *
8904 * @deprecated
8905 * @hide
8906 */
8907 @Deprecated
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008908 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008909 if (mExtras == null) {
8910 mExtras = new Bundle();
8911 }
8912 mExtras.putIBinder(name, value);
8913 return this;
8914 }
8915
8916 /**
8917 * Copy all extras in 'src' in to this intent.
8918 *
8919 * @param src Contains the extras to copy.
8920 *
8921 * @see #putExtra
8922 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008923 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008924 if (src.mExtras != null) {
8925 if (mExtras == null) {
8926 mExtras = new Bundle(src.mExtras);
8927 } else {
8928 mExtras.putAll(src.mExtras);
8929 }
8930 }
8931 return this;
8932 }
8933
8934 /**
8935 * Add a set of extended data to the intent. The keys must include a package
8936 * prefix, for example the app com.android.contacts would use names
8937 * like "com.android.contacts.ShowAll".
8938 *
8939 * @param extras The Bundle of extras to add to this intent.
8940 *
8941 * @see #putExtra
8942 * @see #removeExtra
8943 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008944 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 if (mExtras == null) {
8946 mExtras = new Bundle();
8947 }
8948 mExtras.putAll(extras);
8949 return this;
8950 }
8951
8952 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008953 * Completely replace the extras in the Intent with the extras in the
8954 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07008955 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008956 * @param src The exact extras contained in this Intent are copied
8957 * into the target intent, replacing any that were previously there.
8958 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008959 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008960 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
8961 return this;
8962 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008963
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008964 /**
8965 * Completely replace the extras in the Intent with the given Bundle of
8966 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07008967 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008968 * @param extras The new set of extras in the Intent, or null to erase
8969 * all extras.
8970 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008971 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008972 mExtras = extras != null ? new Bundle(extras) : null;
8973 return this;
8974 }
The Android Open Source Project10592532009-03-18 17:39:46 -07008975
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08008976 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008977 * Remove extended data from the intent.
8978 *
8979 * @see #putExtra
8980 */
8981 public void removeExtra(String name) {
8982 if (mExtras != null) {
8983 mExtras.remove(name);
8984 if (mExtras.size() == 0) {
8985 mExtras = null;
8986 }
8987 }
8988 }
8989
8990 /**
8991 * Set special flags controlling how this intent is handled. Most values
8992 * here depend on the type of component being executed by the Intent,
8993 * specifically the FLAG_ACTIVITY_* flags are all for use with
8994 * {@link Context#startActivity Context.startActivity()} and the
8995 * FLAG_RECEIVER_* flags are all for use with
8996 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
8997 *
Scott Main7aee61f2011-02-08 11:25:01 -08008998 * <p>See the
8999 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9000 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009001 * the behavior of your application.
9002 *
9003 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009004 * @return Returns the same Intent object, for chaining multiple calls
9005 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009006 * @see #getFlags
9007 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009008 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009009 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009010 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009011 mFlags = flags;
9012 return this;
9013 }
9014
9015 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009016 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009017 *
9018 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009019 * @return Returns the same Intent object, for chaining multiple calls into
9020 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009021 * @see #setFlags
9022 * @see #getFlags
9023 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009024 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009025 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009026 mFlags |= flags;
9027 return this;
9028 }
9029
9030 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009031 * Remove these flags from the intent.
9032 *
9033 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009034 * @see #setFlags
9035 * @see #getFlags
9036 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009037 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009038 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009039 mFlags &= ~flags;
9040 }
9041
9042 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009043 * (Usually optional) Set an explicit application package name that limits
9044 * the components this Intent will resolve to. If left to the default
9045 * value of null, all components in all applications will considered.
9046 * If non-null, the Intent can only match the components in the given
9047 * application package.
9048 *
9049 * @param packageName The name of the application package to handle the
9050 * intent, or null to allow any application package.
9051 *
9052 * @return Returns the same Intent object, for chaining multiple calls
9053 * into a single statement.
9054 *
9055 * @see #getPackage
9056 * @see #resolveActivity
9057 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009058 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009059 if (packageName != null && mSelector != null) {
9060 throw new IllegalArgumentException(
9061 "Can't set package name when selector is already set");
9062 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009063 mPackage = packageName;
9064 return this;
9065 }
9066
9067 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009068 * (Usually optional) Explicitly set the component to handle the intent.
9069 * If left with the default value of null, the system will determine the
9070 * appropriate class to use based on the other fields (action, data,
9071 * type, categories) in the Intent. If this class is defined, the
9072 * specified class will always be used regardless of the other fields. You
9073 * should only set this value when you know you absolutely want a specific
9074 * class to be used; otherwise it is better to let the system find the
9075 * appropriate class so that you will respect the installed applications
9076 * and user preferences.
9077 *
9078 * @param component The name of the application component to handle the
9079 * intent, or null to let the system find one for you.
9080 *
9081 * @return Returns the same Intent object, for chaining multiple calls
9082 * into a single statement.
9083 *
9084 * @see #setClass
9085 * @see #setClassName(Context, String)
9086 * @see #setClassName(String, String)
9087 * @see #getComponent
9088 * @see #resolveActivity
9089 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009090 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009091 mComponent = component;
9092 return this;
9093 }
9094
9095 /**
9096 * Convenience for calling {@link #setComponent} with an
9097 * explicit class name.
9098 *
9099 * @param packageContext A Context of the application package implementing
9100 * this class.
9101 * @param className The name of a class inside of the application package
9102 * that will be used as the component for this Intent.
9103 *
9104 * @return Returns the same Intent object, for chaining multiple calls
9105 * into a single statement.
9106 *
9107 * @see #setComponent
9108 * @see #setClass
9109 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009110 public @NonNull Intent setClassName(@NonNull Context packageContext,
9111 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009112 mComponent = new ComponentName(packageContext, className);
9113 return this;
9114 }
9115
9116 /**
9117 * Convenience for calling {@link #setComponent} with an
9118 * explicit application package name and class name.
9119 *
9120 * @param packageName The name of the package implementing the desired
9121 * component.
9122 * @param className The name of a class inside of the application package
9123 * that will be used as the component for this Intent.
9124 *
9125 * @return Returns the same Intent object, for chaining multiple calls
9126 * into a single statement.
9127 *
9128 * @see #setComponent
9129 * @see #setClass
9130 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009131 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009132 mComponent = new ComponentName(packageName, className);
9133 return this;
9134 }
9135
9136 /**
9137 * Convenience for calling {@link #setComponent(ComponentName)} with the
9138 * name returned by a {@link Class} object.
9139 *
9140 * @param packageContext A Context of the application package implementing
9141 * this class.
9142 * @param cls The class name to set, equivalent to
9143 * <code>setClassName(context, cls.getName())</code>.
9144 *
9145 * @return Returns the same Intent object, for chaining multiple calls
9146 * into a single statement.
9147 *
9148 * @see #setComponent
9149 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009150 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009151 mComponent = new ComponentName(packageContext, cls);
9152 return this;
9153 }
9154
9155 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009156 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9157 * used as a hint to the receiver for animations and the like. Null means that there
9158 * is no source bounds.
9159 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009160 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009161 if (r != null) {
9162 mSourceBounds = new Rect(r);
9163 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009164 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009165 }
9166 }
9167
Tor Norbyed9273d62013-05-30 15:59:53 -07009168 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009169 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9170 FILL_IN_ACTION,
9171 FILL_IN_DATA,
9172 FILL_IN_CATEGORIES,
9173 FILL_IN_COMPONENT,
9174 FILL_IN_PACKAGE,
9175 FILL_IN_SOURCE_BOUNDS,
9176 FILL_IN_SELECTOR,
9177 FILL_IN_CLIP_DATA
9178 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009179 @Retention(RetentionPolicy.SOURCE)
9180 public @interface FillInFlags {}
9181
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009182 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009183 * Use with {@link #fillIn} to allow the current action value to be
9184 * overwritten, even if it is already set.
9185 */
9186 public static final int FILL_IN_ACTION = 1<<0;
9187
9188 /**
9189 * Use with {@link #fillIn} to allow the current data or type value
9190 * overwritten, even if it is already set.
9191 */
9192 public static final int FILL_IN_DATA = 1<<1;
9193
9194 /**
9195 * Use with {@link #fillIn} to allow the current categories to be
9196 * overwritten, even if they are already set.
9197 */
9198 public static final int FILL_IN_CATEGORIES = 1<<2;
9199
9200 /**
9201 * Use with {@link #fillIn} to allow the current component value to be
9202 * overwritten, even if it is already set.
9203 */
9204 public static final int FILL_IN_COMPONENT = 1<<3;
9205
9206 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009207 * Use with {@link #fillIn} to allow the current package value to be
9208 * overwritten, even if it is already set.
9209 */
9210 public static final int FILL_IN_PACKAGE = 1<<4;
9211
9212 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009213 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009214 * overwritten, even if it is already set.
9215 */
9216 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9217
9218 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009219 * Use with {@link #fillIn} to allow the current selector to be
9220 * overwritten, even if it is already set.
9221 */
9222 public static final int FILL_IN_SELECTOR = 1<<6;
9223
9224 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009225 * Use with {@link #fillIn} to allow the current ClipData to be
9226 * overwritten, even if it is already set.
9227 */
9228 public static final int FILL_IN_CLIP_DATA = 1<<7;
9229
9230 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009231 * Copy the contents of <var>other</var> in to this object, but only
9232 * where fields are not defined by this object. For purposes of a field
9233 * being defined, the following pieces of data in the Intent are
9234 * considered to be separate fields:
9235 *
9236 * <ul>
9237 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009238 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009239 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9240 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009241 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009242 * <li> component, as set by {@link #setComponent(ComponentName)} or
9243 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009244 * <li> source bounds, as set by {@link #setSourceBounds}.
9245 * <li> selector, as set by {@link #setSelector(Intent)}.
9246 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009247 * <li> each top-level name in the associated extras.
9248 * </ul>
9249 *
9250 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009251 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009252 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9253 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9254 * the restriction where the corresponding field will not be replaced if
9255 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009256 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009257 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9258 * is explicitly specified. The selector will only be copied if
9259 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009260 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009261 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9262 * and Intent B with {action="gotit", data-type="some/thing",
9263 * categories="one","two"}.
9264 *
9265 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9266 * containing: {action="gotit", data-type="some/thing",
9267 * categories="bar"}.
9268 *
9269 * @param other Another Intent whose values are to be used to fill in
9270 * the current one.
9271 * @param flags Options to control which fields can be filled in.
9272 *
9273 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009274 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009275 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009276 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009277 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009278 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009279 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009280 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009281 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009282 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009283 if (other.mAction != null
9284 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009285 mAction = other.mAction;
9286 changes |= FILL_IN_ACTION;
9287 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009288 if ((other.mData != null || other.mType != null)
9289 && ((mData == null && mType == null)
9290 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009291 mData = other.mData;
9292 mType = other.mType;
9293 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009294 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009295 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009296 if (other.mCategories != null
9297 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009298 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009299 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009300 }
9301 changes |= FILL_IN_CATEGORIES;
9302 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009303 if (other.mPackage != null
9304 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009305 // Only do this if mSelector is not set.
9306 if (mSelector == null) {
9307 mPackage = other.mPackage;
9308 changes |= FILL_IN_PACKAGE;
9309 }
9310 }
9311 // Selector is special: it can only be set if explicitly allowed,
9312 // for the same reason as the component name.
9313 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9314 if (mPackage == null) {
9315 mSelector = new Intent(other.mSelector);
9316 mPackage = null;
9317 changes |= FILL_IN_SELECTOR;
9318 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009319 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009320 if (other.mClipData != null
9321 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9322 mClipData = other.mClipData;
9323 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009324 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009325 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009326 // Component is special: it can -only- be set if explicitly allowed,
9327 // since otherwise the sender could force the intent somewhere the
9328 // originator didn't intend.
9329 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009330 mComponent = other.mComponent;
9331 changes |= FILL_IN_COMPONENT;
9332 }
9333 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009334 if (other.mSourceBounds != null
9335 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9336 mSourceBounds = new Rect(other.mSourceBounds);
9337 changes |= FILL_IN_SOURCE_BOUNDS;
9338 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009339 if (mExtras == null) {
9340 if (other.mExtras != null) {
9341 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009342 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009343 }
9344 } else if (other.mExtras != null) {
9345 try {
9346 Bundle newb = new Bundle(other.mExtras);
9347 newb.putAll(mExtras);
9348 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009349 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009350 } catch (RuntimeException e) {
9351 // Modifying the extras can cause us to unparcel the contents
9352 // of the bundle, and if we do this in the system process that
9353 // may fail. We really should handle this (i.e., the Bundle
9354 // impl shouldn't be on top of a plain map), but for now just
9355 // ignore it and keep the original contents. :(
9356 Log.w("Intent", "Failure filling in extras", e);
9357 }
9358 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009359 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9360 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9361 mContentUserHint = other.mContentUserHint;
9362 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009363 return changes;
9364 }
9365
9366 /**
9367 * Wrapper class holding an Intent and implementing comparisons on it for
9368 * the purpose of filtering. The class implements its
9369 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9370 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9371 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9372 * on the wrapped Intent.
9373 */
9374 public static final class FilterComparison {
9375 private final Intent mIntent;
9376 private final int mHashCode;
9377
9378 public FilterComparison(Intent intent) {
9379 mIntent = intent;
9380 mHashCode = intent.filterHashCode();
9381 }
9382
9383 /**
9384 * Return the Intent that this FilterComparison represents.
9385 * @return Returns the Intent held by the FilterComparison. Do
9386 * not modify!
9387 */
9388 public Intent getIntent() {
9389 return mIntent;
9390 }
9391
9392 @Override
9393 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009394 if (obj instanceof FilterComparison) {
9395 Intent other = ((FilterComparison)obj).mIntent;
9396 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009397 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009398 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009399 }
9400
9401 @Override
9402 public int hashCode() {
9403 return mHashCode;
9404 }
9405 }
9406
9407 /**
9408 * Determine if two intents are the same for the purposes of intent
9409 * resolution (filtering). That is, if their action, data, type,
9410 * class, and categories are the same. This does <em>not</em> compare
9411 * any extra data included in the intents.
9412 *
9413 * @param other The other Intent to compare against.
9414 *
9415 * @return Returns true if action, data, type, class, and categories
9416 * are the same.
9417 */
9418 public boolean filterEquals(Intent other) {
9419 if (other == null) {
9420 return false;
9421 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009422 if (!Objects.equals(this.mAction, other.mAction)) return false;
9423 if (!Objects.equals(this.mData, other.mData)) return false;
9424 if (!Objects.equals(this.mType, other.mType)) return false;
9425 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9426 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9427 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009428
9429 return true;
9430 }
9431
9432 /**
9433 * Generate hash code that matches semantics of filterEquals().
9434 *
9435 * @return Returns the hash value of the action, data, type, class, and
9436 * categories.
9437 *
9438 * @see #filterEquals
9439 */
9440 public int filterHashCode() {
9441 int code = 0;
9442 if (mAction != null) {
9443 code += mAction.hashCode();
9444 }
9445 if (mData != null) {
9446 code += mData.hashCode();
9447 }
9448 if (mType != null) {
9449 code += mType.hashCode();
9450 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009451 if (mPackage != null) {
9452 code += mPackage.hashCode();
9453 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009454 if (mComponent != null) {
9455 code += mComponent.hashCode();
9456 }
9457 if (mCategories != null) {
9458 code += mCategories.hashCode();
9459 }
9460 return code;
9461 }
9462
9463 @Override
9464 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009465 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009466
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009467 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009468 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009469 b.append(" }");
9470
9471 return b.toString();
9472 }
9473
9474 /** @hide */
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009475 public String toInsecureString() {
9476 StringBuilder b = new StringBuilder(128);
9477
9478 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009479 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009480 b.append(" }");
9481
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009482 return b.toString();
9483 }
Romain Guy4969af72009-06-17 10:53:19 -07009484
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009485 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009486 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009487 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009488
9489 b.append("Intent { ");
9490 toShortString(b, false, true, true, true);
9491 b.append(" }");
9492
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009493 return b.toString();
9494 }
9495
9496 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009497 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9498 StringBuilder b = new StringBuilder(128);
9499 toShortString(b, secure, comp, extras, clip);
9500 return b.toString();
9501 }
9502
9503 /** @hide */
9504 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9505 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009506 boolean first = true;
9507 if (mAction != null) {
9508 b.append("act=").append(mAction);
9509 first = false;
9510 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009511 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009512 if (!first) {
9513 b.append(' ');
9514 }
9515 first = false;
9516 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009517 for (int i=0; i<mCategories.size(); i++) {
9518 if (i > 0) b.append(',');
9519 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009520 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009521 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009522 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009523 if (mData != null) {
9524 if (!first) {
9525 b.append(' ');
9526 }
9527 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009528 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009529 if (secure) {
9530 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009531 } else {
9532 b.append(mData);
9533 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009534 }
9535 if (mType != null) {
9536 if (!first) {
9537 b.append(' ');
9538 }
9539 first = false;
9540 b.append("typ=").append(mType);
9541 }
9542 if (mFlags != 0) {
9543 if (!first) {
9544 b.append(' ');
9545 }
9546 first = false;
9547 b.append("flg=0x").append(Integer.toHexString(mFlags));
9548 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009549 if (mPackage != null) {
9550 if (!first) {
9551 b.append(' ');
9552 }
9553 first = false;
9554 b.append("pkg=").append(mPackage);
9555 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009556 if (comp && mComponent != null) {
9557 if (!first) {
9558 b.append(' ');
9559 }
9560 first = false;
9561 b.append("cmp=").append(mComponent.flattenToShortString());
9562 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009563 if (mSourceBounds != null) {
9564 if (!first) {
9565 b.append(' ');
9566 }
9567 first = false;
9568 b.append("bnds=").append(mSourceBounds.toShortString());
9569 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009570 if (mClipData != null) {
9571 if (!first) {
9572 b.append(' ');
9573 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009574 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009575 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009576 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009577 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009578 if (mClipData.getDescription() != null) {
9579 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9580 } else {
9581 first = true;
9582 }
9583 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009584 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009585 first = false;
9586 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009587 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009588 if (extras && mExtras != null) {
9589 if (!first) {
9590 b.append(' ');
9591 }
9592 first = false;
9593 b.append("(has extras)");
9594 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009595 if (mContentUserHint != UserHandle.USER_CURRENT) {
9596 if (!first) {
9597 b.append(' ');
9598 }
9599 first = false;
9600 b.append("u=").append(mContentUserHint);
9601 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009602 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009603 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009604 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009605 b.append("}");
9606 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009607 }
9608
Yi Jin129fc6c2017-09-28 15:48:38 -07009609 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009610 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9611 // Same input parameters that toString() gives to toShortString().
9612 writeToProto(proto, fieldId, true, true, true, false);
9613 }
9614
9615 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009616 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9617 boolean extras, boolean clip) {
9618 long token = proto.start(fieldId);
9619 if (mAction != null) {
9620 proto.write(IntentProto.ACTION, mAction);
9621 }
9622 if (mCategories != null) {
9623 for (String category : mCategories) {
9624 proto.write(IntentProto.CATEGORIES, category);
9625 }
9626 }
9627 if (mData != null) {
9628 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9629 }
9630 if (mType != null) {
9631 proto.write(IntentProto.TYPE, mType);
9632 }
9633 if (mFlags != 0) {
9634 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9635 }
9636 if (mPackage != null) {
9637 proto.write(IntentProto.PACKAGE, mPackage);
9638 }
9639 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009640 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009641 }
9642 if (mSourceBounds != null) {
9643 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9644 }
9645 if (mClipData != null) {
9646 StringBuilder b = new StringBuilder();
9647 if (clip) {
9648 mClipData.toShortString(b);
9649 } else {
9650 mClipData.toShortStringShortItems(b, false);
9651 }
9652 proto.write(IntentProto.CLIP_DATA, b.toString());
9653 }
9654 if (extras && mExtras != null) {
9655 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9656 }
9657 if (mContentUserHint != 0) {
9658 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9659 }
9660 if (mSelector != null) {
9661 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9662 }
9663 proto.end(token);
9664 }
9665
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009666 /**
9667 * Call {@link #toUri} with 0 flags.
9668 * @deprecated Use {@link #toUri} instead.
9669 */
9670 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009671 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009672 return toUri(0);
9673 }
9674
9675 /**
9676 * Convert this Intent into a String holding a URI representation of it.
9677 * The returned URI string has been properly URI encoded, so it can be
9678 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9679 * Intent's data as the base URI, with an additional fragment describing
9680 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009681 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009682 * <p>You can convert the returned string back to an Intent with
9683 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009684 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009685 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009686 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009687 * @return Returns a URI encoding URI string describing the entire contents
9688 * of the Intent.
9689 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009690 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009691 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009692 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9693 if (mPackage == null) {
9694 throw new IllegalArgumentException(
9695 "Intent must include an explicit package name to build an android-app: "
9696 + this);
9697 }
9698 uri.append("android-app://");
9699 uri.append(mPackage);
9700 String scheme = null;
9701 if (mData != null) {
9702 scheme = mData.getScheme();
9703 if (scheme != null) {
9704 uri.append('/');
9705 uri.append(scheme);
9706 String authority = mData.getEncodedAuthority();
9707 if (authority != null) {
9708 uri.append('/');
9709 uri.append(authority);
9710 String path = mData.getEncodedPath();
9711 if (path != null) {
9712 uri.append(path);
9713 }
9714 String queryParams = mData.getEncodedQuery();
9715 if (queryParams != null) {
9716 uri.append('?');
9717 uri.append(queryParams);
9718 }
9719 String fragment = mData.getEncodedFragment();
9720 if (fragment != null) {
9721 uri.append('#');
9722 uri.append(fragment);
9723 }
9724 }
9725 }
9726 }
9727 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9728 mPackage, flags);
9729 return uri.toString();
9730 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009731 String scheme = null;
9732 if (mData != null) {
9733 String data = mData.toString();
9734 if ((flags&URI_INTENT_SCHEME) != 0) {
9735 final int N = data.length();
9736 for (int i=0; i<N; i++) {
9737 char c = data.charAt(i);
9738 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009739 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009740 continue;
9741 }
9742 if (c == ':' && i > 0) {
9743 // Valid scheme.
9744 scheme = data.substring(0, i);
9745 uri.append("intent:");
9746 data = data.substring(i+1);
9747 break;
9748 }
Tom Taylord4a47292009-12-21 13:59:18 -08009749
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009750 // No scheme.
9751 break;
9752 }
9753 }
9754 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009755
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009756 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9757 uri.append("intent:");
9758 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009759
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009760 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009761
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009762 return uri.toString();
9763 }
9764
9765 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9766 String defPackage, int flags) {
9767 StringBuilder frag = new StringBuilder(128);
9768
9769 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009770 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009771 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009772 // Note that for now we are not going to try to handle the
9773 // data part; not clear how to represent this as a URI, and
9774 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009775 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9776 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009777 }
9778
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009779 if (frag.length() > 0) {
9780 uri.append("#Intent;");
9781 uri.append(frag);
9782 uri.append("end");
9783 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009784 }
9785
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009786 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9787 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009788 if (scheme != null) {
9789 uri.append("scheme=").append(scheme).append(';');
9790 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009791 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009792 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009793 }
9794 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009795 for (int i=0; i<mCategories.size(); i++) {
9796 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009797 }
9798 }
9799 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009800 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009801 }
9802 if (mFlags != 0) {
9803 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9804 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009805 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009806 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9807 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009808 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009809 uri.append("component=").append(Uri.encode(
9810 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009811 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009812 if (mSourceBounds != null) {
9813 uri.append("sourceBounds=")
9814 .append(Uri.encode(mSourceBounds.flattenToString()))
9815 .append(';');
9816 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009817 if (mExtras != null) {
9818 for (String key : mExtras.keySet()) {
9819 final Object value = mExtras.get(key);
9820 char entryType =
9821 value instanceof String ? 'S' :
9822 value instanceof Boolean ? 'B' :
9823 value instanceof Byte ? 'b' :
9824 value instanceof Character ? 'c' :
9825 value instanceof Double ? 'd' :
9826 value instanceof Float ? 'f' :
9827 value instanceof Integer ? 'i' :
9828 value instanceof Long ? 'l' :
9829 value instanceof Short ? 's' :
9830 '\0';
9831
9832 if (entryType != '\0') {
9833 uri.append(entryType);
9834 uri.append('.');
9835 uri.append(Uri.encode(key));
9836 uri.append('=');
9837 uri.append(Uri.encode(value.toString()));
9838 uri.append(';');
9839 }
9840 }
9841 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009842 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009843
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009844 public int describeContents() {
9845 return (mExtras != null) ? mExtras.describeContents() : 0;
9846 }
9847
9848 public void writeToParcel(Parcel out, int flags) {
9849 out.writeString(mAction);
9850 Uri.writeToParcel(out, mData);
9851 out.writeString(mType);
9852 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009853 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009854 ComponentName.writeToParcel(mComponent, out);
9855
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009856 if (mSourceBounds != null) {
9857 out.writeInt(1);
9858 mSourceBounds.writeToParcel(out, flags);
9859 } else {
9860 out.writeInt(0);
9861 }
9862
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009863 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009864 final int N = mCategories.size();
9865 out.writeInt(N);
9866 for (int i=0; i<N; i++) {
9867 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009868 }
9869 } else {
9870 out.writeInt(0);
9871 }
9872
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009873 if (mSelector != null) {
9874 out.writeInt(1);
9875 mSelector.writeToParcel(out, flags);
9876 } else {
9877 out.writeInt(0);
9878 }
9879
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009880 if (mClipData != null) {
9881 out.writeInt(1);
9882 mClipData.writeToParcel(out, flags);
9883 } else {
9884 out.writeInt(0);
9885 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009886 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009887 out.writeBundle(mExtras);
9888 }
9889
9890 public static final Parcelable.Creator<Intent> CREATOR
9891 = new Parcelable.Creator<Intent>() {
9892 public Intent createFromParcel(Parcel in) {
9893 return new Intent(in);
9894 }
9895 public Intent[] newArray(int size) {
9896 return new Intent[size];
9897 }
9898 };
9899
Dianne Hackborneb034652009-09-07 00:49:58 -07009900 /** @hide */
9901 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009902 readFromParcel(in);
9903 }
9904
9905 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009906 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009907 mData = Uri.CREATOR.createFromParcel(in);
9908 mType = in.readString();
9909 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009910 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009911 mComponent = ComponentName.readFromParcel(in);
9912
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009913 if (in.readInt() != 0) {
9914 mSourceBounds = Rect.CREATOR.createFromParcel(in);
9915 }
9916
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009917 int N = in.readInt();
9918 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009919 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009920 int i;
9921 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009922 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009923 }
9924 } else {
9925 mCategories = null;
9926 }
9927
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009928 if (in.readInt() != 0) {
9929 mSelector = new Intent(in);
9930 }
9931
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009932 if (in.readInt() != 0) {
9933 mClipData = new ClipData(in);
9934 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009935 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009936 mExtras = in.readBundle();
9937 }
9938
9939 /**
9940 * Parses the "intent" element (and its children) from XML and instantiates
9941 * an Intent object. The given XML parser should be located at the tag
9942 * where parsing should start (often named "intent"), from which the
9943 * basic action, data, type, and package and class name will be
9944 * retrieved. The function will then parse in to any child elements,
9945 * looking for <category android:name="xxx"> tags to add categories and
9946 * <extra android:name="xxx" android:value="yyy"> to attach extra data
9947 * to the intent.
9948 *
9949 * @param resources The Resources to use when inflating resources.
9950 * @param parser The XML parser pointing at an "intent" tag.
9951 * @param attrs The AttributeSet interface for retrieving extended
9952 * attribute data at the current <var>parser</var> location.
9953 * @return An Intent object matching the XML data.
9954 * @throws XmlPullParserException If there was an XML parsing error.
9955 * @throws IOException If there was an I/O error.
9956 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009957 public static @NonNull Intent parseIntent(@NonNull Resources resources,
9958 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009959 throws XmlPullParserException, IOException {
9960 Intent intent = new Intent();
9961
9962 TypedArray sa = resources.obtainAttributes(attrs,
9963 com.android.internal.R.styleable.Intent);
9964
9965 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
9966
9967 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
9968 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
9969 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
9970
9971 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
9972 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
9973 if (packageName != null && className != null) {
9974 intent.setComponent(new ComponentName(packageName, className));
9975 }
9976
9977 sa.recycle();
9978
9979 int outerDepth = parser.getDepth();
9980 int type;
9981 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
9982 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
9983 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
9984 continue;
9985 }
9986
9987 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -07009988 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009989 sa = resources.obtainAttributes(attrs,
9990 com.android.internal.R.styleable.IntentCategory);
9991 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
9992 sa.recycle();
9993
9994 if (cat != null) {
9995 intent.addCategory(cat);
9996 }
9997 XmlUtils.skipCurrentTag(parser);
9998
Craig Mautner21d24a22014-04-23 11:45:37 -07009999 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010000 if (intent.mExtras == null) {
10001 intent.mExtras = new Bundle();
10002 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010003 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010004 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010005
10006 } else {
10007 XmlUtils.skipCurrentTag(parser);
10008 }
10009 }
10010
10011 return intent;
10012 }
Nick Pellyccae4122012-01-09 14:12:58 -080010013
Craig Mautner21d24a22014-04-23 11:45:37 -070010014 /** @hide */
10015 public void saveToXml(XmlSerializer out) throws IOException {
10016 if (mAction != null) {
10017 out.attribute(null, ATTR_ACTION, mAction);
10018 }
10019 if (mData != null) {
10020 out.attribute(null, ATTR_DATA, mData.toString());
10021 }
10022 if (mType != null) {
10023 out.attribute(null, ATTR_TYPE, mType);
10024 }
10025 if (mComponent != null) {
10026 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10027 }
10028 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10029
10030 if (mCategories != null) {
10031 out.startTag(null, TAG_CATEGORIES);
10032 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10033 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10034 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010035 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010036 }
10037 }
10038
10039 /** @hide */
10040 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10041 XmlPullParserException {
10042 Intent intent = new Intent();
10043 final int outerDepth = in.getDepth();
10044
10045 int attrCount = in.getAttributeCount();
10046 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10047 final String attrName = in.getAttributeName(attrNdx);
10048 final String attrValue = in.getAttributeValue(attrNdx);
10049 if (ATTR_ACTION.equals(attrName)) {
10050 intent.setAction(attrValue);
10051 } else if (ATTR_DATA.equals(attrName)) {
10052 intent.setData(Uri.parse(attrValue));
10053 } else if (ATTR_TYPE.equals(attrName)) {
10054 intent.setType(attrValue);
10055 } else if (ATTR_COMPONENT.equals(attrName)) {
10056 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10057 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010058 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010059 } else {
10060 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10061 }
10062 }
10063
10064 int event;
10065 String name;
10066 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10067 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10068 if (event == XmlPullParser.START_TAG) {
10069 name = in.getName();
10070 if (TAG_CATEGORIES.equals(name)) {
10071 attrCount = in.getAttributeCount();
10072 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10073 intent.addCategory(in.getAttributeValue(attrNdx));
10074 }
10075 } else {
10076 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10077 XmlUtils.skipCurrentTag(in);
10078 }
10079 }
10080 }
10081
10082 return intent;
10083 }
10084
Nick Pellyccae4122012-01-09 14:12:58 -080010085 /**
10086 * Normalize a MIME data type.
10087 *
10088 * <p>A normalized MIME type has white-space trimmed,
10089 * content-type parameters removed, and is lower-case.
10090 * This aligns the type with Android best practices for
10091 * intent filtering.
10092 *
10093 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10094 * "text/x-vCard" becomes "text/x-vcard".
10095 *
10096 * <p>All MIME types received from outside Android (such as user input,
10097 * or external sources like Bluetooth, NFC, or the Internet) should
10098 * be normalized before they are used to create an Intent.
10099 *
10100 * @param type MIME data type to normalize
10101 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010102 * @see #setType
10103 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010104 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010105 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010106 if (type == null) {
10107 return null;
10108 }
10109
Elliott Hughescb64d432013-08-02 10:00:44 -070010110 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010111
10112 final int semicolonIndex = type.indexOf(';');
10113 if (semicolonIndex != -1) {
10114 type = type.substring(0, semicolonIndex);
10115 }
10116 return type;
10117 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010118
10119 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010120 * Prepare this {@link Intent} to leave an app process.
10121 *
10122 * @hide
10123 */
Jeff Sharkey344744b2016-01-28 19:03:30 -070010124 public void prepareToLeaveProcess(Context context) {
10125 final boolean leavingPackage = (mComponent == null)
10126 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10127 prepareToLeaveProcess(leavingPackage);
10128 }
10129
10130 /**
10131 * Prepare this {@link Intent} to leave an app process.
10132 *
10133 * @hide
10134 */
10135 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010136 setAllowFds(false);
10137
10138 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010139 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010140 }
10141 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010142 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010143 }
10144
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010145 if (mExtras != null && !mExtras.isParcelled()) {
10146 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10147 if (intent instanceof Intent) {
10148 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10149 }
10150 }
10151
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010152 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10153 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010154 switch (mAction) {
10155 case ACTION_MEDIA_REMOVED:
10156 case ACTION_MEDIA_UNMOUNTED:
10157 case ACTION_MEDIA_CHECKING:
10158 case ACTION_MEDIA_NOFS:
10159 case ACTION_MEDIA_MOUNTED:
10160 case ACTION_MEDIA_SHARED:
10161 case ACTION_MEDIA_UNSHARED:
10162 case ACTION_MEDIA_BAD_REMOVAL:
10163 case ACTION_MEDIA_UNMOUNTABLE:
10164 case ACTION_MEDIA_EJECT:
10165 case ACTION_MEDIA_SCANNER_STARTED:
10166 case ACTION_MEDIA_SCANNER_FINISHED:
10167 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010168 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10169 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010170 // Ignore legacy actions
10171 break;
10172 default:
10173 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010174 }
10175 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010176
10177 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10178 && leavingPackage) {
10179 switch (mAction) {
10180 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010181 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010182 // Ignore actions that don't need to grant
10183 break;
10184 default:
10185 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10186 }
10187 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010188 }
10189
10190 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010191 * @hide
10192 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010193 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010194 // We just entered destination process, so we should be able to read all
10195 // parcelables inside.
10196 setDefusable(true);
10197
10198 if (mSelector != null) {
10199 mSelector.prepareToEnterProcess();
10200 }
10201 if (mClipData != null) {
10202 mClipData.prepareToEnterProcess();
10203 }
10204
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010205 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010206 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10207 fixUris(mContentUserHint);
10208 mContentUserHint = UserHandle.USER_CURRENT;
10209 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010210 }
10211 }
10212
Patrick Baumann577d4022018-01-31 16:55:10 +000010213 /** @hide */
10214 public boolean hasWebURI() {
10215 if (getData() == null) {
10216 return false;
10217 }
10218 final String scheme = getScheme();
10219 if (TextUtils.isEmpty(scheme)) {
10220 return false;
10221 }
10222 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10223 }
10224
10225 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010226 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010227 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010228 && hasWebURI();
10229 }
10230
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010231 /**
10232 * @hide
10233 */
10234 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010235 Uri data = getData();
10236 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010237 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010238 }
10239 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010240 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010241 }
10242 String action = getAction();
10243 if (ACTION_SEND.equals(action)) {
10244 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10245 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010246 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010247 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010248 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010249 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10250 if (streams != null) {
10251 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10252 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010253 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010254 }
10255 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10256 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010257 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10258 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10259 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10260 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10261 if (output != null) {
10262 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10263 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010264 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010265 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010266
10267 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010268 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010269 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10270 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010271 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010272 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010273 * @hide
10274 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010275 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010276 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010277 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010278
10279 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010280 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010281
10282 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010283 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010284 // Inspect contained intents to see if we need to migrate extras. We
10285 // don't promote ClipData to the parent, since ChooserActivity will
10286 // already start the picked item as the caller, and we can't combine
10287 // the flags in a safe way.
10288
10289 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010290 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010291 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10292 if (intent != null) {
10293 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010294 }
10295 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010296 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010297 try {
10298 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10299 if (intents != null) {
10300 for (int i = 0; i < intents.length; i++) {
10301 final Intent intent = (Intent) intents[i];
10302 if (intent != null) {
10303 migrated |= intent.migrateExtraStreamToClipData();
10304 }
10305 }
10306 }
10307 } catch (ClassCastException e) {
10308 }
10309 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010310
10311 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010312 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010313 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10314 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10315 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10316 if (stream != null || text != null || htmlText != null) {
10317 final ClipData clipData = new ClipData(
10318 null, new String[] { getType() },
10319 new ClipData.Item(text, htmlText, null, stream));
10320 setClipData(clipData);
10321 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010322 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010323 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010324 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010325 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010326
10327 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010328 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010329 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10330 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10331 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10332 int num = -1;
10333 if (streams != null) {
10334 num = streams.size();
10335 }
10336 if (texts != null) {
10337 if (num >= 0 && num != texts.size()) {
10338 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010339 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010340 }
10341 num = texts.size();
10342 }
10343 if (htmlTexts != null) {
10344 if (num >= 0 && num != htmlTexts.size()) {
10345 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010346 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010347 }
10348 num = htmlTexts.size();
10349 }
10350 if (num > 0) {
10351 final ClipData clipData = new ClipData(
10352 null, new String[] { getType() },
10353 makeClipItem(streams, texts, htmlTexts, 0));
10354
10355 for (int i = 1; i < num; i++) {
10356 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10357 }
10358
10359 setClipData(clipData);
10360 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010361 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010362 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010363 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010364 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010365 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10366 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10367 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10368 final Uri output;
10369 try {
10370 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10371 } catch (ClassCastException e) {
10372 return false;
10373 }
10374 if (output != null) {
10375 setClipData(ClipData.newRawUri("", output));
10376 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10377 return true;
10378 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010379 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010380
10381 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010382 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010383
Michael Wright19859762017-09-18 20:57:58 +010010384 /**
10385 * Convert the dock state to a human readable format.
10386 * @hide
10387 */
10388 public static String dockStateToString(int dock) {
10389 switch (dock) {
10390 case EXTRA_DOCK_STATE_HE_DESK:
10391 return "EXTRA_DOCK_STATE_HE_DESK";
10392 case EXTRA_DOCK_STATE_LE_DESK:
10393 return "EXTRA_DOCK_STATE_LE_DESK";
10394 case EXTRA_DOCK_STATE_CAR:
10395 return "EXTRA_DOCK_STATE_CAR";
10396 case EXTRA_DOCK_STATE_DESK:
10397 return "EXTRA_DOCK_STATE_DESK";
10398 case EXTRA_DOCK_STATE_UNDOCKED:
10399 return "EXTRA_DOCK_STATE_UNDOCKED";
10400 default:
10401 return Integer.toString(dock);
10402 }
10403 }
10404
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010405 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10406 ArrayList<String> htmlTexts, int which) {
10407 Uri uri = streams != null ? streams.get(which) : null;
10408 CharSequence text = texts != null ? texts.get(which) : null;
10409 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10410 return new ClipData.Item(text, htmlText, null, uri);
10411 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010412
10413 /** @hide */
10414 public boolean isDocument() {
10415 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10416 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010417}