blob: ea1a2fe758af2ad82e2a7df3a582e14b1f4f10a5 [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;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010029import android.annotation.UnsupportedAppUsage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070030import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050031import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060032import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.content.pm.PackageManager;
34import android.content.pm.ResolveInfo;
35import android.content.res.Resources;
36import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080037import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070038import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060039import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070040import android.os.Bundle;
41import android.os.IBinder;
42import android.os.Parcel;
43import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070044import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000045import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050046import android.os.ResultReceiver;
47import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070048import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010049import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070050import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070051import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070052import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050053import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070054import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000055import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050056import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070057import android.util.AttributeSet;
58import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070059import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070060
Dianne Hackborn2269d1572010-02-24 19:54:22 -080061import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070062
Jason Monk2f68e8a2016-02-23 17:57:28 -050063import org.xmlpull.v1.XmlPullParser;
64import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070065import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070066
67import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080068import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070069import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070070import java.lang.annotation.Retention;
71import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072import java.net.URISyntaxException;
73import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080074import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070075import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080076import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070077import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070078import java.util.Set;
79
80/**
81 * An intent is an abstract description of an operation to be performed. It
82 * can be used with {@link Context#startActivity(Intent) startActivity} to
83 * launch an {@link android.app.Activity},
84 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
85 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
86 * and {@link android.content.Context#startService} or
87 * {@link android.content.Context#bindService} to communicate with a
88 * background {@link android.app.Service}.
89 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070090 * <p>An Intent provides a facility for performing late runtime binding between the code in
91 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070092 * can be thought of as the glue between activities. It is basically a passive data structure
93 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070094 *
95 * <div class="special reference">
96 * <h3>Developer Guides</h3>
97 * <p>For information about how to create and resolve intents, read the
98 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
99 * developer guide.</p>
100 * </div>
101 *
102 * <a name="IntentStructure"></a>
103 * <h3>Intent Structure</h3>
104 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700105 *
106 * <ul>
107 * <li> <p><b>action</b> -- The general action to be performed, such as
108 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
109 * etc.</p>
110 * </li>
111 * <li> <p><b>data</b> -- The data to operate on, such as a person record
112 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
113 * </li>
114 * </ul>
115 *
116 *
117 * <p>Some examples of action/data pairs are:</p>
118 *
119 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700120 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700121 * information about the person whose identifier is "1".</p>
122 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700123 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700124 * the phone dialer with the person filled in.</p>
125 * </li>
126 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
127 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700128 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700129 * a particular URI.</p>
130 * </li>
131 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
132 * the phone dialer with the given number filled in.</p>
133 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700134 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700135 * information about the person whose identifier is "1".</p>
136 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700137 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700138 * a list of people, which the user can browse through. This example is a
139 * typical top-level entry into the Contacts application, showing you the
140 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700141 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700142 * being used to start an activity to display that person.</p>
143 * </li>
144 * </ul>
145 *
146 * <p>In addition to these primary attributes, there are a number of secondary
147 * attributes that you can also include with an intent:</p>
148 *
149 * <ul>
150 * <li> <p><b>category</b> -- Gives additional information about the action
151 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
152 * appear in the Launcher as a top-level application, while
153 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
154 * of alternative actions the user can perform on a piece of data.</p>
155 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
156 * intent data. Normally the type is inferred from the data itself.
157 * By setting this attribute, you disable that evaluation and force
158 * an explicit type.</p>
159 * <li> <p><b>component</b> -- Specifies an explicit name of a component
160 * class to use for the intent. Normally this is determined by looking
161 * at the other information in the intent (the action, data/type, and
162 * categories) and matching that with a component that can handle it.
163 * If this attribute is set then none of the evaluation is performed,
164 * and this component is used exactly as is. By specifying this attribute,
165 * all of the other Intent attributes become optional.</p>
166 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
167 * This can be used to provide extended information to the component.
168 * For example, if we have a action to send an e-mail message, we could
169 * also include extra pieces of data here to supply a subject, body,
170 * etc.</p>
171 * </ul>
172 *
173 * <p>Here are some examples of other operations you can specify as intents
174 * using these additional parameters:</p>
175 *
176 * <ul>
177 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
178 * Launch the home screen.</p>
179 * </li>
180 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
181 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
182 * vnd.android.cursor.item/phone}</i></b>
183 * -- Display the list of people's phone numbers, allowing the user to
184 * browse through them and pick one and return it to the parent activity.</p>
185 * </li>
186 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
187 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
188 * -- Display all pickers for data that can be opened with
189 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
190 * allowing the user to pick one of them and then some data inside of it
191 * and returning the resulting URI to the caller. This can be used,
192 * for example, in an e-mail application to allow the user to pick some
193 * data to include as an attachment.</p>
194 * </li>
195 * </ul>
196 *
197 * <p>There are a variety of standard Intent action and category constants
198 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700199 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700200 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700201 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700202 *
203 * <p>Put together, the set of actions, data types, categories, and extra data
204 * defines a language for the system allowing for the expression of phrases
205 * such as "call john smith's cell". As applications are added to the system,
206 * they can extend this language by adding new actions, types, and categories, or
207 * they can modify the behavior of existing phrases by supplying their own
208 * activities that handle them.</p>
209 *
210 * <a name="IntentResolution"></a>
211 * <h3>Intent Resolution</h3>
212 *
213 * <p>There are two primary forms of intents you will use.
214 *
215 * <ul>
216 * <li> <p><b>Explicit Intents</b> have specified a component (via
217 * {@link #setComponent} or {@link #setClass}), which provides the exact
218 * class to be run. Often these will not include any other information,
219 * simply being a way for an application to launch various internal
220 * activities it has as the user interacts with the application.
221 *
222 * <li> <p><b>Implicit Intents</b> have not specified a component;
223 * instead, they must include enough information for the system to
224 * determine which of the available components is best to run for that
225 * intent.
226 * </ul>
227 *
228 * <p>When using implicit intents, given such an arbitrary intent we need to
229 * know what to do with it. This is handled by the process of <em>Intent
230 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
231 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
232 * more activities/receivers) that can handle it.</p>
233 *
234 * <p>The intent resolution mechanism basically revolves around matching an
235 * Intent against all of the &lt;intent-filter&gt; descriptions in the
236 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
237 * objects explicitly registered with {@link Context#registerReceiver}.) More
238 * details on this can be found in the documentation on the {@link
239 * IntentFilter} class.</p>
240 *
241 * <p>There are three pieces of information in the Intent that are used for
242 * resolution: the action, type, and category. Using this information, a query
243 * is done on the {@link PackageManager} for a component that can handle the
244 * intent. The appropriate component is determined based on the intent
245 * information supplied in the <code>AndroidManifest.xml</code> file as
246 * follows:</p>
247 *
248 * <ul>
249 * <li> <p>The <b>action</b>, if given, must be listed by the component as
250 * one it handles.</p>
251 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
252 * already supplied in the Intent. Like the action, if a type is
253 * included in the intent (either explicitly or implicitly in its
254 * data), then this must be listed by the component as one it handles.</p>
255 * <li> For data that is not a <code>content:</code> URI and where no explicit
256 * type is included in the Intent, instead the <b>scheme</b> of the
257 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
258 * considered. Again like the action, if we are matching a scheme it
259 * must be listed by the component as one it can handle.
260 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
261 * by the activity as categories it handles. That is, if you include
262 * the categories {@link #CATEGORY_LAUNCHER} and
263 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
264 * with an intent that lists <em>both</em> of those categories.
265 * Activities will very often need to support the
266 * {@link #CATEGORY_DEFAULT} so that they can be found by
267 * {@link Context#startActivity Context.startActivity()}.</p>
268 * </ul>
269 *
270 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700271 * allows a user to browse through a list of notes data and view details about
272 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700273 * name with one specific to your own package.</p>
274 *
275 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
276 * package="<i>com.android.notepad</i>"&gt;
277 * &lt;application android:icon="@drawable/app_notes"
278 * android:label="@string/app_name"&gt;
279 *
280 * &lt;provider class=".NotePadProvider"
281 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
282 *
283 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
284 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700285 * &lt;action android:name="android.intent.action.MAIN" /&gt;
286 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700287 * &lt;/intent-filter&gt;
288 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700289 * &lt;action android:name="android.intent.action.VIEW" /&gt;
290 * &lt;action android:name="android.intent.action.EDIT" /&gt;
291 * &lt;action android:name="android.intent.action.PICK" /&gt;
292 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
293 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700294 * &lt;/intent-filter&gt;
295 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700296 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
297 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
298 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700299 * &lt;/intent-filter&gt;
300 * &lt;/activity&gt;
301 *
302 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
303 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700304 * &lt;action android:name="android.intent.action.VIEW" /&gt;
305 * &lt;action android:name="android.intent.action.EDIT" /&gt;
306 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
307 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700308 * &lt;/intent-filter&gt;
309 *
310 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700311 * &lt;action android:name="android.intent.action.INSERT" /&gt;
312 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700314 * &lt;/intent-filter&gt;
315 *
316 * &lt;/activity&gt;
317 *
318 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
319 * android:theme="@android:style/Theme.Dialog"&gt;
320 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700321 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
322 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
323 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
324 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
325 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700326 * &lt;/intent-filter&gt;
327 * &lt;/activity&gt;
328 *
329 * &lt;/application&gt;
330 * &lt;/manifest&gt;</pre>
331 *
332 * <p>The first activity,
333 * <code>com.android.notepad.NotesList</code>, serves as our main
334 * entry into the app. It can do three things as described by its three intent
335 * templates:
336 * <ol>
337 * <li><pre>
338 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700339 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
340 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700341 * &lt;/intent-filter&gt;</pre>
342 * <p>This provides a top-level entry into the NotePad application: the standard
343 * MAIN action is a main entry point (not requiring any other information in
344 * the Intent), and the LAUNCHER category says that this entry point should be
345 * listed in the application launcher.</p>
346 * <li><pre>
347 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700348 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
349 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
350 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
351 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700352 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700353 * &lt;/intent-filter&gt;</pre>
354 * <p>This declares the things that the activity can do on a directory of
355 * notes. The type being supported is given with the &lt;type&gt; tag, where
356 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
357 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
358 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
359 * The activity allows the user to view or edit the directory of data (via
360 * the VIEW and EDIT actions), or to pick a particular note and return it
361 * to the caller (via the PICK action). Note also the DEFAULT category
362 * supplied here: this is <em>required</em> for the
363 * {@link Context#startActivity Context.startActivity} method to resolve your
364 * activity when its component name is not explicitly specified.</p>
365 * <li><pre>
366 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700367 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
368 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
369 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700370 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700371 * <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 -0700372 * the user without needing to know where it came from. The data type
373 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
374 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
375 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
376 * The GET_CONTENT action is similar to the PICK action, where the activity
377 * will return to its caller a piece of data selected by the user. Here,
378 * however, the caller specifies the type of data they desire instead of
379 * the type of data the user will be picking from.</p>
380 * </ol>
381 *
382 * <p>Given these capabilities, the following intents will resolve to the
383 * NotesList activity:</p>
384 *
385 * <ul>
386 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
387 * activities that can be used as top-level entry points into an
388 * application.</p>
389 * <li> <p><b>{ action=android.app.action.MAIN,
390 * category=android.app.category.LAUNCHER }</b> is the actual intent
391 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700392 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700393 * data=content://com.google.provider.NotePad/notes }</b>
394 * displays a list of all the notes under
395 * "content://com.google.provider.NotePad/notes", which
396 * the user can browse through and see the details on.</p>
397 * <li> <p><b>{ action=android.app.action.PICK
398 * data=content://com.google.provider.NotePad/notes }</b>
399 * provides a list of the notes under
400 * "content://com.google.provider.NotePad/notes", from which
401 * the user can pick a note whose data URL is returned back to the caller.</p>
402 * <li> <p><b>{ action=android.app.action.GET_CONTENT
403 * type=vnd.android.cursor.item/vnd.google.note }</b>
404 * is similar to the pick action, but allows the caller to specify the
405 * kind of data they want back so that the system can find the appropriate
406 * activity to pick something of that data type.</p>
407 * </ul>
408 *
409 * <p>The second activity,
410 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
411 * note entry and allows them to edit it. It can do two things as described
412 * by its two intent templates:
413 * <ol>
414 * <li><pre>
415 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700416 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
417 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
418 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
419 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700420 * &lt;/intent-filter&gt;</pre>
421 * <p>The first, primary, purpose of this activity is to let the user interact
422 * with a single note, as decribed by the MIME type
423 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
424 * either VIEW a note or allow the user to EDIT it. Again we support the
425 * DEFAULT category to allow the activity to be launched without explicitly
426 * specifying its component.</p>
427 * <li><pre>
428 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700429 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
430 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
431 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700432 * &lt;/intent-filter&gt;</pre>
433 * <p>The secondary use of this activity is to insert a new note entry into
434 * an existing directory of notes. This is used when the user creates a new
435 * note: the INSERT action is executed on the directory of notes, causing
436 * this activity to run and have the user create the new note data which
437 * it then adds to the content provider.</p>
438 * </ol>
439 *
440 * <p>Given these capabilities, the following intents will resolve to the
441 * NoteEditor activity:</p>
442 *
443 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700444 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700445 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
446 * shows the user the content of note <var>{ID}</var>.</p>
447 * <li> <p><b>{ action=android.app.action.EDIT
448 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
449 * allows the user to edit the content of note <var>{ID}</var>.</p>
450 * <li> <p><b>{ action=android.app.action.INSERT
451 * data=content://com.google.provider.NotePad/notes }</b>
452 * creates a new, empty note in the notes list at
453 * "content://com.google.provider.NotePad/notes"
454 * and allows the user to edit it. If they keep their changes, the URI
455 * of the newly created note is returned to the caller.</p>
456 * </ul>
457 *
458 * <p>The last activity,
459 * <code>com.android.notepad.TitleEditor</code>, allows the user to
460 * edit the title of a note. This could be implemented as a class that the
461 * application directly invokes (by explicitly setting its component in
462 * the Intent), but here we show a way you can publish alternative
463 * operations on existing data:</p>
464 *
465 * <pre>
466 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700467 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
468 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
469 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
470 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
471 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700472 * &lt;/intent-filter&gt;</pre>
473 *
474 * <p>In the single intent template here, we
475 * have created our own private action called
476 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
477 * edit the title of a note. It must be invoked on a specific note
478 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
479 * view and edit actions, but here displays and edits the title contained
480 * in the note data.
481 *
482 * <p>In addition to supporting the default category as usual, our title editor
483 * also supports two other standard categories: ALTERNATIVE and
484 * SELECTED_ALTERNATIVE. Implementing
485 * these categories allows others to find the special action it provides
486 * without directly knowing about it, through the
487 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
488 * more often to build dynamic menu items with
489 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
490 * template here was also supply an explicit name for the template
491 * (via <code>android:label="@string/resolve_title"</code>) to better control
492 * what the user sees when presented with this activity as an alternative
493 * action to the data they are viewing.
494 *
495 * <p>Given these capabilities, the following intent will resolve to the
496 * TitleEditor activity:</p>
497 *
498 * <ul>
499 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
500 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
501 * displays and allows the user to edit the title associated
502 * with note <var>{ID}</var>.</p>
503 * </ul>
504 *
505 * <h3>Standard Activity Actions</h3>
506 *
507 * <p>These are the current standard actions that Intent defines for launching
508 * activities (usually through {@link Context#startActivity}. The most
509 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
510 * {@link #ACTION_EDIT}.
511 *
512 * <ul>
513 * <li> {@link #ACTION_MAIN}
514 * <li> {@link #ACTION_VIEW}
515 * <li> {@link #ACTION_ATTACH_DATA}
516 * <li> {@link #ACTION_EDIT}
517 * <li> {@link #ACTION_PICK}
518 * <li> {@link #ACTION_CHOOSER}
519 * <li> {@link #ACTION_GET_CONTENT}
520 * <li> {@link #ACTION_DIAL}
521 * <li> {@link #ACTION_CALL}
522 * <li> {@link #ACTION_SEND}
523 * <li> {@link #ACTION_SENDTO}
524 * <li> {@link #ACTION_ANSWER}
525 * <li> {@link #ACTION_INSERT}
526 * <li> {@link #ACTION_DELETE}
527 * <li> {@link #ACTION_RUN}
528 * <li> {@link #ACTION_SYNC}
529 * <li> {@link #ACTION_PICK_ACTIVITY}
530 * <li> {@link #ACTION_SEARCH}
531 * <li> {@link #ACTION_WEB_SEARCH}
532 * <li> {@link #ACTION_FACTORY_TEST}
533 * </ul>
534 *
535 * <h3>Standard Broadcast Actions</h3>
536 *
537 * <p>These are the current standard actions that Intent defines for receiving
538 * broadcasts (usually through {@link Context#registerReceiver} or a
539 * &lt;receiver&gt; tag in a manifest).
540 *
541 * <ul>
542 * <li> {@link #ACTION_TIME_TICK}
543 * <li> {@link #ACTION_TIME_CHANGED}
544 * <li> {@link #ACTION_TIMEZONE_CHANGED}
545 * <li> {@link #ACTION_BOOT_COMPLETED}
546 * <li> {@link #ACTION_PACKAGE_ADDED}
547 * <li> {@link #ACTION_PACKAGE_CHANGED}
548 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 * <li> {@link #ACTION_PACKAGE_RESTARTED}
550 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000551 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
552 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700553 * <li> {@link #ACTION_UID_REMOVED}
554 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700555 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700556 * <li> {@link #ACTION_POWER_DISCONNECTED}
557 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700558 * </ul>
559 *
560 * <h3>Standard Categories</h3>
561 *
562 * <p>These are the current standard categories that can be used to further
563 * clarify an Intent via {@link #addCategory}.
564 *
565 * <ul>
566 * <li> {@link #CATEGORY_DEFAULT}
567 * <li> {@link #CATEGORY_BROWSABLE}
568 * <li> {@link #CATEGORY_TAB}
569 * <li> {@link #CATEGORY_ALTERNATIVE}
570 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
571 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800572 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700573 * <li> {@link #CATEGORY_HOME}
574 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400576 * <li> {@link #CATEGORY_CAR_DOCK}
577 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500578 * <li> {@link #CATEGORY_LE_DESK_DOCK}
579 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200580 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700581 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800582 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700583 * </ul>
584 *
585 * <h3>Standard Extra Data</h3>
586 *
587 * <p>These are the current standard fields that can be used as extra data via
588 * {@link #putExtra}.
589 *
590 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800591 * <li> {@link #EXTRA_ALARM_COUNT}
592 * <li> {@link #EXTRA_BCC}
593 * <li> {@link #EXTRA_CC}
594 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
595 * <li> {@link #EXTRA_DATA_REMOVED}
596 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500597 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
598 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800599 * <li> {@link #EXTRA_DOCK_STATE_CAR}
600 * <li> {@link #EXTRA_DOCK_STATE_DESK}
601 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
602 * <li> {@link #EXTRA_DONT_KILL_APP}
603 * <li> {@link #EXTRA_EMAIL}
604 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700605 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800606 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700607 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700609 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
611 * <li> {@link #EXTRA_REPLACING}
612 * <li> {@link #EXTRA_SHORTCUT_ICON}
613 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
614 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700615 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800616 * <li> {@link #EXTRA_SHORTCUT_NAME}
617 * <li> {@link #EXTRA_SUBJECT}
618 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700619 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800620 * <li> {@link #EXTRA_TITLE}
621 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 * </ul>
623 *
624 * <h3>Flags</h3>
625 *
626 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800627 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
628 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700629 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800630public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700631 private static final String ATTR_ACTION = "action";
632 private static final String TAG_CATEGORIES = "categories";
633 private static final String ATTR_CATEGORY = "category";
634 private static final String TAG_EXTRA = "extra";
635 private static final String ATTR_TYPE = "type";
636 private static final String ATTR_COMPONENT = "component";
637 private static final String ATTR_DATA = "data";
638 private static final String ATTR_FLAGS = "flags";
639
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700640 // ---------------------------------------------------------------------
641 // ---------------------------------------------------------------------
642 // Standard intent activity actions (see action variable).
643
644 /**
645 * Activity Action: Start as a main entry point, does not expect to
646 * receive data.
647 * <p>Input: nothing
648 * <p>Output: nothing
649 */
650 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
651 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800652
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700653 /**
654 * Activity Action: Display the data to the user. This is the most common
655 * action performed on data -- it is the generic action you can use on
656 * a piece of data to get the most reasonable thing to occur. For example,
657 * when used on a contacts entry it will view the entry; when used on a
658 * mailto: URI it will bring up a compose window filled with the information
659 * supplied by the URI; when used with a tel: URI it will invoke the
660 * dialer.
661 * <p>Input: {@link #getData} is URI from which to retrieve data.
662 * <p>Output: nothing.
663 */
664 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
665 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800666
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700667 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700668 * Extra that can be included on activity intents coming from the storage UI
669 * when it launches sub-activities to manage various types of storage. For example,
670 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
671 * the images on the device, and in that case also include this extra to tell the
672 * app it is coming from the storage UI so should help the user manage storage of
673 * this type.
674 */
675 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
676
677 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700678 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
679 * performed on a piece of data.
680 */
681 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800682
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700683 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900684 * Activity Action: Quick view the data. Launches a quick viewer for
685 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900686 * <p>Activities handling this intent action should handle the vast majority of
687 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700688 * <p>Quick viewers must render the quick view image locally, and must not send
689 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900690 * <p>Input: {@link #getData} is a mandatory content URI of the item to
691 * preview. {@link #getClipData} contains an optional list of content URIs
692 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
693 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700694 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
695 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700696 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900697 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700698 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700699 */
700 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
701 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
702
703 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700704 * Used to indicate that some piece of data should be attached to some other
705 * place. For example, image data could be attached to a contact. It is up
706 * to the recipient to decide where the data should be attached; the intent
707 * does not specify the ultimate destination.
708 * <p>Input: {@link #getData} is URI of data to be attached.
709 * <p>Output: nothing.
710 */
711 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
712 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800713
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700714 /**
715 * Activity Action: Provide explicit editable access to the given data.
716 * <p>Input: {@link #getData} is URI of data to be edited.
717 * <p>Output: nothing.
718 */
719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
720 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800721
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700722 /**
723 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
724 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
725 * The extras can contain type specific data to pass through to the editing/creating
726 * activity.
727 * <p>Output: The URI of the item that was picked. This must be a content:
728 * URI so that any receiver can access it.
729 */
730 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
731 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800732
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700733 /**
734 * Activity Action: Pick an item from the data, returning what was selected.
735 * <p>Input: {@link #getData} is URI containing a directory of data
736 * (vnd.android.cursor.dir/*) from which to pick an item.
737 * <p>Output: The URI of the item that was picked.
738 */
739 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
740 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800741
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700742 /**
743 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800745 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
746 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700747 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
748 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800749 * (value: ShortcutIconResource).</p>
750 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800751 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700752 * @see #EXTRA_SHORTCUT_INTENT
753 * @see #EXTRA_SHORTCUT_NAME
754 * @see #EXTRA_SHORTCUT_ICON
755 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
756 * @see android.content.Intent.ShortcutIconResource
757 */
758 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
759 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
760
761 /**
762 * The name of the extra used to define the Intent of a shortcut.
763 *
764 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800765 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700766 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
769 /**
770 * The name of the extra used to define the name of a shortcut.
771 *
772 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800773 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700774 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
777 /**
778 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
779 *
780 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800781 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700782 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800783 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
785 /**
786 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
787 *
788 * @see #ACTION_CREATE_SHORTCUT
789 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800790 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700791 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800792 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700793 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
794 "android.intent.extra.shortcut.ICON_RESOURCE";
795
796 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500797 * An activity that provides a user interface for adjusting application preferences.
798 * Optional but recommended settings for all applications which have settings.
799 */
800 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
801 public static final String ACTION_APPLICATION_PREFERENCES
802 = "android.intent.action.APPLICATION_PREFERENCES";
803
804 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700805 * Activity Action: Launch an activity showing the app information.
806 * For applications which install other applications (such as app stores), it is recommended
807 * to handle this action for providing the app information to the user.
808 *
809 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
810 * to be displayed.
811 * <p>Output: Nothing.
812 */
813 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
814 public static final String ACTION_SHOW_APP_INFO
815 = "android.intent.action.SHOW_APP_INFO";
816
817 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800818 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700819 *
820 * @see Intent#ACTION_CREATE_SHORTCUT
821 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800822 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
823 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700824 */
825 public static class ShortcutIconResource implements Parcelable {
826 /**
827 * The package name of the application containing the icon.
828 */
829 public String packageName;
830
831 /**
832 * The resource name of the icon, including package, name and type.
833 */
834 public String resourceName;
835
836 /**
837 * Creates a new ShortcutIconResource for the specified context and resource
838 * identifier.
839 *
840 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700841 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700842 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700843 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700844 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700845 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700846 ShortcutIconResource icon = new ShortcutIconResource();
847 icon.packageName = context.getPackageName();
848 icon.resourceName = context.getResources().getResourceName(resourceId);
849 return icon;
850 }
851
852 /**
853 * Used to read a ShortcutIconResource from a Parcel.
854 */
855 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
856 new Parcelable.Creator<ShortcutIconResource>() {
857
858 public ShortcutIconResource createFromParcel(Parcel source) {
859 ShortcutIconResource icon = new ShortcutIconResource();
860 icon.packageName = source.readString();
861 icon.resourceName = source.readString();
862 return icon;
863 }
864
865 public ShortcutIconResource[] newArray(int size) {
866 return new ShortcutIconResource[size];
867 }
868 };
869
870 /**
871 * No special parcel contents.
872 */
873 public int describeContents() {
874 return 0;
875 }
876
877 public void writeToParcel(Parcel dest, int flags) {
878 dest.writeString(packageName);
879 dest.writeString(resourceName);
880 }
881
882 @Override
883 public String toString() {
884 return resourceName;
885 }
886 }
887
888 /**
889 * Activity Action: Display an activity chooser, allowing the user to pick
890 * what they want to before proceeding. This can be used as an alternative
891 * to the standard activity picker that is displayed by the system when
892 * you try to start an activity with multiple possible matches, with these
893 * differences in behavior:
894 * <ul>
895 * <li>You can specify the title that will appear in the activity chooser.
896 * <li>The user does not have the option to make one of the matching
897 * activities a preferred activity, and all possible activities will
898 * always be shown even if one of them is currently marked as the
899 * preferred activity.
900 * </ul>
901 * <p>
902 * This action should be used when the user will naturally expect to
903 * select an activity in order to proceed. An example if when not to use
904 * it is when the user clicks on a "mailto:" link. They would naturally
905 * expect to go directly to their mail app, so startActivity() should be
906 * called directly: it will
907 * either launch the current preferred app, or put up a dialog allowing the
908 * user to pick an app to use and optionally marking that as preferred.
909 * <p>
910 * In contrast, if the user is selecting a menu item to send a picture
911 * they are viewing to someone else, there are many different things they
912 * may want to do at this point: send it through e-mail, upload it to a
913 * web service, etc. In this case the CHOOSER action should be used, to
914 * always present to the user a list of the things they can do, with a
915 * nice title given by the caller such as "Send this photo with:".
916 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700917 * If you need to grant URI permissions through a chooser, you must specify
918 * the permissions to be granted on the ACTION_CHOOSER Intent
919 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
920 * {@link #setClipData} to specify the URIs to be granted as well as
921 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
922 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
923 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700924 * As a convenience, an Intent of this form can be created with the
925 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700926 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700928 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
929 * and can optionally have a {@link #EXTRA_TITLE} field containing the
930 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700931 * <p>
932 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700933 */
934 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
935 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
936
937 /**
938 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
939 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700940 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
941 * target intent, also optionally supplying a title. If the target
942 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
943 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
944 * set in the returned chooser intent, with its ClipData set appropriately:
945 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500946 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700947 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700948 * @param target The Intent that the user will be selecting an activity
949 * to perform.
950 * @param title Optional title that will be displayed in the chooser.
951 * @return Return a new Intent object that you can hand to
952 * {@link Context#startActivity(Intent) Context.startActivity()} and
953 * related methods.
954 */
955 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700956 return createChooser(target, title, null);
957 }
958
959 /**
960 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
961 *
962 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
963 * target intent, also optionally supplying a title. If the target
964 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
965 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
966 * set in the returned chooser intent, with its ClipData set appropriately:
967 * either a direct reflection of {@link #getClipData()} if that is non-null,
968 * or a new ClipData built from {@link #getData()}.</p>
969 *
970 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
971 * when the user makes a choice. This can be useful if the calling application wants
972 * to remember the last chosen target and surface it as a more prominent or one-touch
973 * affordance elsewhere in the UI for next time.</p>
974 *
975 * @param target The Intent that the user will be selecting an activity
976 * to perform.
977 * @param title Optional title that will be displayed in the chooser.
978 * @param sender Optional IntentSender to be called when a choice is made.
979 * @return Return a new Intent object that you can hand to
980 * {@link Context#startActivity(Intent) Context.startActivity()} and
981 * related methods.
982 */
983 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700984 Intent intent = new Intent(ACTION_CHOOSER);
985 intent.putExtra(EXTRA_INTENT, target);
986 if (title != null) {
987 intent.putExtra(EXTRA_TITLE, title);
988 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700989
Adam Powell0b3c1122014-10-09 12:50:14 -0700990 if (sender != null) {
991 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
992 }
993
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700994 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700995 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
996 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
997 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700998 if (permFlags != 0) {
999 ClipData targetClipData = target.getClipData();
1000 if (targetClipData == null && target.getData() != null) {
1001 ClipData.Item item = new ClipData.Item(target.getData());
1002 String[] mimeTypes;
1003 if (target.getType() != null) {
1004 mimeTypes = new String[] { target.getType() };
1005 } else {
1006 mimeTypes = new String[] { };
1007 }
1008 targetClipData = new ClipData(null, mimeTypes, item);
1009 }
1010 if (targetClipData != null) {
1011 intent.setClipData(targetClipData);
1012 intent.addFlags(permFlags);
1013 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001014 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001015
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001016 return intent;
1017 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001018
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001019 /**
1020 * Activity Action: Allow the user to select a particular kind of data and
1021 * return it. This is different than {@link #ACTION_PICK} in that here we
1022 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001023 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001024 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001025 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001026 * etc.
1027 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001028 * 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 -07001029 * of data, such as a person contact, you set the MIME type to the kind of
1030 * data you want and launch it with {@link Context#startActivity(Intent)}.
1031 * The system will then launch the best application to select that kind
1032 * of data for you.
1033 * <p>
1034 * You may also be interested in any of a set of types of content the user
1035 * can pick. For example, an e-mail application that wants to allow the
1036 * user to add an attachment to an e-mail message can use this action to
1037 * bring up a list of all of the types of content the user can attach.
1038 * <p>
1039 * In this case, you should wrap the GET_CONTENT intent with a chooser
1040 * (through {@link #createChooser}), which will give the proper interface
1041 * for the user to pick how to send your data and allow you to specify
1042 * a prompt indicating what they are doing. You will usually specify a
1043 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1044 * broad range of content types the user can select from.
1045 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001046 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001047 * only pick from data that can be represented as a stream. This is
1048 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1049 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001050 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001051 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001052 * is locally available on the device. For example, if this extra is set
1053 * to true then an image picker should not show any pictures that are available
1054 * from a remote server but not already on the local device (thus requiring
1055 * they be downloaded when opened).
1056 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001057 * If the caller can handle multiple returned items (the user performing
1058 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1059 * to indicate this.
1060 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001061 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1062 * that no URI is supplied in the intent, as there are no constraints on
1063 * where the returned data originally comes from. You may also include the
1064 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001065 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001066 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1067 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001068 * <p>
1069 * Output: The URI of the item that was picked. This must be a content:
1070 * URI so that any receiver can access it.
1071 */
1072 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1073 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1074 /**
1075 * Activity Action: Dial a number as specified by the data. This shows a
1076 * UI with the number being dialed, allowing the user to explicitly
1077 * initiate the call.
1078 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1079 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1080 * number.
1081 * <p>Output: nothing.
1082 */
1083 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1084 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1085 /**
1086 * Activity Action: Perform a call to someone specified by the data.
1087 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1088 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1089 * number.
1090 * <p>Output: nothing.
1091 *
1092 * <p>Note: there will be restrictions on which applications can initiate a
1093 * call; most applications should use the {@link #ACTION_DIAL}.
1094 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1095 * numbers. Applications can <strong>dial</strong> emergency numbers using
1096 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001097 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001098 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001099 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001100 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001101 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001102 */
1103 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1104 public static final String ACTION_CALL = "android.intent.action.CALL";
1105 /**
1106 * Activity Action: Perform a call to an emergency number specified by the
1107 * data.
1108 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1109 * tel: URI of an explicit phone number.
1110 * <p>Output: nothing.
1111 * @hide
1112 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001113 @SystemApi
1114 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001115 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1116 /**
1117 * Activity action: Perform a call to any number (emergency or not)
1118 * specified by the data.
1119 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1120 * tel: URI of an explicit phone number.
1121 * <p>Output: nothing.
1122 * @hide
1123 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001124 @SystemApi
1125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001126 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001127
Santos Cordon15a13782015-03-31 18:32:31 -07001128 /**
fionaxuadfe7002017-02-17 17:20:46 -08001129 * Activity Action: Main entry point for carrier setup apps.
1130 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1131 * carrier service and typically require
1132 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1133 * fulfill their duties.
1134 */
1135 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1136 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1137 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001138 * Activity Action: Send a message to someone specified by the data.
1139 * <p>Input: {@link #getData} is URI describing the target.
1140 * <p>Output: nothing.
1141 */
1142 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1143 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1144 /**
1145 * Activity Action: Deliver some data to someone else. Who the data is
1146 * being delivered to is not specified; it is up to the receiver of this
1147 * action to ask the user where the data should be sent.
1148 * <p>
1149 * When launching a SEND intent, you should usually wrap it in a chooser
1150 * (through {@link #createChooser}), which will give the proper interface
1151 * for the user to pick how to send your data and allow you to specify
1152 * a prompt indicating what they are doing.
1153 * <p>
1154 * Input: {@link #getType} is the MIME type of the data being sent.
1155 * get*Extra can have either a {@link #EXTRA_TEXT}
1156 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1157 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1158 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1159 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001160 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1161 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1162 * your text with HTML formatting.
1163 * <p>
1164 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1165 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1166 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1167 * content: URIs and other advanced features of {@link ClipData}. If
1168 * using this approach, you still must supply the same data through the
1169 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1170 * for compatibility with old applications. If you don't set a ClipData,
1171 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001172 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001173 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1174 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1175 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1176 * be openable only as asset typed files using
1177 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1178 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001179 * Optional standard extras, which may be interpreted by some recipients as
1180 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1181 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1182 * <p>
1183 * Output: nothing.
1184 */
1185 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1186 public static final String ACTION_SEND = "android.intent.action.SEND";
1187 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001188 * Activity Action: Deliver multiple data to someone else.
1189 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001190 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001191 * <p>
1192 * Input: {@link #getType} is the MIME type of the data being sent.
1193 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001194 * #EXTRA_STREAM} field, containing the data to be sent. If using
1195 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1196 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001197 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001198 * Multiple types are supported, and receivers should handle mixed types
1199 * whenever possible. The right way for the receiver to check them is to
1200 * use the content resolver on each URI. The intent sender should try to
1201 * put the most concrete mime type in the intent type, but it can fall
1202 * back to {@literal <type>/*} or {@literal *}/* as needed.
1203 * <p>
1204 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1205 * be image/jpg, but if you are sending image/jpg and image/png, then the
1206 * intent's type should be image/*.
1207 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001208 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1209 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1210 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1211 * content: URIs and other advanced features of {@link ClipData}. If
1212 * using this approach, you still must supply the same data through the
1213 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1214 * for compatibility with old applications. If you don't set a ClipData,
1215 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1216 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001217 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1218 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1219 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1220 * be openable only as asset typed files using
1221 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1222 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001223 * Optional standard extras, which may be interpreted by some recipients as
1224 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1225 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1226 * <p>
1227 * Output: nothing.
1228 */
1229 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1230 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1231 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001232 * Activity Action: Handle an incoming phone call.
1233 * <p>Input: nothing.
1234 * <p>Output: nothing.
1235 */
1236 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1238 /**
1239 * Activity Action: Insert an empty item into the given container.
1240 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1241 * in which to place the data.
1242 * <p>Output: URI of the new data that was created.
1243 */
1244 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1245 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1246 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001247 * Activity Action: Create a new item in the given container, initializing it
1248 * from the current contents of the clipboard.
1249 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1250 * in which to place the data.
1251 * <p>Output: URI of the new data that was created.
1252 */
1253 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1254 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1255 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001256 * Activity Action: Delete the given data from its container.
1257 * <p>Input: {@link #getData} is URI of data to be deleted.
1258 * <p>Output: nothing.
1259 */
1260 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1261 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1262 /**
1263 * Activity Action: Run the data, whatever that means.
1264 * <p>Input: ? (Note: this is currently specific to the test harness.)
1265 * <p>Output: nothing.
1266 */
1267 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1268 public static final String ACTION_RUN = "android.intent.action.RUN";
1269 /**
1270 * Activity Action: Perform a data synchronization.
1271 * <p>Input: ?
1272 * <p>Output: ?
1273 */
1274 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1275 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1276 /**
1277 * Activity Action: Pick an activity given an intent, returning the class
1278 * selected.
1279 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1280 * used with {@link PackageManager#queryIntentActivities} to determine the
1281 * set of activities from which to pick.
1282 * <p>Output: Class name of the activity that was selected.
1283 */
1284 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1285 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1286 /**
1287 * Activity Action: Perform a search.
1288 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1289 * is the text to search for. If empty, simply
1290 * enter your search results Activity with the search UI activated.
1291 * <p>Output: nothing.
1292 */
1293 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1294 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1295 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001296 * Activity Action: Start the platform-defined tutorial
1297 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1298 * is the text to search for. If empty, simply
1299 * enter your search results Activity with the search UI activated.
1300 * <p>Output: nothing.
1301 */
1302 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1303 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001305 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001306 * <p>
1307 * Input: {@link android.app.SearchManager#QUERY
1308 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1309 * a url starts with http or https, the site will be opened. If it is plain
1310 * text, Google search will be applied.
1311 * <p>
1312 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001313 */
1314 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1315 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001316
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001317 /**
Jim Miller07994402012-05-02 14:22:27 -07001318 * Activity Action: Perform assist action.
1319 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001320 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1321 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001322 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1323 * information.
Jim Miller07994402012-05-02 14:22:27 -07001324 * Output: nothing.
1325 */
1326 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1327 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001328
1329 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001330 * Activity Action: Perform voice assist action.
1331 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001332 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1333 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001334 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001335 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001336 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001337 */
Amith Yamasani16452032017-03-03 10:15:57 -08001338 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001339 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1340 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1341
1342 /**
Adam Skory7140a252013-09-11 12:04:58 +01001343 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1344 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001345 */
1346 public static final String EXTRA_ASSIST_PACKAGE
1347 = "android.intent.extra.ASSIST_PACKAGE";
1348
1349 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001350 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1351 * application package at the time the assist was invoked.
1352 */
1353 public static final String EXTRA_ASSIST_UID
1354 = "android.intent.extra.ASSIST_UID";
1355
1356 /**
Adam Skory7140a252013-09-11 12:04:58 +01001357 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1358 * information supplied by the current foreground app at the time of the assist request.
1359 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001360 */
1361 public static final String EXTRA_ASSIST_CONTEXT
1362 = "android.intent.extra.ASSIST_CONTEXT";
1363
Jim Miller07994402012-05-02 14:22:27 -07001364 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001365 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1366 * keyboard as the primary input device for assistance.
1367 */
1368 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1369 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1370
1371 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001372 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1373 * that was used to invoke the assist.
1374 */
1375 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1376 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1377
1378 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001379 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001380 * <p>Input: Nothing.
1381 * <p>Output: nothing.
1382 */
1383 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1384 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1385 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001386 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001387 * <p>Input: Nothing.
1388 * <p>Output: Nothing.
1389 */
1390 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1392
1393 /**
1394 * Activity Action: Show activity for reporting a bug.
1395 * <p>Input: Nothing.
1396 * <p>Output: Nothing.
1397 */
1398 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1399 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1400
1401 /**
1402 * Activity Action: Main entry point for factory tests. Only used when
1403 * the device is booting in factory test node. The implementing package
1404 * must be installed in the system image.
1405 * <p>Input: nothing
1406 * <p>Output: nothing
1407 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001408 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001409 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1410
1411 /**
1412 * Activity Action: The user pressed the "call" button to go to the dialer
1413 * or other appropriate UI for placing a call.
1414 * <p>Input: Nothing.
1415 * <p>Output: Nothing.
1416 */
1417 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1418 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1419
1420 /**
1421 * Activity Action: Start Voice Command.
1422 * <p>Input: Nothing.
1423 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001424 * <p class="note">
1425 * In some cases, a matching Activity may not exist, so ensure you
1426 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001427 */
1428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001430
1431 /**
1432 * Activity Action: Start action associated with long pressing on the
1433 * search key.
1434 * <p>Input: Nothing.
1435 * <p>Output: Nothing.
1436 */
1437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001439
Jacek Surazski86b6c532009-05-13 14:38:28 +02001440 /**
1441 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1442 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001443 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001444 * <p>Input: No data is specified. The bug report is passed in using
1445 * an {@link #EXTRA_BUG_REPORT} field.
1446 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001447 *
1448 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001449 */
1450 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1451 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001452
1453 /**
1454 * Activity Action: Show power usage information to the user.
1455 * <p>Input: Nothing.
1456 * <p>Output: Nothing.
1457 */
1458 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1459 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001460
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001461 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001462 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1463 * to run.
1464 * <p>Input: Nothing.
1465 * <p>Output: Nothing.
1466 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1467 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1468 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001469 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001470 */
1471 @Deprecated
1472 @SystemApi
1473 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1474 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1475
1476 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001477 * Activity Action: Setup wizard to launch after a platform update. This
1478 * activity should have a string meta-data field associated with it,
1479 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1480 * the platform for setup. The activity will be launched only if
1481 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1482 * same value.
1483 * <p>Input: Nothing.
1484 * <p>Output: Nothing.
1485 * @hide
1486 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001487 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001488 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1489 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001490
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001491 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001492 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1493 * <p>Input: Nothing.
1494 * <p>Output: Nothing.
1495 * @hide
1496 */
1497 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1498 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001499 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001500
1501 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001502 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1503 * <p>Input: Nothing.
1504 * <p>Output: Nothing.
1505 * @hide
1506 */
1507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1508 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001509 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001510
1511 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001512 * Activity Action: Show settings for managing network data usage of a
1513 * specific application. Applications should define an activity that offers
1514 * options to control data usage.
1515 */
1516 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1517 public static final String ACTION_MANAGE_NETWORK_USAGE =
1518 "android.intent.action.MANAGE_NETWORK_USAGE";
1519
1520 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001521 * Activity Action: Launch application installer.
1522 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001523 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001524 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1525 * you can also use "package:<package-name>" to install an application for the
1526 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001527 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1528 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1529 * <p>
1530 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1531 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001532 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001533 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001534 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1535 * in order to launch the application installer.
1536 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001537 *
1538 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1539 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1540 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001541 *
1542 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001543 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001544 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001545 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1546 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1547
1548 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001549 * Activity Action: Activity to handle split installation failures.
1550 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1551 * but the split that contains the application isn't installed. When a split is
1552 * installed in this manner, the containing package usually doesn't know this is
1553 * happening. However, if an error occurs during installation, the containing
1554 * package can define a single activity handling this action to deal with such
1555 * failures.
1556 * <p>The activity handling this action must be in the base package.
1557 * <p>
1558 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1559 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1560 */
1561 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1562 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1563
1564 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001565 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001566 * <p class="note">
1567 * This is a protected intent that can only be sent by the system.
1568 * </p>
1569 *
1570 * @hide
1571 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001572 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001573 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001574 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1575 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001576
1577 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001578 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001579 * <p>
1580 * The system will have a persistent connection to this service.
1581 * This is a protected intent that can only be sent by the system.
1582 * </p>
1583 *
1584 * @hide
1585 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001586 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001587 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001588 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1589 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001590
1591 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001592 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001593 *
1594 * <p class="note">
1595 * This is a protected intent that can only be sent by the system.
1596 * </p>
1597 *
1598 * @hide
1599 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001600 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001601 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001602 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1603 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001604
1605 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001606 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1607 * package. Specifies the installer package name; this package will receive the
1608 * {@link #ACTION_APP_ERROR} intent.
1609 */
1610 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1611 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1612
1613 /**
1614 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1615 * package. Specifies that the application being installed should not be
1616 * treated as coming from an unknown source, but as coming from the app
1617 * invoking the Intent. For this to work you must start the installer with
1618 * startActivityForResult().
1619 */
1620 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1621 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1622
1623 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001624 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1625 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001626 * data field originated from.
1627 */
rich cannings706e8ba2012-08-20 13:20:14 -07001628 public static final String EXTRA_ORIGINATING_URI
1629 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001630
1631 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001632 * This extra can be used with any Intent used to launch an activity, supplying information
1633 * about who is launching that activity. This field contains a {@link android.net.Uri}
1634 * object, typically an http: or https: URI of the web site that the referral came from;
1635 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1636 * a native application that it came from.
1637 *
1638 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1639 * instead of directly retrieving the extra. It is also valid for applications to
1640 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1641 * a string, not a Uri; the field here, if supplied, will always take precedence,
1642 * however.</p>
1643 *
1644 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001645 */
1646 public static final String EXTRA_REFERRER
1647 = "android.intent.extra.REFERRER";
1648
1649 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001650 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1651 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1652 * not be created, in particular when Intent extras are supplied through the
1653 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1654 * schemes.
1655 *
1656 * @see #EXTRA_REFERRER
1657 */
1658 public static final String EXTRA_REFERRER_NAME
1659 = "android.intent.extra.REFERRER_NAME";
1660
1661 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001662 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001663 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001664 * Currently only a system app that hosts the provider authority "downloads" or holds the
1665 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001666 * @hide
1667 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001668 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001669 public static final String EXTRA_ORIGINATING_UID
1670 = "android.intent.extra.ORIGINATING_UID";
1671
1672 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001673 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1674 * package. Tells the installer UI to skip the confirmation with the user
1675 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001676 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1677 * will no longer show an interstitial message about updating existing
1678 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001679 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001680 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001681 public static final String EXTRA_ALLOW_REPLACE
1682 = "android.intent.extra.ALLOW_REPLACE";
1683
1684 /**
1685 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1686 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1687 * return to the application the result code of the install/uninstall. The returned result
1688 * code will be {@link android.app.Activity#RESULT_OK} on success or
1689 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1690 */
1691 public static final String EXTRA_RETURN_RESULT
1692 = "android.intent.extra.RETURN_RESULT";
1693
1694 /**
1695 * Package manager install result code. @hide because result codes are not
1696 * yet ready to be exposed.
1697 */
1698 public static final String EXTRA_INSTALL_RESULT
1699 = "android.intent.extra.INSTALL_RESULT";
1700
1701 /**
1702 * Activity Action: Launch application uninstaller.
1703 * <p>
1704 * Input: The data must be a package: URI whose scheme specific part is
1705 * the package name of the current installed package to be uninstalled.
1706 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1707 * <p>
1708 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1709 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001710 * <p>
1711 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1712 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001713 *
1714 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1715 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001716 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001717 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001718 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1719 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1720
1721 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001722 * Specify whether the package should be uninstalled for all users.
1723 * @hide because these should not be part of normal application flow.
1724 */
1725 public static final String EXTRA_UNINSTALL_ALL_USERS
1726 = "android.intent.extra.UNINSTALL_ALL_USERS";
1727
1728 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001729 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1730 * describing the last run version of the platform that was setup.
1731 * @hide
1732 */
1733 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1734
Svet Ganov3695b8a2015-03-24 16:30:25 -07001735 /**
1736 * Activity action: Launch UI to manage the permissions of an app.
1737 * <p>
1738 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1739 * will be managed by the launched UI.
1740 * </p>
1741 * <p>
1742 * Output: Nothing.
1743 * </p>
1744 *
1745 * @see #EXTRA_PACKAGE_NAME
1746 *
1747 * @hide
1748 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001749 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001750 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1751 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1752 "android.intent.action.MANAGE_APP_PERMISSIONS";
1753
1754 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001755 * Activity action: Launch UI to manage permissions.
1756 * <p>
1757 * Input: Nothing.
1758 * </p>
1759 * <p>
1760 * Output: Nothing.
1761 * </p>
1762 *
1763 * @hide
1764 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001765 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001766 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1767 public static final String ACTION_MANAGE_PERMISSIONS =
1768 "android.intent.action.MANAGE_PERMISSIONS";
1769
1770 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001771 * Activity action: Launch UI to review permissions for an app.
1772 * The system uses this intent if permission review for apps not
1773 * supporting the new runtime permissions model is enabled. In
1774 * this mode a permission review is required before any of the
1775 * app components can run.
1776 * <p>
1777 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1778 * permissions will be reviewed (mandatory).
1779 * </p>
1780 * <p>
1781 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1782 * be fired after the permission review (optional).
1783 * </p>
1784 * <p>
1785 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1786 * be invoked after the permission review (optional).
1787 * </p>
1788 * <p>
1789 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1790 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1791 * </p>
1792 * <p>
1793 * Output: Nothing.
1794 * </p>
1795 *
1796 * @see #EXTRA_PACKAGE_NAME
1797 * @see #EXTRA_INTENT
1798 * @see #EXTRA_REMOTE_CALLBACK
1799 * @see #EXTRA_RESULT_NEEDED
1800 *
1801 * @hide
1802 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001803 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805 public static final String ACTION_REVIEW_PERMISSIONS =
1806 "android.intent.action.REVIEW_PERMISSIONS";
1807
1808 /**
1809 * Intent extra: A callback for reporting remote result as a bundle.
1810 * <p>
1811 * Type: IRemoteCallback
1812 * </p>
1813 *
1814 * @hide
1815 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001816 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001817 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1818
1819 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001820 * Intent extra: An app package name.
1821 * <p>
1822 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001823 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001824 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001825 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001826 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1827
1828 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001829 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1830 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1831 *
1832 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1833 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1834 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001835 *
1836 * @see #ACTION_MY_PACKAGE_SUSPENDED
1837 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1838 * @see PackageManager#isPackageSuspended()
1839 * @see PackageManager#getSuspendedPackageAppExtras()
1840 */
1841 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1842
1843 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001844 * Intent extra: An app split name.
1845 * <p>
1846 * Type: String
1847 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001848 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001849 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1850
1851 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001852 * Intent extra: A {@link ComponentName} value.
1853 * <p>
1854 * Type: String
1855 * </p>
1856 */
1857 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1858
1859 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001860 * Intent extra: An extra for specifying whether a result is needed.
1861 * <p>
1862 * Type: boolean
1863 * </p>
1864 *
1865 * @hide
1866 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001867 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001868 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1869
1870 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001871 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1872 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1873 *
1874 * @see PackageManager#isPackageSuspended()
1875 * @see #ACTION_PACKAGES_SUSPENDED
1876 *
1877 * @hide
1878 */
1879 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1880
1881 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001882 * Activity action: Launch UI to manage which apps have a given permission.
1883 * <p>
1884 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1885 * to which will be managed by the launched UI.
1886 * </p>
1887 * <p>
1888 * Output: Nothing.
1889 * </p>
1890 *
1891 * @see #EXTRA_PERMISSION_NAME
1892 *
1893 * @hide
1894 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001895 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001896 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1897 public static final String ACTION_MANAGE_PERMISSION_APPS =
1898 "android.intent.action.MANAGE_PERMISSION_APPS";
1899
1900 /**
1901 * Intent extra: The name of a permission.
1902 * <p>
1903 * Type: String
1904 * </p>
1905 *
1906 * @hide
1907 */
1908 @SystemApi
1909 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1910
Joel Galenson13096ea2018-09-27 11:18:44 -07001911 /**
1912 * Activity action: Launch UI to review app uses of permissions.
1913 * <p>
1914 * Input: Nothing
1915 * </p>
1916 * <p>
1917 * Output: Nothing.
1918 * </p>
1919 *
1920 * @hide
1921 */
1922 @SystemApi
1923 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1924 public static final String ACTION_REVIEW_PERMISSION_USAGE =
1925 "android.intent.action.REVIEW_PERMISSION_USAGE";
1926
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001927 // ---------------------------------------------------------------------
1928 // ---------------------------------------------------------------------
1929 // Standard intent broadcast actions (see action variable).
1930
1931 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001932 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1933 * <p>
1934 * For historical reasons, the name of this broadcast action refers to the power
1935 * state of the screen but it is actually sent in response to changes in the
1936 * overall interactive state of the device.
1937 * </p><p>
1938 * This broadcast is sent when the device becomes non-interactive which may have
1939 * nothing to do with the screen turning off. To determine the
1940 * actual state of the screen, use {@link android.view.Display#getState}.
1941 * </p><p>
1942 * See {@link android.os.PowerManager#isInteractive} for details.
1943 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001944 * You <em>cannot</em> receive this through components declared in
1945 * manifests, only by explicitly registering for it with
1946 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1947 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001948 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001949 * <p class="note">This is a protected intent that can only be sent
1950 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001951 */
1952 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1953 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001954
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001955 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001956 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1957 * <p>
1958 * For historical reasons, the name of this broadcast action refers to the power
1959 * state of the screen but it is actually sent in response to changes in the
1960 * overall interactive state of the device.
1961 * </p><p>
1962 * This broadcast is sent when the device becomes interactive which may have
1963 * nothing to do with the screen turning on. To determine the
1964 * actual state of the screen, use {@link android.view.Display#getState}.
1965 * </p><p>
1966 * See {@link android.os.PowerManager#isInteractive} for details.
1967 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001968 * You <em>cannot</em> receive this through components declared in
1969 * manifests, only by explicitly registering for it with
1970 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1971 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001972 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001973 * <p class="note">This is a protected intent that can only be sent
1974 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 */
1976 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1977 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07001978
1979 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07001980 * Broadcast Action: Sent after the system stops dreaming.
1981 *
1982 * <p class="note">This is a protected intent that can only be sent by the system.
1983 * It is only sent to registered receivers.</p>
1984 */
1985 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1986 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
1987
1988 /**
1989 * Broadcast Action: Sent after the system starts dreaming.
1990 *
1991 * <p class="note">This is a protected intent that can only be sent by the system.
1992 * It is only sent to registered receivers.</p>
1993 */
1994 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1995 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
1996
1997 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07001998 * 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 -07001999 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002000 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002001 * <p class="note">This is a protected intent that can only be sent
2002 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002003 */
2004 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002005 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002006
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002007 /**
2008 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002009 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002010 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002011 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2012 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002013 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002014 * <p class="note">This is a protected intent that can only be sent
2015 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002016 */
2017 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2018 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2019 /**
2020 * Broadcast Action: The time was set.
2021 */
2022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2023 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2024 /**
2025 * Broadcast Action: The date has changed.
2026 */
2027 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2028 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2029 /**
2030 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2031 * <ul>
2032 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2033 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002034 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002035 * <p class="note">This is a protected intent that can only be sent
2036 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002037 */
2038 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2039 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2040 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002041 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2042 * DNS entries should be tossed.
2043 * @hide
2044 */
2045 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2046 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2047 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002048 * Alarm Changed Action: This is broadcast when the AlarmClock
2049 * application's alarm is set or unset. It is used by the
2050 * AlarmClock application and the StatusBar service.
2051 * @hide
2052 */
2053 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002054 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002055 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002056
2057 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002058 * Broadcast Action: This is broadcast once, after the user has finished
2059 * booting, but while still in the "locked" state. It can be used to perform
2060 * application-specific initialization, such as installing alarms. You must
2061 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2062 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002063 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002064 * This broadcast is sent immediately at boot by all devices (regardless of
2065 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2066 * higher. Upon receipt of this broadcast, the user is still locked and only
2067 * device-protected storage can be accessed safely. If you want to access
2068 * credential-protected storage, you need to wait for the user to be
2069 * unlocked (typically by entering their lock pattern or PIN for the first
2070 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2071 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2072 * <p>
2073 * To receive this broadcast, your receiver component must be marked as
2074 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002075 * <p class="note">
2076 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002077 *
2078 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002079 */
2080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2081 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2082
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002083 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002084 * Broadcast Action: This is broadcast once, after the user has finished
2085 * booting. It can be used to perform application-specific initialization,
2086 * such as installing alarms. You must hold the
2087 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2088 * order to receive this broadcast.
2089 * <p>
2090 * This broadcast is sent at boot by all devices (both with and without
2091 * direct boot support). Upon receipt of this broadcast, the user is
2092 * unlocked and both device-protected and credential-protected storage can
2093 * accessed safely.
2094 * <p>
2095 * If you need to run while the user is still locked (before they've entered
2096 * their lock pattern or PIN for the first time), you can listen for the
2097 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2098 * <p class="note">
2099 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002100 */
2101 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002102 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002103 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002104
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002105 /**
2106 * Broadcast Action: This is broadcast when a user action should request a
2107 * temporary system dialog to dismiss. Some examples of temporary system
2108 * dialogs are the notification window-shade and the recent tasks dialog.
2109 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002111 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2112 /**
2113 * Broadcast Action: Trigger the download and eventual installation
2114 * of a package.
2115 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002116 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002117 * <p class="note">This is a protected intent that can only be sent
2118 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002119 *
2120 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002121 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002122 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002123 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2124 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2125 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002126 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002127 * device. The data contains the name of the package. Note that the
2128 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002129 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002130 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002131 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2132 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2134 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002135 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002136 * <p class="note">This is a protected intent that can only be sent
2137 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002138 */
2139 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2140 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2141 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002142 * Broadcast Action: A new version of an application package has been
2143 * installed, replacing an existing version that was previously installed.
2144 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002145 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002146 * <ul>
2147 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2148 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2155 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002156 * Broadcast Action: A new version of your application has been installed
2157 * over an existing one. This is only sent to the application that was
2158 * replaced. It does not contain any additional data; to receive it, just
2159 * use an intent filter for this action.
2160 *
2161 * <p class="note">This is a protected intent that can only be sent
2162 * by the system.
2163 */
2164 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2165 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2166 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002167 * Broadcast Action: An existing application package has been removed from
2168 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002169 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002170 * <ul>
2171 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2172 * to the package.
2173 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2174 * application -- data and code -- is being removed.
2175 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2176 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2177 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002178 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002179 * <p class="note">This is a protected intent that can only be sent
2180 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002181 */
2182 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2183 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2184 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002185 * Broadcast Action: An existing application package has been completely
2186 * removed from the device. The data contains the name of the package.
2187 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2188 * {@link #EXTRA_DATA_REMOVED} is true and
2189 * {@link #EXTRA_REPLACING} is false of that broadcast.
2190 *
2191 * <ul>
2192 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2193 * to the package.
2194 * </ul>
2195 *
2196 * <p class="note">This is a protected intent that can only be sent
2197 * by the system.
2198 */
2199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2200 public static final String ACTION_PACKAGE_FULLY_REMOVED
2201 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2202 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002203 * Broadcast Action: An existing application package has been changed (for
2204 * example, a component has been enabled or disabled). The data contains
2205 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002206 * <ul>
2207 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002208 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002209 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002210 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2211 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002212 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002213 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002214 * <p class="note">This is a protected intent that can only be sent
2215 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002216 */
2217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2218 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2219 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002220 * @hide
2221 * Broadcast Action: Ask system services if there is any reason to
2222 * restart the given package. The data contains the name of the
2223 * package.
2224 * <ul>
2225 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2226 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2227 * </ul>
2228 *
2229 * <p class="note">This is a protected intent that can only be sent
2230 * by the system.
2231 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002232 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002233 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2234 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2235 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002236 * Broadcast Action: The user has restarted a package, and all of its
2237 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002238 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002239 * be removed. Note that the restarted package does <em>not</em>
2240 * receive this broadcast.
2241 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002242 * <ul>
2243 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2244 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002245 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002246 * <p class="note">This is a protected intent that can only be sent
2247 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002248 */
2249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2250 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2251 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002252 * Broadcast Action: The user has cleared the data of a package. This should
2253 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002254 * its persistent data is erased and this broadcast sent.
2255 * Note that the cleared package does <em>not</em>
2256 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002257 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002258 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2259 * package whose data was cleared is an uninstalled instant app, then the UID
2260 * will be -1. The platform keeps some meta-data associated with instant apps
2261 * after they are uninstalled.
2262 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2263 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002264 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002265 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002266 * <p class="note">This is a protected intent that can only be sent
2267 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002268 */
2269 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2270 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2271 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002272 * Broadcast Action: Packages have been suspended.
2273 * <p>Includes the following extras:
2274 * <ul>
2275 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002276 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002277 * </ul>
2278 *
2279 * <p class="note">This is a protected intent that can only be sent
2280 * by the system. It is only sent to registered receivers.
2281 */
2282 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2283 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2284 /**
2285 * Broadcast Action: Packages have been unsuspended.
2286 * <p>Includes the following extras:
2287 * <ul>
2288 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002289 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002290 * </ul>
2291 *
2292 * <p class="note">This is a protected intent that can only be sent
2293 * by the system. It is only sent to registered receivers.
2294 */
2295 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2296 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002297
2298 /**
2299 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002300 * whenever a package is put into a suspended state or any of its app extras change while in the
2301 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002302 * <p> Optionally includes the following extras:
2303 * <ul>
2304 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2305 * useful information for the app being suspended.
2306 * </ul>
2307 * <p class="note">This is a protected intent that can only be sent
2308 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2309 * the manifest.</em>
2310 *
2311 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2312 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2313 * @see PackageManager#isPackageSuspended()
2314 * @see PackageManager#getSuspendedPackageAppExtras()
2315 */
2316 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2317 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2318
2319 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002320 * Activity Action: Started to show more details about why an application was suspended.
2321 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002322 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2323 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002324 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002325 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2326 * handling this intent and protect it with
2327 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2328 *
2329 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2330 *
2331 * <p class="note">This is a protected intent that can only be sent
2332 * by the system.
2333 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002334 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2335 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002336 * @see PackageManager#isPackageSuspended()
2337 * @see #ACTION_PACKAGES_SUSPENDED
2338 *
2339 * @hide
2340 */
2341 @SystemApi
2342 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2343 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2344 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2345
2346 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002347 * Broadcast Action: Sent to a package that has been unsuspended.
2348 *
2349 * <p class="note">This is a protected intent that can only be sent
2350 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2351 * the manifest.</em>
2352 *
2353 * @see #ACTION_MY_PACKAGE_SUSPENDED
2354 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2355 * @see PackageManager#isPackageSuspended()
2356 * @see PackageManager#getSuspendedPackageAppExtras()
2357 */
2358 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2359 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2360
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002361 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002362 * Broadcast Action: A user ID has been removed from the system. The user
2363 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002364 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002365 * <p class="note">This is a protected intent that can only be sent
2366 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002367 */
2368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2369 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002370
2371 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002372 * Broadcast Action: Sent to the installer package of an application when
2373 * that application is first launched (that is the first time it is moved
2374 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002375 *
2376 * <p class="note">This is a protected intent that can only be sent
2377 * by the system.
2378 */
2379 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2380 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2381
2382 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002383 * Broadcast Action: Sent to the system package verifier when a package
2384 * needs to be verified. The data contains the package URI.
2385 * <p class="note">
2386 * This is a protected intent that can only be sent by the system.
2387 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002388 */
2389 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2390 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2391
2392 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002393 * Broadcast Action: Sent to the system package verifier when a package is
2394 * verified. The data contains the package URI.
2395 * <p class="note">
2396 * This is a protected intent that can only be sent by the system.
2397 */
2398 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2399 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2400
2401 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002402 * Broadcast Action: Sent to the system intent filter verifier when an
2403 * intent filter needs to be verified. The data contains the filter data
2404 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002405 * <p class="note">
2406 * This is a protected intent that can only be sent by the system.
2407 * </p>
2408 *
2409 * @hide
2410 */
2411 @SystemApi
2412 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2413 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2414
2415 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002416 * Broadcast Action: Resources for a set of packages (which were
2417 * previously unavailable) are currently
2418 * available since the media on which they exist is available.
2419 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2420 * list of packages whose availability changed.
2421 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2422 * list of uids of packages whose availability changed.
2423 * Note that the
2424 * packages in this list do <em>not</em> receive this broadcast.
2425 * The specified set of packages are now available on the system.
2426 * <p>Includes the following extras:
2427 * <ul>
2428 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2429 * whose resources(were previously unavailable) are currently available.
2430 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2431 * packages whose resources(were previously unavailable)
2432 * are currently available.
2433 * </ul>
2434 *
2435 * <p class="note">This is a protected intent that can only be sent
2436 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002437 */
2438 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002439 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2440 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002441
2442 /**
2443 * Broadcast Action: Resources for a set of packages are currently
2444 * unavailable since the media on which they exist is unavailable.
2445 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2446 * list of packages whose availability changed.
2447 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2448 * list of uids of packages whose availability changed.
2449 * The specified set of packages can no longer be
2450 * launched and are practically unavailable on the system.
2451 * <p>Inclues the following extras:
2452 * <ul>
2453 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2454 * whose resources are no longer available.
2455 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2456 * whose resources are no longer available.
2457 * </ul>
2458 *
2459 * <p class="note">This is a protected intent that can only be sent
2460 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002461 */
2462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002463 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002464 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002466 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002467 * Broadcast Action: preferred activities have changed *explicitly*.
2468 *
2469 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2470 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2471 * be sent.
2472 *
2473 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2474 *
2475 * @hide
2476 */
2477 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2478 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2479 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2480
2481
2482 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002483 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002484 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002485 * This should <em>only</em> be used to determine when the wallpaper
2486 * has changed to show the new wallpaper to the user. You should certainly
2487 * never, in response to this, change the wallpaper or other attributes of
2488 * it such as the suggested size. That would be crazy, right? You'd cause
2489 * all kinds of loops, especially if other apps are doing similar things,
2490 * right? Of course. So please don't do this.
2491 *
2492 * @deprecated Modern applications should use
2493 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2494 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2495 * shown behind their UI, rather than watching for this broadcast and
2496 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002497 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002498 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002499 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2500 /**
2501 * Broadcast Action: The current device {@link android.content.res.Configuration}
2502 * (orientation, locale, etc) has changed. When such a change happens, the
2503 * UIs (view hierarchy) will need to be rebuilt based on this new
2504 * information; for the most part, applications don't need to worry about
2505 * this, because the system will take care of stopping and restarting the
2506 * application to make sure it sees the new changes. Some system code that
2507 * can not be restarted will need to watch for this action and handle it
2508 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002509 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002510 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002511 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002512 * in manifests, only by explicitly registering for it with
2513 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2514 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002515 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002516 * <p class="note">This is a protected intent that can only be sent
2517 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002518 *
2519 * @see android.content.res.Configuration
2520 */
2521 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2522 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002523
2524 /**
2525 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2526 * such that the device may be eligible for the installation of additional configuration splits.
2527 * Configuration properties that can trigger this broadcast include locale and display density.
2528 *
2529 * <p class="note">
2530 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2531 * components declared in manifests. However, the receiver <em>must</em> hold the
2532 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2533 *
2534 * <p class="note">
2535 * This is a protected intent that can only be sent by the system.
2536 *
2537 * @hide
2538 */
2539 @SystemApi
2540 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2541 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2542 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002543 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002544 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002545 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002546 * <p class="note">This is a protected intent that can only be sent
2547 * by the system.
2548 */
2549 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2550 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2551 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002552 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2553 * charging state, level, and other information about the battery.
2554 * See {@link android.os.BatteryManager} for documentation on the
2555 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002556 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002557 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002558 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002559 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002560 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002561 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2562 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2563 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2564 * broadcasts that are sent and can be received through manifest
2565 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002566 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002567 * <p class="note">This is a protected intent that can only be sent
2568 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002569 */
2570 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2571 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002572
2573
2574 /**
2575 * Broadcast Action: Sent when the current battery level changes.
2576 *
2577 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2578 * instances representing individual battery level changes with associated
2579 * extras from {@link #ACTION_BATTERY_CHANGED}.
2580 *
2581 * <p class="note">
2582 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2583 *
2584 * @hide
2585 */
2586 @SystemApi
2587 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2588 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002589 /**
2590 * Broadcast Action: Indicates low battery condition on the device.
2591 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002592 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002593 * <p class="note">This is a protected intent that can only be sent
2594 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002595 */
2596 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2597 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2598 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002599 * Broadcast Action: Indicates the battery is now okay after being low.
2600 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2601 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002602 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002603 * <p class="note">This is a protected intent that can only be sent
2604 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002605 */
2606 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2607 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2608 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002609 * Broadcast Action: External power has been connected to the device.
2610 * This is intended for applications that wish to register specifically to this notification.
2611 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2612 * stay active to receive this notification. This action can be used to implement actions
2613 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002614 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002615 * <p class="note">This is a protected intent that can only be sent
2616 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002617 */
2618 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002619 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002620 /**
2621 * Broadcast Action: External power has been removed from the device.
2622 * This is intended for applications that wish to register specifically to this notification.
2623 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2624 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002625 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002626 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002627 * <p class="note">This is a protected intent that can only be sent
2628 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002629 */
2630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002631 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002632 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002633 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002634 * Broadcast Action: Device is shutting down.
2635 * This is broadcast when the device is being shut down (completely turned
2636 * off, not sleeping). Once the broadcast is complete, the final shutdown
2637 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002638 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002639 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2640 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2641 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002642 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002643 * <p class="note">This is a protected intent that can only be sent
2644 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002645 * <p>May include the following extras:
2646 * <ul>
2647 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2648 * shutdown is only for userspace processes. If not set, assumed to be false.
2649 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002650 */
2651 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002652 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002653 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002654 * Activity Action: Start this activity to request system shutdown.
2655 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002656 * to request confirmation from the user before shutting down. The optional boolean
2657 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2658 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002659 *
2660 * <p class="note">This is a protected intent that can only be sent
2661 * by the system.
2662 *
2663 * {@hide}
2664 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002665 public static final String ACTION_REQUEST_SHUTDOWN
2666 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002667 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002668 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002669 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002670 * <p class="note">
2671 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002672 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002673 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2674 * or above, this broadcast will no longer be delivered to any
2675 * {@link BroadcastReceiver} defined in your manifest. Instead,
2676 * apps are strongly encouraged to use the improved
2677 * {@link Context#getCacheDir()} behavior so the system can
2678 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002679 */
2680 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002681 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002682 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2683 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002684 * Broadcast Action: Indicates low storage space condition on the device no
2685 * longer exists
2686 * <p class="note">
2687 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002688 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002689 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2690 * or above, this broadcast will no longer be delivered to any
2691 * {@link BroadcastReceiver} defined in your manifest. Instead,
2692 * apps are strongly encouraged to use the improved
2693 * {@link Context#getCacheDir()} behavior so the system can
2694 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002697 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002698 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2699 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002700 * Broadcast Action: A sticky broadcast that indicates a storage space full
2701 * condition on the device. This is intended for activities that want to be
2702 * able to fill the data partition completely, leaving only enough free
2703 * space to prevent system-wide SQLite failures.
2704 * <p class="note">
2705 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002706 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002707 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2708 * or above, this broadcast will no longer be delivered to any
2709 * {@link BroadcastReceiver} defined in your manifest. Instead,
2710 * apps are strongly encouraged to use the improved
2711 * {@link Context#getCacheDir()} behavior so the system can
2712 * automatically free up storage when needed.
2713 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002714 */
2715 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002716 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002717 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2718 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002719 * Broadcast Action: Indicates storage space full condition on the device no
2720 * longer exists.
2721 * <p class="note">
2722 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002723 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002724 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2725 * or above, this broadcast will no longer be delivered to any
2726 * {@link BroadcastReceiver} defined in your manifest. Instead,
2727 * apps are strongly encouraged to use the improved
2728 * {@link Context#getCacheDir()} behavior so the system can
2729 * automatically free up storage when needed.
2730 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002731 */
2732 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002733 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002734 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2735 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002736 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2737 * and package management should be started.
2738 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2739 * notification.
2740 */
2741 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2742 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2743 /**
2744 * Broadcast Action: The device has entered USB Mass Storage mode.
2745 * This is used mainly for the USB Settings panel.
2746 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2747 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002748 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002749 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002750 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002751 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002752 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2753
2754 /**
2755 * Broadcast Action: The device has exited USB Mass Storage mode.
2756 * This is used mainly for the USB Settings panel.
2757 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2758 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002759 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002760 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002761 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002762 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002763 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2764
2765 /**
2766 * Broadcast Action: External media has been removed.
2767 * The path to the mount point for the removed media is contained in the Intent.mData field.
2768 */
2769 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2770 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2771
2772 /**
2773 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002774 * 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 -07002775 */
2776 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2777 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2778
2779 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002780 * Broadcast Action: External media is present, and being disk-checked
2781 * 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 -08002782 */
2783 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2784 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2785
2786 /**
2787 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2788 * 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 -08002789 */
2790 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2791 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2792
2793 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002794 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002795 * 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 -07002796 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2797 * media was mounted read only.
2798 */
2799 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2800 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2801
2802 /**
2803 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002804 * 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 -07002805 */
2806 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2807 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2808
2809 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002810 * Broadcast Action: External media is no longer being shared via USB mass storage.
2811 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2812 *
2813 * @hide
2814 */
2815 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2816
2817 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2819 * The path to the mount point for the removed media is contained in the Intent.mData field.
2820 */
2821 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2822 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2823
2824 /**
2825 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002826 * 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 -07002827 */
2828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2829 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2830
2831 /**
2832 * Broadcast Action: User has expressed the desire to remove the external storage media.
2833 * Applications should close all files they have open within the mount point when they receive this intent.
2834 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2835 */
2836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2837 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2838
2839 /**
2840 * Broadcast Action: The media scanner has started scanning a directory.
2841 * The path to the directory being scanned is contained in the Intent.mData field.
2842 */
2843 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2844 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2845
2846 /**
2847 * Broadcast Action: The media scanner has finished scanning a directory.
2848 * The path to the scanned directory is contained in the Intent.mData field.
2849 */
2850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2851 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2852
2853 /**
2854 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2855 * The path to the file is contained in the Intent.mData field.
2856 */
2857 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2858 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2859
2860 /**
2861 * Broadcast Action: The "Media Button" was pressed. Includes a single
2862 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2863 * caused the broadcast.
2864 */
2865 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2866 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2867
2868 /**
2869 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2870 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2871 * caused the broadcast.
2872 */
2873 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2874 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2875
2876 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2877 // location; they are not general-purpose actions.
2878
2879 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002880 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002881 */
2882 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2883 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2884 "android.intent.action.GTALK_CONNECTED";
2885
2886 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002887 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002888 */
2889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2890 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2891 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002892
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002893 /**
2894 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002895 */
2896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2897 public static final String ACTION_INPUT_METHOD_CHANGED =
2898 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002899
2900 /**
2901 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2902 * more radios have been turned off or on. The intent will have the following extra value:</p>
2903 * <ul>
2904 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2905 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2906 * turned off</li>
2907 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002908 *
Peng Xua35b5532016-01-20 00:05:45 -08002909 * <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 -07002910 */
2911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2912 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2913
2914 /**
2915 * Broadcast Action: Some content providers have parts of their namespace
2916 * where they publish new events or items that the user may be especially
2917 * interested in. For these things, they may broadcast this action when the
2918 * set of interesting items change.
2919 *
2920 * For example, GmailProvider sends this notification when the set of unread
2921 * mail in the inbox changes.
2922 *
2923 * <p>The data of the intent identifies which part of which provider
2924 * changed. When queried through the content resolver, the data URI will
2925 * return the data set in question.
2926 *
2927 * <p>The intent will have the following extra values:
2928 * <ul>
2929 * <li><em>count</em> - The number of items in the data set. This is the
2930 * same as the number of items in the cursor returned by querying the
2931 * data URI. </li>
2932 * </ul>
2933 *
2934 * This intent will be sent at boot (if the count is non-zero) and when the
2935 * data set changes. It is possible for the data set to change without the
2936 * count changing (for example, if a new unread message arrives in the same
2937 * sync operation in which a message is archived). The phone should still
2938 * ring/vibrate/etc as normal in this case.
2939 */
2940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2941 public static final String ACTION_PROVIDER_CHANGED =
2942 "android.intent.action.PROVIDER_CHANGED";
2943
2944 /**
2945 * Broadcast Action: Wired Headset plugged in or unplugged.
2946 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002947 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2948 * and documentation.
2949 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002950 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002951 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002952 */
2953 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002954 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002955
2956 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002957 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2958 * <ul>
2959 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2960 * </ul>
2961 *
2962 * <p class="note">This is a protected intent that can only be sent
2963 * by the system.
2964 *
2965 * @hide
2966 */
2967 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2968 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2969 = "android.intent.action.ADVANCED_SETTINGS";
2970
2971 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002972 * Broadcast Action: Sent after application restrictions are changed.
2973 *
2974 * <p class="note">This is a protected intent that can only be sent
2975 * by the system.</p>
2976 */
2977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2978 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
2979 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
2980
2981 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002982 * Broadcast Action: An outgoing call is about to be placed.
2983 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07002984 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002985 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07002986 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002987 * the phone number originally intended to be dialed.</li>
2988 * </ul>
2989 * <p>Once the broadcast is finished, the resultData is used as the actual
2990 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07002991 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002992 * outgoing call in turn: for example, a parental control application
2993 * might verify that the user is authorized to place the call at that
2994 * time, then a number-rewriting application might add an area code if
2995 * one was not specified.</p>
2996 * <p>For consistency, any receiver whose purpose is to prohibit phone
2997 * calls should have a priority of 0, to ensure it will see the final
2998 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07002999 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003000 * should have a positive priority.
3001 * Negative priorities are reserved for the system for this broadcast;
3002 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003003 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3004 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003005 * <p>Emergency calls cannot be intercepted using this mechanism, and
3006 * other calls cannot be modified to call emergency numbers using this
3007 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003008 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3009 * call to use their own service instead. Those apps should first prevent
3010 * the call from being placed by setting resultData to <code>null</code>
3011 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003012 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003013 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3014 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003015 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003016 * <p class="note">This is a protected intent that can only be sent
3017 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003018 */
3019 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3020 public static final String ACTION_NEW_OUTGOING_CALL =
3021 "android.intent.action.NEW_OUTGOING_CALL";
3022
3023 /**
3024 * Broadcast Action: Have the device reboot. This is only for use by
3025 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003026 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003027 * <p class="note">This is a protected intent that can only be sent
3028 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003029 */
3030 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3031 public static final String ACTION_REBOOT =
3032 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003033
Wei Huang97ecc9c2009-05-11 17:44:20 -07003034 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003035 * Broadcast Action: A sticky broadcast for changes in the physical
3036 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003037 *
3038 * <p>The intent will have the following extra values:
3039 * <ul>
3040 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003041 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003042 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003043 * <p>This is intended for monitoring the current physical dock state.
3044 * See {@link android.app.UiModeManager} for the normal API dealing with
3045 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003046 */
3047 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3048 public static final String ACTION_DOCK_EVENT =
3049 "android.intent.action.DOCK_EVENT";
3050
3051 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003052 * Broadcast Action: A broadcast when idle maintenance can be started.
3053 * This means that the user is not interacting with the device and is
3054 * not expected to do so soon. Typical use of the idle maintenance is
3055 * to perform somehow expensive tasks that can be postponed at a moment
3056 * when they will not degrade user experience.
3057 * <p>
3058 * <p class="note">In order to keep the device responsive in case of an
3059 * unexpected user interaction, implementations of a maintenance task
3060 * should be interruptible. In such a scenario a broadcast with action
3061 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3062 * should not do the maintenance work in
3063 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3064 * maintenance service by {@link Context#startService(Intent)}. Also
3065 * you should hold a wake lock while your maintenance service is running
3066 * to prevent the device going to sleep.
3067 * </p>
3068 * <p>
3069 * <p class="note">This is a protected intent that can only be sent by
3070 * the system.
3071 * </p>
3072 *
3073 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003074 *
3075 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003076 */
3077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3078 public static final String ACTION_IDLE_MAINTENANCE_START =
3079 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3080
3081 /**
3082 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3083 * This means that the user was not interacting with the device as a result
3084 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3085 * was sent and now the user started interacting with the device. Typical
3086 * use of the idle maintenance is to perform somehow expensive tasks that
3087 * can be postponed at a moment when they will not degrade user experience.
3088 * <p>
3089 * <p class="note">In order to keep the device responsive in case of an
3090 * unexpected user interaction, implementations of a maintenance task
3091 * should be interruptible. Hence, on receiving a broadcast with this
3092 * action, the maintenance task should be interrupted as soon as possible.
3093 * In other words, you should not do the maintenance work in
3094 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3095 * maintenance service that was started on receiving of
3096 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3097 * lock you acquired when your maintenance service started.
3098 * </p>
3099 * <p class="note">This is a protected intent that can only be sent
3100 * by the system.
3101 *
3102 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003103 *
3104 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003105 */
3106 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3107 public static final String ACTION_IDLE_MAINTENANCE_END =
3108 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3109
3110 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003111 * Broadcast Action: a remote intent is to be broadcasted.
3112 *
3113 * A remote intent is used for remote RPC between devices. The remote intent
3114 * is serialized and sent from one device to another device. The receiving
3115 * device parses the remote intent and broadcasts it. Note that anyone can
3116 * broadcast a remote intent. However, if the intent receiver of the remote intent
3117 * does not trust intent broadcasts from arbitrary intent senders, it should require
3118 * the sender to hold certain permissions so only trusted sender's broadcast will be
3119 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003120 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003121 */
3122 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003123 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003124
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003125 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003126 * Broadcast Action: This is broadcast once when the user is booting after a
3127 * system update. It can be used to perform cleanup or upgrades after a
3128 * system update.
3129 * <p>
3130 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3131 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3132 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3133 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003134 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003135 * @hide
3136 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003137 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003138 public static final String ACTION_PRE_BOOT_COMPLETED =
3139 "android.intent.action.PRE_BOOT_COMPLETED";
3140
Amith Yamasani13593602012-03-22 16:16:17 -07003141 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003142 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003143 * on restricted users. The broadcast intent contains an extra
3144 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3145 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3146 * String[] depending on the restriction type.<p/>
3147 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003148 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3149 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3150 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003151 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3152 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003153 * @see RestrictionEntry
3154 */
3155 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3156 "android.intent.action.GET_RESTRICTION_ENTRIES";
3157
3158 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003159 * Sent the first time a user is starting, to allow system apps to
3160 * perform one time initialization. (This will not be seen by third
3161 * party applications because a newly initialized user does not have any
3162 * third party applications installed for it.) This is sent early in
3163 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003164 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3165 * broadcast, since it is part of a visible user interaction; be as quick
3166 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003167 */
3168 public static final String ACTION_USER_INITIALIZE =
3169 "android.intent.action.USER_INITIALIZE";
3170
3171 /**
3172 * Sent when a user switch is happening, causing the process's user to be
3173 * brought to the foreground. This is only sent to receivers registered
3174 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3175 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003176 * foreground. This is sent as a foreground
3177 * broadcast, since it is part of a visible user interaction; be as quick
3178 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003179 */
3180 public static final String ACTION_USER_FOREGROUND =
3181 "android.intent.action.USER_FOREGROUND";
3182
3183 /**
3184 * Sent when a user switch is happening, causing the process's user to be
3185 * sent to the background. This is only sent to receivers registered
3186 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3187 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003188 * background. This is sent as a foreground
3189 * broadcast, since it is part of a visible user interaction; be as quick
3190 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003191 */
3192 public static final String ACTION_USER_BACKGROUND =
3193 "android.intent.action.USER_BACKGROUND";
3194
3195 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003196 * Broadcast sent to the system when a user is added. Carries an extra
3197 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3198 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003199 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003200 * @hide
3201 */
3202 public static final String ACTION_USER_ADDED =
3203 "android.intent.action.USER_ADDED";
3204
3205 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003206 * Broadcast sent by the system when a user is started. Carries an extra
3207 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003208 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003209 * that has been started. This is sent as a foreground
3210 * broadcast, since it is part of a visible user interaction; be as quick
3211 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003212 * @hide
3213 */
3214 public static final String ACTION_USER_STARTED =
3215 "android.intent.action.USER_STARTED";
3216
3217 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003218 * Broadcast sent when a user is in the process of starting. Carries an extra
3219 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3220 * sent to registered receivers, not manifest receivers. It is sent to all
3221 * users (including the one that is being started). You must hold
3222 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3223 * this broadcast. This is sent as a background broadcast, since
3224 * its result is not part of the primary UX flow; to safely keep track of
3225 * started/stopped state of a user you can use this in conjunction with
3226 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3227 * other user state broadcasts since those are foreground broadcasts so can
3228 * execute in a different order.
3229 * @hide
3230 */
3231 public static final String ACTION_USER_STARTING =
3232 "android.intent.action.USER_STARTING";
3233
3234 /**
3235 * Broadcast sent when a user is going to be stopped. Carries an extra
3236 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3237 * sent to registered receivers, not manifest receivers. It is sent to all
3238 * users (including the one that is being stopped). You must hold
3239 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3240 * this broadcast. The user will not stop until all receivers have
3241 * handled the broadcast. This is sent as a background broadcast, since
3242 * its result is not part of the primary UX flow; to safely keep track of
3243 * started/stopped state of a user you can use this in conjunction with
3244 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3245 * other user state broadcasts since those are foreground broadcasts so can
3246 * execute in a different order.
3247 * @hide
3248 */
3249 public static final String ACTION_USER_STOPPING =
3250 "android.intent.action.USER_STOPPING";
3251
3252 /**
3253 * Broadcast sent to the system when a user is stopped. Carries an extra
3254 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3255 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3256 * specific package. This is only sent to registered receivers, not manifest
3257 * receivers. It is sent to all running users <em>except</em> the one that
3258 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003259 * @hide
3260 */
3261 public static final String ACTION_USER_STOPPED =
3262 "android.intent.action.USER_STOPPED";
3263
3264 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003265 * 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 -07003266 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003267 * one that has been removed. The user will not be completely removed until all receivers have
3268 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003269 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003270 * @hide
3271 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003272 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003273 public static final String ACTION_USER_REMOVED =
3274 "android.intent.action.USER_REMOVED";
3275
3276 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003277 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003278 * the userHandle of the user to become the current one. This is only sent to
3279 * registered receivers, not manifest receivers. It is sent to all running users.
3280 * You must hold
3281 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003282 * @hide
3283 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003284 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003285 public static final String ACTION_USER_SWITCHED =
3286 "android.intent.action.USER_SWITCHED";
3287
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003288 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003289 * Broadcast Action: Sent when the credential-encrypted private storage has
3290 * become unlocked for the target user. This is only sent to registered
3291 * receivers, not manifest receivers.
3292 */
3293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3294 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3295
3296 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003297 * Broadcast sent to the system when a user's information changes. Carries an extra
3298 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003299 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003300 * @hide
3301 */
3302 public static final String ACTION_USER_INFO_CHANGED =
3303 "android.intent.action.USER_INFO_CHANGED";
3304
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003305 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003306 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3307 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003308 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3309 * that need to display merged content across both primary and managed profiles need to
3310 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003311 * not manifest receivers.
3312 */
3313 public static final String ACTION_MANAGED_PROFILE_ADDED =
3314 "android.intent.action.MANAGED_PROFILE_ADDED";
3315
3316 /**
3317 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003318 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3319 * Only applications (for example Launchers) that need to display merged content across both
3320 * primary and managed profiles need to worry about this broadcast. This is only sent to
3321 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003322 */
3323 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3324 "android.intent.action.MANAGED_PROFILE_REMOVED";
3325
3326 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003327 * Broadcast sent to the primary user when the credential-encrypted private storage for
3328 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3329 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3330 * Launchers) that need to display merged content across both primary and managed profiles
3331 * need to worry about this broadcast. This is only sent to registered receivers,
3332 * not manifest receivers.
3333 */
3334 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3335 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3336
3337 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003338 * Broadcast sent to the primary user when an associated managed profile has become available.
3339 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003340 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3341 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3342 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003343 */
Rubin Xue95057a2016-04-01 16:49:25 +01003344 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3345 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3346
3347 /**
3348 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3349 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3350 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3351 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3352 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3353 */
3354 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3355 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003356
3357 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003358 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3359 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3360 * the device was locked or unlocked.
3361 *
3362 * This is only sent to registered receivers.
3363 *
3364 * @hide
3365 */
3366 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3367 "android.intent.action.DEVICE_LOCKED_CHANGED";
3368
3369 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003370 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3371 */
3372 public static final String ACTION_QUICK_CLOCK =
3373 "android.intent.action.QUICK_CLOCK";
3374
Michael Wright0087a142013-02-05 16:29:39 -08003375 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003376 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003377 * @hide
3378 */
3379 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003380 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003381
Justin Kohd378ad72013-04-01 12:18:26 -07003382 /**
3383 * Broadcast Action: A global button was pressed. Includes a single
3384 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3385 * caused the broadcast.
3386 * @hide
3387 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003388 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003389 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3390
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003391 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003392 * Broadcast Action: Sent when media resource is granted.
3393 * <p>
3394 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3395 * granted.
3396 * </p>
3397 * <p class="note">
3398 * This is a protected intent that can only be sent by the system.
3399 * </p>
3400 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003401 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003402 * </p>
3403 *
3404 * @hide
3405 */
3406 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3407 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3408
3409 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003410 * Broadcast Action: An overlay package has changed. The data contains the
3411 * name of the overlay package which has changed. This is broadcast on all
3412 * changes to the OverlayInfo returned by {@link
3413 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3414 * most common change is a state change that will change whether the
3415 * overlay is enabled or not.
3416 * @hide
3417 */
3418 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3419
3420 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003421 * Activity Action: Allow the user to select and return one or more existing
3422 * documents. When invoked, the system will display the various
3423 * {@link DocumentsProvider} instances installed on the device, letting the
3424 * user interactively navigate through them. These documents include local
3425 * media, such as photos and video, and documents provided by installed
3426 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003427 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003428 * Each document is represented as a {@code content://} URI backed by a
3429 * {@link DocumentsProvider}, which can be opened as a stream with
3430 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3431 * {@link android.provider.DocumentsContract.Document} metadata.
3432 * <p>
3433 * All selected documents are returned to the calling application with
3434 * persistable read and write permission grants. If you want to maintain
3435 * access to the documents across device reboots, you need to explicitly
3436 * take the persistable permissions using
3437 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3438 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003439 * Callers must indicate the acceptable document MIME types through
3440 * {@link #setType(String)}. For example, to select photos, use
3441 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3442 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3443 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003444 * <p>
3445 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003446 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3447 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003448 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003449 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3450 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003451 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003452 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003453 * Callers can set a document URI through
3454 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3455 * location of documents navigator. System will do its best to launch the
3456 * navigator in the specified document if it's a folder, or the folder that
3457 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003458 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003459 * Output: The URI of the item that was picked, returned in
3460 * {@link #getData()}. This must be a {@code content://} URI so that any
3461 * receiver can access it. If multiple documents were selected, they are
3462 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003463 *
3464 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003465 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003466 * @see #ACTION_CREATE_DOCUMENT
3467 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003468 */
3469 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3470 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3471
3472 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003473 * Activity Action: Allow the user to create a new document. When invoked,
3474 * the system will display the various {@link DocumentsProvider} instances
3475 * installed on the device, letting the user navigate through them. The
3476 * returned document may be a newly created document with no content, or it
3477 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003478 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003479 * Each document is represented as a {@code content://} URI backed by a
3480 * {@link DocumentsProvider}, which can be opened as a stream with
3481 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3482 * {@link android.provider.DocumentsContract.Document} metadata.
3483 * <p>
3484 * Callers must indicate the concrete MIME type of the document being
3485 * created by setting {@link #setType(String)}. This MIME type cannot be
3486 * changed after the document is created.
3487 * <p>
3488 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3489 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003490 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003491 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3492 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003493 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003494 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003495 * Callers can set a document URI through
3496 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3497 * location of documents navigator. System will do its best to launch the
3498 * navigator in the specified document if it's a folder, or the folder that
3499 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003500 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003501 * Output: The URI of the item that was created. This must be a
3502 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003503 *
3504 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003505 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003506 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003507 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003508 */
3509 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3510 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3511
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003512 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003513 * Activity Action: Allow the user to pick a directory subtree. When
3514 * invoked, the system will display the various {@link DocumentsProvider}
3515 * instances installed on the device, letting the user navigate through
3516 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003517 * <p>
3518 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003519 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3520 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3521 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003522 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003523 * Callers can set a document URI through
3524 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3525 * location of documents navigator. System will do its best to launch the
3526 * navigator in the specified document if it's a folder, or the folder that
3527 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003528 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003529 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003530 *
3531 * @see DocumentsContract
3532 */
3533 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003534 public static final String
3535 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003536
Felipe Lemec7b1f892016-01-15 15:02:31 -08003537 /**
Peng Xua35b5532016-01-20 00:05:45 -08003538 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3539 * exisiting sensor being disconnected.
3540 *
3541 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3542 *
3543 * {@hide}
3544 */
3545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3546 public static final String
3547 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3548
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003549 /**
Sam Line707f832017-04-13 17:00:55 -07003550 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003551 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003552 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003553 */
3554 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003555 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003556 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3557
Christopher Tate6597e342015-02-17 12:15:25 -08003558 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003559 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3560 * is about to be performed.
3561 * @hide
3562 */
3563 @SystemApi
3564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3565 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3566 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3567
3568 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003569 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3570 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3571 *
3572 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3573 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003574 * @hide
3575 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003576 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003577 public static final String EXTRA_FORCE_MASTER_CLEAR =
3578 "android.intent.extra.FORCE_MASTER_CLEAR";
3579
3580 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003581 * A broadcast action to trigger a factory reset.
3582 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003583 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3584 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003585 *
3586 * <p>Not for use by third-party applications.
3587 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003588 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003589 *
3590 * {@hide}
3591 */
3592 @SystemApi
3593 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3594 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3595
3596 /**
3597 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3598 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3599 *
3600 * <p>Not for use by third-party applications.
3601 *
3602 * @hide
3603 */
3604 @SystemApi
3605 public static final String EXTRA_FORCE_FACTORY_RESET =
3606 "android.intent.extra.FORCE_FACTORY_RESET";
3607
3608 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003609 * Broadcast action: report that a settings element is being restored from backup. The intent
3610 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3611 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3612 * is the value of that settings entry prior to the restore operation, and
3613 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3614 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3615 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003616 *
3617 * <p>This broadcast is sent only for settings provider entries known to require special handling
3618 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3619 * the provider's backup agent implementation.
3620 *
3621 * @see #EXTRA_SETTING_NAME
3622 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3623 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003624 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003625 * {@hide}
3626 */
3627 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3628
3629 /** {@hide} */
3630 public static final String EXTRA_SETTING_NAME = "setting_name";
3631 /** {@hide} */
3632 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3633 /** {@hide} */
3634 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003635 /** {@hide} */
3636 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003637
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003638 /**
3639 * Activity Action: Process a piece of text.
3640 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3641 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3642 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3643 */
3644 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3645 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003646
3647 /**
3648 * Broadcast Action: The sim card state has changed.
3649 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3650 * because TelephonyIntents is an internal class.
3651 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003652 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3653 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003654 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003655 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003656 @SystemApi
3657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3658 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3659
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003660 /**
fionaxu90fee272017-03-31 12:45:12 -07003661 * Broadcast Action: indicate that the phone service state has changed.
3662 * The intent will have the following extra values:</p>
3663 * <p>
3664 * @see #EXTRA_VOICE_REG_STATE
3665 * @see #EXTRA_DATA_REG_STATE
3666 * @see #EXTRA_VOICE_ROAMING_TYPE
3667 * @see #EXTRA_DATA_ROAMING_TYPE
3668 * @see #EXTRA_OPERATOR_ALPHA_LONG
3669 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3670 * @see #EXTRA_OPERATOR_NUMERIC
3671 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3672 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3673 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3674 * @see #EXTRA_MANUAL
3675 * @see #EXTRA_VOICE_RADIO_TECH
3676 * @see #EXTRA_DATA_RADIO_TECH
3677 * @see #EXTRA_CSS_INDICATOR
3678 * @see #EXTRA_NETWORK_ID
3679 * @see #EXTRA_SYSTEM_ID
3680 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3681 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3682 * @see #EXTRA_EMERGENCY_ONLY
3683 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3684 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3685 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3686 *
3687 * <p class="note">
3688 * Requires the READ_PHONE_STATE permission.
3689 *
3690 * <p class="note">This is a protected intent that can only be sent by the system.
3691 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003692 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003693 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3694 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3695 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3696 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003697 */
3698 @Deprecated
3699 @SystemApi
3700 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3701 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3702
3703 /**
3704 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3705 * state.
3706 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3707 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3708 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3709 * @see android.telephony.ServiceState#STATE_POWER_OFF
3710 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003711 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003712 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003713 */
3714 @Deprecated
3715 @SystemApi
3716 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3717
3718 /**
3719 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3720 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3721 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3722 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3723 * @see android.telephony.ServiceState#STATE_POWER_OFF
3724 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003725 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003726 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003727 */
3728 @Deprecated
3729 @SystemApi
3730 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3731
3732 /**
3733 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3734 * type.
3735 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003736 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003737 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003738 */
3739 @Deprecated
3740 @SystemApi
3741 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3742
3743 /**
3744 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3745 * type.
3746 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003747 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003748 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003749 */
3750 @Deprecated
3751 @SystemApi
3752 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3753
3754 /**
3755 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3756 * registered voice operator name in long alphanumeric format.
3757 * {@code null} if the operator name is not known or unregistered.
3758 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003759 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003760 * @deprecated Use
3761 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003762 */
3763 @Deprecated
3764 @SystemApi
3765 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3766
3767 /**
3768 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3769 * registered voice operator name in short alphanumeric format.
3770 * {@code null} if the operator name is not known or unregistered.
3771 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003772 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003773 * @deprecated Use
3774 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003775 */
3776 @Deprecated
3777 @SystemApi
3778 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3779
3780 /**
3781 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3782 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3783 * network.
3784 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003785 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003786 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003787 */
3788 @Deprecated
3789 @SystemApi
3790 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3791
3792 /**
3793 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3794 * registered data operator name in long alphanumeric format.
3795 * {@code null} if the operator name is not known or unregistered.
3796 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003797 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003798 * @deprecated Use
3799 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003800 */
3801 @Deprecated
3802 @SystemApi
3803 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3804
3805 /**
3806 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3807 * registered data operator name in short alphanumeric format.
3808 * {@code null} if the operator name is not known or unregistered.
3809 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003810 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003811 * @deprecated Use
3812 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003813 */
3814 @Deprecated
3815 @SystemApi
3816 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3817
3818 /**
3819 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3820 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3821 * data operator.
3822 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003823 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003824 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003825 */
3826 @Deprecated
3827 @SystemApi
3828 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3829
3830 /**
3831 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3832 * network selection mode is manual.
3833 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3834 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003835 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003836 * @deprecated Use
3837 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003838 */
3839 @Deprecated
3840 @SystemApi
3841 public static final String EXTRA_MANUAL = "manual";
3842
3843 /**
3844 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3845 * radio technology.
3846 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003847 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003848 * @deprecated Use
3849 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003850 */
3851 @Deprecated
3852 @SystemApi
3853 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3854
3855 /**
3856 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3857 * radio technology.
3858 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003859 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003860 * @deprecated Use
3861 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003862 */
3863 @Deprecated
3864 @SystemApi
3865 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3866
3867 /**
3868 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3869 * support on CDMA network.
3870 * Will be {@code true} if support, {@code false} otherwise.
3871 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003872 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003873 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003874 */
3875 @Deprecated
3876 @SystemApi
3877 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3878
3879 /**
3880 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3881 * id. {@code Integer.MAX_VALUE} if unknown.
3882 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003883 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003884 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003885 */
3886 @Deprecated
3887 @SystemApi
3888 public static final String EXTRA_NETWORK_ID = "networkId";
3889
3890 /**
3891 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3892 * {@code Integer.MAX_VALUE} if unknown.
3893 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003894 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003895 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003896 */
3897 @Deprecated
3898 @SystemApi
3899 public static final String EXTRA_SYSTEM_ID = "systemId";
3900
3901 /**
3902 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3903 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3904 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003905 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003906 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003907 */
3908 @Deprecated
3909 @SystemApi
3910 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3911
3912 /**
3913 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3914 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3915 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003916 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003917 * @deprecated Use
3918 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003919 */
3920 @Deprecated
3921 @SystemApi
3922 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3923
3924 /**
3925 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3926 * only mode.
3927 * {@code true} if in emergency only mode, {@code false} otherwise.
3928 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003929 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003930 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003931 */
3932 @Deprecated
3933 @SystemApi
3934 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3935
3936 /**
3937 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3938 * registration state is roaming.
3939 * {@code true} if registration indicates roaming, {@code false} otherwise
3940 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003941 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003942 * @deprecated Use
3943 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003944 */
3945 @Deprecated
3946 @SystemApi
3947 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3948 "isDataRoamingFromRegistration";
3949
3950 /**
3951 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3952 * aggregation is in use.
3953 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3954 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003955 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003956 * @deprecated Use
3957 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003958 */
3959 @Deprecated
3960 @SystemApi
3961 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3962
3963 /**
3964 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3965 * is reduced from the rsrp threshold while calculating signal strength level.
3966 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003967 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003968 */
3969 @Deprecated
3970 @SystemApi
3971 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3972
3973 /**
chen xu02811692018-10-03 19:07:09 -07003974 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
3975 * @hide
3976 */
3977 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
3978
3979 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003980 * The name of the extra used to define the text to be processed, as a
3981 * CharSequence. Note that this may be a styled CharSequence, so you must use
3982 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003983 */
3984 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
3985 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01003986 * 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 +00003987 */
3988 public static final String EXTRA_PROCESS_TEXT_READONLY =
3989 "android.intent.extra.PROCESS_TEXT_READONLY";
3990
Bryce Leebc58f592015-09-25 16:43:01 -07003991 /**
3992 * Broadcast action: reports when a new thermal event has been reached. When the device
3993 * is reaching its maximum temperatue, the thermal level reported
3994 * {@hide}
3995 */
3996 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3997 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
3998
3999 /** {@hide} */
4000 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4001
4002 /**
4003 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004004 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004005 * {@hide}
4006 */
4007 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4008
4009 /**
4010 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004011 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004012 * {@hide}
4013 */
4014 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4015
4016 /**
4017 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004018 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004019 * {@hide}
4020 */
4021 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4022
lpeter318abc92018-05-04 16:13:14 +08004023 /**
4024 * Broadcast Action: Indicates the dock in idle state while device is docked.
4025 *
4026 * <p class="note">This is a protected intent that can only be sent
4027 * by the system.
4028 *
4029 * @hide
4030 */
4031 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4032
4033 /**
4034 * Broadcast Action: Indicates the dock in active state while device is docked.
4035 *
4036 * <p class="note">This is a protected intent that can only be sent
4037 * by the system.
4038 *
4039 * @hide
4040 */
4041 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4042
Bryce Leebc58f592015-09-25 16:43:01 -07004043
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004044 // ---------------------------------------------------------------------
4045 // ---------------------------------------------------------------------
4046 // Standard intent categories (see addCategory()).
4047
4048 /**
4049 * Set if the activity should be an option for the default action
4050 * (center press) to perform on a piece of data. Setting this will
4051 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004052 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004053 * Intent when initiating an action -- it is for use in intent filters
4054 * specified in packages.
4055 */
4056 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4057 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4058 /**
4059 * Activities that can be safely invoked from a browser must support this
4060 * category. For example, if the user is viewing a web page or an e-mail
4061 * and clicks on a link in the text, the Intent generated execute that
4062 * link will require the BROWSABLE category, so that only activities
4063 * supporting this category will be considered as possible actions. By
4064 * supporting this category, you are promising that there is nothing
4065 * damaging (without user intervention) that can happen by invoking any
4066 * matching Intent.
4067 */
4068 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4069 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4070 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004071 * Categories for activities that can participate in voice interaction.
4072 * An activity that supports this category must be prepared to run with
4073 * no UI shown at all (though in some case it may have a UI shown), and
4074 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4075 */
4076 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4077 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4078 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004079 * Set if the activity should be considered as an alternative action to
4080 * the data the user is currently viewing. See also
4081 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4082 * applies to the selection in a list of items.
4083 *
4084 * <p>Supporting this category means that you would like your activity to be
4085 * displayed in the set of alternative things the user can do, usually as
4086 * part of the current activity's options menu. You will usually want to
4087 * include a specific label in the &lt;intent-filter&gt; of this action
4088 * describing to the user what it does.
4089 *
4090 * <p>The action of IntentFilter with this category is important in that it
4091 * describes the specific action the target will perform. This generally
4092 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4093 * a specific name such as "com.android.camera.action.CROP. Only one
4094 * alternative of any particular action will be shown to the user, so using
4095 * a specific action like this makes sure that your alternative will be
4096 * displayed while also allowing other applications to provide their own
4097 * overrides of that particular action.
4098 */
4099 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4100 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4101 /**
4102 * Set if the activity should be considered as an alternative selection
4103 * action to the data the user has currently selected. This is like
4104 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4105 * of items from which the user can select, giving them alternatives to the
4106 * default action that will be performed on it.
4107 */
4108 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4109 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4110 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004111 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004112 */
4113 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4114 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4115 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004116 * Should be displayed in the top-level launcher.
4117 */
4118 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4119 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4120 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004121 * Indicates an activity optimized for Leanback mode, and that should
4122 * be displayed in the Leanback launcher.
4123 */
4124 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4125 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4126 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004127 * Indicates the preferred entry-point activity when an application is launched from a Car
4128 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4129 * fallback, or exclude the application entirely.
4130 * @hide
4131 */
4132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4133 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4134 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004135 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4136 * @hide
4137 */
4138 @SystemApi
4139 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4140 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004141 * Provides information about the package it is in; typically used if
4142 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4143 * a front-door to the user without having to be shown in the all apps list.
4144 */
4145 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4146 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4147 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004148 * This is the home activity, that is the first activity that is displayed
4149 * when the device boots.
4150 */
4151 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4152 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4153 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004154 * This is the home activity that is displayed when the device is finished setting up and ready
4155 * for use.
4156 * @hide
4157 */
4158 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4159 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4160 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004161 * This is the setup wizard activity, that is the first activity that is displayed
4162 * when the user sets up the device for the first time.
4163 * @hide
4164 */
4165 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4166 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4167 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004168 * This is the home activity, that is the activity that serves as the launcher app
4169 * from there the user can start other apps. Often components with lower/higher
4170 * priority intent filters handle the home intent, for example SetupWizard, to
4171 * setup the device and we need to be able to distinguish the home app from these
4172 * setup helpers.
4173 * @hide
4174 */
4175 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4176 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4177 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004178 * This activity is a preference panel.
4179 */
4180 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4181 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4182 /**
4183 * This activity is a development preference panel.
4184 */
4185 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4186 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4187 /**
4188 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004189 */
4190 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4191 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4192 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004193 * This activity allows the user to browse and download new applications.
4194 */
4195 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4196 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4197 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004198 * This activity may be exercised by the monkey or other automated test tools.
4199 */
4200 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4201 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4202 /**
4203 * To be used as a test (not part of the normal user experience).
4204 */
4205 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4206 /**
4207 * To be used as a unit test (run through the Test Harness).
4208 */
4209 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4210 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004211 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004212 * experience).
4213 */
4214 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004215
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004216 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004217 * Used to indicate that an intent only wants URIs that can be opened with
4218 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4219 * must support at least the columns defined in {@link OpenableColumns} when
4220 * queried.
4221 *
4222 * @see #ACTION_GET_CONTENT
4223 * @see #ACTION_OPEN_DOCUMENT
4224 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004225 */
4226 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4227 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4228
4229 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004230 * Used to indicate that an intent filter can accept files which are not necessarily
4231 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4232 * at least streamable via
4233 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4234 * using one of the stream types exposed via
4235 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4236 *
4237 * @see #ACTION_SEND
4238 * @see #ACTION_SEND_MULTIPLE
4239 */
4240 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4241 public static final String CATEGORY_TYPED_OPENABLE =
4242 "android.intent.category.TYPED_OPENABLE";
4243
4244 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004245 * To be used as code under test for framework instrumentation tests.
4246 */
4247 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4248 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004249 /**
4250 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004251 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4252 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004253 */
4254 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4255 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4256 /**
4257 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004258 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4259 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004260 */
4261 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4262 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004263 /**
4264 * An activity to run when device is inserted into a analog (low end) dock.
4265 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4266 * information, see {@link android.app.UiModeManager}.
4267 */
4268 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4269 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4270
4271 /**
4272 * An activity to run when device is inserted into a digital (high end) dock.
4273 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4274 * information, see {@link android.app.UiModeManager}.
4275 */
4276 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4277 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004278
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004279 /**
4280 * Used to indicate that the activity can be used in a car environment.
4281 */
4282 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4283 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4284
Zak Cohendb6ca492017-01-26 14:09:00 -08004285 /**
4286 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4287 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4288 * information, see {@link android.app.UiModeManager}.
4289 */
4290 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4291 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004292 // ---------------------------------------------------------------------
4293 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004294 // Application launch intent categories (see addCategory()).
4295
4296 /**
4297 * Used with {@link #ACTION_MAIN} to launch the browser application.
4298 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004299 * <p>NOTE: This should not be used as the primary key of an Intent,
4300 * since it will not result in the app launching with the correct
4301 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004302 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004303 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004304 */
4305 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4306 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4307
4308 /**
4309 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4310 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004311 * <p>NOTE: This should not be used as the primary key of an Intent,
4312 * since it will not result in the app launching with the correct
4313 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004314 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004315 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004316 */
4317 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4318 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4319
4320 /**
4321 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4322 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004323 * <p>NOTE: This should not be used as the primary key of an Intent,
4324 * since it will not result in the app launching with the correct
4325 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004326 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004327 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004328 */
4329 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4330 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4331
4332 /**
4333 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4334 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004335 * <p>NOTE: This should not be used as the primary key of an Intent,
4336 * since it will not result in the app launching with the correct
4337 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004338 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004339 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004340 */
4341 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4342 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4343
4344 /**
4345 * Used with {@link #ACTION_MAIN} to launch the email application.
4346 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004347 * <p>NOTE: This should not be used as the primary key of an Intent,
4348 * since it will not result in the app launching with the correct
4349 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004350 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004351 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004352 */
4353 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4354 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4355
4356 /**
4357 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4358 * The activity should be able to view and manipulate image and video files
4359 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004360 * <p>NOTE: This should not be used as the primary key of an Intent,
4361 * since it will not result in the app launching with the correct
4362 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004363 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004364 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004365 */
4366 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4367 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4368
4369 /**
4370 * Used with {@link #ACTION_MAIN} to launch the maps application.
4371 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004372 * <p>NOTE: This should not be used as the primary key of an Intent,
4373 * since it will not result in the app launching with the correct
4374 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004375 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004376 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004377 */
4378 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4379 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4380
4381 /**
4382 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4383 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004384 * <p>NOTE: This should not be used as the primary key of an Intent,
4385 * since it will not result in the app launching with the correct
4386 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004387 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004388 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004389 */
4390 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4391 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4392
4393 /**
4394 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004395 * The activity should be able to play, browse, or manipulate music files
4396 * stored on the device.
4397 * <p>NOTE: This should not be used as the primary key of an Intent,
4398 * since it will not result in the app launching with the correct
4399 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004400 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004401 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004402 */
4403 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4404 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4405
4406 // ---------------------------------------------------------------------
4407 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004408 // Standard extra data keys.
4409
4410 /**
4411 * The initial data to place in a newly created record. Use with
4412 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4413 * fields as would be given to the underlying ContentProvider.insert()
4414 * call.
4415 */
4416 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4417
4418 /**
4419 * A constant CharSequence that is associated with the Intent, used with
4420 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4421 * this may be a styled CharSequence, so you must use
4422 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4423 * retrieve it.
4424 */
4425 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4426
4427 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004428 * A constant String that is associated with the Intent, used with
4429 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4430 * as HTML formatted text. Note that you <em>must</em> also supply
4431 * {@link #EXTRA_TEXT}.
4432 */
4433 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4434
4435 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004436 * A content: URI holding a stream of data associated with the Intent,
4437 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004438 */
4439 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4440
4441 /**
4442 * A String[] holding e-mail addresses that should be delivered to.
4443 */
4444 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4445
4446 /**
4447 * A String[] holding e-mail addresses that should be carbon copied.
4448 */
4449 public static final String EXTRA_CC = "android.intent.extra.CC";
4450
4451 /**
4452 * A String[] holding e-mail addresses that should be blind carbon copied.
4453 */
4454 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4455
4456 /**
4457 * A constant string holding the desired subject line of a message.
4458 */
4459 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4460
4461 /**
4462 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004463 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004464 */
4465 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4466
4467 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004468 * An int representing the user id to be used.
4469 *
4470 * @hide
4471 */
4472 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4473
4474 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004475 * An int representing the task id to be retrieved. This is used when a launch from recents is
4476 * intercepted by another action such as credentials confirmation to remember which task should
4477 * be resumed when complete.
4478 *
4479 * @hide
4480 */
4481 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4482
4483 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004484 * An Intent[] describing additional, alternate choices you would like shown with
4485 * {@link #ACTION_CHOOSER}.
4486 *
4487 * <p>An app may be capable of providing several different payload types to complete a
4488 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4489 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4490 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4491 * photo data or a hosted link where the photos can be viewed.</p>
4492 *
4493 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4494 * first/primary/preferred intent in the set. Additional intents specified in
4495 * this extra are ordered; by default intents that appear earlier in the array will be
4496 * preferred over intents that appear later in the array as matches for the same
4497 * target component. To alter this preference, a calling app may also supply
4498 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4499 */
4500 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4501
4502 /**
Adam Powell52c39212016-04-07 15:14:18 -07004503 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4504 * and omitted from a list of components presented to the user.
4505 *
4506 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4507 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4508 * from your own package or other apps from your organization if the idea of sending to those
4509 * targets would be redundant with other app functionality. Filtered components will not
4510 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4511 */
4512 public static final String EXTRA_EXCLUDE_COMPONENTS
4513 = "android.intent.extra.EXCLUDE_COMPONENTS";
4514
4515 /**
4516 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4517 * describing additional high-priority deep-link targets for the chooser to present to the user.
4518 *
4519 * <p>Targets provided in this way will be presented inline with all other targets provided
4520 * by services from other apps. They will be prioritized before other service targets, but
4521 * after those targets provided by sources that the user has manually pinned to the front.</p>
4522 *
4523 * @see #ACTION_CHOOSER
4524 */
4525 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4526
4527 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004528 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4529 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4530 *
4531 * <p>An app preparing an action for another app to complete may wish to allow the user to
4532 * disambiguate between several options for completing the action based on the chosen target
4533 * or otherwise refine the action before it is invoked.
4534 * </p>
4535 *
4536 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4537 * <ul>
4538 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4539 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4540 * chosen target beyond the first</li>
4541 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4542 * should fill in and send once the disambiguation is complete</li>
4543 * </ul>
4544 */
4545 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4546 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4547
4548 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004549 * An {@code ArrayList} of {@code String} annotations describing content for
4550 * {@link #ACTION_CHOOSER}.
4551 *
4552 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4553 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4554 *
4555 * <p>Annotations should describe the major components or topics of the content. It is up to
4556 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4557 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004558 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4559 * character. Performance on customized annotations can suffer, if they are rarely used for
4560 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4561 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004562 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004563 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004564 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004565 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004566 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004567 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004568 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004569 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004570 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004571 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4572 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4573 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4574 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4575 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004576 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004577 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4578 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004579 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004580 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004581 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004582 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004583 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004584 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004585 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004586 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004587 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004588 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004589 * Christmas and Thanksgiving.</li>
4590 * </ul>
4591 */
4592 public static final String EXTRA_CONTENT_ANNOTATIONS
4593 = "android.intent.extra.CONTENT_ANNOTATIONS";
4594
4595 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004596 * A {@link ResultReceiver} used to return data back to the sender.
4597 *
4598 * <p>Used to complete an app-specific
4599 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4600 *
4601 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4602 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4603 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4604 * when the user selects a target component from the chooser. It is up to the recipient
4605 * to send a result to this ResultReceiver to signal that disambiguation is complete
4606 * and that the chooser should invoke the user's choice.</p>
4607 *
4608 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4609 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4610 * to match and fill in the final Intent or ChooserTarget before starting it.
4611 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4612 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4613 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4614 *
4615 * <p>The result code passed to the ResultReceiver should be
4616 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4617 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4618 * the chooser should finish without starting a target.</p>
4619 */
4620 public static final String EXTRA_RESULT_RECEIVER
4621 = "android.intent.extra.RESULT_RECEIVER";
4622
4623 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004624 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004625 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004626 */
4627 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4628
4629 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004630 * A Parcelable[] of {@link Intent} or
4631 * {@link android.content.pm.LabeledIntent} objects as set with
4632 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4633 * a the front of the list of choices, when shown to the user with a
4634 * {@link #ACTION_CHOOSER}.
4635 */
4636 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4637
4638 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004639 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004640 * @hide
4641 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004642 @SystemApi
4643 public static final String EXTRA_INSTANT_APP_SUCCESS =
4644 "android.intent.extra.INSTANT_APP_SUCCESS";
4645
4646 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004647 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004648 * @hide
4649 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004650 @SystemApi
4651 public static final String EXTRA_INSTANT_APP_FAILURE =
4652 "android.intent.extra.INSTANT_APP_FAILURE";
4653
4654 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004655 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004656 * @hide
4657 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004658 @SystemApi
4659 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4660 "android.intent.extra.INSTANT_APP_HOSTNAME";
4661
4662 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004663 * An opaque token to track instant app resolution.
4664 * @hide
4665 */
4666 @SystemApi
4667 public static final String EXTRA_INSTANT_APP_TOKEN =
4668 "android.intent.extra.INSTANT_APP_TOKEN";
4669
4670 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004671 * The action that triggered an instant application resolution.
4672 * @hide
4673 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004674 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004675 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4676
4677 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004678 * An array of {@link Bundle}s containing details about resolved instant apps..
4679 * @hide
4680 */
4681 @SystemApi
4682 public static final String EXTRA_INSTANT_APP_BUNDLES =
4683 "android.intent.extra.INSTANT_APP_BUNDLES";
4684
4685 /**
4686 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004687 * installed. This data is populated from the response to
4688 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4689 * instant application resolver.
4690 * @hide
4691 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004692 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004693 public static final String EXTRA_INSTANT_APP_EXTRAS =
4694 "android.intent.extra.INSTANT_APP_EXTRAS";
4695
4696 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004697 * A boolean value indicating that the instant app resolver was unable to state with certainty
4698 * that it did or did not have an app for the sanitized {@link Intent} defined at
4699 * {@link #EXTRA_INTENT}.
4700 * @hide
4701 */
4702 @SystemApi
4703 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4704 "android.intent.extra.UNKNOWN_INSTANT_APP";
4705
4706 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004707 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004708 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004709 * @hide
4710 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004711 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004712 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4713
4714 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004715 * The version code of the app to install components from.
4716 * @hide
4717 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004718 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004719 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4720
4721 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004722 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004723 * @hide
4724 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004725 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004726 public static final String EXTRA_CALLING_PACKAGE
4727 = "android.intent.extra.CALLING_PACKAGE";
4728
4729 /**
4730 * Optional calling app provided bundle containing additional launch information the
4731 * installer may use.
4732 * @hide
4733 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004734 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004735 public static final String EXTRA_VERIFICATION_BUNDLE
4736 = "android.intent.extra.VERIFICATION_BUNDLE";
4737
4738 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004739 * A Bundle forming a mapping of potential target package names to different extras Bundles
4740 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4741 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4742 * be currently installed on the device.
4743 *
4744 * <p>An application may choose to provide alternate extras for the case where a user
4745 * selects an activity from a predetermined set of target packages. If the activity
4746 * the user selects from the chooser belongs to a package with its package name as
4747 * a key in this bundle, the corresponding extras for that package will be merged with
4748 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4749 * extra has the same key as an extra already present in the intent it will overwrite
4750 * the extra from the intent.</p>
4751 *
4752 * <p><em>Examples:</em>
4753 * <ul>
4754 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4755 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4756 * parameters for that target.</li>
4757 * <li>An application may offer additional metadata for known targets of a given intent
4758 * to pass along information only relevant to that target such as account or content
4759 * identifiers already known to that application.</li>
4760 * </ul></p>
4761 */
4762 public static final String EXTRA_REPLACEMENT_EXTRAS =
4763 "android.intent.extra.REPLACEMENT_EXTRAS";
4764
4765 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004766 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4767 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4768 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4769 * {@link ComponentName} of the chosen component.
4770 *
4771 * <p>In some situations this callback may never come, for example if the user abandons
4772 * the chooser, switches to another task or any number of other reasons. Apps should not
4773 * be written assuming that this callback will always occur.</p>
4774 */
4775 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4776 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4777
4778 /**
4779 * The {@link ComponentName} chosen by the user to complete an action.
4780 *
4781 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4782 */
4783 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4784
4785 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004786 * A {@link android.view.KeyEvent} object containing the event that
4787 * triggered the creation of the Intent it is in.
4788 */
4789 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4790
4791 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004792 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4793 * before shutting down.
4794 *
4795 * {@hide}
4796 */
4797 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4798
4799 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004800 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4801 * requested by the user.
4802 *
4803 * {@hide}
4804 */
4805 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4806 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4807
4808 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004809 * 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 -07004810 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4811 * of restarting the application.
4812 */
4813 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4814
4815 /**
4816 * A String holding the phone number originally entered in
4817 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4818 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4819 */
4820 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004821
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004822 /**
4823 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4824 * intents to supply the uid the package had been assigned. Also an optional
4825 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4826 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4827 * purpose.
4828 */
4829 public static final String EXTRA_UID = "android.intent.extra.UID";
4830
4831 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004832 * @hide String array of package names.
4833 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004834 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004835 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4836
4837 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004838 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4839 * intents to indicate whether this represents a full uninstall (removing
4840 * both the code and its data) or a partial uninstall (leaving its data,
4841 * implying that this is an update).
4842 */
4843 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004844
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004845 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004846 * @hide
4847 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4848 * intents to indicate that at this point the package has been removed for
4849 * all users on the device.
4850 */
4851 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4852 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4853
4854 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004855 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4856 * intents to indicate that this is a replacement of the package, so this
4857 * broadcast will immediately be followed by an add broadcast for a
4858 * different version of the same package.
4859 */
4860 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004861
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004862 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004863 * Used as an int extra field in {@link android.app.AlarmManager} intents
4864 * to tell the application being invoked how many pending alarms are being
4865 * delievered with the intent. For one-shot alarms this will always be 1.
4866 * For recurring alarms, this might be greater than 1 if the device was
4867 * asleep or powered off at the time an earlier alarm would have been
4868 * delivered.
4869 */
4870 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004871
Jacek Surazski86b6c532009-05-13 14:38:28 +02004872 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004873 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4874 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004875 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4876 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004877 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4878 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4879 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004880 */
4881 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4882
4883 /**
4884 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4885 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004886 */
4887 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4888
4889 /**
4890 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4891 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004892 */
4893 public static final int EXTRA_DOCK_STATE_DESK = 1;
4894
4895 /**
4896 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4897 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004898 */
4899 public static final int EXTRA_DOCK_STATE_CAR = 2;
4900
4901 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004902 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4903 * to represent that the phone is in a analog (low end) dock.
4904 */
4905 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4906
4907 /**
4908 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4909 * to represent that the phone is in a digital (high end) dock.
4910 */
4911 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4912
4913 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004914 * Boolean that can be supplied as meta-data with a dock activity, to
4915 * indicate that the dock should take over the home key when it is active.
4916 */
4917 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004918
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004919 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004920 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4921 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004922 */
4923 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4924
4925 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004926 * Used in the extra field in the remote intent. It's astring token passed with the
4927 * remote intent.
4928 */
4929 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4930 "android.intent.extra.remote_intent_token";
4931
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004932 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004933 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004934 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004935 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004936 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004937 "android.intent.extra.changed_component_name";
4938
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004939 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004940 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004941 * and contains a string array of all of the components that have changed. If
4942 * the state of the overall package has changed, then it will contain an entry
4943 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004944 */
4945 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4946 "android.intent.extra.changed_component_name_list";
4947
4948 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004949 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004950 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004951 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4952 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4953 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004954 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004955 */
4956 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4957 "android.intent.extra.changed_package_list";
4958
4959 /**
4960 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004961 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4962 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004963 * and contains an integer array of uids of all of the components
4964 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004965 */
4966 public static final String EXTRA_CHANGED_UID_LIST =
4967 "android.intent.extra.changed_uid_list";
4968
4969 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004970 * @hide
4971 * Magic extra system code can use when binding, to give a label for
4972 * who it is that has bound to a service. This is an integer giving
4973 * a framework string resource that can be displayed to the user.
4974 */
4975 public static final String EXTRA_CLIENT_LABEL =
4976 "android.intent.extra.client_label";
4977
4978 /**
4979 * @hide
4980 * Magic extra system code can use when binding, to give a PendingIntent object
4981 * that can be launched for the user to disable the system's use of this
4982 * service.
4983 */
4984 public static final String EXTRA_CLIENT_INTENT =
4985 "android.intent.extra.client_intent";
4986
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004987 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004988 * Extra used to indicate that an intent should only return data that is on
4989 * the local device. This is a boolean extra; the default is false. If true,
4990 * an implementation should only allow the user to select data that is
4991 * already on the device, not requiring it be downloaded from a remote
4992 * service when opened.
4993 *
4994 * @see #ACTION_GET_CONTENT
4995 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07004996 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004997 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08004998 */
4999 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005000 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005001
Amith Yamasani13593602012-03-22 16:16:17 -07005002 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005003 * Extra used to indicate that an intent can allow the user to select and
5004 * return multiple items. This is a boolean extra; the default is false. If
5005 * true, an implementation is allowed to present the user with a UI where
5006 * they can pick multiple items that are all returned to the caller. When
5007 * this happens, they should be returned as the {@link #getClipData()} part
5008 * of the result Intent.
5009 *
5010 * @see #ACTION_GET_CONTENT
5011 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005012 */
5013 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005014 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005015
5016 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005017 * The integer userHandle carried with broadcast intents related to addition, removal and
5018 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5019 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5020 *
Amith Yamasani13593602012-03-22 16:16:17 -07005021 * @hide
5022 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005023 public static final String EXTRA_USER_HANDLE =
5024 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005025
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005026 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005027 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005028 */
5029 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005030 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005031
5032 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005033 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005034 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5035 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005036 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005037 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5038
5039 /**
5040 * Extra sent in the intent to the BroadcastReceiver that handles
5041 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5042 * the restrictions as key/value pairs.
5043 */
5044 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5045 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005046
Amith Yamasani86118ba2013-03-28 14:33:16 -07005047 /**
5048 * Extra used in the response from a BroadcastReceiver that handles
5049 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5050 */
5051 public static final String EXTRA_RESTRICTIONS_INTENT =
5052 "android.intent.extra.restrictions_intent";
5053
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005054 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005055 * Extra used to communicate a set of acceptable MIME types. The type of the
5056 * extra is {@code String[]}. Values may be a combination of concrete MIME
5057 * types (such as "image/png") and/or partial MIME types (such as
5058 * "audio/*").
5059 *
5060 * @see #ACTION_GET_CONTENT
5061 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005062 */
5063 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5064
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005065 /**
5066 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5067 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005068 * When this is true, hardware devices can use this information to determine that
5069 * they shouldn't do a complete shutdown of their device since this is not a
5070 * complete shutdown down to the kernel, but only user space restarting.
5071 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005072 */
5073 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5074 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5075
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005076 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005077 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5078 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5079 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5080 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005081 *
5082 * @hide for internal use only.
5083 */
5084 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5085 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005086 /** @hide */
5087 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5088 /** @hide */
5089 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5090 /** @hide */
5091 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005092
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005093 /**
5094 * Intent extra: the reason that the operation associated with this intent is being performed.
5095 *
5096 * <p>Type: String
5097 * @hide
5098 */
5099 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005100 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5101
qingxi240c2bb2017-04-12 17:31:18 -07005102 /**
5103 * {@hide}
5104 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5105 */
Rubin Xue8490f12015-06-25 12:17:48 +01005106 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5107
Santos Cordon15a13782015-03-31 18:32:31 -07005108 /**
qingxi240c2bb2017-04-12 17:31:18 -07005109 * {@hide}
5110 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5111 * reset for the device with eSIM. This extra will be sent together with
5112 * {@link #ACTION_FACTORY_RESET}
5113 */
5114 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5115
5116 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005117 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5118 * activation request.
5119 * TODO: Add information about the structure and response data used with the pending intent.
5120 * @hide
5121 */
5122 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5123 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5124
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005125 /**
5126 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005127 *
5128 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005129 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005130 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005131 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5132
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005133 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005134 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5135 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5136 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005137 *
5138 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005139 * @see #ACTION_QUICK_VIEW
5140 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005141 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005142 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005143 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5144 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005145
5146 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005147 * An optional extra of {@code String[]} indicating which quick view features should be made
5148 * available to the user in the quick view UI while handing a
5149 * {@link Intent#ACTION_QUICK_VIEW} intent.
5150 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5151 * Quick viewer can implement features not listed below.
5152 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005153 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5154 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5155 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005156 * <p>
5157 * Requirements:
5158 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5159 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5160 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5161 * internal policies.
5162 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5163 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5164 * disable or hide features.
5165 *
5166 * @see #ACTION_QUICK_VIEW
5167 */
5168 public static final String EXTRA_QUICK_VIEW_FEATURES =
5169 "android.intent.extra.QUICK_VIEW_FEATURES";
5170
5171 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005172 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005173 * When a profile goes into quiet mode, all apps in the profile are killed and the
5174 * profile user is stopped. Widgets originating from the profile are masked, and app
5175 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005176 */
5177 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005178
5179 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005180 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005181 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005182 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5183 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005184 *
5185 * @hide
5186 */
5187 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5188 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5189
5190 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005191 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5192 * whether to show the chooser or not when there is only one application available
5193 * to choose from.
5194 *
5195 * @hide
5196 */
5197 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5198 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5199
5200 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005201 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005202 * to represent that a video codec is allowed to use.
5203 *
5204 * @hide
5205 */
5206 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5207
5208 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005209 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005210 * to represent that a audio codec is allowed to use.
5211 *
5212 * @hide
5213 */
5214 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5215
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005216 // ---------------------------------------------------------------------
5217 // ---------------------------------------------------------------------
5218 // Intent flags (see mFlags variable).
5219
Tor Norbyed9273d62013-05-30 15:59:53 -07005220 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005221 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005222 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5223 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005224 @Retention(RetentionPolicy.SOURCE)
5225 public @interface GrantUriMode {}
5226
Jeff Sharkey846318a2014-04-04 12:12:41 -07005227 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005228 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005229 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5230 @Retention(RetentionPolicy.SOURCE)
5231 public @interface AccessUriMode {}
5232
5233 /**
5234 * Test if given mode flags specify an access mode, which must be at least
5235 * read and/or write.
5236 *
5237 * @hide
5238 */
5239 public static boolean isAccessUriMode(int modeFlags) {
5240 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5241 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5242 }
5243
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005244 /** @hide */
5245 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5246 FLAG_GRANT_READ_URI_PERMISSION,
5247 FLAG_GRANT_WRITE_URI_PERMISSION,
5248 FLAG_FROM_BACKGROUND,
5249 FLAG_DEBUG_LOG_RESOLUTION,
5250 FLAG_EXCLUDE_STOPPED_PACKAGES,
5251 FLAG_INCLUDE_STOPPED_PACKAGES,
5252 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5253 FLAG_GRANT_PREFIX_URI_PERMISSION,
5254 FLAG_DEBUG_TRIAGED_MISSING,
5255 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005256 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005257 FLAG_ACTIVITY_NO_HISTORY,
5258 FLAG_ACTIVITY_SINGLE_TOP,
5259 FLAG_ACTIVITY_NEW_TASK,
5260 FLAG_ACTIVITY_MULTIPLE_TASK,
5261 FLAG_ACTIVITY_CLEAR_TOP,
5262 FLAG_ACTIVITY_FORWARD_RESULT,
5263 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5264 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5265 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5266 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5267 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5268 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5269 FLAG_ACTIVITY_NEW_DOCUMENT,
5270 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5271 FLAG_ACTIVITY_NO_USER_ACTION,
5272 FLAG_ACTIVITY_REORDER_TO_FRONT,
5273 FLAG_ACTIVITY_NO_ANIMATION,
5274 FLAG_ACTIVITY_CLEAR_TASK,
5275 FLAG_ACTIVITY_TASK_ON_HOME,
5276 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5277 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5278 FLAG_RECEIVER_REGISTERED_ONLY,
5279 FLAG_RECEIVER_REPLACE_PENDING,
5280 FLAG_RECEIVER_FOREGROUND,
5281 FLAG_RECEIVER_NO_ABORT,
5282 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5283 FLAG_RECEIVER_BOOT_UPGRADE,
5284 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5285 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5286 FLAG_RECEIVER_FROM_SHELL,
5287 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5288 })
5289 @Retention(RetentionPolicy.SOURCE)
5290 public @interface Flags {}
5291
5292 /** @hide */
5293 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5294 FLAG_FROM_BACKGROUND,
5295 FLAG_DEBUG_LOG_RESOLUTION,
5296 FLAG_EXCLUDE_STOPPED_PACKAGES,
5297 FLAG_INCLUDE_STOPPED_PACKAGES,
5298 FLAG_DEBUG_TRIAGED_MISSING,
5299 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005300 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005301 FLAG_ACTIVITY_NO_HISTORY,
5302 FLAG_ACTIVITY_SINGLE_TOP,
5303 FLAG_ACTIVITY_NEW_TASK,
5304 FLAG_ACTIVITY_MULTIPLE_TASK,
5305 FLAG_ACTIVITY_CLEAR_TOP,
5306 FLAG_ACTIVITY_FORWARD_RESULT,
5307 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5308 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5309 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5310 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5311 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5312 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5313 FLAG_ACTIVITY_NEW_DOCUMENT,
5314 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5315 FLAG_ACTIVITY_NO_USER_ACTION,
5316 FLAG_ACTIVITY_REORDER_TO_FRONT,
5317 FLAG_ACTIVITY_NO_ANIMATION,
5318 FLAG_ACTIVITY_CLEAR_TASK,
5319 FLAG_ACTIVITY_TASK_ON_HOME,
5320 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5321 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5322 FLAG_RECEIVER_REGISTERED_ONLY,
5323 FLAG_RECEIVER_REPLACE_PENDING,
5324 FLAG_RECEIVER_FOREGROUND,
5325 FLAG_RECEIVER_NO_ABORT,
5326 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5327 FLAG_RECEIVER_BOOT_UPGRADE,
5328 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5329 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5330 FLAG_RECEIVER_FROM_SHELL,
5331 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5332 })
5333 @Retention(RetentionPolicy.SOURCE)
5334 public @interface MutableFlags {}
5335
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005336 /**
5337 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005338 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005339 * specified in its ClipData. When applying to an Intent's ClipData,
5340 * all URIs as well as recursive traversals through data or other ClipData
5341 * in Intent items will be granted; only the grant flags of the top-level
5342 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005343 */
5344 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5345 /**
5346 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005347 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005348 * specified in its ClipData. When applying to an Intent's ClipData,
5349 * all URIs as well as recursive traversals through data or other ClipData
5350 * in Intent items will be granted; only the grant flags of the top-level
5351 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005352 */
5353 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5354 /**
5355 * Can be set by the caller to indicate that this Intent is coming from
5356 * a background operation, not from direct user interaction.
5357 */
5358 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5359 /**
5360 * A flag you can enable for debugging: when set, log messages will be
5361 * printed during the resolution of this intent to show you what has
5362 * been found to create the final resolved list.
5363 */
5364 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005365 /**
5366 * If set, this intent will not match any components in packages that
5367 * are currently stopped. If this is not set, then the default behavior
5368 * is to include such applications in the result.
5369 */
5370 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5371 /**
5372 * If set, this intent will always match any components in packages that
5373 * are currently stopped. This is the default behavior when
5374 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5375 * flags are set, this one wins (it allows overriding of exclude for
5376 * places where the framework may automatically set the exclude flag).
5377 */
5378 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005379
5380 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005381 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005382 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005383 * persisted across device reboots until explicitly revoked with
5384 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5385 * grant for possible persisting; the receiving application must call
5386 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5387 * actually persist.
5388 *
5389 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5390 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5391 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005392 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005393 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005394 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005395
5396 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005397 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5398 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5399 * applies to any URI that is a prefix match against the original granted
5400 * URI. (Without this flag, the URI must match exactly for access to be
5401 * granted.) Another URI is considered a prefix match only when scheme,
5402 * authority, and all path segments defined by the prefix are an exact
5403 * match.
5404 */
5405 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5406
5407 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005408 * Flag used to automatically match intents based on their Direct Boot
5409 * awareness and the current user state.
5410 * <p>
5411 * Since the default behavior is to automatically apply the current user
5412 * state, this is effectively a sentinel value that doesn't change the
5413 * output of any queries based on its presence or absence.
5414 * <p>
5415 * Instead, this value can be useful in conjunction with
5416 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5417 * to detect when a caller is relying on implicit automatic matching,
5418 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005419 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005420 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5421
5422 /** {@hide} */
5423 @Deprecated
5424 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005425
5426 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005427 * Internal flag used to indicate ephemeral applications should not be
5428 * considered when resolving the intent.
5429 *
5430 * @hide
5431 */
5432 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5433
5434 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005435 * If set, the new activity is not kept in the history stack. As soon as
5436 * the user navigates away from it, the activity is finished. This may also
5437 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5438 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005439 *
5440 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5441 * is never invoked when the current activity starts a new activity which
5442 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005443 */
5444 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5445 /**
5446 * If set, the activity will not be launched if it is already running
5447 * at the top of the history stack.
5448 */
5449 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5450 /**
5451 * If set, this activity will become the start of a new task on this
5452 * history stack. A task (from the activity that started it to the
5453 * next task activity) defines an atomic group of activities that the
5454 * user can move to. Tasks can be moved to the foreground and background;
5455 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005456 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005457 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5458 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005459 *
5460 * <p>This flag is generally used by activities that want
5461 * to present a "launcher" style behavior: they give the user a list of
5462 * separate things that can be done, which otherwise run completely
5463 * independently of the activity launching them.
5464 *
5465 * <p>When using this flag, if a task is already running for the activity
5466 * you are now starting, then a new activity will not be started; instead,
5467 * the current task will simply be brought to the front of the screen with
5468 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5469 * to disable this behavior.
5470 *
5471 * <p>This flag can not be used when the caller is requesting a result from
5472 * the activity being launched.
5473 */
5474 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5475 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005476 * This flag is used to create a new task and launch an activity into it.
5477 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5478 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5479 * search through existing tasks for ones matching this Intent. Only if no such
5480 * task is found would a new task be created. When paired with
5481 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5482 * the search for a matching task and unconditionally start a new task.
5483 *
5484 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5485 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005486 * top-level application launcher.</strong> Used in conjunction with
5487 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5488 * behavior of bringing an existing task to the foreground. When set,
5489 * a new task is <em>always</em> started to host the Activity for the
5490 * Intent, regardless of whether there is already an existing task running
5491 * the same thing.
5492 *
5493 * <p><strong>Because the default system does not include graphical task management,
5494 * you should not use this flag unless you provide some way for a user to
5495 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005496 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005497 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5498 * creating new document tasks.
5499 *
5500 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005501 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005502 *
Scott Main7aee61f2011-02-08 11:25:01 -08005503 * <p>See
5504 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5505 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005506 *
5507 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5508 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005509 */
5510 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5511 /**
5512 * If set, and the activity being launched is already running in the
5513 * current task, then instead of launching a new instance of that activity,
5514 * all of the other activities on top of it will be closed and this Intent
5515 * will be delivered to the (now on top) old activity as a new Intent.
5516 *
5517 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5518 * If D calls startActivity() with an Intent that resolves to the component
5519 * of activity B, then C and D will be finished and B receive the given
5520 * Intent, resulting in the stack now being: A, B.
5521 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005522 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005523 * either receive the new intent you are starting here in its
5524 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005525 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005526 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5527 * the same intent, then it will be finished and re-created; for all other
5528 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5529 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005530 *
5531 * <p>This launch mode can also be used to good effect in conjunction with
5532 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5533 * of a task, it will bring any currently running instance of that task
5534 * to the foreground, and then clear it to its root state. This is
5535 * especially useful, for example, when launching an activity from the
5536 * notification manager.
5537 *
Scott Main7aee61f2011-02-08 11:25:01 -08005538 * <p>See
5539 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5540 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005541 */
5542 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5543 /**
5544 * If set and this intent is being used to launch a new activity from an
5545 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005546 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005547 * {@link android.app.Activity#setResult} and have that result sent back to
5548 * the reply target of the original activity.
5549 */
5550 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5551 /**
5552 * If set and this intent is being used to launch a new activity from an
5553 * existing one, the current activity will not be counted as the top
5554 * activity for deciding whether the new intent should be delivered to
5555 * the top instead of starting a new one. The previous activity will
5556 * be used as the top, with the assumption being that the current activity
5557 * will finish itself immediately.
5558 */
5559 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5560 /**
5561 * If set, the new activity is not kept in the list of recently launched
5562 * activities.
5563 */
5564 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5565 /**
5566 * This flag is not normally set by application code, but set for you by
5567 * the system as described in the
5568 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5569 * launchMode} documentation for the singleTask mode.
5570 */
5571 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5572 /**
5573 * If set, and this activity is either being started in a new task or
5574 * bringing to the top an existing task, then it will be launched as
5575 * the front door of the task. This will result in the application of
5576 * any affinities needed to have that task in the proper state (either
5577 * moving activities to or from it), or simply resetting that task to
5578 * its initial state if needed.
5579 */
5580 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5581 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005582 * This flag is not normally set by application code, but set for you by
5583 * the system if this activity is being launched from history
5584 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005585 */
5586 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005587 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005588 * @deprecated As of API 21 this performs identically to
5589 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005590 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005591 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005592 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005593 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005594 * This flag is used to open a document into a new task rooted at the activity launched
5595 * by this Intent. Through the use of this flag, or its equivalent attribute,
5596 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005597 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005598 *
Craig Mautner026596b2014-05-21 15:35:44 -07005599 * <p>The use of the activity attribute form of this,
5600 * {@link android.R.attr#documentLaunchMode}, is
5601 * preferred over the Intent flag described here. The attribute form allows the
5602 * Activity to specify multiple document behavior for all launchers of the Activity
5603 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005604 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005605 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5606 * it is kept after the activity is finished is different than the use of
5607 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5608 * this flag is being used to create a new recents entry, then by default that entry
5609 * will be removed once the activity is finished. You can modify this behavior with
5610 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5611 *
Craig Mautner026596b2014-05-21 15:35:44 -07005612 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5613 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5614 * equivalent of the Activity manifest specifying {@link
5615 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5616 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5617 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005618 *
Craig Mautner026596b2014-05-21 15:35:44 -07005619 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005620 *
Craig Mautner026596b2014-05-21 15:35:44 -07005621 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005622 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5623 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005624 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005625 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005626 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005627 * callback from occurring on the current frontmost activity before it is
5628 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005629 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005630 * <p>Typically, an activity can rely on that callback to indicate that an
5631 * explicit user action has caused their activity to be moved out of the
5632 * foreground. The callback marks an appropriate point in the activity's
5633 * lifecycle for it to dismiss any notifications that it intends to display
5634 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005635 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005636 * <p>If an activity is ever started via any non-user-driven events such as
5637 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5638 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005639 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005640 */
5641 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005642 /**
5643 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5644 * this flag will cause the launched activity to be brought to the front of its
5645 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005646 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005647 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5648 * If D calls startActivity() with an Intent that resolves to the component
5649 * of activity B, then B will be brought to the front of the history stack,
5650 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005651 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005652 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005653 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005654 */
5655 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005656 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005657 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5658 * this flag will prevent the system from applying an activity transition
5659 * animation to go to the next activity state. This doesn't mean an
5660 * animation will never run -- if another activity change happens that doesn't
5661 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005662 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005663 * when you are going to do a series of activity operations but the
5664 * animation seen by the user shouldn't be driven by the first activity
5665 * change but rather a later one.
5666 */
5667 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5668 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005669 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5670 * this flag will cause any existing task that would be associated with the
5671 * activity to be cleared before the activity is started. That is, the activity
5672 * becomes the new root of an otherwise empty task, and any old activities
5673 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5674 */
5675 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5676 /**
5677 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5678 * this flag will cause a newly launching task to be placed on top of the current
5679 * home activity task (if there is one). That is, pressing back from the task
5680 * will always return the user to home even if that was not the last activity they
5681 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5682 */
5683 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5684 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005685 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5686 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005687 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005688 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005689 * this flag. When set and the task's activity is finished, the recents
5690 * entry will remain in the interface for the user to re-launch it, like a
5691 * recents entry for a top-level application.
5692 * <p>
5693 * The receiving activity can override this request with
5694 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5695 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005696 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005697 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005698 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005699
5700 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005701 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5702 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005703 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5704 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005705 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005706 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005707
Patrick Baumann577d4022018-01-31 16:55:10 +00005708
5709 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005710 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5711 * this flag will attempt to launch an instant app if no full app on the device can already
5712 * handle the intent.
5713 * <p>
5714 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5715 * are supported:
5716 * <ul>
5717 * <li>{@link Intent#setAction(String)}</li>
5718 * <li>{@link Intent#addCategory(String)}</li>
5719 * <li>{@link Intent#setData(Uri)}</li>
5720 * <li>{@link Intent#setType(String)}</li>
5721 * <li>{@link Intent#setPackage(String)}</li>
5722 * <li>{@link Intent#addFlags(int)}</li>
5723 * </ul>
5724 * <p>
5725 * In the case that no instant app can be found, the installer will be launched to notify the
5726 * user that the intent could not be resolved. On devices that do not support instant apps,
5727 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005728 */
5729 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5730
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005731 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005732 * If set, when sending a broadcast only registered receivers will be
5733 * called -- no BroadcastReceiver components will be launched.
5734 */
5735 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005736 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005737 * If set, when sending a broadcast the new broadcast will replace
5738 * any existing pending broadcast that matches it. Matching is defined
5739 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5740 * true for the intents of the two broadcasts. When a match is found,
5741 * the new broadcast (and receivers associated with it) will replace the
5742 * existing one in the pending broadcast list, remaining at the same
5743 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005744 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005745 * <p>This flag is most typically used with sticky broadcasts, which
5746 * only care about delivering the most recent values of the broadcast
5747 * to their receivers.
5748 */
5749 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5750 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005751 * If set, when sending a broadcast the recipient is allowed to run at
5752 * foreground priority, with a shorter timeout interval. During normal
5753 * broadcasts the receivers are not automatically hoisted out of the
5754 * background priority class.
5755 */
5756 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5757 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005758 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5759 * They can still propagate results through to later receivers, but they can not prevent
5760 * later receivers from seeing the broadcast.
5761 */
5762 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5763 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005764 * If set, when sending a broadcast <i>before boot has completed</i> only
5765 * registered receivers will be called -- no BroadcastReceiver components
5766 * will be launched. Sticky intent state will be recorded properly even
5767 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5768 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005769 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005770 * <p>This flag is only for use by system sevices as a convenience to
5771 * avoid having to implement a more complex mechanism around detection
5772 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005773 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005774 * @hide
5775 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005776 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005777 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005778 /**
5779 * Set when this broadcast is for a boot upgrade, a special mode that
5780 * allows the broadcast to be sent before the system is ready and launches
5781 * the app process with no providers running in it.
5782 * @hide
5783 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005784 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005785 /**
5786 * If set, the broadcast will always go to manifest receivers in background (cached
5787 * or not running) apps, regardless of whether that would be done by default. By
5788 * default they will only receive broadcasts if the broadcast has specified an
5789 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005790 *
5791 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5792 * the broadcast code there must also be changed to match.
5793 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005794 * @hide
5795 */
5796 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5797 /**
5798 * If set, the broadcast will never go to manifest receivers in background (cached
5799 * or not running) apps, regardless of whether that would be done by default. By
5800 * default they will receive broadcasts if the broadcast has specified an
5801 * explicit component or package name.
5802 * @hide
5803 */
5804 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005805 /**
5806 * If set, this broadcast is being sent from the shell.
5807 * @hide
5808 */
5809 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005810
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005811 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005812 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5813 * will not receive broadcasts.
5814 *
5815 * <em>This flag has no effect when used by an Instant App.</em>
5816 */
5817 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5818
5819 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005820 * @hide Flags that can't be changed with PendingIntent.
5821 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005822 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5823 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5824 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005825
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005826 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005827 // ---------------------------------------------------------------------
5828 // toUri() and parseUri() options.
5829
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005830 /** @hide */
5831 @IntDef(flag = true, prefix = { "URI_" }, value = {
5832 URI_ALLOW_UNSAFE,
5833 URI_ANDROID_APP_SCHEME,
5834 URI_INTENT_SCHEME,
5835 })
5836 @Retention(RetentionPolicy.SOURCE)
5837 public @interface UriFlags {}
5838
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005839 /**
5840 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5841 * always has the "intent:" scheme. This syntax can be used when you want
5842 * to later disambiguate between URIs that are intended to describe an
5843 * Intent vs. all others that should be treated as raw URIs. When used
5844 * with {@link #parseUri}, any other scheme will result in a generic
5845 * VIEW action for that raw URI.
5846 */
5847 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005848
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005849 /**
5850 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5851 * always has the "android-app:" scheme. This is a variation of
5852 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5853 * http/https URI being delivered to a specific package name. The format
5854 * is:
5855 *
5856 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005857 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005858 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005859 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5860 * you must also include a scheme; including a path also requires both a host and a scheme.
5861 * The final #Intent; fragment can be used without a scheme, host, or path.
5862 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005863 * used with intents that have a {@link #setSelector}, since the base intent
5864 * will always have an explicit package name.</p>
5865 *
5866 * <p>Some examples of how this scheme maps to Intent objects:</p>
5867 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5868 * <colgroup align="left" />
5869 * <colgroup align="left" />
5870 * <thead>
5871 * <tr><th>URI</th> <th>Intent</th></tr>
5872 * </thead>
5873 *
5874 * <tbody>
5875 * <tr><td><code>android-app://com.example.app</code></td>
5876 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5877 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5878 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5879 * </table></td>
5880 * </tr>
5881 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5882 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5883 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5884 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5885 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5886 * </table></td>
5887 * </tr>
5888 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5889 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5890 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5891 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5892 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5893 * </table></td>
5894 * </tr>
5895 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5896 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5897 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5898 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5899 * </table></td>
5900 * </tr>
5901 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5902 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5903 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5904 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5905 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5906 * </table></td>
5907 * </tr>
5908 * <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>
5909 * <td><table border="" style="margin:0" >
5910 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5911 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5912 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5913 * </table></td>
5914 * </tr>
5915 * </tbody>
5916 * </table>
5917 */
5918 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5919
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005920 /**
5921 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5922 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5923 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5924 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5925 * generated Intent can not cause unexpected data access to happen.
5926 *
5927 * <p>If you do not trust the source of the URI being parsed, you should still do further
5928 * processing to protect yourself from it. In particular, when using it to start an
5929 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5930 * that can handle it.</p>
5931 */
5932 public static final int URI_ALLOW_UNSAFE = 1<<2;
5933
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005934 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005935
5936 private String mAction;
5937 private Uri mData;
5938 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005939 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005940 private ComponentName mComponent;
5941 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005942 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005943 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005944 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005945 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005946 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005947 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005948 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005949 /** Token to track instant app launches. Local only; do not copy cross-process. */
5950 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005951
5952 // ---------------------------------------------------------------------
5953
Makoto Onuki97f82f22017-05-31 16:20:21 -07005954 private static final int COPY_MODE_ALL = 0;
5955 private static final int COPY_MODE_FILTER = 1;
5956 private static final int COPY_MODE_HISTORY = 2;
5957
5958 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005959 @IntDef(prefix = { "COPY_MODE_" }, value = {
5960 COPY_MODE_ALL,
5961 COPY_MODE_FILTER,
5962 COPY_MODE_HISTORY
5963 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005964 @Retention(RetentionPolicy.SOURCE)
5965 public @interface CopyMode {}
5966
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005967 /**
5968 * Create an empty intent.
5969 */
5970 public Intent() {
5971 }
5972
5973 /**
5974 * Copy constructor.
5975 */
5976 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005977 this(o, COPY_MODE_ALL);
5978 }
5979
5980 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005981 this.mAction = o.mAction;
5982 this.mData = o.mData;
5983 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005984 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005985 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07005986
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005987 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07005988 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005989 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07005990
5991 if (copyMode != COPY_MODE_FILTER) {
5992 this.mFlags = o.mFlags;
5993 this.mContentUserHint = o.mContentUserHint;
5994 this.mLaunchToken = o.mLaunchToken;
5995 if (o.mSourceBounds != null) {
5996 this.mSourceBounds = new Rect(o.mSourceBounds);
5997 }
5998 if (o.mSelector != null) {
5999 this.mSelector = new Intent(o.mSelector);
6000 }
6001
6002 if (copyMode != COPY_MODE_HISTORY) {
6003 if (o.mExtras != null) {
6004 this.mExtras = new Bundle(o.mExtras);
6005 }
6006 if (o.mClipData != null) {
6007 this.mClipData = new ClipData(o.mClipData);
6008 }
6009 } else {
6010 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6011 this.mExtras = Bundle.STRIPPED;
6012 }
6013
6014 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6015 // history.
6016 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006017 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006018 }
6019
6020 @Override
6021 public Object clone() {
6022 return new Intent(this);
6023 }
6024
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006025 /**
6026 * Make a clone of only the parts of the Intent that are relevant for
6027 * filter matching: the action, data, type, component, and categories.
6028 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006029 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006030 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006031 }
6032
6033 /**
6034 * Create an intent with a given action. All other fields (data, type,
6035 * class) are null. Note that the action <em>must</em> be in a
6036 * namespace because Intents are used globally in the system -- for
6037 * example the system VIEW action is android.intent.action.VIEW; an
6038 * application's custom action would be something like
6039 * com.google.app.myapp.CUSTOM_ACTION.
6040 *
6041 * @param action The Intent action, such as ACTION_VIEW.
6042 */
6043 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006044 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006045 }
6046
6047 /**
6048 * Create an intent with a given action and for a given data url. Note
6049 * that the action <em>must</em> be in a namespace because Intents are
6050 * used globally in the system -- for example the system VIEW action is
6051 * android.intent.action.VIEW; an application's custom action would be
6052 * something like com.google.app.myapp.CUSTOM_ACTION.
6053 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006054 * <p><em>Note: scheme and host name matching in the Android framework is
6055 * case-sensitive, unlike the formal RFC. As a result,
6056 * you should always ensure that you write your Uri with these elements
6057 * using lower case letters, and normalize any Uris you receive from
6058 * outside of Android to ensure the scheme and host is lower case.</em></p>
6059 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006060 * @param action The Intent action, such as ACTION_VIEW.
6061 * @param uri The Intent data URI.
6062 */
6063 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006064 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006065 mData = uri;
6066 }
6067
6068 /**
6069 * Create an intent for a specific component. All other fields (action, data,
6070 * type, class) are null, though they can be modified later with explicit
6071 * calls. This provides a convenient way to create an intent that is
6072 * intended to execute a hard-coded class name, rather than relying on the
6073 * system to find an appropriate class for you; see {@link #setComponent}
6074 * for more information on the repercussions of this.
6075 *
6076 * @param packageContext A Context of the application package implementing
6077 * this class.
6078 * @param cls The component class that is to be used for the intent.
6079 *
6080 * @see #setClass
6081 * @see #setComponent
6082 * @see #Intent(String, android.net.Uri , Context, Class)
6083 */
6084 public Intent(Context packageContext, Class<?> cls) {
6085 mComponent = new ComponentName(packageContext, cls);
6086 }
6087
6088 /**
6089 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006090 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006091 * construct the Intent and then calling {@link #setClass} to set its
6092 * class.
6093 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006094 * <p><em>Note: scheme and host name matching in the Android framework is
6095 * case-sensitive, unlike the formal RFC. As a result,
6096 * you should always ensure that you write your Uri with these elements
6097 * using lower case letters, and normalize any Uris you receive from
6098 * outside of Android to ensure the scheme and host is lower case.</em></p>
6099 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006100 * @param action The Intent action, such as ACTION_VIEW.
6101 * @param uri The Intent data URI.
6102 * @param packageContext A Context of the application package implementing
6103 * this class.
6104 * @param cls The component class that is to be used for the intent.
6105 *
6106 * @see #Intent(String, android.net.Uri)
6107 * @see #Intent(Context, Class)
6108 * @see #setClass
6109 * @see #setComponent
6110 */
6111 public Intent(String action, Uri uri,
6112 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006113 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006114 mData = uri;
6115 mComponent = new ComponentName(packageContext, cls);
6116 }
6117
6118 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006119 * Create an intent to launch the main (root) activity of a task. This
6120 * is the Intent that is started when the application's is launched from
6121 * Home. For anything else that wants to launch an application in the
6122 * same way, it is important that they use an Intent structured the same
6123 * way, and can use this function to ensure this is the case.
6124 *
6125 * <p>The returned Intent has the given Activity component as its explicit
6126 * component, {@link #ACTION_MAIN} as its action, and includes the
6127 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6128 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6129 * to do that through {@link #addFlags(int)} on the returned Intent.
6130 *
6131 * @param mainActivity The main activity component that this Intent will
6132 * launch.
6133 * @return Returns a newly created Intent that can be used to launch the
6134 * activity as a main application entry.
6135 *
6136 * @see #setClass
6137 * @see #setComponent
6138 */
6139 public static Intent makeMainActivity(ComponentName mainActivity) {
6140 Intent intent = new Intent(ACTION_MAIN);
6141 intent.setComponent(mainActivity);
6142 intent.addCategory(CATEGORY_LAUNCHER);
6143 return intent;
6144 }
6145
6146 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006147 * Make an Intent for the main activity of an application, without
6148 * specifying a specific activity to run but giving a selector to find
6149 * the activity. This results in a final Intent that is structured
6150 * the same as when the application is launched from
6151 * Home. For anything else that wants to launch an application in the
6152 * same way, it is important that they use an Intent structured the same
6153 * way, and can use this function to ensure this is the case.
6154 *
6155 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6156 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6157 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6158 * to do that through {@link #addFlags(int)} on the returned Intent.
6159 *
6160 * @param selectorAction The action name of the Intent's selector.
6161 * @param selectorCategory The name of a category to add to the Intent's
6162 * selector.
6163 * @return Returns a newly created Intent that can be used to launch the
6164 * activity as a main application entry.
6165 *
6166 * @see #setSelector(Intent)
6167 */
6168 public static Intent makeMainSelectorActivity(String selectorAction,
6169 String selectorCategory) {
6170 Intent intent = new Intent(ACTION_MAIN);
6171 intent.addCategory(CATEGORY_LAUNCHER);
6172 Intent selector = new Intent();
6173 selector.setAction(selectorAction);
6174 selector.addCategory(selectorCategory);
6175 intent.setSelector(selector);
6176 return intent;
6177 }
6178
6179 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006180 * Make an Intent that can be used to re-launch an application's task
6181 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6182 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6183 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6184 *
6185 * @param mainActivity The activity component that is the root of the
6186 * task; this is the activity that has been published in the application's
6187 * manifest as the main launcher icon.
6188 *
6189 * @return Returns a newly created Intent that can be used to relaunch the
6190 * activity's task in its root state.
6191 */
6192 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6193 Intent intent = makeMainActivity(mainActivity);
6194 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6195 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6196 return intent;
6197 }
6198
6199 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006200 * Call {@link #parseUri} with 0 flags.
6201 * @deprecated Use {@link #parseUri} instead.
6202 */
6203 @Deprecated
6204 public static Intent getIntent(String uri) throws URISyntaxException {
6205 return parseUri(uri, 0);
6206 }
Tom Taylord4a47292009-12-21 13:59:18 -08006207
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006208 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006209 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006210 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006211 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006212 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006213 *
6214 * <p>The URI given here must not be relative -- that is, it must include
6215 * the scheme and full path.
6216 *
6217 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006218 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006219 *
6220 * @return Intent The newly created Intent object.
6221 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006222 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6223 * it bad (as parsed by the Uri class) or the Intent data within the
6224 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006225 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006226 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006227 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006228 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006229 int i = 0;
6230 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006231 final boolean androidApp = uri.startsWith("android-app:");
6232
6233 // Validate intent scheme if requested.
6234 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6235 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006236 Intent intent = new Intent(ACTION_VIEW);
6237 try {
6238 intent.setData(Uri.parse(uri));
6239 } catch (IllegalArgumentException e) {
6240 throw new URISyntaxException(uri, e.getMessage());
6241 }
6242 return intent;
6243 }
6244 }
Tom Taylord4a47292009-12-21 13:59:18 -08006245
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006246 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006247 // simple case
6248 if (i == -1) {
6249 if (!androidApp) {
6250 return new Intent(ACTION_VIEW, Uri.parse(uri));
6251 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006252
6253 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006254 } else if (!uri.startsWith("#Intent;", i)) {
6255 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006256 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006257 } else {
6258 i = -1;
6259 }
6260 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006261
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006262 // new format
6263 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006264 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006265 boolean explicitAction = false;
6266 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006267
6268 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006269 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006270 String data;
6271 if (i >= 0) {
6272 data = uri.substring(0, i);
6273 i += 8; // length of "#Intent;"
6274 } else {
6275 data = uri;
6276 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006277
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006278 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006279 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006280 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006281 if (eq < 0) eq = i-1;
6282 int semi = uri.indexOf(';', i);
6283 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006284
6285 // action
6286 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006287 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006288 if (!inSelector) {
6289 explicitAction = true;
6290 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006291 }
6292
6293 // categories
6294 else if (uri.startsWith("category=", i)) {
6295 intent.addCategory(value);
6296 }
6297
6298 // type
6299 else if (uri.startsWith("type=", i)) {
6300 intent.mType = value;
6301 }
6302
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006303 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006304 else if (uri.startsWith("launchFlags=", i)) {
6305 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006306 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6307 intent.mFlags &= ~IMMUTABLE_FLAGS;
6308 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006309 }
6310
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006311 // package
6312 else if (uri.startsWith("package=", i)) {
6313 intent.mPackage = value;
6314 }
6315
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006316 // component
6317 else if (uri.startsWith("component=", i)) {
6318 intent.mComponent = ComponentName.unflattenFromString(value);
6319 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006320
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006321 // scheme
6322 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006323 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006324 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006325 } else {
6326 scheme = value;
6327 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006328 }
6329
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006330 // source bounds
6331 else if (uri.startsWith("sourceBounds=", i)) {
6332 intent.mSourceBounds = Rect.unflattenFromString(value);
6333 }
6334
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006335 // selector
6336 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6337 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006338 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006339 }
6340
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006341 // extra
6342 else {
6343 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006344 // create Bundle if it doesn't already exist
6345 if (intent.mExtras == null) intent.mExtras = new Bundle();
6346 Bundle b = intent.mExtras;
6347 // add EXTRA
6348 if (uri.startsWith("S.", i)) b.putString(key, value);
6349 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6350 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6351 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6352 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6353 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6354 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6355 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6356 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6357 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6358 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006359
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006360 // move to the next item
6361 i = semi + 1;
6362 }
6363
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006364 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006365 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006366 if (baseIntent.mPackage == null) {
6367 baseIntent.setSelector(intent);
6368 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006369 intent = baseIntent;
6370 }
6371
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006372 if (data != null) {
6373 if (data.startsWith("intent:")) {
6374 data = data.substring(7);
6375 if (scheme != null) {
6376 data = scheme + ':' + data;
6377 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006378 } else if (data.startsWith("android-app:")) {
6379 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6380 // Correctly formed android-app, first part is package name.
6381 int end = data.indexOf('/', 14);
6382 if (end < 0) {
6383 // All we have is a package name.
6384 intent.mPackage = data.substring(14);
6385 if (!explicitAction) {
6386 intent.setAction(ACTION_MAIN);
6387 }
6388 data = "";
6389 } else {
6390 // Target the Intent at the given package name always.
6391 String authority = null;
6392 intent.mPackage = data.substring(14, end);
6393 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006394 if ((end+1) < data.length()) {
6395 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6396 // Found a scheme, remember it.
6397 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006398 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006399 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6400 // Found a authority, remember it.
6401 authority = data.substring(end+1, newEnd);
6402 end = newEnd;
6403 }
6404 } else {
6405 // All we have is a scheme.
6406 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006407 }
6408 }
6409 if (scheme == null) {
6410 // If there was no scheme, then this just targets the package.
6411 if (!explicitAction) {
6412 intent.setAction(ACTION_MAIN);
6413 }
6414 data = "";
6415 } else if (authority == null) {
6416 data = scheme + ":";
6417 } else {
6418 data = scheme + "://" + authority + data.substring(end);
6419 }
6420 }
6421 } else {
6422 data = "";
6423 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006424 }
Tom Taylord4a47292009-12-21 13:59:18 -08006425
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006426 if (data.length() > 0) {
6427 try {
6428 intent.mData = Uri.parse(data);
6429 } catch (IllegalArgumentException e) {
6430 throw new URISyntaxException(uri, e.getMessage());
6431 }
6432 }
6433 }
Tom Taylord4a47292009-12-21 13:59:18 -08006434
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006435 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006436
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006437 } catch (IndexOutOfBoundsException e) {
6438 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6439 }
6440 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006441
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006442 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006443 return getIntentOld(uri, 0);
6444 }
6445
6446 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006447 Intent intent;
6448
6449 int i = uri.lastIndexOf('#');
6450 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006451 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006452 final int intentFragmentStart = i;
6453 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006454
6455 i++;
6456
6457 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006458 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006459 i += 7;
6460 int j = uri.indexOf(')', i);
6461 action = uri.substring(i, j);
6462 i = j + 1;
6463 }
6464
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006465 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006466
6467 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006468 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006469 i += 11;
6470 int j = uri.indexOf(')', i);
6471 while (i < j) {
6472 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006473 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006474 if (i < sep) {
6475 intent.addCategory(uri.substring(i, sep));
6476 }
6477 i = sep + 1;
6478 }
6479 i = j + 1;
6480 }
6481
6482 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006483 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006484 i += 5;
6485 int j = uri.indexOf(')', i);
6486 intent.mType = uri.substring(i, j);
6487 i = j + 1;
6488 }
6489
6490 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006491 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006492 i += 12;
6493 int j = uri.indexOf(')', i);
6494 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006495 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6496 intent.mFlags &= ~IMMUTABLE_FLAGS;
6497 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006498 i = j + 1;
6499 }
6500
6501 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006502 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006503 i += 10;
6504 int j = uri.indexOf(')', i);
6505 int sep = uri.indexOf('!', i);
6506 if (sep >= 0 && sep < j) {
6507 String pkg = uri.substring(i, sep);
6508 String cls = uri.substring(sep + 1, j);
6509 intent.mComponent = new ComponentName(pkg, cls);
6510 }
6511 i = j + 1;
6512 }
6513
6514 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006515 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006516 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006517
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006518 final int closeParen = uri.indexOf(')', i);
6519 if (closeParen == -1) throw new URISyntaxException(uri,
6520 "EXTRA missing trailing ')'", i);
6521
6522 while (i < closeParen) {
6523 // fetch the key value
6524 int j = uri.indexOf('=', i);
6525 if (j <= i + 1 || i >= closeParen) {
6526 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6527 }
6528 char type = uri.charAt(i);
6529 i++;
6530 String key = uri.substring(i, j);
6531 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006532
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006533 // get type-value
6534 j = uri.indexOf('!', i);
6535 if (j == -1 || j >= closeParen) j = closeParen;
6536 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6537 String value = uri.substring(i, j);
6538 i = j;
6539
6540 // create Bundle if it doesn't already exist
6541 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006542
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006543 // add item to bundle
6544 try {
6545 switch (type) {
6546 case 'S':
6547 intent.mExtras.putString(key, Uri.decode(value));
6548 break;
6549 case 'B':
6550 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6551 break;
6552 case 'b':
6553 intent.mExtras.putByte(key, Byte.parseByte(value));
6554 break;
6555 case 'c':
6556 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6557 break;
6558 case 'd':
6559 intent.mExtras.putDouble(key, Double.parseDouble(value));
6560 break;
6561 case 'f':
6562 intent.mExtras.putFloat(key, Float.parseFloat(value));
6563 break;
6564 case 'i':
6565 intent.mExtras.putInt(key, Integer.parseInt(value));
6566 break;
6567 case 'l':
6568 intent.mExtras.putLong(key, Long.parseLong(value));
6569 break;
6570 case 's':
6571 intent.mExtras.putShort(key, Short.parseShort(value));
6572 break;
6573 default:
6574 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6575 }
6576 } catch (NumberFormatException e) {
6577 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6578 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006579
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006580 char ch = uri.charAt(i);
6581 if (ch == ')') break;
6582 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6583 i++;
6584 }
6585 }
6586
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006587 if (isIntentFragment) {
6588 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6589 } else {
6590 intent.mData = Uri.parse(uri);
6591 }
Tom Taylord4a47292009-12-21 13:59:18 -08006592
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006593 if (intent.mAction == null) {
6594 // By default, if no action is specified, then use VIEW.
6595 intent.mAction = ACTION_VIEW;
6596 }
6597
6598 } else {
6599 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6600 }
6601
6602 return intent;
6603 }
6604
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006605 /** @hide */
6606 public interface CommandOptionHandler {
6607 boolean handleOption(String opt, ShellCommand cmd);
6608 }
6609
6610 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006611 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006612 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6613 throws URISyntaxException {
6614 Intent intent = new Intent();
6615 Intent baseIntent = intent;
6616 boolean hasIntentInfo = false;
6617
6618 Uri data = null;
6619 String type = null;
6620
6621 String opt;
6622 while ((opt=cmd.getNextOption()) != null) {
6623 switch (opt) {
6624 case "-a":
6625 intent.setAction(cmd.getNextArgRequired());
6626 if (intent == baseIntent) {
6627 hasIntentInfo = true;
6628 }
6629 break;
6630 case "-d":
6631 data = Uri.parse(cmd.getNextArgRequired());
6632 if (intent == baseIntent) {
6633 hasIntentInfo = true;
6634 }
6635 break;
6636 case "-t":
6637 type = cmd.getNextArgRequired();
6638 if (intent == baseIntent) {
6639 hasIntentInfo = true;
6640 }
6641 break;
6642 case "-c":
6643 intent.addCategory(cmd.getNextArgRequired());
6644 if (intent == baseIntent) {
6645 hasIntentInfo = true;
6646 }
6647 break;
6648 case "-e":
6649 case "--es": {
6650 String key = cmd.getNextArgRequired();
6651 String value = cmd.getNextArgRequired();
6652 intent.putExtra(key, value);
6653 }
6654 break;
6655 case "--esn": {
6656 String key = cmd.getNextArgRequired();
6657 intent.putExtra(key, (String) null);
6658 }
6659 break;
6660 case "--ei": {
6661 String key = cmd.getNextArgRequired();
6662 String value = cmd.getNextArgRequired();
6663 intent.putExtra(key, Integer.decode(value));
6664 }
6665 break;
6666 case "--eu": {
6667 String key = cmd.getNextArgRequired();
6668 String value = cmd.getNextArgRequired();
6669 intent.putExtra(key, Uri.parse(value));
6670 }
6671 break;
6672 case "--ecn": {
6673 String key = cmd.getNextArgRequired();
6674 String value = cmd.getNextArgRequired();
6675 ComponentName cn = ComponentName.unflattenFromString(value);
6676 if (cn == null)
6677 throw new IllegalArgumentException("Bad component name: " + value);
6678 intent.putExtra(key, cn);
6679 }
6680 break;
6681 case "--eia": {
6682 String key = cmd.getNextArgRequired();
6683 String value = cmd.getNextArgRequired();
6684 String[] strings = value.split(",");
6685 int[] list = new int[strings.length];
6686 for (int i = 0; i < strings.length; i++) {
6687 list[i] = Integer.decode(strings[i]);
6688 }
6689 intent.putExtra(key, list);
6690 }
6691 break;
6692 case "--eial": {
6693 String key = cmd.getNextArgRequired();
6694 String value = cmd.getNextArgRequired();
6695 String[] strings = value.split(",");
6696 ArrayList<Integer> list = new ArrayList<>(strings.length);
6697 for (int i = 0; i < strings.length; i++) {
6698 list.add(Integer.decode(strings[i]));
6699 }
6700 intent.putExtra(key, list);
6701 }
6702 break;
6703 case "--el": {
6704 String key = cmd.getNextArgRequired();
6705 String value = cmd.getNextArgRequired();
6706 intent.putExtra(key, Long.valueOf(value));
6707 }
6708 break;
6709 case "--ela": {
6710 String key = cmd.getNextArgRequired();
6711 String value = cmd.getNextArgRequired();
6712 String[] strings = value.split(",");
6713 long[] list = new long[strings.length];
6714 for (int i = 0; i < strings.length; i++) {
6715 list[i] = Long.valueOf(strings[i]);
6716 }
6717 intent.putExtra(key, list);
6718 hasIntentInfo = true;
6719 }
6720 break;
6721 case "--elal": {
6722 String key = cmd.getNextArgRequired();
6723 String value = cmd.getNextArgRequired();
6724 String[] strings = value.split(",");
6725 ArrayList<Long> list = new ArrayList<>(strings.length);
6726 for (int i = 0; i < strings.length; i++) {
6727 list.add(Long.valueOf(strings[i]));
6728 }
6729 intent.putExtra(key, list);
6730 hasIntentInfo = true;
6731 }
6732 break;
6733 case "--ef": {
6734 String key = cmd.getNextArgRequired();
6735 String value = cmd.getNextArgRequired();
6736 intent.putExtra(key, Float.valueOf(value));
6737 hasIntentInfo = true;
6738 }
6739 break;
6740 case "--efa": {
6741 String key = cmd.getNextArgRequired();
6742 String value = cmd.getNextArgRequired();
6743 String[] strings = value.split(",");
6744 float[] list = new float[strings.length];
6745 for (int i = 0; i < strings.length; i++) {
6746 list[i] = Float.valueOf(strings[i]);
6747 }
6748 intent.putExtra(key, list);
6749 hasIntentInfo = true;
6750 }
6751 break;
6752 case "--efal": {
6753 String key = cmd.getNextArgRequired();
6754 String value = cmd.getNextArgRequired();
6755 String[] strings = value.split(",");
6756 ArrayList<Float> list = new ArrayList<>(strings.length);
6757 for (int i = 0; i < strings.length; i++) {
6758 list.add(Float.valueOf(strings[i]));
6759 }
6760 intent.putExtra(key, list);
6761 hasIntentInfo = true;
6762 }
6763 break;
6764 case "--esa": {
6765 String key = cmd.getNextArgRequired();
6766 String value = cmd.getNextArgRequired();
6767 // Split on commas unless they are preceeded by an escape.
6768 // The escape character must be escaped for the string and
6769 // again for the regex, thus four escape characters become one.
6770 String[] strings = value.split("(?<!\\\\),");
6771 intent.putExtra(key, strings);
6772 hasIntentInfo = true;
6773 }
6774 break;
6775 case "--esal": {
6776 String key = cmd.getNextArgRequired();
6777 String value = cmd.getNextArgRequired();
6778 // Split on commas unless they are preceeded by an escape.
6779 // The escape character must be escaped for the string and
6780 // again for the regex, thus four escape characters become one.
6781 String[] strings = value.split("(?<!\\\\),");
6782 ArrayList<String> list = new ArrayList<>(strings.length);
6783 for (int i = 0; i < strings.length; i++) {
6784 list.add(strings[i]);
6785 }
6786 intent.putExtra(key, list);
6787 hasIntentInfo = true;
6788 }
6789 break;
6790 case "--ez": {
6791 String key = cmd.getNextArgRequired();
6792 String value = cmd.getNextArgRequired().toLowerCase();
6793 // Boolean.valueOf() results in false for anything that is not "true", which is
6794 // error-prone in shell commands
6795 boolean arg;
6796 if ("true".equals(value) || "t".equals(value)) {
6797 arg = true;
6798 } else if ("false".equals(value) || "f".equals(value)) {
6799 arg = false;
6800 } else {
6801 try {
6802 arg = Integer.decode(value) != 0;
6803 } catch (NumberFormatException ex) {
6804 throw new IllegalArgumentException("Invalid boolean value: " + value);
6805 }
6806 }
6807
6808 intent.putExtra(key, arg);
6809 }
6810 break;
6811 case "-n": {
6812 String str = cmd.getNextArgRequired();
6813 ComponentName cn = ComponentName.unflattenFromString(str);
6814 if (cn == null)
6815 throw new IllegalArgumentException("Bad component name: " + str);
6816 intent.setComponent(cn);
6817 if (intent == baseIntent) {
6818 hasIntentInfo = true;
6819 }
6820 }
6821 break;
6822 case "-p": {
6823 String str = cmd.getNextArgRequired();
6824 intent.setPackage(str);
6825 if (intent == baseIntent) {
6826 hasIntentInfo = true;
6827 }
6828 }
6829 break;
6830 case "-f":
6831 String str = cmd.getNextArgRequired();
6832 intent.setFlags(Integer.decode(str).intValue());
6833 break;
6834 case "--grant-read-uri-permission":
6835 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6836 break;
6837 case "--grant-write-uri-permission":
6838 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6839 break;
6840 case "--grant-persistable-uri-permission":
6841 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6842 break;
6843 case "--grant-prefix-uri-permission":
6844 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6845 break;
6846 case "--exclude-stopped-packages":
6847 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6848 break;
6849 case "--include-stopped-packages":
6850 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6851 break;
6852 case "--debug-log-resolution":
6853 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6854 break;
6855 case "--activity-brought-to-front":
6856 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6857 break;
6858 case "--activity-clear-top":
6859 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6860 break;
6861 case "--activity-clear-when-task-reset":
6862 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6863 break;
6864 case "--activity-exclude-from-recents":
6865 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6866 break;
6867 case "--activity-launched-from-history":
6868 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6869 break;
6870 case "--activity-multiple-task":
6871 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6872 break;
6873 case "--activity-no-animation":
6874 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6875 break;
6876 case "--activity-no-history":
6877 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6878 break;
6879 case "--activity-no-user-action":
6880 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6881 break;
6882 case "--activity-previous-is-top":
6883 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6884 break;
6885 case "--activity-reorder-to-front":
6886 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6887 break;
6888 case "--activity-reset-task-if-needed":
6889 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6890 break;
6891 case "--activity-single-top":
6892 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6893 break;
6894 case "--activity-clear-task":
6895 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6896 break;
6897 case "--activity-task-on-home":
6898 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6899 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006900 case "--activity-match-external":
6901 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6902 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006903 case "--receiver-registered-only":
6904 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6905 break;
6906 case "--receiver-replace-pending":
6907 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6908 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006909 case "--receiver-foreground":
6910 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6911 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006912 case "--receiver-no-abort":
6913 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6914 break;
6915 case "--receiver-include-background":
6916 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6917 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006918 case "--selector":
6919 intent.setDataAndType(data, type);
6920 intent = new Intent();
6921 break;
6922 default:
6923 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6924 // Okay, caller handled this option.
6925 } else {
6926 throw new IllegalArgumentException("Unknown option: " + opt);
6927 }
6928 break;
6929 }
6930 }
6931 intent.setDataAndType(data, type);
6932
6933 final boolean hasSelector = intent != baseIntent;
6934 if (hasSelector) {
6935 // A selector was specified; fix up.
6936 baseIntent.setSelector(intent);
6937 intent = baseIntent;
6938 }
6939
6940 String arg = cmd.getNextArg();
6941 baseIntent = null;
6942 if (arg == null) {
6943 if (hasSelector) {
6944 // If a selector has been specified, and no arguments
6945 // have been supplied for the main Intent, then we can
6946 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6947 // need to have a component name specified yet, the
6948 // selector will take care of that.
6949 baseIntent = new Intent(Intent.ACTION_MAIN);
6950 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6951 }
6952 } else if (arg.indexOf(':') >= 0) {
6953 // The argument is a URI. Fully parse it, and use that result
6954 // to fill in any data not specified so far.
6955 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6956 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6957 } else if (arg.indexOf('/') >= 0) {
6958 // The argument is a component name. Build an Intent to launch
6959 // it.
6960 baseIntent = new Intent(Intent.ACTION_MAIN);
6961 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6962 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6963 } else {
6964 // Assume the argument is a package name.
6965 baseIntent = new Intent(Intent.ACTION_MAIN);
6966 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6967 baseIntent.setPackage(arg);
6968 }
6969 if (baseIntent != null) {
6970 Bundle extras = intent.getExtras();
6971 intent.replaceExtras((Bundle)null);
6972 Bundle uriExtras = baseIntent.getExtras();
6973 baseIntent.replaceExtras((Bundle)null);
6974 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6975 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
6976 for (String c : cats) {
6977 baseIntent.removeCategory(c);
6978 }
6979 }
6980 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
6981 if (extras == null) {
6982 extras = uriExtras;
6983 } else if (uriExtras != null) {
6984 uriExtras.putAll(extras);
6985 extras = uriExtras;
6986 }
6987 intent.replaceExtras(extras);
6988 hasIntentInfo = true;
6989 }
6990
6991 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
6992 return intent;
6993 }
6994
6995 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006996 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006997 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
6998 final String[] lines = new String[] {
6999 "<INTENT> specifications include these flags and arguments:",
7000 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7001 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007002 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007003 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7004 " [--esn <EXTRA_KEY> ...]",
7005 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7006 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7007 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7008 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7009 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7010 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7011 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7012 " (mutiple extras passed as Integer[])",
7013 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7014 " (mutiple extras passed as List<Integer>)",
7015 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7016 " (mutiple extras passed as Long[])",
7017 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7018 " (mutiple extras passed as List<Long>)",
7019 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7020 " (mutiple extras passed as Float[])",
7021 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7022 " (mutiple extras passed as List<Float>)",
7023 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7024 " (mutiple extras passed as String[]; to embed a comma into a string,",
7025 " escape it using \"\\,\")",
7026 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7027 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7028 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007029 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007030 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7031 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7032 " [--debug-log-resolution] [--exclude-stopped-packages]",
7033 " [--include-stopped-packages]",
7034 " [--activity-brought-to-front] [--activity-clear-top]",
7035 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7036 " [--activity-launched-from-history] [--activity-multiple-task]",
7037 " [--activity-no-animation] [--activity-no-history]",
7038 " [--activity-no-user-action] [--activity-previous-is-top]",
7039 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7040 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007041 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007042 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007043 " [--receiver-foreground] [--receiver-no-abort]",
7044 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007045 " [--selector]",
7046 " [<URI> | <PACKAGE> | <COMPONENT>]"
7047 };
7048 for (String line : lines) {
7049 pw.print(prefix);
7050 pw.println(line);
7051 }
7052 }
7053
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007054 /**
7055 * Retrieve the general action to be performed, such as
7056 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7057 * the information in the intent should be interpreted -- most importantly,
7058 * what to do with the data returned by {@link #getData}.
7059 *
7060 * @return The action of this intent or null if none is specified.
7061 *
7062 * @see #setAction
7063 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007064 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007065 return mAction;
7066 }
7067
7068 /**
7069 * Retrieve data this intent is operating on. This URI specifies the name
7070 * of the data; often it uses the content: scheme, specifying data in a
7071 * content provider. Other schemes may be handled by specific activities,
7072 * such as http: by the web browser.
7073 *
7074 * @return The URI of the data this intent is targeting or null.
7075 *
7076 * @see #getScheme
7077 * @see #setData
7078 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007079 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007080 return mData;
7081 }
7082
7083 /**
7084 * The same as {@link #getData()}, but returns the URI as an encoded
7085 * String.
7086 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007087 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007088 return mData != null ? mData.toString() : null;
7089 }
7090
7091 /**
7092 * Return the scheme portion of the intent's data. If the data is null or
7093 * does not include a scheme, null is returned. Otherwise, the scheme
7094 * prefix without the final ':' is returned, i.e. "http".
7095 *
7096 * <p>This is the same as calling getData().getScheme() (and checking for
7097 * null data).
7098 *
7099 * @return The scheme of this intent.
7100 *
7101 * @see #getData
7102 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007103 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007104 return mData != null ? mData.getScheme() : null;
7105 }
7106
7107 /**
7108 * Retrieve any explicit MIME type included in the intent. This is usually
7109 * null, as the type is determined by the intent data.
7110 *
7111 * @return If a type was manually set, it is returned; else null is
7112 * returned.
7113 *
7114 * @see #resolveType(ContentResolver)
7115 * @see #setType
7116 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007117 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007118 return mType;
7119 }
7120
7121 /**
7122 * Return the MIME data type of this intent. If the type field is
7123 * explicitly set, that is simply returned. Otherwise, if the data is set,
7124 * the type of that data is returned. If neither fields are set, a null is
7125 * returned.
7126 *
7127 * @return The MIME type of this intent.
7128 *
7129 * @see #getType
7130 * @see #resolveType(ContentResolver)
7131 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007132 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007133 return resolveType(context.getContentResolver());
7134 }
7135
7136 /**
7137 * Return the MIME data type of this intent. If the type field is
7138 * explicitly set, that is simply returned. Otherwise, if the data is set,
7139 * the type of that data is returned. If neither fields are set, a null is
7140 * returned.
7141 *
7142 * @param resolver A ContentResolver that can be used to determine the MIME
7143 * type of the intent's data.
7144 *
7145 * @return The MIME type of this intent.
7146 *
7147 * @see #getType
7148 * @see #resolveType(Context)
7149 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007150 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007151 if (mType != null) {
7152 return mType;
7153 }
7154 if (mData != null) {
7155 if ("content".equals(mData.getScheme())) {
7156 return resolver.getType(mData);
7157 }
7158 }
7159 return null;
7160 }
7161
7162 /**
7163 * Return the MIME data type of this intent, only if it will be needed for
7164 * intent resolution. This is not generally useful for application code;
7165 * it is used by the frameworks for communicating with back-end system
7166 * services.
7167 *
7168 * @param resolver A ContentResolver that can be used to determine the MIME
7169 * type of the intent's data.
7170 *
7171 * @return The MIME type of this intent, or null if it is unknown or not
7172 * needed.
7173 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007174 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007175 if (mComponent != null) {
7176 return mType;
7177 }
7178 return resolveType(resolver);
7179 }
7180
7181 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007182 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007183 *
7184 * @param category The category to check.
7185 *
7186 * @return boolean True if the intent contains the category, else false.
7187 *
7188 * @see #getCategories
7189 * @see #addCategory
7190 */
7191 public boolean hasCategory(String category) {
7192 return mCategories != null && mCategories.contains(category);
7193 }
7194
7195 /**
7196 * Return the set of all categories in the intent. If there are no categories,
7197 * returns NULL.
7198 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007199 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007200 *
7201 * @see #hasCategory
7202 * @see #addCategory
7203 */
7204 public Set<String> getCategories() {
7205 return mCategories;
7206 }
7207
7208 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007209 * Return the specific selector associated with this Intent. If there is
7210 * none, returns null. See {@link #setSelector} for more information.
7211 *
7212 * @see #setSelector
7213 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007214 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007215 return mSelector;
7216 }
7217
7218 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007219 * Return the {@link ClipData} associated with this Intent. If there is
7220 * none, returns null. See {@link #setClipData} for more information.
7221 *
John Spurlock125d1332013-11-25 11:58:37 -05007222 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007223 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007224 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007225 return mClipData;
7226 }
7227
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007228 /** @hide */
7229 public int getContentUserHint() {
7230 return mContentUserHint;
7231 }
7232
Todd Kennedyb3b431302017-03-20 16:05:48 -07007233 /** @hide */
7234 public String getLaunchToken() {
7235 return mLaunchToken;
7236 }
7237
7238 /** @hide */
7239 public void setLaunchToken(String launchToken) {
7240 mLaunchToken = launchToken;
7241 }
7242
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007243 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007244 * Sets the ClassLoader that will be used when unmarshalling
7245 * any Parcelable values from the extras of this Intent.
7246 *
7247 * @param loader a ClassLoader, or null to use the default loader
7248 * at the time of unmarshalling.
7249 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007250 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007251 if (mExtras != null) {
7252 mExtras.setClassLoader(loader);
7253 }
7254 }
7255
7256 /**
7257 * Returns true if an extra value is associated with the given name.
7258 * @param name the extra's name
7259 * @return true if the given extra is present.
7260 */
7261 public boolean hasExtra(String name) {
7262 return mExtras != null && mExtras.containsKey(name);
7263 }
7264
7265 /**
7266 * Returns true if the Intent's extras contain a parcelled file descriptor.
7267 * @return true if the Intent contains a parcelled file descriptor.
7268 */
7269 public boolean hasFileDescriptors() {
7270 return mExtras != null && mExtras.hasFileDescriptors();
7271 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007272
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007273 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007274 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007275 public void setAllowFds(boolean allowFds) {
7276 if (mExtras != null) {
7277 mExtras.setAllowFds(allowFds);
7278 }
7279 }
7280
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007281 /** {@hide} */
7282 public void setDefusable(boolean defusable) {
7283 if (mExtras != null) {
7284 mExtras.setDefusable(defusable);
7285 }
7286 }
7287
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007288 /**
7289 * Retrieve extended data from the intent.
7290 *
7291 * @param name The name of the desired item.
7292 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007293 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007294 * or null if none was found.
7295 *
7296 * @deprecated
7297 * @hide
7298 */
7299 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007300 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007301 public Object getExtra(String name) {
7302 return getExtra(name, null);
7303 }
7304
7305 /**
7306 * Retrieve extended data from the intent.
7307 *
7308 * @param name The name of the desired item.
7309 * @param defaultValue the value to be returned if no value of the desired
7310 * type is stored with the given name.
7311 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007312 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007313 * or the default value if none was found.
7314 *
7315 * @see #putExtra(String, boolean)
7316 */
7317 public boolean getBooleanExtra(String name, boolean defaultValue) {
7318 return mExtras == null ? defaultValue :
7319 mExtras.getBoolean(name, defaultValue);
7320 }
7321
7322 /**
7323 * Retrieve extended data from the intent.
7324 *
7325 * @param name The name of the desired item.
7326 * @param defaultValue the value to be returned if no value of the desired
7327 * type is stored with the given name.
7328 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007329 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007330 * or the default value if none was found.
7331 *
7332 * @see #putExtra(String, byte)
7333 */
7334 public byte getByteExtra(String name, byte defaultValue) {
7335 return mExtras == null ? defaultValue :
7336 mExtras.getByte(name, defaultValue);
7337 }
7338
7339 /**
7340 * Retrieve extended data from the intent.
7341 *
7342 * @param name The name of the desired item.
7343 * @param defaultValue the value to be returned if no value of the desired
7344 * type is stored with the given name.
7345 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007346 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007347 * or the default value if none was found.
7348 *
7349 * @see #putExtra(String, short)
7350 */
7351 public short getShortExtra(String name, short defaultValue) {
7352 return mExtras == null ? defaultValue :
7353 mExtras.getShort(name, defaultValue);
7354 }
7355
7356 /**
7357 * Retrieve extended data from the intent.
7358 *
7359 * @param name The name of the desired item.
7360 * @param defaultValue the value to be returned if no value of the desired
7361 * type is stored with the given name.
7362 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007363 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007364 * or the default value if none was found.
7365 *
7366 * @see #putExtra(String, char)
7367 */
7368 public char getCharExtra(String name, char defaultValue) {
7369 return mExtras == null ? defaultValue :
7370 mExtras.getChar(name, defaultValue);
7371 }
7372
7373 /**
7374 * Retrieve extended data from the intent.
7375 *
7376 * @param name The name of the desired item.
7377 * @param defaultValue the value to be returned if no value of the desired
7378 * type is stored with the given name.
7379 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007380 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007381 * or the default value if none was found.
7382 *
7383 * @see #putExtra(String, int)
7384 */
7385 public int getIntExtra(String name, int defaultValue) {
7386 return mExtras == null ? defaultValue :
7387 mExtras.getInt(name, defaultValue);
7388 }
7389
7390 /**
7391 * Retrieve extended data from the intent.
7392 *
7393 * @param name The name of the desired item.
7394 * @param defaultValue the value to be returned if no value of the desired
7395 * type is stored with the given name.
7396 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007397 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007398 * or the default value if none was found.
7399 *
7400 * @see #putExtra(String, long)
7401 */
7402 public long getLongExtra(String name, long defaultValue) {
7403 return mExtras == null ? defaultValue :
7404 mExtras.getLong(name, defaultValue);
7405 }
7406
7407 /**
7408 * Retrieve extended data from the intent.
7409 *
7410 * @param name The name of the desired item.
7411 * @param defaultValue the value to be returned if no value of the desired
7412 * type is stored with the given name.
7413 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007414 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007415 * or the default value if no such item is present
7416 *
7417 * @see #putExtra(String, float)
7418 */
7419 public float getFloatExtra(String name, float defaultValue) {
7420 return mExtras == null ? defaultValue :
7421 mExtras.getFloat(name, defaultValue);
7422 }
7423
7424 /**
7425 * Retrieve extended data from the intent.
7426 *
7427 * @param name The name of the desired item.
7428 * @param defaultValue the value to be returned if no value of the desired
7429 * type is stored with the given name.
7430 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007431 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007432 * or the default value if none was found.
7433 *
7434 * @see #putExtra(String, double)
7435 */
7436 public double getDoubleExtra(String name, double defaultValue) {
7437 return mExtras == null ? defaultValue :
7438 mExtras.getDouble(name, defaultValue);
7439 }
7440
7441 /**
7442 * Retrieve extended data from the intent.
7443 *
7444 * @param name The name of the desired item.
7445 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007446 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007447 * or null if no String value was found.
7448 *
7449 * @see #putExtra(String, String)
7450 */
7451 public String getStringExtra(String name) {
7452 return mExtras == null ? null : mExtras.getString(name);
7453 }
7454
7455 /**
7456 * Retrieve extended data from the intent.
7457 *
7458 * @param name The name of the desired item.
7459 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007460 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007461 * or null if no CharSequence value was found.
7462 *
7463 * @see #putExtra(String, CharSequence)
7464 */
7465 public CharSequence getCharSequenceExtra(String name) {
7466 return mExtras == null ? null : mExtras.getCharSequence(name);
7467 }
7468
7469 /**
7470 * Retrieve extended data from the intent.
7471 *
7472 * @param name The name of the desired item.
7473 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007474 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007475 * or null if no Parcelable value was found.
7476 *
7477 * @see #putExtra(String, Parcelable)
7478 */
7479 public <T extends Parcelable> T getParcelableExtra(String name) {
7480 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7481 }
7482
7483 /**
7484 * Retrieve extended data from the intent.
7485 *
7486 * @param name The name of the desired item.
7487 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007488 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007489 * or null if no Parcelable[] value was found.
7490 *
7491 * @see #putExtra(String, Parcelable[])
7492 */
7493 public Parcelable[] getParcelableArrayExtra(String name) {
7494 return mExtras == null ? null : mExtras.getParcelableArray(name);
7495 }
7496
7497 /**
7498 * Retrieve extended data from the intent.
7499 *
7500 * @param name The name of the desired item.
7501 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007502 * @return the value of an item previously added with
7503 * putParcelableArrayListExtra(), or null if no
7504 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007505 *
7506 * @see #putParcelableArrayListExtra(String, ArrayList)
7507 */
7508 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7509 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7510 }
7511
7512 /**
7513 * Retrieve extended data from the intent.
7514 *
7515 * @param name The name of the desired item.
7516 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007517 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007518 * or null if no Serializable value was found.
7519 *
7520 * @see #putExtra(String, Serializable)
7521 */
7522 public Serializable getSerializableExtra(String name) {
7523 return mExtras == null ? null : mExtras.getSerializable(name);
7524 }
7525
7526 /**
7527 * Retrieve extended data from the intent.
7528 *
7529 * @param name The name of the desired item.
7530 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007531 * @return the value of an item previously added with
7532 * putIntegerArrayListExtra(), or null if no
7533 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007534 *
7535 * @see #putIntegerArrayListExtra(String, ArrayList)
7536 */
7537 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7538 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7539 }
7540
7541 /**
7542 * Retrieve extended data from the intent.
7543 *
7544 * @param name The name of the desired item.
7545 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007546 * @return the value of an item previously added with
7547 * putStringArrayListExtra(), or null if no
7548 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007549 *
7550 * @see #putStringArrayListExtra(String, ArrayList)
7551 */
7552 public ArrayList<String> getStringArrayListExtra(String name) {
7553 return mExtras == null ? null : mExtras.getStringArrayList(name);
7554 }
7555
7556 /**
7557 * Retrieve extended data from the intent.
7558 *
7559 * @param name The name of the desired item.
7560 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007561 * @return the value of an item previously added with
7562 * putCharSequenceArrayListExtra, or null if no
7563 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007564 *
7565 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7566 */
7567 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7568 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7569 }
7570
7571 /**
7572 * Retrieve extended data from the intent.
7573 *
7574 * @param name The name of the desired item.
7575 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007576 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007577 * or null if no boolean array value was found.
7578 *
7579 * @see #putExtra(String, boolean[])
7580 */
7581 public boolean[] getBooleanArrayExtra(String name) {
7582 return mExtras == null ? null : mExtras.getBooleanArray(name);
7583 }
7584
7585 /**
7586 * Retrieve extended data from the intent.
7587 *
7588 * @param name The name of the desired item.
7589 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007590 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007591 * or null if no byte array value was found.
7592 *
7593 * @see #putExtra(String, byte[])
7594 */
7595 public byte[] getByteArrayExtra(String name) {
7596 return mExtras == null ? null : mExtras.getByteArray(name);
7597 }
7598
7599 /**
7600 * Retrieve extended data from the intent.
7601 *
7602 * @param name The name of the desired item.
7603 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007604 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007605 * or null if no short array value was found.
7606 *
7607 * @see #putExtra(String, short[])
7608 */
7609 public short[] getShortArrayExtra(String name) {
7610 return mExtras == null ? null : mExtras.getShortArray(name);
7611 }
7612
7613 /**
7614 * Retrieve extended data from the intent.
7615 *
7616 * @param name The name of the desired item.
7617 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007618 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007619 * or null if no char array value was found.
7620 *
7621 * @see #putExtra(String, char[])
7622 */
7623 public char[] getCharArrayExtra(String name) {
7624 return mExtras == null ? null : mExtras.getCharArray(name);
7625 }
7626
7627 /**
7628 * Retrieve extended data from the intent.
7629 *
7630 * @param name The name of the desired item.
7631 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007632 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007633 * or null if no int array value was found.
7634 *
7635 * @see #putExtra(String, int[])
7636 */
7637 public int[] getIntArrayExtra(String name) {
7638 return mExtras == null ? null : mExtras.getIntArray(name);
7639 }
7640
7641 /**
7642 * Retrieve extended data from the intent.
7643 *
7644 * @param name The name of the desired item.
7645 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007646 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007647 * or null if no long array value was found.
7648 *
7649 * @see #putExtra(String, long[])
7650 */
7651 public long[] getLongArrayExtra(String name) {
7652 return mExtras == null ? null : mExtras.getLongArray(name);
7653 }
7654
7655 /**
7656 * Retrieve extended data from the intent.
7657 *
7658 * @param name The name of the desired item.
7659 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007660 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007661 * or null if no float array value was found.
7662 *
7663 * @see #putExtra(String, float[])
7664 */
7665 public float[] getFloatArrayExtra(String name) {
7666 return mExtras == null ? null : mExtras.getFloatArray(name);
7667 }
7668
7669 /**
7670 * Retrieve extended data from the intent.
7671 *
7672 * @param name The name of the desired item.
7673 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007674 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007675 * or null if no double array value was found.
7676 *
7677 * @see #putExtra(String, double[])
7678 */
7679 public double[] getDoubleArrayExtra(String name) {
7680 return mExtras == null ? null : mExtras.getDoubleArray(name);
7681 }
7682
7683 /**
7684 * Retrieve extended data from the intent.
7685 *
7686 * @param name The name of the desired item.
7687 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007688 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007689 * or null if no String array value was found.
7690 *
7691 * @see #putExtra(String, String[])
7692 */
7693 public String[] getStringArrayExtra(String name) {
7694 return mExtras == null ? null : mExtras.getStringArray(name);
7695 }
7696
7697 /**
7698 * Retrieve extended data from the intent.
7699 *
7700 * @param name The name of the desired item.
7701 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007702 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007703 * or null if no CharSequence array value was found.
7704 *
7705 * @see #putExtra(String, CharSequence[])
7706 */
7707 public CharSequence[] getCharSequenceArrayExtra(String name) {
7708 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7709 }
7710
7711 /**
7712 * Retrieve extended data from the intent.
7713 *
7714 * @param name The name of the desired item.
7715 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007716 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007717 * or null if no Bundle value was found.
7718 *
7719 * @see #putExtra(String, Bundle)
7720 */
7721 public Bundle getBundleExtra(String name) {
7722 return mExtras == null ? null : mExtras.getBundle(name);
7723 }
7724
7725 /**
7726 * Retrieve extended data from the intent.
7727 *
7728 * @param name The name of the desired item.
7729 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007730 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007731 * or null if no IBinder value was found.
7732 *
7733 * @see #putExtra(String, IBinder)
7734 *
7735 * @deprecated
7736 * @hide
7737 */
7738 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007739 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007740 public IBinder getIBinderExtra(String name) {
7741 return mExtras == null ? null : mExtras.getIBinder(name);
7742 }
7743
7744 /**
7745 * Retrieve extended data from the intent.
7746 *
7747 * @param name The name of the desired item.
7748 * @param defaultValue The default value to return in case no item is
7749 * associated with the key 'name'
7750 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007751 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007752 * or defaultValue if none was found.
7753 *
7754 * @see #putExtra
7755 *
7756 * @deprecated
7757 * @hide
7758 */
7759 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007760 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007761 public Object getExtra(String name, Object defaultValue) {
7762 Object result = defaultValue;
7763 if (mExtras != null) {
7764 Object result2 = mExtras.get(name);
7765 if (result2 != null) {
7766 result = result2;
7767 }
7768 }
7769
7770 return result;
7771 }
7772
7773 /**
7774 * Retrieves a map of extended data from the intent.
7775 *
7776 * @return the map of all extras previously added with putExtra(),
7777 * or null if none have been added.
7778 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007779 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007780 return (mExtras != null)
7781 ? new Bundle(mExtras)
7782 : null;
7783 }
7784
7785 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007786 * Filter extras to only basic types.
7787 * @hide
7788 */
7789 public void removeUnsafeExtras() {
7790 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007791 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007792 }
7793 }
7794
7795 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007796 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7797 * return itself as-is.
7798 * @hide
7799 */
7800 public boolean canStripForHistory() {
7801 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7802 }
7803
7804 /**
7805 * Call it when the system needs to keep an intent for logging purposes to remove fields
7806 * that are not needed for logging.
7807 * @hide
7808 */
7809 public Intent maybeStripForHistory() {
7810 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7811
7812 if (!canStripForHistory()) {
7813 return this;
7814 }
7815 return new Intent(this, COPY_MODE_HISTORY);
7816 }
7817
7818 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 * Retrieve any special flags associated with this intent. You will
7820 * normally just set them with {@link #setFlags} and let the system
7821 * take the appropriate action with them.
7822 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007823 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007824 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007825 * @see #addFlags
7826 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007827 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007828 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007829 return mFlags;
7830 }
7831
Dianne Hackborne7f97212011-02-24 14:40:20 -08007832 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007833 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007834 public boolean isExcludingStopped() {
7835 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7836 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7837 }
7838
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007839 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007840 * Retrieve the application package name this Intent is limited to. When
7841 * resolving an Intent, if non-null this limits the resolution to only
7842 * components in the given application package.
7843 *
7844 * @return The name of the application package for the Intent.
7845 *
7846 * @see #resolveActivity
7847 * @see #setPackage
7848 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007849 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007850 return mPackage;
7851 }
7852
7853 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007854 * Retrieve the concrete component associated with the intent. When receiving
7855 * an intent, this is the component that was found to best handle it (that is,
7856 * yourself) and will always be non-null; in all other cases it will be
7857 * null unless explicitly set.
7858 *
7859 * @return The name of the application component to handle the intent.
7860 *
7861 * @see #resolveActivity
7862 * @see #setComponent
7863 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007864 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007865 return mComponent;
7866 }
7867
7868 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007869 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7870 * used as a hint to the receiver for animations and the like. Null means that there
7871 * is no source bounds.
7872 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007873 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007874 return mSourceBounds;
7875 }
7876
7877 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007878 * Return the Activity component that should be used to handle this intent.
7879 * The appropriate component is determined based on the information in the
7880 * intent, evaluated as follows:
7881 *
7882 * <p>If {@link #getComponent} returns an explicit class, that is returned
7883 * without any further consideration.
7884 *
7885 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7886 * category to be considered.
7887 *
7888 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7889 * action.
7890 *
7891 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7892 * this type.
7893 *
7894 * <p>If {@link #addCategory} has added any categories, the activity must
7895 * handle ALL of the categories specified.
7896 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007897 * <p>If {@link #getPackage} is non-NULL, only activity components in
7898 * that application package will be considered.
7899 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007900 * <p>If there are no activities that satisfy all of these conditions, a
7901 * null string is returned.
7902 *
7903 * <p>If multiple activities are found to satisfy the intent, the one with
7904 * the highest priority will be used. If there are multiple activities
7905 * with the same priority, the system will either pick the best activity
7906 * based on user preference, or resolve to a system class that will allow
7907 * the user to pick an activity and forward from there.
7908 *
7909 * <p>This method is implemented simply by calling
7910 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7911 * true.</p>
7912 * <p> This API is called for you as part of starting an activity from an
7913 * intent. You do not normally need to call it yourself.</p>
7914 *
7915 * @param pm The package manager with which to resolve the Intent.
7916 *
7917 * @return Name of the component implementing an activity that can
7918 * display the intent.
7919 *
7920 * @see #setComponent
7921 * @see #getComponent
7922 * @see #resolveActivityInfo
7923 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007924 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007925 if (mComponent != null) {
7926 return mComponent;
7927 }
7928
7929 ResolveInfo info = pm.resolveActivity(
7930 this, PackageManager.MATCH_DEFAULT_ONLY);
7931 if (info != null) {
7932 return new ComponentName(
7933 info.activityInfo.applicationInfo.packageName,
7934 info.activityInfo.name);
7935 }
7936
7937 return null;
7938 }
7939
7940 /**
7941 * Resolve the Intent into an {@link ActivityInfo}
7942 * describing the activity that should execute the intent. Resolution
7943 * follows the same rules as described for {@link #resolveActivity}, but
7944 * you get back the completely information about the resolved activity
7945 * instead of just its class name.
7946 *
7947 * @param pm The package manager with which to resolve the Intent.
7948 * @param flags Addition information to retrieve as per
7949 * {@link PackageManager#getActivityInfo(ComponentName, int)
7950 * PackageManager.getActivityInfo()}.
7951 *
7952 * @return PackageManager.ActivityInfo
7953 *
7954 * @see #resolveActivity
7955 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007956 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7957 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007958 ActivityInfo ai = null;
7959 if (mComponent != null) {
7960 try {
7961 ai = pm.getActivityInfo(mComponent, flags);
7962 } catch (PackageManager.NameNotFoundException e) {
7963 // ignore
7964 }
7965 } else {
7966 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007967 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007968 if (info != null) {
7969 ai = info.activityInfo;
7970 }
7971 }
7972
7973 return ai;
7974 }
7975
7976 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07007977 * Special function for use by the system to resolve service
7978 * intents to system apps. Throws an exception if there are
7979 * multiple potential matches to the Intent. Returns null if
7980 * there are no matches.
7981 * @hide
7982 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007983 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007984 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
7985 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07007986 if (mComponent != null) {
7987 return mComponent;
7988 }
7989
7990 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
7991 if (results == null) {
7992 return null;
7993 }
7994 ComponentName comp = null;
7995 for (int i=0; i<results.size(); i++) {
7996 ResolveInfo ri = results.get(i);
7997 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
7998 continue;
7999 }
8000 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8001 ri.serviceInfo.name);
8002 if (comp != null) {
8003 throw new IllegalStateException("Multiple system services handle " + this
8004 + ": " + comp + ", " + foundComp);
8005 }
8006 comp = foundComp;
8007 }
8008 return comp;
8009 }
8010
8011 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008012 * Set the general action to be performed.
8013 *
8014 * @param action An action name, such as ACTION_VIEW. Application-specific
8015 * actions should be prefixed with the vendor's package name.
8016 *
8017 * @return Returns the same Intent object, for chaining multiple calls
8018 * into a single statement.
8019 *
8020 * @see #getAction
8021 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008022 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008023 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008024 return this;
8025 }
8026
8027 /**
8028 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008029 * clears any type that was previously set by {@link #setType} or
8030 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008031 *
Nick Pellyccae4122012-01-09 14:12:58 -08008032 * <p><em>Note: scheme matching in the Android framework is
8033 * case-sensitive, unlike the formal RFC. As a result,
8034 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008035 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008036 * {@link #setDataAndNormalize}
8037 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008038 *
Nick Pellyccae4122012-01-09 14:12:58 -08008039 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008040 *
8041 * @return Returns the same Intent object, for chaining multiple calls
8042 * into a single statement.
8043 *
8044 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008045 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008046 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008047 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008048 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008049 mData = data;
8050 mType = null;
8051 return this;
8052 }
8053
8054 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008055 * Normalize and set the data this intent is operating on.
8056 *
8057 * <p>This method automatically clears any type that was
8058 * previously set (for example, by {@link #setType}).
8059 *
8060 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008061 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008062 * so really this is just a convenience method for
8063 * <pre>
8064 * setData(data.normalize())
8065 * </pre>
8066 *
8067 * @param data The Uri of the data this intent is now targeting.
8068 *
8069 * @return Returns the same Intent object, for chaining multiple calls
8070 * into a single statement.
8071 *
8072 * @see #getData
8073 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008074 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008075 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008076 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008077 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008078 }
8079
8080 /**
8081 * Set an explicit MIME data type.
8082 *
8083 * <p>This is used to create intents that only specify a type and not data,
8084 * for example to indicate the type of data to return.
8085 *
8086 * <p>This method automatically clears any data that was
8087 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008088 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008089 * <p><em>Note: MIME type matching in the Android framework is
8090 * case-sensitive, unlike formal RFC MIME types. As a result,
8091 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008092 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8093 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008094 *
8095 * @param type The MIME type of the data being handled by this intent.
8096 *
8097 * @return Returns the same Intent object, for chaining multiple calls
8098 * into a single statement.
8099 *
8100 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008101 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008102 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008103 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008104 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008105 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008106 mData = null;
8107 mType = type;
8108 return this;
8109 }
8110
8111 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008112 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008113 *
Nick Pellyccae4122012-01-09 14:12:58 -08008114 * <p>This is used to create intents that only specify a type and not data,
8115 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008116 *
Nick Pellyccae4122012-01-09 14:12:58 -08008117 * <p>This method automatically clears any data that was
8118 * previously set (for example by {@link #setData}).
8119 *
8120 * <p>The MIME type is normalized using
8121 * {@link #normalizeMimeType} before it is set,
8122 * so really this is just a convenience method for
8123 * <pre>
8124 * setType(Intent.normalizeMimeType(type))
8125 * </pre>
8126 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008127 * @param type The MIME type of the data being handled by this intent.
8128 *
8129 * @return Returns the same Intent object, for chaining multiple calls
8130 * into a single statement.
8131 *
Nick Pellyccae4122012-01-09 14:12:58 -08008132 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008133 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008134 * @see #normalizeMimeType
8135 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008136 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008137 return setType(normalizeMimeType(type));
8138 }
8139
8140 /**
8141 * (Usually optional) Set the data for the intent along with an explicit
8142 * MIME data type. This method should very rarely be used -- it allows you
8143 * to override the MIME type that would ordinarily be inferred from the
8144 * data with your own type given here.
8145 *
8146 * <p><em>Note: MIME type and Uri scheme matching in the
8147 * Android framework is case-sensitive, unlike the formal RFC definitions.
8148 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008149 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008150 * {@link #setDataAndTypeAndNormalize}
8151 * to ensure that they are converted to lower case.</em>
8152 *
8153 * @param data The Uri of the data this intent is now targeting.
8154 * @param type The MIME type of the data being handled by this intent.
8155 *
8156 * @return Returns the same Intent object, for chaining multiple calls
8157 * into a single statement.
8158 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008159 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008160 * @see #setData
8161 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008162 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008163 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008164 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008165 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008166 mData = data;
8167 mType = type;
8168 return this;
8169 }
8170
8171 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008172 * (Usually optional) Normalize and set both the data Uri and an explicit
8173 * MIME data type. This method should very rarely be used -- it allows you
8174 * to override the MIME type that would ordinarily be inferred from the
8175 * data with your own type given here.
8176 *
8177 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008178 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008179 * before they are set, so really this is just a convenience method for
8180 * <pre>
8181 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8182 * </pre>
8183 *
8184 * @param data The Uri of the data this intent is now targeting.
8185 * @param type The MIME type of the data being handled by this intent.
8186 *
8187 * @return Returns the same Intent object, for chaining multiple calls
8188 * into a single statement.
8189 *
8190 * @see #setType
8191 * @see #setData
8192 * @see #setDataAndType
8193 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008194 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008195 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008196 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008197 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008198 }
8199
8200 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008201 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008202 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008203 * activities that provide <em>all</em> of the requested categories will be
8204 * used.
8205 *
8206 * @param category The desired category. This can be either one of the
8207 * predefined Intent categories, or a custom category in your own
8208 * namespace.
8209 *
8210 * @return Returns the same Intent object, for chaining multiple calls
8211 * into a single statement.
8212 *
8213 * @see #hasCategory
8214 * @see #removeCategory
8215 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008216 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008217 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008218 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008219 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008220 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008221 return this;
8222 }
8223
8224 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008225 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008226 *
8227 * @param category The category to remove.
8228 *
8229 * @see #addCategory
8230 */
8231 public void removeCategory(String category) {
8232 if (mCategories != null) {
8233 mCategories.remove(category);
8234 if (mCategories.size() == 0) {
8235 mCategories = null;
8236 }
8237 }
8238 }
8239
8240 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008241 * Set a selector for this Intent. This is a modification to the kinds of
8242 * things the Intent will match. If the selector is set, it will be used
8243 * when trying to find entities that can handle the Intent, instead of the
8244 * main contents of the Intent. This allows you build an Intent containing
8245 * a generic protocol while targeting it more specifically.
8246 *
8247 * <p>An example of where this may be used is with things like
8248 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8249 * Intent that will launch the Browser application. However, the correct
8250 * main entry point of an application is actually {@link #ACTION_MAIN}
8251 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8252 * used to specify the actual Activity to launch. If you launch the browser
8253 * with something different, undesired behavior may happen if the user has
8254 * previously or later launches it the normal way, since they do not match.
8255 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8256 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8257 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8258 *
8259 * <p>Setting a selector does not impact the behavior of
8260 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8261 * desired behavior of a selector -- it does not impact the base meaning
8262 * of the Intent, just what kinds of things will be matched against it
8263 * when determining who can handle it.</p>
8264 *
8265 * <p>You can not use both a selector and {@link #setPackage(String)} on
8266 * the same base Intent.</p>
8267 *
8268 * @param selector The desired selector Intent; set to null to not use
8269 * a special selector.
8270 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008271 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008272 if (selector == this) {
8273 throw new IllegalArgumentException(
8274 "Intent being set as a selector of itself");
8275 }
8276 if (selector != null && mPackage != null) {
8277 throw new IllegalArgumentException(
8278 "Can't set selector when package name is already set");
8279 }
8280 mSelector = selector;
8281 }
8282
8283 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008284 * Set a {@link ClipData} associated with this Intent. This replaces any
8285 * previously set ClipData.
8286 *
8287 * <p>The ClipData in an intent is not used for Intent matching or other
8288 * such operations. Semantically it is like extras, used to transmit
8289 * additional data with the Intent. The main feature of using this over
8290 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8291 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8292 * items included in the clip data. This is useful, in particular, if
8293 * you want to transmit an Intent containing multiple <code>content:</code>
8294 * URIs for which the recipient may not have global permission to access the
8295 * content provider.
8296 *
8297 * <p>If the ClipData contains items that are themselves Intents, any
8298 * grant flags in those Intents will be ignored. Only the top-level flags
8299 * of the main Intent are respected, and will be applied to all Uri or
8300 * Intent items in the clip (or sub-items of the clip).
8301 *
8302 * <p>The MIME type, label, and icon in the ClipData object are not
8303 * directly used by Intent. Applications should generally rely on the
8304 * MIME type of the Intent itself, not what it may find in the ClipData.
8305 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008306 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008307 *
8308 * @param clip The new clip to set. May be null to clear the current clip.
8309 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008310 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008311 mClipData = clip;
8312 }
8313
8314 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008315 * This is NOT a secure mechanism to identify the user who sent the intent.
8316 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8317 * who sent the intent.
8318 * @hide
8319 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008320 public void prepareToLeaveUser(int userId) {
8321 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8322 // We want mContentUserHint to refer to the original user, so don't do anything.
8323 if (mContentUserHint == UserHandle.USER_CURRENT) {
8324 mContentUserHint = userId;
8325 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008326 }
8327
8328 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008329 * Add extended data to the intent. The name must include a package
8330 * prefix, for example the app com.android.contacts would use names
8331 * like "com.android.contacts.ShowAll".
8332 *
8333 * @param name The name of the extra data, with package prefix.
8334 * @param value The boolean data value.
8335 *
8336 * @return Returns the same Intent object, for chaining multiple calls
8337 * into a single statement.
8338 *
8339 * @see #putExtras
8340 * @see #removeExtra
8341 * @see #getBooleanExtra(String, boolean)
8342 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008343 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008344 if (mExtras == null) {
8345 mExtras = new Bundle();
8346 }
8347 mExtras.putBoolean(name, value);
8348 return this;
8349 }
8350
8351 /**
8352 * Add extended data to the intent. The name must include a package
8353 * prefix, for example the app com.android.contacts would use names
8354 * like "com.android.contacts.ShowAll".
8355 *
8356 * @param name The name of the extra data, with package prefix.
8357 * @param value The byte data value.
8358 *
8359 * @return Returns the same Intent object, for chaining multiple calls
8360 * into a single statement.
8361 *
8362 * @see #putExtras
8363 * @see #removeExtra
8364 * @see #getByteExtra(String, byte)
8365 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008366 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008367 if (mExtras == null) {
8368 mExtras = new Bundle();
8369 }
8370 mExtras.putByte(name, value);
8371 return this;
8372 }
8373
8374 /**
8375 * Add extended data to the intent. The name must include a package
8376 * prefix, for example the app com.android.contacts would use names
8377 * like "com.android.contacts.ShowAll".
8378 *
8379 * @param name The name of the extra data, with package prefix.
8380 * @param value The char data value.
8381 *
8382 * @return Returns the same Intent object, for chaining multiple calls
8383 * into a single statement.
8384 *
8385 * @see #putExtras
8386 * @see #removeExtra
8387 * @see #getCharExtra(String, char)
8388 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008389 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008390 if (mExtras == null) {
8391 mExtras = new Bundle();
8392 }
8393 mExtras.putChar(name, value);
8394 return this;
8395 }
8396
8397 /**
8398 * Add extended data to the intent. The name must include a package
8399 * prefix, for example the app com.android.contacts would use names
8400 * like "com.android.contacts.ShowAll".
8401 *
8402 * @param name The name of the extra data, with package prefix.
8403 * @param value The short data value.
8404 *
8405 * @return Returns the same Intent object, for chaining multiple calls
8406 * into a single statement.
8407 *
8408 * @see #putExtras
8409 * @see #removeExtra
8410 * @see #getShortExtra(String, short)
8411 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008412 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008413 if (mExtras == null) {
8414 mExtras = new Bundle();
8415 }
8416 mExtras.putShort(name, value);
8417 return this;
8418 }
8419
8420 /**
8421 * Add extended data to the intent. The name must include a package
8422 * prefix, for example the app com.android.contacts would use names
8423 * like "com.android.contacts.ShowAll".
8424 *
8425 * @param name The name of the extra data, with package prefix.
8426 * @param value The integer data value.
8427 *
8428 * @return Returns the same Intent object, for chaining multiple calls
8429 * into a single statement.
8430 *
8431 * @see #putExtras
8432 * @see #removeExtra
8433 * @see #getIntExtra(String, int)
8434 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008435 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008436 if (mExtras == null) {
8437 mExtras = new Bundle();
8438 }
8439 mExtras.putInt(name, value);
8440 return this;
8441 }
8442
8443 /**
8444 * Add extended data to the intent. The name must include a package
8445 * prefix, for example the app com.android.contacts would use names
8446 * like "com.android.contacts.ShowAll".
8447 *
8448 * @param name The name of the extra data, with package prefix.
8449 * @param value The long data value.
8450 *
8451 * @return Returns the same Intent object, for chaining multiple calls
8452 * into a single statement.
8453 *
8454 * @see #putExtras
8455 * @see #removeExtra
8456 * @see #getLongExtra(String, long)
8457 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008458 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008459 if (mExtras == null) {
8460 mExtras = new Bundle();
8461 }
8462 mExtras.putLong(name, value);
8463 return this;
8464 }
8465
8466 /**
8467 * Add extended data to the intent. The name must include a package
8468 * prefix, for example the app com.android.contacts would use names
8469 * like "com.android.contacts.ShowAll".
8470 *
8471 * @param name The name of the extra data, with package prefix.
8472 * @param value The float data value.
8473 *
8474 * @return Returns the same Intent object, for chaining multiple calls
8475 * into a single statement.
8476 *
8477 * @see #putExtras
8478 * @see #removeExtra
8479 * @see #getFloatExtra(String, float)
8480 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008481 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008482 if (mExtras == null) {
8483 mExtras = new Bundle();
8484 }
8485 mExtras.putFloat(name, value);
8486 return this;
8487 }
8488
8489 /**
8490 * Add extended data to the intent. The name must include a package
8491 * prefix, for example the app com.android.contacts would use names
8492 * like "com.android.contacts.ShowAll".
8493 *
8494 * @param name The name of the extra data, with package prefix.
8495 * @param value The double data value.
8496 *
8497 * @return Returns the same Intent object, for chaining multiple calls
8498 * into a single statement.
8499 *
8500 * @see #putExtras
8501 * @see #removeExtra
8502 * @see #getDoubleExtra(String, double)
8503 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008504 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008505 if (mExtras == null) {
8506 mExtras = new Bundle();
8507 }
8508 mExtras.putDouble(name, value);
8509 return this;
8510 }
8511
8512 /**
8513 * Add extended data to the intent. The name must include a package
8514 * prefix, for example the app com.android.contacts would use names
8515 * like "com.android.contacts.ShowAll".
8516 *
8517 * @param name The name of the extra data, with package prefix.
8518 * @param value The String data value.
8519 *
8520 * @return Returns the same Intent object, for chaining multiple calls
8521 * into a single statement.
8522 *
8523 * @see #putExtras
8524 * @see #removeExtra
8525 * @see #getStringExtra(String)
8526 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008527 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008528 if (mExtras == null) {
8529 mExtras = new Bundle();
8530 }
8531 mExtras.putString(name, value);
8532 return this;
8533 }
8534
8535 /**
8536 * Add extended data to the intent. The name must include a package
8537 * prefix, for example the app com.android.contacts would use names
8538 * like "com.android.contacts.ShowAll".
8539 *
8540 * @param name The name of the extra data, with package prefix.
8541 * @param value The CharSequence data value.
8542 *
8543 * @return Returns the same Intent object, for chaining multiple calls
8544 * into a single statement.
8545 *
8546 * @see #putExtras
8547 * @see #removeExtra
8548 * @see #getCharSequenceExtra(String)
8549 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008550 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008551 if (mExtras == null) {
8552 mExtras = new Bundle();
8553 }
8554 mExtras.putCharSequence(name, value);
8555 return this;
8556 }
8557
8558 /**
8559 * Add extended data to the intent. The name must include a package
8560 * prefix, for example the app com.android.contacts would use names
8561 * like "com.android.contacts.ShowAll".
8562 *
8563 * @param name The name of the extra data, with package prefix.
8564 * @param value The Parcelable data value.
8565 *
8566 * @return Returns the same Intent object, for chaining multiple calls
8567 * into a single statement.
8568 *
8569 * @see #putExtras
8570 * @see #removeExtra
8571 * @see #getParcelableExtra(String)
8572 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008573 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008574 if (mExtras == null) {
8575 mExtras = new Bundle();
8576 }
8577 mExtras.putParcelable(name, value);
8578 return this;
8579 }
8580
8581 /**
8582 * Add extended data to the intent. The name must include a package
8583 * prefix, for example the app com.android.contacts would use names
8584 * like "com.android.contacts.ShowAll".
8585 *
8586 * @param name The name of the extra data, with package prefix.
8587 * @param value The Parcelable[] data value.
8588 *
8589 * @return Returns the same Intent object, for chaining multiple calls
8590 * into a single statement.
8591 *
8592 * @see #putExtras
8593 * @see #removeExtra
8594 * @see #getParcelableArrayExtra(String)
8595 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008596 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008597 if (mExtras == null) {
8598 mExtras = new Bundle();
8599 }
8600 mExtras.putParcelableArray(name, value);
8601 return this;
8602 }
8603
8604 /**
8605 * Add extended data to the intent. The name must include a package
8606 * prefix, for example the app com.android.contacts would use names
8607 * like "com.android.contacts.ShowAll".
8608 *
8609 * @param name The name of the extra data, with package prefix.
8610 * @param value The ArrayList<Parcelable> data value.
8611 *
8612 * @return Returns the same Intent object, for chaining multiple calls
8613 * into a single statement.
8614 *
8615 * @see #putExtras
8616 * @see #removeExtra
8617 * @see #getParcelableArrayListExtra(String)
8618 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008619 public @NonNull Intent putParcelableArrayListExtra(String name,
8620 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008621 if (mExtras == null) {
8622 mExtras = new Bundle();
8623 }
8624 mExtras.putParcelableArrayList(name, value);
8625 return this;
8626 }
8627
8628 /**
8629 * Add extended data to the intent. The name must include a package
8630 * prefix, for example the app com.android.contacts would use names
8631 * like "com.android.contacts.ShowAll".
8632 *
8633 * @param name The name of the extra data, with package prefix.
8634 * @param value The ArrayList<Integer> data value.
8635 *
8636 * @return Returns the same Intent object, for chaining multiple calls
8637 * into a single statement.
8638 *
8639 * @see #putExtras
8640 * @see #removeExtra
8641 * @see #getIntegerArrayListExtra(String)
8642 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008643 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008644 if (mExtras == null) {
8645 mExtras = new Bundle();
8646 }
8647 mExtras.putIntegerArrayList(name, value);
8648 return this;
8649 }
8650
8651 /**
8652 * Add extended data to the intent. The name must include a package
8653 * prefix, for example the app com.android.contacts would use names
8654 * like "com.android.contacts.ShowAll".
8655 *
8656 * @param name The name of the extra data, with package prefix.
8657 * @param value The ArrayList<String> data value.
8658 *
8659 * @return Returns the same Intent object, for chaining multiple calls
8660 * into a single statement.
8661 *
8662 * @see #putExtras
8663 * @see #removeExtra
8664 * @see #getStringArrayListExtra(String)
8665 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008666 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008667 if (mExtras == null) {
8668 mExtras = new Bundle();
8669 }
8670 mExtras.putStringArrayList(name, value);
8671 return this;
8672 }
8673
8674 /**
8675 * Add extended data to the intent. The name must include a package
8676 * prefix, for example the app com.android.contacts would use names
8677 * like "com.android.contacts.ShowAll".
8678 *
8679 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008680 * @param value The ArrayList<CharSequence> data value.
8681 *
8682 * @return Returns the same Intent object, for chaining multiple calls
8683 * into a single statement.
8684 *
8685 * @see #putExtras
8686 * @see #removeExtra
8687 * @see #getCharSequenceArrayListExtra(String)
8688 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008689 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8690 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008691 if (mExtras == null) {
8692 mExtras = new Bundle();
8693 }
8694 mExtras.putCharSequenceArrayList(name, value);
8695 return this;
8696 }
8697
8698 /**
8699 * Add extended data to the intent. The name must include a package
8700 * prefix, for example the app com.android.contacts would use names
8701 * like "com.android.contacts.ShowAll".
8702 *
8703 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008704 * @param value The Serializable data value.
8705 *
8706 * @return Returns the same Intent object, for chaining multiple calls
8707 * into a single statement.
8708 *
8709 * @see #putExtras
8710 * @see #removeExtra
8711 * @see #getSerializableExtra(String)
8712 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008713 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008714 if (mExtras == null) {
8715 mExtras = new Bundle();
8716 }
8717 mExtras.putSerializable(name, value);
8718 return this;
8719 }
8720
8721 /**
8722 * Add extended data to the intent. The name must include a package
8723 * prefix, for example the app com.android.contacts would use names
8724 * like "com.android.contacts.ShowAll".
8725 *
8726 * @param name The name of the extra data, with package prefix.
8727 * @param value The boolean array data value.
8728 *
8729 * @return Returns the same Intent object, for chaining multiple calls
8730 * into a single statement.
8731 *
8732 * @see #putExtras
8733 * @see #removeExtra
8734 * @see #getBooleanArrayExtra(String)
8735 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008736 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008737 if (mExtras == null) {
8738 mExtras = new Bundle();
8739 }
8740 mExtras.putBooleanArray(name, value);
8741 return this;
8742 }
8743
8744 /**
8745 * Add extended data to the intent. The name must include a package
8746 * prefix, for example the app com.android.contacts would use names
8747 * like "com.android.contacts.ShowAll".
8748 *
8749 * @param name The name of the extra data, with package prefix.
8750 * @param value The byte array data value.
8751 *
8752 * @return Returns the same Intent object, for chaining multiple calls
8753 * into a single statement.
8754 *
8755 * @see #putExtras
8756 * @see #removeExtra
8757 * @see #getByteArrayExtra(String)
8758 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008759 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008760 if (mExtras == null) {
8761 mExtras = new Bundle();
8762 }
8763 mExtras.putByteArray(name, value);
8764 return this;
8765 }
8766
8767 /**
8768 * Add extended data to the intent. The name must include a package
8769 * prefix, for example the app com.android.contacts would use names
8770 * like "com.android.contacts.ShowAll".
8771 *
8772 * @param name The name of the extra data, with package prefix.
8773 * @param value The short array data value.
8774 *
8775 * @return Returns the same Intent object, for chaining multiple calls
8776 * into a single statement.
8777 *
8778 * @see #putExtras
8779 * @see #removeExtra
8780 * @see #getShortArrayExtra(String)
8781 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008782 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008783 if (mExtras == null) {
8784 mExtras = new Bundle();
8785 }
8786 mExtras.putShortArray(name, value);
8787 return this;
8788 }
8789
8790 /**
8791 * Add extended data to the intent. The name must include a package
8792 * prefix, for example the app com.android.contacts would use names
8793 * like "com.android.contacts.ShowAll".
8794 *
8795 * @param name The name of the extra data, with package prefix.
8796 * @param value The char array data value.
8797 *
8798 * @return Returns the same Intent object, for chaining multiple calls
8799 * into a single statement.
8800 *
8801 * @see #putExtras
8802 * @see #removeExtra
8803 * @see #getCharArrayExtra(String)
8804 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008805 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008806 if (mExtras == null) {
8807 mExtras = new Bundle();
8808 }
8809 mExtras.putCharArray(name, value);
8810 return this;
8811 }
8812
8813 /**
8814 * Add extended data to the intent. The name must include a package
8815 * prefix, for example the app com.android.contacts would use names
8816 * like "com.android.contacts.ShowAll".
8817 *
8818 * @param name The name of the extra data, with package prefix.
8819 * @param value The int array data value.
8820 *
8821 * @return Returns the same Intent object, for chaining multiple calls
8822 * into a single statement.
8823 *
8824 * @see #putExtras
8825 * @see #removeExtra
8826 * @see #getIntArrayExtra(String)
8827 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008828 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008829 if (mExtras == null) {
8830 mExtras = new Bundle();
8831 }
8832 mExtras.putIntArray(name, value);
8833 return this;
8834 }
8835
8836 /**
8837 * Add extended data to the intent. The name must include a package
8838 * prefix, for example the app com.android.contacts would use names
8839 * like "com.android.contacts.ShowAll".
8840 *
8841 * @param name The name of the extra data, with package prefix.
8842 * @param value The byte array data value.
8843 *
8844 * @return Returns the same Intent object, for chaining multiple calls
8845 * into a single statement.
8846 *
8847 * @see #putExtras
8848 * @see #removeExtra
8849 * @see #getLongArrayExtra(String)
8850 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008851 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008852 if (mExtras == null) {
8853 mExtras = new Bundle();
8854 }
8855 mExtras.putLongArray(name, value);
8856 return this;
8857 }
8858
8859 /**
8860 * Add extended data to the intent. The name must include a package
8861 * prefix, for example the app com.android.contacts would use names
8862 * like "com.android.contacts.ShowAll".
8863 *
8864 * @param name The name of the extra data, with package prefix.
8865 * @param value The float array data value.
8866 *
8867 * @return Returns the same Intent object, for chaining multiple calls
8868 * into a single statement.
8869 *
8870 * @see #putExtras
8871 * @see #removeExtra
8872 * @see #getFloatArrayExtra(String)
8873 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008874 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008875 if (mExtras == null) {
8876 mExtras = new Bundle();
8877 }
8878 mExtras.putFloatArray(name, value);
8879 return this;
8880 }
8881
8882 /**
8883 * Add extended data to the intent. The name must include a package
8884 * prefix, for example the app com.android.contacts would use names
8885 * like "com.android.contacts.ShowAll".
8886 *
8887 * @param name The name of the extra data, with package prefix.
8888 * @param value The double array data value.
8889 *
8890 * @return Returns the same Intent object, for chaining multiple calls
8891 * into a single statement.
8892 *
8893 * @see #putExtras
8894 * @see #removeExtra
8895 * @see #getDoubleArrayExtra(String)
8896 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008897 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008898 if (mExtras == null) {
8899 mExtras = new Bundle();
8900 }
8901 mExtras.putDoubleArray(name, value);
8902 return this;
8903 }
8904
8905 /**
8906 * Add extended data to the intent. The name must include a package
8907 * prefix, for example the app com.android.contacts would use names
8908 * like "com.android.contacts.ShowAll".
8909 *
8910 * @param name The name of the extra data, with package prefix.
8911 * @param value The String array data value.
8912 *
8913 * @return Returns the same Intent object, for chaining multiple calls
8914 * into a single statement.
8915 *
8916 * @see #putExtras
8917 * @see #removeExtra
8918 * @see #getStringArrayExtra(String)
8919 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008920 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008921 if (mExtras == null) {
8922 mExtras = new Bundle();
8923 }
8924 mExtras.putStringArray(name, value);
8925 return this;
8926 }
8927
8928 /**
8929 * Add extended data to the intent. The name must include a package
8930 * prefix, for example the app com.android.contacts would use names
8931 * like "com.android.contacts.ShowAll".
8932 *
8933 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008934 * @param value The CharSequence array data value.
8935 *
8936 * @return Returns the same Intent object, for chaining multiple calls
8937 * into a single statement.
8938 *
8939 * @see #putExtras
8940 * @see #removeExtra
8941 * @see #getCharSequenceArrayExtra(String)
8942 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008943 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008944 if (mExtras == null) {
8945 mExtras = new Bundle();
8946 }
8947 mExtras.putCharSequenceArray(name, value);
8948 return this;
8949 }
8950
8951 /**
8952 * Add extended data to the intent. The name must include a package
8953 * prefix, for example the app com.android.contacts would use names
8954 * like "com.android.contacts.ShowAll".
8955 *
8956 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008957 * @param value The Bundle data value.
8958 *
8959 * @return Returns the same Intent object, for chaining multiple calls
8960 * into a single statement.
8961 *
8962 * @see #putExtras
8963 * @see #removeExtra
8964 * @see #getBundleExtra(String)
8965 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008966 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008967 if (mExtras == null) {
8968 mExtras = new Bundle();
8969 }
8970 mExtras.putBundle(name, value);
8971 return this;
8972 }
8973
8974 /**
8975 * Add extended data to the intent. The name must include a package
8976 * prefix, for example the app com.android.contacts would use names
8977 * like "com.android.contacts.ShowAll".
8978 *
8979 * @param name The name of the extra data, with package prefix.
8980 * @param value The IBinder data value.
8981 *
8982 * @return Returns the same Intent object, for chaining multiple calls
8983 * into a single statement.
8984 *
8985 * @see #putExtras
8986 * @see #removeExtra
8987 * @see #getIBinderExtra(String)
8988 *
8989 * @deprecated
8990 * @hide
8991 */
8992 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008993 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008994 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008995 if (mExtras == null) {
8996 mExtras = new Bundle();
8997 }
8998 mExtras.putIBinder(name, value);
8999 return this;
9000 }
9001
9002 /**
9003 * Copy all extras in 'src' in to this intent.
9004 *
9005 * @param src Contains the extras to copy.
9006 *
9007 * @see #putExtra
9008 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009009 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009010 if (src.mExtras != null) {
9011 if (mExtras == null) {
9012 mExtras = new Bundle(src.mExtras);
9013 } else {
9014 mExtras.putAll(src.mExtras);
9015 }
9016 }
9017 return this;
9018 }
9019
9020 /**
9021 * Add a set of extended data to the intent. The keys must include a package
9022 * prefix, for example the app com.android.contacts would use names
9023 * like "com.android.contacts.ShowAll".
9024 *
9025 * @param extras The Bundle of extras to add to this intent.
9026 *
9027 * @see #putExtra
9028 * @see #removeExtra
9029 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009030 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009031 if (mExtras == null) {
9032 mExtras = new Bundle();
9033 }
9034 mExtras.putAll(extras);
9035 return this;
9036 }
9037
9038 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009039 * Completely replace the extras in the Intent with the extras in the
9040 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009041 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009042 * @param src The exact extras contained in this Intent are copied
9043 * into the target intent, replacing any that were previously there.
9044 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009045 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009046 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9047 return this;
9048 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009049
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009050 /**
9051 * Completely replace the extras in the Intent with the given Bundle of
9052 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009053 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009054 * @param extras The new set of extras in the Intent, or null to erase
9055 * all extras.
9056 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009057 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009058 mExtras = extras != null ? new Bundle(extras) : null;
9059 return this;
9060 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009061
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009062 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009063 * Remove extended data from the intent.
9064 *
9065 * @see #putExtra
9066 */
9067 public void removeExtra(String name) {
9068 if (mExtras != null) {
9069 mExtras.remove(name);
9070 if (mExtras.size() == 0) {
9071 mExtras = null;
9072 }
9073 }
9074 }
9075
9076 /**
9077 * Set special flags controlling how this intent is handled. Most values
9078 * here depend on the type of component being executed by the Intent,
9079 * specifically the FLAG_ACTIVITY_* flags are all for use with
9080 * {@link Context#startActivity Context.startActivity()} and the
9081 * FLAG_RECEIVER_* flags are all for use with
9082 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9083 *
Scott Main7aee61f2011-02-08 11:25:01 -08009084 * <p>See the
9085 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9086 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009087 * the behavior of your application.
9088 *
9089 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 * @return Returns the same Intent object, for chaining multiple calls
9091 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009092 * @see #getFlags
9093 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009094 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009095 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009096 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009097 mFlags = flags;
9098 return this;
9099 }
9100
9101 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009102 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009103 *
9104 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009105 * @return Returns the same Intent object, for chaining multiple calls into
9106 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009107 * @see #setFlags
9108 * @see #getFlags
9109 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009110 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009111 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009112 mFlags |= flags;
9113 return this;
9114 }
9115
9116 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009117 * Remove these flags from the intent.
9118 *
9119 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009120 * @see #setFlags
9121 * @see #getFlags
9122 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009123 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009124 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009125 mFlags &= ~flags;
9126 }
9127
9128 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009129 * (Usually optional) Set an explicit application package name that limits
9130 * the components this Intent will resolve to. If left to the default
9131 * value of null, all components in all applications will considered.
9132 * If non-null, the Intent can only match the components in the given
9133 * application package.
9134 *
9135 * @param packageName The name of the application package to handle the
9136 * intent, or null to allow any application package.
9137 *
9138 * @return Returns the same Intent object, for chaining multiple calls
9139 * into a single statement.
9140 *
9141 * @see #getPackage
9142 * @see #resolveActivity
9143 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009144 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009145 if (packageName != null && mSelector != null) {
9146 throw new IllegalArgumentException(
9147 "Can't set package name when selector is already set");
9148 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009149 mPackage = packageName;
9150 return this;
9151 }
9152
9153 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009154 * (Usually optional) Explicitly set the component to handle the intent.
9155 * If left with the default value of null, the system will determine the
9156 * appropriate class to use based on the other fields (action, data,
9157 * type, categories) in the Intent. If this class is defined, the
9158 * specified class will always be used regardless of the other fields. You
9159 * should only set this value when you know you absolutely want a specific
9160 * class to be used; otherwise it is better to let the system find the
9161 * appropriate class so that you will respect the installed applications
9162 * and user preferences.
9163 *
9164 * @param component The name of the application component to handle the
9165 * intent, or null to let the system find one for you.
9166 *
9167 * @return Returns the same Intent object, for chaining multiple calls
9168 * into a single statement.
9169 *
9170 * @see #setClass
9171 * @see #setClassName(Context, String)
9172 * @see #setClassName(String, String)
9173 * @see #getComponent
9174 * @see #resolveActivity
9175 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009176 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009177 mComponent = component;
9178 return this;
9179 }
9180
9181 /**
9182 * Convenience for calling {@link #setComponent} with an
9183 * explicit class name.
9184 *
9185 * @param packageContext A Context of the application package implementing
9186 * this class.
9187 * @param className The name of a class inside of the application package
9188 * that will be used as the component for this Intent.
9189 *
9190 * @return Returns the same Intent object, for chaining multiple calls
9191 * into a single statement.
9192 *
9193 * @see #setComponent
9194 * @see #setClass
9195 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009196 public @NonNull Intent setClassName(@NonNull Context packageContext,
9197 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009198 mComponent = new ComponentName(packageContext, className);
9199 return this;
9200 }
9201
9202 /**
9203 * Convenience for calling {@link #setComponent} with an
9204 * explicit application package name and class name.
9205 *
9206 * @param packageName The name of the package implementing the desired
9207 * component.
9208 * @param className The name of a class inside of the application package
9209 * that will be used as the component for this Intent.
9210 *
9211 * @return Returns the same Intent object, for chaining multiple calls
9212 * into a single statement.
9213 *
9214 * @see #setComponent
9215 * @see #setClass
9216 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009217 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009218 mComponent = new ComponentName(packageName, className);
9219 return this;
9220 }
9221
9222 /**
9223 * Convenience for calling {@link #setComponent(ComponentName)} with the
9224 * name returned by a {@link Class} object.
9225 *
9226 * @param packageContext A Context of the application package implementing
9227 * this class.
9228 * @param cls The class name to set, equivalent to
9229 * <code>setClassName(context, cls.getName())</code>.
9230 *
9231 * @return Returns the same Intent object, for chaining multiple calls
9232 * into a single statement.
9233 *
9234 * @see #setComponent
9235 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009236 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009237 mComponent = new ComponentName(packageContext, cls);
9238 return this;
9239 }
9240
9241 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009242 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9243 * used as a hint to the receiver for animations and the like. Null means that there
9244 * is no source bounds.
9245 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009246 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009247 if (r != null) {
9248 mSourceBounds = new Rect(r);
9249 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009250 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009251 }
9252 }
9253
Tor Norbyed9273d62013-05-30 15:59:53 -07009254 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009255 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9256 FILL_IN_ACTION,
9257 FILL_IN_DATA,
9258 FILL_IN_CATEGORIES,
9259 FILL_IN_COMPONENT,
9260 FILL_IN_PACKAGE,
9261 FILL_IN_SOURCE_BOUNDS,
9262 FILL_IN_SELECTOR,
9263 FILL_IN_CLIP_DATA
9264 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009265 @Retention(RetentionPolicy.SOURCE)
9266 public @interface FillInFlags {}
9267
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009268 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009269 * Use with {@link #fillIn} to allow the current action value to be
9270 * overwritten, even if it is already set.
9271 */
9272 public static final int FILL_IN_ACTION = 1<<0;
9273
9274 /**
9275 * Use with {@link #fillIn} to allow the current data or type value
9276 * overwritten, even if it is already set.
9277 */
9278 public static final int FILL_IN_DATA = 1<<1;
9279
9280 /**
9281 * Use with {@link #fillIn} to allow the current categories to be
9282 * overwritten, even if they are already set.
9283 */
9284 public static final int FILL_IN_CATEGORIES = 1<<2;
9285
9286 /**
9287 * Use with {@link #fillIn} to allow the current component value to be
9288 * overwritten, even if it is already set.
9289 */
9290 public static final int FILL_IN_COMPONENT = 1<<3;
9291
9292 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009293 * Use with {@link #fillIn} to allow the current package value to be
9294 * overwritten, even if it is already set.
9295 */
9296 public static final int FILL_IN_PACKAGE = 1<<4;
9297
9298 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009299 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009300 * overwritten, even if it is already set.
9301 */
9302 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9303
9304 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009305 * Use with {@link #fillIn} to allow the current selector to be
9306 * overwritten, even if it is already set.
9307 */
9308 public static final int FILL_IN_SELECTOR = 1<<6;
9309
9310 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009311 * Use with {@link #fillIn} to allow the current ClipData to be
9312 * overwritten, even if it is already set.
9313 */
9314 public static final int FILL_IN_CLIP_DATA = 1<<7;
9315
9316 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009317 * Copy the contents of <var>other</var> in to this object, but only
9318 * where fields are not defined by this object. For purposes of a field
9319 * being defined, the following pieces of data in the Intent are
9320 * considered to be separate fields:
9321 *
9322 * <ul>
9323 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009324 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009325 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9326 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009327 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009328 * <li> component, as set by {@link #setComponent(ComponentName)} or
9329 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009330 * <li> source bounds, as set by {@link #setSourceBounds}.
9331 * <li> selector, as set by {@link #setSelector(Intent)}.
9332 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009333 * <li> each top-level name in the associated extras.
9334 * </ul>
9335 *
9336 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009337 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009338 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9339 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9340 * the restriction where the corresponding field will not be replaced if
9341 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009342 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009343 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9344 * is explicitly specified. The selector will only be copied if
9345 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009346 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009347 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9348 * and Intent B with {action="gotit", data-type="some/thing",
9349 * categories="one","two"}.
9350 *
9351 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9352 * containing: {action="gotit", data-type="some/thing",
9353 * categories="bar"}.
9354 *
9355 * @param other Another Intent whose values are to be used to fill in
9356 * the current one.
9357 * @param flags Options to control which fields can be filled in.
9358 *
9359 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009360 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009361 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009362 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009363 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009364 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009365 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009366 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009367 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009368 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009369 if (other.mAction != null
9370 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009371 mAction = other.mAction;
9372 changes |= FILL_IN_ACTION;
9373 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009374 if ((other.mData != null || other.mType != null)
9375 && ((mData == null && mType == null)
9376 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009377 mData = other.mData;
9378 mType = other.mType;
9379 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009380 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009381 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009382 if (other.mCategories != null
9383 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009384 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009385 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009386 }
9387 changes |= FILL_IN_CATEGORIES;
9388 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009389 if (other.mPackage != null
9390 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009391 // Only do this if mSelector is not set.
9392 if (mSelector == null) {
9393 mPackage = other.mPackage;
9394 changes |= FILL_IN_PACKAGE;
9395 }
9396 }
9397 // Selector is special: it can only be set if explicitly allowed,
9398 // for the same reason as the component name.
9399 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9400 if (mPackage == null) {
9401 mSelector = new Intent(other.mSelector);
9402 mPackage = null;
9403 changes |= FILL_IN_SELECTOR;
9404 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009405 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009406 if (other.mClipData != null
9407 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9408 mClipData = other.mClipData;
9409 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009410 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009411 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009412 // Component is special: it can -only- be set if explicitly allowed,
9413 // since otherwise the sender could force the intent somewhere the
9414 // originator didn't intend.
9415 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009416 mComponent = other.mComponent;
9417 changes |= FILL_IN_COMPONENT;
9418 }
9419 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009420 if (other.mSourceBounds != null
9421 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9422 mSourceBounds = new Rect(other.mSourceBounds);
9423 changes |= FILL_IN_SOURCE_BOUNDS;
9424 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009425 if (mExtras == null) {
9426 if (other.mExtras != null) {
9427 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009428 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009429 }
9430 } else if (other.mExtras != null) {
9431 try {
9432 Bundle newb = new Bundle(other.mExtras);
9433 newb.putAll(mExtras);
9434 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009435 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009436 } catch (RuntimeException e) {
9437 // Modifying the extras can cause us to unparcel the contents
9438 // of the bundle, and if we do this in the system process that
9439 // may fail. We really should handle this (i.e., the Bundle
9440 // impl shouldn't be on top of a plain map), but for now just
9441 // ignore it and keep the original contents. :(
9442 Log.w("Intent", "Failure filling in extras", e);
9443 }
9444 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009445 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9446 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9447 mContentUserHint = other.mContentUserHint;
9448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009449 return changes;
9450 }
9451
9452 /**
9453 * Wrapper class holding an Intent and implementing comparisons on it for
9454 * the purpose of filtering. The class implements its
9455 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9456 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9457 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9458 * on the wrapped Intent.
9459 */
9460 public static final class FilterComparison {
9461 private final Intent mIntent;
9462 private final int mHashCode;
9463
9464 public FilterComparison(Intent intent) {
9465 mIntent = intent;
9466 mHashCode = intent.filterHashCode();
9467 }
9468
9469 /**
9470 * Return the Intent that this FilterComparison represents.
9471 * @return Returns the Intent held by the FilterComparison. Do
9472 * not modify!
9473 */
9474 public Intent getIntent() {
9475 return mIntent;
9476 }
9477
9478 @Override
9479 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009480 if (obj instanceof FilterComparison) {
9481 Intent other = ((FilterComparison)obj).mIntent;
9482 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009483 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009484 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009485 }
9486
9487 @Override
9488 public int hashCode() {
9489 return mHashCode;
9490 }
9491 }
9492
9493 /**
9494 * Determine if two intents are the same for the purposes of intent
9495 * resolution (filtering). That is, if their action, data, type,
9496 * class, and categories are the same. This does <em>not</em> compare
9497 * any extra data included in the intents.
9498 *
9499 * @param other The other Intent to compare against.
9500 *
9501 * @return Returns true if action, data, type, class, and categories
9502 * are the same.
9503 */
9504 public boolean filterEquals(Intent other) {
9505 if (other == null) {
9506 return false;
9507 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009508 if (!Objects.equals(this.mAction, other.mAction)) return false;
9509 if (!Objects.equals(this.mData, other.mData)) return false;
9510 if (!Objects.equals(this.mType, other.mType)) return false;
9511 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9512 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9513 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009514
9515 return true;
9516 }
9517
9518 /**
9519 * Generate hash code that matches semantics of filterEquals().
9520 *
9521 * @return Returns the hash value of the action, data, type, class, and
9522 * categories.
9523 *
9524 * @see #filterEquals
9525 */
9526 public int filterHashCode() {
9527 int code = 0;
9528 if (mAction != null) {
9529 code += mAction.hashCode();
9530 }
9531 if (mData != null) {
9532 code += mData.hashCode();
9533 }
9534 if (mType != null) {
9535 code += mType.hashCode();
9536 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009537 if (mPackage != null) {
9538 code += mPackage.hashCode();
9539 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009540 if (mComponent != null) {
9541 code += mComponent.hashCode();
9542 }
9543 if (mCategories != null) {
9544 code += mCategories.hashCode();
9545 }
9546 return code;
9547 }
9548
9549 @Override
9550 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009551 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009552
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009553 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009554 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009555 b.append(" }");
9556
9557 return b.toString();
9558 }
9559
9560 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009561 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009562 public String toInsecureString() {
9563 StringBuilder b = new StringBuilder(128);
9564
9565 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009566 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009567 b.append(" }");
9568
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009569 return b.toString();
9570 }
Romain Guy4969af72009-06-17 10:53:19 -07009571
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009572 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009573 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009574 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009575
9576 b.append("Intent { ");
9577 toShortString(b, false, true, true, true);
9578 b.append(" }");
9579
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009580 return b.toString();
9581 }
9582
9583 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009584 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9585 StringBuilder b = new StringBuilder(128);
9586 toShortString(b, secure, comp, extras, clip);
9587 return b.toString();
9588 }
9589
9590 /** @hide */
9591 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9592 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009593 boolean first = true;
9594 if (mAction != null) {
9595 b.append("act=").append(mAction);
9596 first = false;
9597 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009598 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009599 if (!first) {
9600 b.append(' ');
9601 }
9602 first = false;
9603 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009604 for (int i=0; i<mCategories.size(); i++) {
9605 if (i > 0) b.append(',');
9606 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009607 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009608 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009609 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009610 if (mData != null) {
9611 if (!first) {
9612 b.append(' ');
9613 }
9614 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009615 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009616 if (secure) {
9617 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009618 } else {
9619 b.append(mData);
9620 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009621 }
9622 if (mType != null) {
9623 if (!first) {
9624 b.append(' ');
9625 }
9626 first = false;
9627 b.append("typ=").append(mType);
9628 }
9629 if (mFlags != 0) {
9630 if (!first) {
9631 b.append(' ');
9632 }
9633 first = false;
9634 b.append("flg=0x").append(Integer.toHexString(mFlags));
9635 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009636 if (mPackage != null) {
9637 if (!first) {
9638 b.append(' ');
9639 }
9640 first = false;
9641 b.append("pkg=").append(mPackage);
9642 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009643 if (comp && mComponent != null) {
9644 if (!first) {
9645 b.append(' ');
9646 }
9647 first = false;
9648 b.append("cmp=").append(mComponent.flattenToShortString());
9649 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009650 if (mSourceBounds != null) {
9651 if (!first) {
9652 b.append(' ');
9653 }
9654 first = false;
9655 b.append("bnds=").append(mSourceBounds.toShortString());
9656 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009657 if (mClipData != null) {
9658 if (!first) {
9659 b.append(' ');
9660 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009661 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009662 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009663 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009664 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009665 if (mClipData.getDescription() != null) {
9666 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9667 } else {
9668 first = true;
9669 }
9670 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009671 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009672 first = false;
9673 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009674 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009675 if (extras && mExtras != null) {
9676 if (!first) {
9677 b.append(' ');
9678 }
9679 first = false;
9680 b.append("(has extras)");
9681 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009682 if (mContentUserHint != UserHandle.USER_CURRENT) {
9683 if (!first) {
9684 b.append(' ');
9685 }
9686 first = false;
9687 b.append("u=").append(mContentUserHint);
9688 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009689 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009690 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009691 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009692 b.append("}");
9693 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009694 }
9695
Yi Jin129fc6c2017-09-28 15:48:38 -07009696 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009697 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9698 // Same input parameters that toString() gives to toShortString().
9699 writeToProto(proto, fieldId, true, true, true, false);
9700 }
9701
9702 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009703 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9704 boolean extras, boolean clip) {
9705 long token = proto.start(fieldId);
9706 if (mAction != null) {
9707 proto.write(IntentProto.ACTION, mAction);
9708 }
9709 if (mCategories != null) {
9710 for (String category : mCategories) {
9711 proto.write(IntentProto.CATEGORIES, category);
9712 }
9713 }
9714 if (mData != null) {
9715 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9716 }
9717 if (mType != null) {
9718 proto.write(IntentProto.TYPE, mType);
9719 }
9720 if (mFlags != 0) {
9721 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9722 }
9723 if (mPackage != null) {
9724 proto.write(IntentProto.PACKAGE, mPackage);
9725 }
9726 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009727 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009728 }
9729 if (mSourceBounds != null) {
9730 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9731 }
9732 if (mClipData != null) {
9733 StringBuilder b = new StringBuilder();
9734 if (clip) {
9735 mClipData.toShortString(b);
9736 } else {
9737 mClipData.toShortStringShortItems(b, false);
9738 }
9739 proto.write(IntentProto.CLIP_DATA, b.toString());
9740 }
9741 if (extras && mExtras != null) {
9742 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9743 }
9744 if (mContentUserHint != 0) {
9745 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9746 }
9747 if (mSelector != null) {
9748 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9749 }
9750 proto.end(token);
9751 }
9752
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009753 /**
9754 * Call {@link #toUri} with 0 flags.
9755 * @deprecated Use {@link #toUri} instead.
9756 */
9757 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009758 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009759 return toUri(0);
9760 }
9761
9762 /**
9763 * Convert this Intent into a String holding a URI representation of it.
9764 * The returned URI string has been properly URI encoded, so it can be
9765 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9766 * Intent's data as the base URI, with an additional fragment describing
9767 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009768 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009769 * <p>You can convert the returned string back to an Intent with
9770 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009771 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009772 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009773 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009774 * @return Returns a URI encoding URI string describing the entire contents
9775 * of the Intent.
9776 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009777 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009778 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009779 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9780 if (mPackage == null) {
9781 throw new IllegalArgumentException(
9782 "Intent must include an explicit package name to build an android-app: "
9783 + this);
9784 }
9785 uri.append("android-app://");
9786 uri.append(mPackage);
9787 String scheme = null;
9788 if (mData != null) {
9789 scheme = mData.getScheme();
9790 if (scheme != null) {
9791 uri.append('/');
9792 uri.append(scheme);
9793 String authority = mData.getEncodedAuthority();
9794 if (authority != null) {
9795 uri.append('/');
9796 uri.append(authority);
9797 String path = mData.getEncodedPath();
9798 if (path != null) {
9799 uri.append(path);
9800 }
9801 String queryParams = mData.getEncodedQuery();
9802 if (queryParams != null) {
9803 uri.append('?');
9804 uri.append(queryParams);
9805 }
9806 String fragment = mData.getEncodedFragment();
9807 if (fragment != null) {
9808 uri.append('#');
9809 uri.append(fragment);
9810 }
9811 }
9812 }
9813 }
9814 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9815 mPackage, flags);
9816 return uri.toString();
9817 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009818 String scheme = null;
9819 if (mData != null) {
9820 String data = mData.toString();
9821 if ((flags&URI_INTENT_SCHEME) != 0) {
9822 final int N = data.length();
9823 for (int i=0; i<N; i++) {
9824 char c = data.charAt(i);
9825 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009826 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009827 continue;
9828 }
9829 if (c == ':' && i > 0) {
9830 // Valid scheme.
9831 scheme = data.substring(0, i);
9832 uri.append("intent:");
9833 data = data.substring(i+1);
9834 break;
9835 }
Tom Taylord4a47292009-12-21 13:59:18 -08009836
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009837 // No scheme.
9838 break;
9839 }
9840 }
9841 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009842
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009843 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9844 uri.append("intent:");
9845 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009846
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009847 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009848
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009849 return uri.toString();
9850 }
9851
9852 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9853 String defPackage, int flags) {
9854 StringBuilder frag = new StringBuilder(128);
9855
9856 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009857 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009858 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009859 // Note that for now we are not going to try to handle the
9860 // data part; not clear how to represent this as a URI, and
9861 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009862 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9863 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009864 }
9865
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009866 if (frag.length() > 0) {
9867 uri.append("#Intent;");
9868 uri.append(frag);
9869 uri.append("end");
9870 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009871 }
9872
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009873 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9874 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009875 if (scheme != null) {
9876 uri.append("scheme=").append(scheme).append(';');
9877 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009878 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009879 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009880 }
9881 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009882 for (int i=0; i<mCategories.size(); i++) {
9883 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009884 }
9885 }
9886 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009887 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009888 }
9889 if (mFlags != 0) {
9890 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9891 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009892 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009893 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9894 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009895 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009896 uri.append("component=").append(Uri.encode(
9897 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009898 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009899 if (mSourceBounds != null) {
9900 uri.append("sourceBounds=")
9901 .append(Uri.encode(mSourceBounds.flattenToString()))
9902 .append(';');
9903 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009904 if (mExtras != null) {
9905 for (String key : mExtras.keySet()) {
9906 final Object value = mExtras.get(key);
9907 char entryType =
9908 value instanceof String ? 'S' :
9909 value instanceof Boolean ? 'B' :
9910 value instanceof Byte ? 'b' :
9911 value instanceof Character ? 'c' :
9912 value instanceof Double ? 'd' :
9913 value instanceof Float ? 'f' :
9914 value instanceof Integer ? 'i' :
9915 value instanceof Long ? 'l' :
9916 value instanceof Short ? 's' :
9917 '\0';
9918
9919 if (entryType != '\0') {
9920 uri.append(entryType);
9921 uri.append('.');
9922 uri.append(Uri.encode(key));
9923 uri.append('=');
9924 uri.append(Uri.encode(value.toString()));
9925 uri.append(';');
9926 }
9927 }
9928 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009929 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009930
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009931 public int describeContents() {
9932 return (mExtras != null) ? mExtras.describeContents() : 0;
9933 }
9934
9935 public void writeToParcel(Parcel out, int flags) {
9936 out.writeString(mAction);
9937 Uri.writeToParcel(out, mData);
9938 out.writeString(mType);
9939 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009940 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009941 ComponentName.writeToParcel(mComponent, out);
9942
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009943 if (mSourceBounds != null) {
9944 out.writeInt(1);
9945 mSourceBounds.writeToParcel(out, flags);
9946 } else {
9947 out.writeInt(0);
9948 }
9949
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009950 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009951 final int N = mCategories.size();
9952 out.writeInt(N);
9953 for (int i=0; i<N; i++) {
9954 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009955 }
9956 } else {
9957 out.writeInt(0);
9958 }
9959
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009960 if (mSelector != null) {
9961 out.writeInt(1);
9962 mSelector.writeToParcel(out, flags);
9963 } else {
9964 out.writeInt(0);
9965 }
9966
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009967 if (mClipData != null) {
9968 out.writeInt(1);
9969 mClipData.writeToParcel(out, flags);
9970 } else {
9971 out.writeInt(0);
9972 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009973 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009974 out.writeBundle(mExtras);
9975 }
9976
9977 public static final Parcelable.Creator<Intent> CREATOR
9978 = new Parcelable.Creator<Intent>() {
9979 public Intent createFromParcel(Parcel in) {
9980 return new Intent(in);
9981 }
9982 public Intent[] newArray(int size) {
9983 return new Intent[size];
9984 }
9985 };
9986
Dianne Hackborneb034652009-09-07 00:49:58 -07009987 /** @hide */
9988 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009989 readFromParcel(in);
9990 }
9991
9992 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08009993 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009994 mData = Uri.CREATOR.createFromParcel(in);
9995 mType = in.readString();
9996 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009997 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009998 mComponent = ComponentName.readFromParcel(in);
9999
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010000 if (in.readInt() != 0) {
10001 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10002 }
10003
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010004 int N = in.readInt();
10005 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010006 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010007 int i;
10008 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010009 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010010 }
10011 } else {
10012 mCategories = null;
10013 }
10014
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010015 if (in.readInt() != 0) {
10016 mSelector = new Intent(in);
10017 }
10018
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010019 if (in.readInt() != 0) {
10020 mClipData = new ClipData(in);
10021 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010022 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010023 mExtras = in.readBundle();
10024 }
10025
10026 /**
10027 * Parses the "intent" element (and its children) from XML and instantiates
10028 * an Intent object. The given XML parser should be located at the tag
10029 * where parsing should start (often named "intent"), from which the
10030 * basic action, data, type, and package and class name will be
10031 * retrieved. The function will then parse in to any child elements,
10032 * looking for <category android:name="xxx"> tags to add categories and
10033 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10034 * to the intent.
10035 *
10036 * @param resources The Resources to use when inflating resources.
10037 * @param parser The XML parser pointing at an "intent" tag.
10038 * @param attrs The AttributeSet interface for retrieving extended
10039 * attribute data at the current <var>parser</var> location.
10040 * @return An Intent object matching the XML data.
10041 * @throws XmlPullParserException If there was an XML parsing error.
10042 * @throws IOException If there was an I/O error.
10043 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010044 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10045 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010046 throws XmlPullParserException, IOException {
10047 Intent intent = new Intent();
10048
10049 TypedArray sa = resources.obtainAttributes(attrs,
10050 com.android.internal.R.styleable.Intent);
10051
10052 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10053
10054 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10055 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10056 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10057
10058 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10059 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10060 if (packageName != null && className != null) {
10061 intent.setComponent(new ComponentName(packageName, className));
10062 }
10063
10064 sa.recycle();
10065
10066 int outerDepth = parser.getDepth();
10067 int type;
10068 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10069 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10070 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10071 continue;
10072 }
10073
10074 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010075 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010076 sa = resources.obtainAttributes(attrs,
10077 com.android.internal.R.styleable.IntentCategory);
10078 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10079 sa.recycle();
10080
10081 if (cat != null) {
10082 intent.addCategory(cat);
10083 }
10084 XmlUtils.skipCurrentTag(parser);
10085
Craig Mautner21d24a22014-04-23 11:45:37 -070010086 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010087 if (intent.mExtras == null) {
10088 intent.mExtras = new Bundle();
10089 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010090 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010091 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010092
10093 } else {
10094 XmlUtils.skipCurrentTag(parser);
10095 }
10096 }
10097
10098 return intent;
10099 }
Nick Pellyccae4122012-01-09 14:12:58 -080010100
Craig Mautner21d24a22014-04-23 11:45:37 -070010101 /** @hide */
10102 public void saveToXml(XmlSerializer out) throws IOException {
10103 if (mAction != null) {
10104 out.attribute(null, ATTR_ACTION, mAction);
10105 }
10106 if (mData != null) {
10107 out.attribute(null, ATTR_DATA, mData.toString());
10108 }
10109 if (mType != null) {
10110 out.attribute(null, ATTR_TYPE, mType);
10111 }
10112 if (mComponent != null) {
10113 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10114 }
10115 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10116
10117 if (mCategories != null) {
10118 out.startTag(null, TAG_CATEGORIES);
10119 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10120 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10121 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010122 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010123 }
10124 }
10125
10126 /** @hide */
10127 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10128 XmlPullParserException {
10129 Intent intent = new Intent();
10130 final int outerDepth = in.getDepth();
10131
10132 int attrCount = in.getAttributeCount();
10133 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10134 final String attrName = in.getAttributeName(attrNdx);
10135 final String attrValue = in.getAttributeValue(attrNdx);
10136 if (ATTR_ACTION.equals(attrName)) {
10137 intent.setAction(attrValue);
10138 } else if (ATTR_DATA.equals(attrName)) {
10139 intent.setData(Uri.parse(attrValue));
10140 } else if (ATTR_TYPE.equals(attrName)) {
10141 intent.setType(attrValue);
10142 } else if (ATTR_COMPONENT.equals(attrName)) {
10143 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10144 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010145 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010146 } else {
10147 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10148 }
10149 }
10150
10151 int event;
10152 String name;
10153 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10154 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10155 if (event == XmlPullParser.START_TAG) {
10156 name = in.getName();
10157 if (TAG_CATEGORIES.equals(name)) {
10158 attrCount = in.getAttributeCount();
10159 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10160 intent.addCategory(in.getAttributeValue(attrNdx));
10161 }
10162 } else {
10163 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10164 XmlUtils.skipCurrentTag(in);
10165 }
10166 }
10167 }
10168
10169 return intent;
10170 }
10171
Nick Pellyccae4122012-01-09 14:12:58 -080010172 /**
10173 * Normalize a MIME data type.
10174 *
10175 * <p>A normalized MIME type has white-space trimmed,
10176 * content-type parameters removed, and is lower-case.
10177 * This aligns the type with Android best practices for
10178 * intent filtering.
10179 *
10180 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10181 * "text/x-vCard" becomes "text/x-vcard".
10182 *
10183 * <p>All MIME types received from outside Android (such as user input,
10184 * or external sources like Bluetooth, NFC, or the Internet) should
10185 * be normalized before they are used to create an Intent.
10186 *
10187 * @param type MIME data type to normalize
10188 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010189 * @see #setType
10190 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010191 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010192 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010193 if (type == null) {
10194 return null;
10195 }
10196
Elliott Hughescb64d432013-08-02 10:00:44 -070010197 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010198
10199 final int semicolonIndex = type.indexOf(';');
10200 if (semicolonIndex != -1) {
10201 type = type.substring(0, semicolonIndex);
10202 }
10203 return type;
10204 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010205
10206 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010207 * Prepare this {@link Intent} to leave an app process.
10208 *
10209 * @hide
10210 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010211 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010212 public void prepareToLeaveProcess(Context context) {
10213 final boolean leavingPackage = (mComponent == null)
10214 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10215 prepareToLeaveProcess(leavingPackage);
10216 }
10217
10218 /**
10219 * Prepare this {@link Intent} to leave an app process.
10220 *
10221 * @hide
10222 */
10223 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010224 setAllowFds(false);
10225
10226 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010227 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010228 }
10229 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010230 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010231 }
10232
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010233 if (mExtras != null && !mExtras.isParcelled()) {
10234 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10235 if (intent instanceof Intent) {
10236 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10237 }
10238 }
10239
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010240 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10241 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010242 switch (mAction) {
10243 case ACTION_MEDIA_REMOVED:
10244 case ACTION_MEDIA_UNMOUNTED:
10245 case ACTION_MEDIA_CHECKING:
10246 case ACTION_MEDIA_NOFS:
10247 case ACTION_MEDIA_MOUNTED:
10248 case ACTION_MEDIA_SHARED:
10249 case ACTION_MEDIA_UNSHARED:
10250 case ACTION_MEDIA_BAD_REMOVAL:
10251 case ACTION_MEDIA_UNMOUNTABLE:
10252 case ACTION_MEDIA_EJECT:
10253 case ACTION_MEDIA_SCANNER_STARTED:
10254 case ACTION_MEDIA_SCANNER_FINISHED:
10255 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010256 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10257 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010258 // Ignore legacy actions
10259 break;
10260 default:
10261 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010262 }
10263 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010264
10265 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10266 && leavingPackage) {
10267 switch (mAction) {
10268 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010269 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010270 // Ignore actions that don't need to grant
10271 break;
10272 default:
10273 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10274 }
10275 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010276 }
10277
10278 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010279 * @hide
10280 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010281 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010282 // We just entered destination process, so we should be able to read all
10283 // parcelables inside.
10284 setDefusable(true);
10285
10286 if (mSelector != null) {
10287 mSelector.prepareToEnterProcess();
10288 }
10289 if (mClipData != null) {
10290 mClipData.prepareToEnterProcess();
10291 }
10292
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010293 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010294 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10295 fixUris(mContentUserHint);
10296 mContentUserHint = UserHandle.USER_CURRENT;
10297 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010298 }
10299 }
10300
Patrick Baumann577d4022018-01-31 16:55:10 +000010301 /** @hide */
10302 public boolean hasWebURI() {
10303 if (getData() == null) {
10304 return false;
10305 }
10306 final String scheme = getScheme();
10307 if (TextUtils.isEmpty(scheme)) {
10308 return false;
10309 }
10310 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10311 }
10312
10313 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010314 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010315 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010316 && hasWebURI();
10317 }
10318
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010319 /**
10320 * @hide
10321 */
10322 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010323 Uri data = getData();
10324 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010325 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010326 }
10327 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010328 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010329 }
10330 String action = getAction();
10331 if (ACTION_SEND.equals(action)) {
10332 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10333 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010334 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010335 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010336 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010337 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10338 if (streams != null) {
10339 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10340 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010341 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010342 }
10343 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10344 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010345 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10346 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10347 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10348 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10349 if (output != null) {
10350 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10351 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010352 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010353 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010354
10355 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010356 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010357 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10358 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010359 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010360 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010361 * @hide
10362 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010363 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010364 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010365 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010366
10367 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010368 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010369
10370 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010371 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010372 // Inspect contained intents to see if we need to migrate extras. We
10373 // don't promote ClipData to the parent, since ChooserActivity will
10374 // already start the picked item as the caller, and we can't combine
10375 // the flags in a safe way.
10376
10377 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010378 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010379 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10380 if (intent != null) {
10381 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010382 }
10383 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010384 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010385 try {
10386 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10387 if (intents != null) {
10388 for (int i = 0; i < intents.length; i++) {
10389 final Intent intent = (Intent) intents[i];
10390 if (intent != null) {
10391 migrated |= intent.migrateExtraStreamToClipData();
10392 }
10393 }
10394 }
10395 } catch (ClassCastException e) {
10396 }
10397 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010398
10399 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010400 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010401 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10402 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10403 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10404 if (stream != null || text != null || htmlText != null) {
10405 final ClipData clipData = new ClipData(
10406 null, new String[] { getType() },
10407 new ClipData.Item(text, htmlText, null, stream));
10408 setClipData(clipData);
10409 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010410 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010411 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010412 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010413 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010414
10415 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010416 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010417 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10418 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10419 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10420 int num = -1;
10421 if (streams != null) {
10422 num = streams.size();
10423 }
10424 if (texts != null) {
10425 if (num >= 0 && num != texts.size()) {
10426 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010427 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010428 }
10429 num = texts.size();
10430 }
10431 if (htmlTexts != null) {
10432 if (num >= 0 && num != htmlTexts.size()) {
10433 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010434 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010435 }
10436 num = htmlTexts.size();
10437 }
10438 if (num > 0) {
10439 final ClipData clipData = new ClipData(
10440 null, new String[] { getType() },
10441 makeClipItem(streams, texts, htmlTexts, 0));
10442
10443 for (int i = 1; i < num; i++) {
10444 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10445 }
10446
10447 setClipData(clipData);
10448 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010449 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010450 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010451 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010452 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010453 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10454 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10455 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10456 final Uri output;
10457 try {
10458 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10459 } catch (ClassCastException e) {
10460 return false;
10461 }
10462 if (output != null) {
10463 setClipData(ClipData.newRawUri("", output));
10464 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10465 return true;
10466 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010467 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010468
10469 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010470 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010471
Michael Wright19859762017-09-18 20:57:58 +010010472 /**
10473 * Convert the dock state to a human readable format.
10474 * @hide
10475 */
10476 public static String dockStateToString(int dock) {
10477 switch (dock) {
10478 case EXTRA_DOCK_STATE_HE_DESK:
10479 return "EXTRA_DOCK_STATE_HE_DESK";
10480 case EXTRA_DOCK_STATE_LE_DESK:
10481 return "EXTRA_DOCK_STATE_LE_DESK";
10482 case EXTRA_DOCK_STATE_CAR:
10483 return "EXTRA_DOCK_STATE_CAR";
10484 case EXTRA_DOCK_STATE_DESK:
10485 return "EXTRA_DOCK_STATE_DESK";
10486 case EXTRA_DOCK_STATE_UNDOCKED:
10487 return "EXTRA_DOCK_STATE_UNDOCKED";
10488 default:
10489 return Integer.toString(dock);
10490 }
10491 }
10492
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010493 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10494 ArrayList<String> htmlTexts, int which) {
10495 Uri uri = streams != null ? streams.get(which) : null;
10496 CharSequence text = texts != null ? texts.get(which) : null;
10497 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10498 return new ClipData.Item(text, htmlText, null, uri);
10499 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010500
10501 /** @hide */
10502 public boolean isDocument() {
10503 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10504 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010505}