blob: d7898776965ed7009179708ac0f7f64deea8390d [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;
Joel Galenson78ec58d2018-10-24 10:06:25 -070026import android.annotation.RequiresPermission;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070027import android.annotation.SdkConstant;
28import android.annotation.SdkConstant.SdkConstantType;
Jason Monk2f68e8a2016-02-23 17:57:28 -050029import android.annotation.SystemApi;
Hai Zhang22435862019-02-26 16:57:47 -080030import android.annotation.TestApi;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010031import android.annotation.UnsupportedAppUsage;
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060032import android.app.AppGlobals;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070033import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050034import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060035import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070036import android.content.pm.PackageManager;
37import android.content.pm.ResolveInfo;
Mehdi Alizadeh406e8b32018-12-11 18:21:49 -080038import android.content.pm.ShortcutInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.content.res.Resources;
40import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080041import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070042import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060043import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070044import android.os.Bundle;
45import android.os.IBinder;
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060046import android.os.IncidentManager;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070047import android.os.Parcel;
48import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070049import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000050import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050051import android.os.ResultReceiver;
52import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070053import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010054import android.os.UserHandle;
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060055import android.os.storage.StorageManager;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070056import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070057import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070058import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050059import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070060import android.provider.OpenableColumns;
Brad Ebinger3636d742019-05-21 15:28:19 -070061import android.telecom.PhoneAccount;
62import android.telecom.TelecomManager;
Patrick Baumann577d4022018-01-31 16:55:10 +000063import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050064import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070065import android.util.AttributeSet;
66import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070067import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070068
Dianne Hackborn2269d1572010-02-24 19:54:22 -080069import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070070
Jason Monk2f68e8a2016-02-23 17:57:28 -050071import org.xmlpull.v1.XmlPullParser;
72import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070073import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070074
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060075import java.io.File;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070076import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080077import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070078import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070079import java.lang.annotation.Retention;
80import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070081import java.net.URISyntaxException;
82import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080083import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070084import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080085import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070086import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070087import java.util.Set;
88
89/**
90 * An intent is an abstract description of an operation to be performed. It
91 * can be used with {@link Context#startActivity(Intent) startActivity} to
92 * launch an {@link android.app.Activity},
93 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
94 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
95 * and {@link android.content.Context#startService} or
96 * {@link android.content.Context#bindService} to communicate with a
97 * background {@link android.app.Service}.
98 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070099 * <p>An Intent provides a facility for performing late runtime binding between the code in
100 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -0700101 * can be thought of as the glue between activities. It is basically a passive data structure
102 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -0700103 *
104 * <div class="special reference">
105 * <h3>Developer Guides</h3>
106 * <p>For information about how to create and resolve intents, read the
107 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
108 * developer guide.</p>
109 * </div>
110 *
111 * <a name="IntentStructure"></a>
112 * <h3>Intent Structure</h3>
113 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700114 *
115 * <ul>
116 * <li> <p><b>action</b> -- The general action to be performed, such as
117 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
118 * etc.</p>
119 * </li>
120 * <li> <p><b>data</b> -- The data to operate on, such as a person record
121 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
122 * </li>
123 * </ul>
124 *
125 *
126 * <p>Some examples of action/data pairs are:</p>
127 *
128 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700129 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * information about the person whose identifier is "1".</p>
131 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700132 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700133 * the phone dialer with the person filled in.</p>
134 * </li>
135 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
136 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700137 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700138 * a particular URI.</p>
139 * </li>
140 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
141 * the phone dialer with the given number filled in.</p>
142 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700143 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700144 * information about the person whose identifier is "1".</p>
145 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700146 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700147 * a list of people, which the user can browse through. This example is a
148 * typical top-level entry into the Contacts application, showing you the
149 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700150 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700151 * being used to start an activity to display that person.</p>
152 * </li>
153 * </ul>
154 *
155 * <p>In addition to these primary attributes, there are a number of secondary
156 * attributes that you can also include with an intent:</p>
157 *
158 * <ul>
159 * <li> <p><b>category</b> -- Gives additional information about the action
160 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
161 * appear in the Launcher as a top-level application, while
162 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
163 * of alternative actions the user can perform on a piece of data.</p>
164 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
165 * intent data. Normally the type is inferred from the data itself.
166 * By setting this attribute, you disable that evaluation and force
167 * an explicit type.</p>
168 * <li> <p><b>component</b> -- Specifies an explicit name of a component
169 * class to use for the intent. Normally this is determined by looking
170 * at the other information in the intent (the action, data/type, and
171 * categories) and matching that with a component that can handle it.
172 * If this attribute is set then none of the evaluation is performed,
173 * and this component is used exactly as is. By specifying this attribute,
174 * all of the other Intent attributes become optional.</p>
175 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
176 * This can be used to provide extended information to the component.
177 * For example, if we have a action to send an e-mail message, we could
178 * also include extra pieces of data here to supply a subject, body,
179 * etc.</p>
180 * </ul>
181 *
182 * <p>Here are some examples of other operations you can specify as intents
183 * using these additional parameters:</p>
184 *
185 * <ul>
186 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
187 * Launch the home screen.</p>
188 * </li>
189 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
190 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
191 * vnd.android.cursor.item/phone}</i></b>
192 * -- Display the list of people's phone numbers, allowing the user to
193 * browse through them and pick one and return it to the parent activity.</p>
194 * </li>
195 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
196 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
197 * -- Display all pickers for data that can be opened with
198 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
199 * allowing the user to pick one of them and then some data inside of it
200 * and returning the resulting URI to the caller. This can be used,
201 * for example, in an e-mail application to allow the user to pick some
202 * data to include as an attachment.</p>
203 * </li>
204 * </ul>
205 *
206 * <p>There are a variety of standard Intent action and category constants
207 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700208 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700209 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700210 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700211 *
212 * <p>Put together, the set of actions, data types, categories, and extra data
213 * defines a language for the system allowing for the expression of phrases
214 * such as "call john smith's cell". As applications are added to the system,
215 * they can extend this language by adding new actions, types, and categories, or
216 * they can modify the behavior of existing phrases by supplying their own
217 * activities that handle them.</p>
218 *
219 * <a name="IntentResolution"></a>
220 * <h3>Intent Resolution</h3>
221 *
222 * <p>There are two primary forms of intents you will use.
223 *
224 * <ul>
225 * <li> <p><b>Explicit Intents</b> have specified a component (via
226 * {@link #setComponent} or {@link #setClass}), which provides the exact
227 * class to be run. Often these will not include any other information,
228 * simply being a way for an application to launch various internal
229 * activities it has as the user interacts with the application.
230 *
231 * <li> <p><b>Implicit Intents</b> have not specified a component;
232 * instead, they must include enough information for the system to
233 * determine which of the available components is best to run for that
234 * intent.
235 * </ul>
236 *
237 * <p>When using implicit intents, given such an arbitrary intent we need to
238 * know what to do with it. This is handled by the process of <em>Intent
239 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
240 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
241 * more activities/receivers) that can handle it.</p>
242 *
243 * <p>The intent resolution mechanism basically revolves around matching an
244 * Intent against all of the &lt;intent-filter&gt; descriptions in the
245 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
246 * objects explicitly registered with {@link Context#registerReceiver}.) More
247 * details on this can be found in the documentation on the {@link
248 * IntentFilter} class.</p>
249 *
250 * <p>There are three pieces of information in the Intent that are used for
251 * resolution: the action, type, and category. Using this information, a query
252 * is done on the {@link PackageManager} for a component that can handle the
253 * intent. The appropriate component is determined based on the intent
254 * information supplied in the <code>AndroidManifest.xml</code> file as
255 * follows:</p>
256 *
257 * <ul>
258 * <li> <p>The <b>action</b>, if given, must be listed by the component as
259 * one it handles.</p>
260 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
261 * already supplied in the Intent. Like the action, if a type is
262 * included in the intent (either explicitly or implicitly in its
263 * data), then this must be listed by the component as one it handles.</p>
264 * <li> For data that is not a <code>content:</code> URI and where no explicit
265 * type is included in the Intent, instead the <b>scheme</b> of the
266 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
267 * considered. Again like the action, if we are matching a scheme it
268 * must be listed by the component as one it can handle.
269 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
270 * by the activity as categories it handles. That is, if you include
271 * the categories {@link #CATEGORY_LAUNCHER} and
272 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
273 * with an intent that lists <em>both</em> of those categories.
274 * Activities will very often need to support the
275 * {@link #CATEGORY_DEFAULT} so that they can be found by
276 * {@link Context#startActivity Context.startActivity()}.</p>
277 * </ul>
278 *
279 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700280 * allows a user to browse through a list of notes data and view details about
281 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700282 * name with one specific to your own package.</p>
283 *
284 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
285 * package="<i>com.android.notepad</i>"&gt;
286 * &lt;application android:icon="@drawable/app_notes"
287 * android:label="@string/app_name"&gt;
288 *
289 * &lt;provider class=".NotePadProvider"
290 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
291 *
292 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
293 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700294 * &lt;action android:name="android.intent.action.MAIN" /&gt;
295 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700296 * &lt;/intent-filter&gt;
297 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700298 * &lt;action android:name="android.intent.action.VIEW" /&gt;
299 * &lt;action android:name="android.intent.action.EDIT" /&gt;
300 * &lt;action android:name="android.intent.action.PICK" /&gt;
301 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
302 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700303 * &lt;/intent-filter&gt;
304 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700305 * &lt;action android:name="android.intent.action.GET_CONTENT" /&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 * &lt;/activity&gt;
310 *
311 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
312 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="android.intent.action.VIEW" /&gt;
314 * &lt;action android:name="android.intent.action.EDIT" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700317 * &lt;/intent-filter&gt;
318 *
319 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700320 * &lt;action android:name="android.intent.action.INSERT" /&gt;
321 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
322 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700323 * &lt;/intent-filter&gt;
324 *
325 * &lt;/activity&gt;
326 *
327 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
328 * android:theme="@android:style/Theme.Dialog"&gt;
329 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700330 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
331 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
332 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
333 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
334 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700335 * &lt;/intent-filter&gt;
336 * &lt;/activity&gt;
337 *
338 * &lt;/application&gt;
339 * &lt;/manifest&gt;</pre>
340 *
341 * <p>The first activity,
342 * <code>com.android.notepad.NotesList</code>, serves as our main
343 * entry into the app. It can do three things as described by its three intent
344 * templates:
345 * <ol>
346 * <li><pre>
347 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700348 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
349 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700350 * &lt;/intent-filter&gt;</pre>
351 * <p>This provides a top-level entry into the NotePad application: the standard
352 * MAIN action is a main entry point (not requiring any other information in
353 * the Intent), and the LAUNCHER category says that this entry point should be
354 * listed in the application launcher.</p>
355 * <li><pre>
356 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700357 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
358 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
359 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
360 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700361 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700362 * &lt;/intent-filter&gt;</pre>
363 * <p>This declares the things that the activity can do on a directory of
364 * notes. The type being supported is given with the &lt;type&gt; tag, where
365 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
366 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
367 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
368 * The activity allows the user to view or edit the directory of data (via
369 * the VIEW and EDIT actions), or to pick a particular note and return it
370 * to the caller (via the PICK action). Note also the DEFAULT category
371 * supplied here: this is <em>required</em> for the
372 * {@link Context#startActivity Context.startActivity} method to resolve your
373 * activity when its component name is not explicitly specified.</p>
374 * <li><pre>
375 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700376 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
377 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
378 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700379 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700380 * <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 -0700381 * the user without needing to know where it came from. The data type
382 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
383 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
384 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
385 * The GET_CONTENT action is similar to the PICK action, where the activity
386 * will return to its caller a piece of data selected by the user. Here,
387 * however, the caller specifies the type of data they desire instead of
388 * the type of data the user will be picking from.</p>
389 * </ol>
390 *
391 * <p>Given these capabilities, the following intents will resolve to the
392 * NotesList activity:</p>
393 *
394 * <ul>
395 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
396 * activities that can be used as top-level entry points into an
397 * application.</p>
398 * <li> <p><b>{ action=android.app.action.MAIN,
399 * category=android.app.category.LAUNCHER }</b> is the actual intent
400 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700401 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700402 * data=content://com.google.provider.NotePad/notes }</b>
403 * displays a list of all the notes under
404 * "content://com.google.provider.NotePad/notes", which
405 * the user can browse through and see the details on.</p>
406 * <li> <p><b>{ action=android.app.action.PICK
407 * data=content://com.google.provider.NotePad/notes }</b>
408 * provides a list of the notes under
409 * "content://com.google.provider.NotePad/notes", from which
410 * the user can pick a note whose data URL is returned back to the caller.</p>
411 * <li> <p><b>{ action=android.app.action.GET_CONTENT
412 * type=vnd.android.cursor.item/vnd.google.note }</b>
413 * is similar to the pick action, but allows the caller to specify the
414 * kind of data they want back so that the system can find the appropriate
415 * activity to pick something of that data type.</p>
416 * </ul>
417 *
418 * <p>The second activity,
419 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
420 * note entry and allows them to edit it. It can do two things as described
421 * by its two intent templates:
422 * <ol>
423 * <li><pre>
424 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700425 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
426 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
427 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
428 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700429 * &lt;/intent-filter&gt;</pre>
430 * <p>The first, primary, purpose of this activity is to let the user interact
431 * with a single note, as decribed by the MIME type
432 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
433 * either VIEW a note or allow the user to EDIT it. Again we support the
434 * DEFAULT category to allow the activity to be launched without explicitly
435 * specifying its component.</p>
436 * <li><pre>
437 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700438 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
439 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
440 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700441 * &lt;/intent-filter&gt;</pre>
442 * <p>The secondary use of this activity is to insert a new note entry into
443 * an existing directory of notes. This is used when the user creates a new
444 * note: the INSERT action is executed on the directory of notes, causing
445 * this activity to run and have the user create the new note data which
446 * it then adds to the content provider.</p>
447 * </ol>
448 *
449 * <p>Given these capabilities, the following intents will resolve to the
450 * NoteEditor activity:</p>
451 *
452 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700453 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700454 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
455 * shows the user the content of note <var>{ID}</var>.</p>
456 * <li> <p><b>{ action=android.app.action.EDIT
457 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
458 * allows the user to edit the content of note <var>{ID}</var>.</p>
459 * <li> <p><b>{ action=android.app.action.INSERT
460 * data=content://com.google.provider.NotePad/notes }</b>
461 * creates a new, empty note in the notes list at
462 * "content://com.google.provider.NotePad/notes"
463 * and allows the user to edit it. If they keep their changes, the URI
464 * of the newly created note is returned to the caller.</p>
465 * </ul>
466 *
467 * <p>The last activity,
468 * <code>com.android.notepad.TitleEditor</code>, allows the user to
469 * edit the title of a note. This could be implemented as a class that the
470 * application directly invokes (by explicitly setting its component in
471 * the Intent), but here we show a way you can publish alternative
472 * operations on existing data:</p>
473 *
474 * <pre>
475 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700476 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
477 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
478 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
479 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
480 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700481 * &lt;/intent-filter&gt;</pre>
482 *
483 * <p>In the single intent template here, we
484 * have created our own private action called
485 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
486 * edit the title of a note. It must be invoked on a specific note
487 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
488 * view and edit actions, but here displays and edits the title contained
489 * in the note data.
490 *
491 * <p>In addition to supporting the default category as usual, our title editor
492 * also supports two other standard categories: ALTERNATIVE and
493 * SELECTED_ALTERNATIVE. Implementing
494 * these categories allows others to find the special action it provides
495 * without directly knowing about it, through the
496 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
497 * more often to build dynamic menu items with
498 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
499 * template here was also supply an explicit name for the template
500 * (via <code>android:label="@string/resolve_title"</code>) to better control
501 * what the user sees when presented with this activity as an alternative
502 * action to the data they are viewing.
503 *
504 * <p>Given these capabilities, the following intent will resolve to the
505 * TitleEditor activity:</p>
506 *
507 * <ul>
508 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
509 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
510 * displays and allows the user to edit the title associated
511 * with note <var>{ID}</var>.</p>
512 * </ul>
513 *
514 * <h3>Standard Activity Actions</h3>
515 *
516 * <p>These are the current standard actions that Intent defines for launching
517 * activities (usually through {@link Context#startActivity}. The most
518 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
519 * {@link #ACTION_EDIT}.
520 *
521 * <ul>
522 * <li> {@link #ACTION_MAIN}
523 * <li> {@link #ACTION_VIEW}
524 * <li> {@link #ACTION_ATTACH_DATA}
525 * <li> {@link #ACTION_EDIT}
526 * <li> {@link #ACTION_PICK}
527 * <li> {@link #ACTION_CHOOSER}
528 * <li> {@link #ACTION_GET_CONTENT}
529 * <li> {@link #ACTION_DIAL}
530 * <li> {@link #ACTION_CALL}
531 * <li> {@link #ACTION_SEND}
532 * <li> {@link #ACTION_SENDTO}
533 * <li> {@link #ACTION_ANSWER}
534 * <li> {@link #ACTION_INSERT}
535 * <li> {@link #ACTION_DELETE}
536 * <li> {@link #ACTION_RUN}
537 * <li> {@link #ACTION_SYNC}
538 * <li> {@link #ACTION_PICK_ACTIVITY}
539 * <li> {@link #ACTION_SEARCH}
540 * <li> {@link #ACTION_WEB_SEARCH}
541 * <li> {@link #ACTION_FACTORY_TEST}
542 * </ul>
543 *
544 * <h3>Standard Broadcast Actions</h3>
545 *
546 * <p>These are the current standard actions that Intent defines for receiving
547 * broadcasts (usually through {@link Context#registerReceiver} or a
548 * &lt;receiver&gt; tag in a manifest).
549 *
550 * <ul>
551 * <li> {@link #ACTION_TIME_TICK}
552 * <li> {@link #ACTION_TIME_CHANGED}
553 * <li> {@link #ACTION_TIMEZONE_CHANGED}
554 * <li> {@link #ACTION_BOOT_COMPLETED}
555 * <li> {@link #ACTION_PACKAGE_ADDED}
556 * <li> {@link #ACTION_PACKAGE_CHANGED}
557 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800558 * <li> {@link #ACTION_PACKAGE_RESTARTED}
559 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000560 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
561 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700562 * <li> {@link #ACTION_UID_REMOVED}
563 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700564 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700565 * <li> {@link #ACTION_POWER_DISCONNECTED}
566 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700567 * </ul>
568 *
569 * <h3>Standard Categories</h3>
570 *
571 * <p>These are the current standard categories that can be used to further
572 * clarify an Intent via {@link #addCategory}.
573 *
574 * <ul>
575 * <li> {@link #CATEGORY_DEFAULT}
576 * <li> {@link #CATEGORY_BROWSABLE}
577 * <li> {@link #CATEGORY_TAB}
578 * <li> {@link #CATEGORY_ALTERNATIVE}
579 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
580 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800581 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700582 * <li> {@link #CATEGORY_HOME}
583 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700584 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400585 * <li> {@link #CATEGORY_CAR_DOCK}
586 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500587 * <li> {@link #CATEGORY_LE_DESK_DOCK}
588 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200589 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700590 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800591 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700592 * </ul>
593 *
594 * <h3>Standard Extra Data</h3>
595 *
596 * <p>These are the current standard fields that can be used as extra data via
597 * {@link #putExtra}.
598 *
599 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_ALARM_COUNT}
601 * <li> {@link #EXTRA_BCC}
602 * <li> {@link #EXTRA_CC}
603 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
604 * <li> {@link #EXTRA_DATA_REMOVED}
605 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500606 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
607 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_DOCK_STATE_CAR}
609 * <li> {@link #EXTRA_DOCK_STATE_DESK}
610 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
611 * <li> {@link #EXTRA_DONT_KILL_APP}
612 * <li> {@link #EXTRA_EMAIL}
613 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700614 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800615 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700616 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800617 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700618 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800619 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
620 * <li> {@link #EXTRA_REPLACING}
621 * <li> {@link #EXTRA_SHORTCUT_ICON}
622 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
623 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700624 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800625 * <li> {@link #EXTRA_SHORTCUT_NAME}
626 * <li> {@link #EXTRA_SUBJECT}
627 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700628 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800629 * <li> {@link #EXTRA_TITLE}
630 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631 * </ul>
632 *
633 * <h3>Flags</h3>
634 *
635 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800636 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
637 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700638 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800639public class Intent implements Parcelable, Cloneable {
Jeff Sharkey9c9ee952019-03-22 17:18:38 -0600640 private static final String TAG = "Intent";
641
Craig Mautner21d24a22014-04-23 11:45:37 -0700642 private static final String ATTR_ACTION = "action";
643 private static final String TAG_CATEGORIES = "categories";
644 private static final String ATTR_CATEGORY = "category";
645 private static final String TAG_EXTRA = "extra";
646 private static final String ATTR_TYPE = "type";
Dianne Hackborn3c2758d2019-04-11 13:18:58 -0700647 private static final String ATTR_IDENTIFIER = "ident";
Craig Mautner21d24a22014-04-23 11:45:37 -0700648 private static final String ATTR_COMPONENT = "component";
649 private static final String ATTR_DATA = "data";
650 private static final String ATTR_FLAGS = "flags";
651
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700652 // ---------------------------------------------------------------------
653 // ---------------------------------------------------------------------
654 // Standard intent activity actions (see action variable).
655
656 /**
657 * Activity Action: Start as a main entry point, does not expect to
658 * receive data.
659 * <p>Input: nothing
660 * <p>Output: nothing
661 */
662 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
663 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800664
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700665 /**
666 * Activity Action: Display the data to the user. This is the most common
667 * action performed on data -- it is the generic action you can use on
668 * a piece of data to get the most reasonable thing to occur. For example,
669 * when used on a contacts entry it will view the entry; when used on a
670 * mailto: URI it will bring up a compose window filled with the information
671 * supplied by the URI; when used with a tel: URI it will invoke the
672 * dialer.
673 * <p>Input: {@link #getData} is URI from which to retrieve data.
674 * <p>Output: nothing.
675 */
676 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
677 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800678
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700680 * Extra that can be included on activity intents coming from the storage UI
681 * when it launches sub-activities to manage various types of storage. For example,
682 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
683 * the images on the device, and in that case also include this extra to tell the
684 * app it is coming from the storage UI so should help the user manage storage of
685 * this type.
686 */
687 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
688
689 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700690 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
691 * performed on a piece of data.
692 */
693 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800694
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700695 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900696 * Activity Action: Quick view the data. Launches a quick viewer for
697 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900698 * <p>Activities handling this intent action should handle the vast majority of
699 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700700 * <p>Quick viewers must render the quick view image locally, and must not send
701 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900702 * <p>Input: {@link #getData} is a mandatory content URI of the item to
703 * preview. {@link #getClipData} contains an optional list of content URIs
704 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
705 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700706 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
707 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700708 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900709 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700710 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
714
715 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 * Used to indicate that some piece of data should be attached to some other
717 * place. For example, image data could be attached to a contact. It is up
718 * to the recipient to decide where the data should be attached; the intent
719 * does not specify the ultimate destination.
720 * <p>Input: {@link #getData} is URI of data to be attached.
721 * <p>Output: nothing.
722 */
723 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
724 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800725
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700726 /**
727 * Activity Action: Provide explicit editable access to the given data.
728 * <p>Input: {@link #getData} is URI of data to be edited.
729 * <p>Output: nothing.
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 /**
735 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
736 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
737 * The extras can contain type specific data to pass through to the editing/creating
738 * activity.
739 * <p>Output: The URI of the item that was picked. This must be a content:
740 * URI so that any receiver can access it.
741 */
742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
743 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700745 /**
746 * Activity Action: Pick an item from the data, returning what was selected.
747 * <p>Input: {@link #getData} is URI containing a directory of data
748 * (vnd.android.cursor.dir/*) from which to pick an item.
749 * <p>Output: The URI of the item that was picked.
750 */
751 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
752 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800753
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700754 /**
755 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800756 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800757 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
758 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700759 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
760 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800761 * (value: ShortcutIconResource).</p>
762 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800763 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700764 * @see #EXTRA_SHORTCUT_INTENT
765 * @see #EXTRA_SHORTCUT_NAME
766 * @see #EXTRA_SHORTCUT_ICON
767 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
768 * @see android.content.Intent.ShortcutIconResource
769 */
770 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
771 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
772
773 /**
774 * The name of the extra used to define the Intent of a shortcut.
775 *
776 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800777 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800779 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700780 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
781 /**
782 * The name of the extra used to define the name of a shortcut.
783 *
784 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800785 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700786 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800787 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700788 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
789 /**
790 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
791 *
792 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800793 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800795 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700796 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
797 /**
798 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
799 *
800 * @see #ACTION_CREATE_SHORTCUT
801 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800802 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700803 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800804 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700805 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
806 "android.intent.extra.shortcut.ICON_RESOURCE";
807
808 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500809 * An activity that provides a user interface for adjusting application preferences.
810 * Optional but recommended settings for all applications which have settings.
811 */
812 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
813 public static final String ACTION_APPLICATION_PREFERENCES
814 = "android.intent.action.APPLICATION_PREFERENCES";
815
816 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700817 * Activity Action: Launch an activity showing the app information.
818 * For applications which install other applications (such as app stores), it is recommended
819 * to handle this action for providing the app information to the user.
820 *
821 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
822 * to be displayed.
823 * <p>Output: Nothing.
824 */
825 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
826 public static final String ACTION_SHOW_APP_INFO
827 = "android.intent.action.SHOW_APP_INFO";
828
829 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800830 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700831 *
832 * @see Intent#ACTION_CREATE_SHORTCUT
833 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800834 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
835 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700836 */
837 public static class ShortcutIconResource implements Parcelable {
838 /**
839 * The package name of the application containing the icon.
840 */
841 public String packageName;
842
843 /**
844 * The resource name of the icon, including package, name and type.
845 */
846 public String resourceName;
847
848 /**
849 * Creates a new ShortcutIconResource for the specified context and resource
850 * identifier.
851 *
852 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700853 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700854 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700855 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700856 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700857 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700858 ShortcutIconResource icon = new ShortcutIconResource();
859 icon.packageName = context.getPackageName();
860 icon.resourceName = context.getResources().getResourceName(resourceId);
861 return icon;
862 }
863
864 /**
865 * Used to read a ShortcutIconResource from a Parcel.
866 */
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -0700867 public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700868 new Parcelable.Creator<ShortcutIconResource>() {
869
870 public ShortcutIconResource createFromParcel(Parcel source) {
871 ShortcutIconResource icon = new ShortcutIconResource();
872 icon.packageName = source.readString();
873 icon.resourceName = source.readString();
874 return icon;
875 }
876
877 public ShortcutIconResource[] newArray(int size) {
878 return new ShortcutIconResource[size];
879 }
880 };
881
882 /**
883 * No special parcel contents.
884 */
885 public int describeContents() {
886 return 0;
887 }
888
889 public void writeToParcel(Parcel dest, int flags) {
890 dest.writeString(packageName);
891 dest.writeString(resourceName);
892 }
893
894 @Override
895 public String toString() {
896 return resourceName;
897 }
898 }
899
900 /**
901 * Activity Action: Display an activity chooser, allowing the user to pick
902 * what they want to before proceeding. This can be used as an alternative
903 * to the standard activity picker that is displayed by the system when
904 * you try to start an activity with multiple possible matches, with these
905 * differences in behavior:
906 * <ul>
907 * <li>You can specify the title that will appear in the activity chooser.
908 * <li>The user does not have the option to make one of the matching
909 * activities a preferred activity, and all possible activities will
910 * always be shown even if one of them is currently marked as the
911 * preferred activity.
912 * </ul>
913 * <p>
914 * This action should be used when the user will naturally expect to
915 * select an activity in order to proceed. An example if when not to use
916 * it is when the user clicks on a "mailto:" link. They would naturally
917 * expect to go directly to their mail app, so startActivity() should be
918 * called directly: it will
919 * either launch the current preferred app, or put up a dialog allowing the
920 * user to pick an app to use and optionally marking that as preferred.
921 * <p>
922 * In contrast, if the user is selecting a menu item to send a picture
923 * they are viewing to someone else, there are many different things they
924 * may want to do at this point: send it through e-mail, upload it to a
925 * web service, etc. In this case the CHOOSER action should be used, to
926 * always present to the user a list of the things they can do, with a
927 * nice title given by the caller such as "Send this photo with:".
928 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700929 * If you need to grant URI permissions through a chooser, you must specify
930 * the permissions to be granted on the ACTION_CHOOSER Intent
931 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
932 * {@link #setClipData} to specify the URIs to be granted as well as
933 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
934 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
935 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700936 * As a convenience, an Intent of this form can be created with the
937 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700938 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700939 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700940 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
941 * and can optionally have a {@link #EXTRA_TITLE} field containing the
942 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700943 * <p>
944 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700945 */
946 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
947 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
948
949 /**
950 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
951 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700952 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
953 * target intent, also optionally supplying a title. If the target
954 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
955 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
956 * set in the returned chooser intent, with its ClipData set appropriately:
957 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500958 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700959 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700960 * @param target The Intent that the user will be selecting an activity
961 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500962 * @param title Optional title that will be displayed in the chooser,
963 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700964 * @return Return a new Intent object that you can hand to
965 * {@link Context#startActivity(Intent) Context.startActivity()} and
966 * related methods.
967 */
968 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700969 return createChooser(target, title, null);
970 }
971
972 /**
973 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
974 *
975 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
976 * target intent, also optionally supplying a title. If the target
977 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
978 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
979 * set in the returned chooser intent, with its ClipData set appropriately:
980 * either a direct reflection of {@link #getClipData()} if that is non-null,
981 * or a new ClipData built from {@link #getData()}.</p>
982 *
983 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
984 * when the user makes a choice. This can be useful if the calling application wants
985 * to remember the last chosen target and surface it as a more prominent or one-touch
986 * affordance elsewhere in the UI for next time.</p>
987 *
988 * @param target The Intent that the user will be selecting an activity
989 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500990 * @param title Optional title that will be displayed in the chooser,
991 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
Adam Powell0b3c1122014-10-09 12:50:14 -0700992 * @param sender Optional IntentSender to be called when a choice is made.
993 * @return Return a new Intent object that you can hand to
994 * {@link Context#startActivity(Intent) Context.startActivity()} and
995 * related methods.
996 */
997 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700998 Intent intent = new Intent(ACTION_CHOOSER);
999 intent.putExtra(EXTRA_INTENT, target);
1000 if (title != null) {
1001 intent.putExtra(EXTRA_TITLE, title);
1002 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001003
Adam Powell0b3c1122014-10-09 12:50:14 -07001004 if (sender != null) {
1005 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1006 }
1007
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001008 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -07001009 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1010 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1011 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -07001012 if (permFlags != 0) {
1013 ClipData targetClipData = target.getClipData();
1014 if (targetClipData == null && target.getData() != null) {
1015 ClipData.Item item = new ClipData.Item(target.getData());
1016 String[] mimeTypes;
1017 if (target.getType() != null) {
1018 mimeTypes = new String[] { target.getType() };
1019 } else {
1020 mimeTypes = new String[] { };
1021 }
1022 targetClipData = new ClipData(null, mimeTypes, item);
1023 }
1024 if (targetClipData != null) {
1025 intent.setClipData(targetClipData);
1026 intent.addFlags(permFlags);
1027 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001028 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001029
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001030 return intent;
1031 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001032
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001033 /**
1034 * Activity Action: Allow the user to select a particular kind of data and
1035 * return it. This is different than {@link #ACTION_PICK} in that here we
1036 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001037 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001038 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001039 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001040 * etc.
1041 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001042 * 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 -07001043 * of data, such as a person contact, you set the MIME type to the kind of
1044 * data you want and launch it with {@link Context#startActivity(Intent)}.
1045 * The system will then launch the best application to select that kind
1046 * of data for you.
1047 * <p>
1048 * You may also be interested in any of a set of types of content the user
1049 * can pick. For example, an e-mail application that wants to allow the
1050 * user to add an attachment to an e-mail message can use this action to
1051 * bring up a list of all of the types of content the user can attach.
1052 * <p>
1053 * In this case, you should wrap the GET_CONTENT intent with a chooser
1054 * (through {@link #createChooser}), which will give the proper interface
1055 * for the user to pick how to send your data and allow you to specify
1056 * a prompt indicating what they are doing. You will usually specify a
1057 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1058 * broad range of content types the user can select from.
1059 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001060 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001061 * only pick from data that can be represented as a stream. This is
1062 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1063 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001064 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001065 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001066 * is locally available on the device. For example, if this extra is set
1067 * to true then an image picker should not show any pictures that are available
1068 * from a remote server but not already on the local device (thus requiring
1069 * they be downloaded when opened).
1070 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001071 * If the caller can handle multiple returned items (the user performing
1072 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1073 * to indicate this.
1074 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001075 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1076 * that no URI is supplied in the intent, as there are no constraints on
1077 * where the returned data originally comes from. You may also include the
1078 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001079 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001080 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1081 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001082 * <p>
1083 * Output: The URI of the item that was picked. This must be a content:
1084 * URI so that any receiver can access it.
1085 */
1086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1088 /**
1089 * Activity Action: Dial a number as specified by the data. This shows a
1090 * UI with the number being dialed, allowing the user to explicitly
1091 * initiate the call.
1092 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1093 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1094 * number.
1095 * <p>Output: nothing.
1096 */
1097 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1098 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1099 /**
1100 * Activity Action: Perform a call to someone specified by the data.
1101 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1102 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1103 * number.
1104 * <p>Output: nothing.
1105 *
1106 * <p>Note: there will be restrictions on which applications can initiate a
1107 * call; most applications should use the {@link #ACTION_DIAL}.
1108 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1109 * numbers. Applications can <strong>dial</strong> emergency numbers using
1110 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001111 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001112 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001113 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001114 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001115 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001116 */
1117 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118 public static final String ACTION_CALL = "android.intent.action.CALL";
1119 /**
1120 * Activity Action: Perform a call to an emergency number specified by the
1121 * data.
1122 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1123 * tel: URI of an explicit phone number.
1124 * <p>Output: nothing.
Brad Ebinger3636d742019-05-21 15:28:19 -07001125 *
1126 * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1127 * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1128 * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1129 * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1130 * factors, such as network conditions and Modem/SIM status.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001131 * @hide
1132 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001133 @SystemApi
1134 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001135 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1136 /**
1137 * Activity action: Perform a call to any number (emergency or not)
1138 * specified by the data.
1139 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1140 * tel: URI of an explicit phone number.
1141 * <p>Output: nothing.
1142 * @hide
1143 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001144 @SystemApi
1145 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001146 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001147
Santos Cordon15a13782015-03-31 18:32:31 -07001148 /**
fionaxuadfe7002017-02-17 17:20:46 -08001149 * Activity Action: Main entry point for carrier setup apps.
1150 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1151 * carrier service and typically require
1152 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1153 * fulfill their duties.
1154 */
1155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1156 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1157 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001158 * Activity Action: Send a message to someone specified by the data.
1159 * <p>Input: {@link #getData} is URI describing the target.
1160 * <p>Output: nothing.
1161 */
1162 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1164 /**
1165 * Activity Action: Deliver some data to someone else. Who the data is
1166 * being delivered to is not specified; it is up to the receiver of this
1167 * action to ask the user where the data should be sent.
1168 * <p>
1169 * When launching a SEND intent, you should usually wrap it in a chooser
1170 * (through {@link #createChooser}), which will give the proper interface
1171 * for the user to pick how to send your data and allow you to specify
1172 * a prompt indicating what they are doing.
1173 * <p>
1174 * Input: {@link #getType} is the MIME type of the data being sent.
1175 * get*Extra can have either a {@link #EXTRA_TEXT}
1176 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1177 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1178 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1179 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001180 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1181 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1182 * your text with HTML formatting.
1183 * <p>
1184 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1185 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1186 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1187 * content: URIs and other advanced features of {@link ClipData}. If
1188 * using this approach, you still must supply the same data through the
1189 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1190 * for compatibility with old applications. If you don't set a ClipData,
1191 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001192 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001193 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1194 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1195 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1196 * be openable only as asset typed files using
1197 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1198 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001199 * Optional standard extras, which may be interpreted by some recipients as
1200 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1201 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1202 * <p>
1203 * Output: nothing.
1204 */
1205 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206 public static final String ACTION_SEND = "android.intent.action.SEND";
1207 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001208 * Activity Action: Deliver multiple data to someone else.
1209 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001210 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001211 * <p>
1212 * Input: {@link #getType} is the MIME type of the data being sent.
1213 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001214 * #EXTRA_STREAM} field, containing the data to be sent. If using
1215 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1216 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001217 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001218 * Multiple types are supported, and receivers should handle mixed types
1219 * whenever possible. The right way for the receiver to check them is to
1220 * use the content resolver on each URI. The intent sender should try to
1221 * put the most concrete mime type in the intent type, but it can fall
1222 * back to {@literal <type>/*} or {@literal *}/* as needed.
1223 * <p>
1224 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1225 * be image/jpg, but if you are sending image/jpg and image/png, then the
1226 * intent's type should be image/*.
1227 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001228 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1229 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1230 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1231 * content: URIs and other advanced features of {@link ClipData}. If
1232 * using this approach, you still must supply the same data through the
1233 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1234 * for compatibility with old applications. If you don't set a ClipData,
1235 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1236 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001237 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1238 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1239 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1240 * be openable only as asset typed files using
1241 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1242 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001243 * Optional standard extras, which may be interpreted by some recipients as
1244 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1245 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1246 * <p>
1247 * Output: nothing.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1251 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001252 * Activity Action: Handle an incoming phone call.
1253 * <p>Input: nothing.
1254 * <p>Output: nothing.
1255 */
1256 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1258 /**
1259 * Activity Action: Insert an empty item into the given container.
1260 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1261 * in which to place the data.
1262 * <p>Output: URI of the new data that was created.
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1266 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001267 * Activity Action: Create a new item in the given container, initializing it
1268 * from the current contents of the clipboard.
1269 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1270 * in which to place the data.
1271 * <p>Output: URI of the new data that was created.
1272 */
1273 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1275 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001276 * Activity Action: Delete the given data from its container.
1277 * <p>Input: {@link #getData} is URI of data to be deleted.
1278 * <p>Output: nothing.
1279 */
1280 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1282 /**
1283 * Activity Action: Run the data, whatever that means.
1284 * <p>Input: ? (Note: this is currently specific to the test harness.)
1285 * <p>Output: nothing.
1286 */
1287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288 public static final String ACTION_RUN = "android.intent.action.RUN";
1289 /**
1290 * Activity Action: Perform a data synchronization.
1291 * <p>Input: ?
1292 * <p>Output: ?
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1296 /**
1297 * Activity Action: Pick an activity given an intent, returning the class
1298 * selected.
1299 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1300 * used with {@link PackageManager#queryIntentActivities} to determine the
1301 * set of activities from which to pick.
1302 * <p>Output: Class name of the activity that was selected.
1303 */
1304 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1305 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1306 /**
1307 * Activity Action: Perform a search.
1308 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1309 * is the text to search for. If empty, simply
1310 * enter your search results Activity with the search UI activated.
1311 * <p>Output: nothing.
1312 */
1313 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1315 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001316 * Activity Action: Start the platform-defined tutorial
1317 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1318 * is the text to search for. If empty, simply
1319 * enter your search results Activity with the search UI activated.
1320 * <p>Output: nothing.
1321 */
1322 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1323 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1324 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001325 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001326 * <p>
1327 * Input: {@link android.app.SearchManager#QUERY
1328 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1329 * a url starts with http or https, the site will be opened. If it is plain
1330 * text, Google search will be applied.
1331 * <p>
1332 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001333 */
1334 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1335 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001336
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001337 /**
Jim Miller07994402012-05-02 14:22:27 -07001338 * Activity Action: Perform assist action.
1339 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001340 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1341 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001342 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1343 * information.
Jim Miller07994402012-05-02 14:22:27 -07001344 * Output: nothing.
1345 */
1346 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1347 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001348
1349 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001350 * Activity Action: Perform voice assist action.
1351 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001352 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1353 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001354 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001355 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001356 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001357 */
Amith Yamasani16452032017-03-03 10:15:57 -08001358 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001359 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1360 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1361
1362 /**
Adam Skory7140a252013-09-11 12:04:58 +01001363 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1364 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001365 */
1366 public static final String EXTRA_ASSIST_PACKAGE
1367 = "android.intent.extra.ASSIST_PACKAGE";
1368
1369 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001370 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1371 * application package at the time the assist was invoked.
1372 */
1373 public static final String EXTRA_ASSIST_UID
1374 = "android.intent.extra.ASSIST_UID";
1375
1376 /**
Adam Skory7140a252013-09-11 12:04:58 +01001377 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1378 * information supplied by the current foreground app at the time of the assist request.
1379 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001380 */
1381 public static final String EXTRA_ASSIST_CONTEXT
1382 = "android.intent.extra.ASSIST_CONTEXT";
1383
Jim Miller07994402012-05-02 14:22:27 -07001384 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001385 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1386 * keyboard as the primary input device for assistance.
1387 */
1388 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1389 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1390
1391 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001392 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1393 * that was used to invoke the assist.
1394 */
1395 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1396 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1397
1398 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001399 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001400 * <p>Input: Nothing.
1401 * <p>Output: nothing.
1402 */
1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1405 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001406 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001407 * <p>Input: Nothing.
1408 * <p>Output: Nothing.
1409 */
1410 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1411 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1412
1413 /**
1414 * Activity Action: Show activity for reporting a bug.
1415 * <p>Input: Nothing.
1416 * <p>Output: Nothing.
1417 */
1418 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1419 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1420
1421 /**
1422 * Activity Action: Main entry point for factory tests. Only used when
1423 * the device is booting in factory test node. The implementing package
1424 * must be installed in the system image.
1425 * <p>Input: nothing
1426 * <p>Output: nothing
1427 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001428 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001429 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1430
1431 /**
1432 * Activity Action: The user pressed the "call" button to go to the dialer
1433 * or other appropriate UI for placing a call.
1434 * <p>Input: Nothing.
1435 * <p>Output: Nothing.
1436 */
1437 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1439
1440 /**
1441 * Activity Action: Start Voice Command.
1442 * <p>Input: Nothing.
1443 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001444 * <p class="note">
1445 * In some cases, a matching Activity may not exist, so ensure you
1446 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001447 */
1448 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1449 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001450
1451 /**
1452 * Activity Action: Start action associated with long pressing on the
1453 * search key.
1454 * <p>Input: Nothing.
1455 * <p>Output: Nothing.
1456 */
1457 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1458 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001459
Jacek Surazski86b6c532009-05-13 14:38:28 +02001460 /**
1461 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1462 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001463 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001464 * <p>Input: No data is specified. The bug report is passed in using
1465 * an {@link #EXTRA_BUG_REPORT} field.
1466 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001467 *
1468 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001469 */
1470 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1471 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001472
1473 /**
Joe Onoratoe21ab7e2018-12-18 15:00:25 -08001474 * An incident or bug report has been taken, and a system app has requested it to be shared,
1475 * so trigger the confirmation screen.
1476 *
1477 * This will be sent directly to the registered receiver with the
1478 * android.permission.APPROVE_INCIDENT_REPORTS permission.
1479 * @hide
1480 */
1481 @SystemApi
1482 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1483 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1484
1485 /**
Joe Onorato8daca752019-01-28 19:41:58 -08001486 * An incident report has been taken, and the user has approved it for sharing.
1487 * <p>
1488 * This will be sent directly to the registered receiver, which must have
1489 * both the DUMP and USAGE_STATS permissions.
1490 * <p>
1491 * After receiving this, the application should wait until a suitable time
1492 * (e.g. network available), get the list of available reports with
1493 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1494 * and then when the reports have been successfully uploaded, call
1495 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1496 *
1497 * @hide
1498 */
1499 @SystemApi
1500 public static final String ACTION_INCIDENT_REPORT_READY =
1501 "android.intent.action.INCIDENT_REPORT_READY";
1502
1503 /**
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001504 * Activity Action: Show power usage information to the user.
1505 * <p>Input: Nothing.
1506 * <p>Output: Nothing.
1507 */
1508 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1509 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001510
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001511 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001512 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1513 * to run.
1514 * <p>Input: Nothing.
1515 * <p>Output: Nothing.
1516 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1517 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1518 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001519 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001520 */
1521 @Deprecated
1522 @SystemApi
1523 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1524 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1525
1526 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001527 * Activity Action: Setup wizard to launch after a platform update. This
1528 * activity should have a string meta-data field associated with it,
1529 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1530 * the platform for setup. The activity will be launched only if
1531 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1532 * same value.
1533 * <p>Input: Nothing.
1534 * <p>Output: Nothing.
1535 * @hide
1536 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001537 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001538 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1539 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001540
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001541 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001542 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1543 * <p>Input: Nothing.
1544 * <p>Output: Nothing.
1545 * @hide
1546 */
1547 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1548 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001549 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001550
1551 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001552 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1553 * <p>Input: Nothing.
1554 * <p>Output: Nothing.
1555 * @hide
1556 */
1557 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1558 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001559 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001560
1561 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001562 * Activity Action: Show settings for managing network data usage of a
1563 * specific application. Applications should define an activity that offers
1564 * options to control data usage.
1565 */
1566 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1567 public static final String ACTION_MANAGE_NETWORK_USAGE =
1568 "android.intent.action.MANAGE_NETWORK_USAGE";
1569
1570 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001571 * Activity Action: Launch application installer.
1572 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001573 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001574 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1575 * you can also use "package:<package-name>" to install an application for the
1576 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001577 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1578 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1579 * <p>
1580 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1581 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001582 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001583 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001584 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1585 * in order to launch the application installer.
1586 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001587 *
1588 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1589 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1590 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001591 *
1592 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001593 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001594 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001595 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1596 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1597
1598 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001599 * Activity Action: Activity to handle split installation failures.
1600 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1601 * but the split that contains the application isn't installed. When a split is
1602 * installed in this manner, the containing package usually doesn't know this is
1603 * happening. However, if an error occurs during installation, the containing
1604 * package can define a single activity handling this action to deal with such
1605 * failures.
1606 * <p>The activity handling this action must be in the base package.
1607 * <p>
1608 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1609 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1610 */
1611 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1612 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1613
1614 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001615 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001616 * <p class="note">
1617 * This is a protected intent that can only be sent by the system.
1618 * </p>
1619 *
1620 * @hide
1621 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001622 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001623 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001624 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1625 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001626
1627 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001628 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001629 * <p>
1630 * The system will have a persistent connection to this service.
1631 * This is a protected intent that can only be sent by the system.
1632 * </p>
1633 *
1634 * @hide
1635 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001636 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001637 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001638 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1639 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001640
1641 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001642 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001643 *
1644 * <p class="note">
1645 * This is a protected intent that can only be sent by the system.
1646 * </p>
1647 *
1648 * @hide
1649 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001650 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001652 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1653 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001654
1655 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001656 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1657 * package. Specifies the installer package name; this package will receive the
1658 * {@link #ACTION_APP_ERROR} intent.
1659 */
1660 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1661 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1662
1663 /**
1664 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1665 * package. Specifies that the application being installed should not be
1666 * treated as coming from an unknown source, but as coming from the app
1667 * invoking the Intent. For this to work you must start the installer with
1668 * startActivityForResult().
1669 */
1670 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1671 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1672
1673 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001674 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1675 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001676 * data field originated from.
1677 */
rich cannings706e8ba2012-08-20 13:20:14 -07001678 public static final String EXTRA_ORIGINATING_URI
1679 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001680
1681 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001682 * This extra can be used with any Intent used to launch an activity, supplying information
1683 * about who is launching that activity. This field contains a {@link android.net.Uri}
1684 * object, typically an http: or https: URI of the web site that the referral came from;
1685 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1686 * a native application that it came from.
1687 *
1688 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1689 * instead of directly retrieving the extra. It is also valid for applications to
1690 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1691 * a string, not a Uri; the field here, if supplied, will always take precedence,
1692 * however.</p>
1693 *
1694 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001695 */
1696 public static final String EXTRA_REFERRER
1697 = "android.intent.extra.REFERRER";
1698
1699 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001700 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1701 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1702 * not be created, in particular when Intent extras are supplied through the
1703 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1704 * schemes.
1705 *
1706 * @see #EXTRA_REFERRER
1707 */
1708 public static final String EXTRA_REFERRER_NAME
1709 = "android.intent.extra.REFERRER_NAME";
1710
1711 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001712 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001713 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001714 * Currently only a system app that hosts the provider authority "downloads" or holds the
1715 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001716 * @hide
1717 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001718 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001719 public static final String EXTRA_ORIGINATING_UID
1720 = "android.intent.extra.ORIGINATING_UID";
1721
1722 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001723 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1724 * package. Tells the installer UI to skip the confirmation with the user
1725 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001726 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1727 * will no longer show an interstitial message about updating existing
1728 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001729 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001730 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001731 public static final String EXTRA_ALLOW_REPLACE
1732 = "android.intent.extra.ALLOW_REPLACE";
1733
1734 /**
1735 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1736 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1737 * return to the application the result code of the install/uninstall. The returned result
1738 * code will be {@link android.app.Activity#RESULT_OK} on success or
1739 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1740 */
1741 public static final String EXTRA_RETURN_RESULT
1742 = "android.intent.extra.RETURN_RESULT";
1743
1744 /**
1745 * Package manager install result code. @hide because result codes are not
1746 * yet ready to be exposed.
1747 */
1748 public static final String EXTRA_INSTALL_RESULT
1749 = "android.intent.extra.INSTALL_RESULT";
1750
1751 /**
1752 * Activity Action: Launch application uninstaller.
1753 * <p>
1754 * Input: The data must be a package: URI whose scheme specific part is
1755 * the package name of the current installed package to be uninstalled.
1756 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1757 * <p>
1758 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1759 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001760 * <p>
1761 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1762 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001763 *
1764 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1765 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001766 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001767 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001768 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1769 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1770
1771 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001772 * Specify whether the package should be uninstalled for all users.
1773 * @hide because these should not be part of normal application flow.
1774 */
1775 public static final String EXTRA_UNINSTALL_ALL_USERS
1776 = "android.intent.extra.UNINSTALL_ALL_USERS";
1777
1778 /**
Varun Shahb9fd6be2018-10-22 19:16:33 -07001779 * A string that associates with a metadata entry, indicating the last run version of the
1780 * platform that was setup.
1781 *
1782 * @see #ACTION_UPGRADE_SETUP
1783 *
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001784 * @hide
1785 */
Varun Shahb9fd6be2018-10-22 19:16:33 -07001786 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001787 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1788
Svet Ganov3695b8a2015-03-24 16:30:25 -07001789 /**
1790 * Activity action: Launch UI to manage the permissions of an app.
1791 * <p>
1792 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1793 * will be managed by the launched UI.
1794 * </p>
1795 * <p>
1796 * Output: Nothing.
1797 * </p>
1798 *
1799 * @see #EXTRA_PACKAGE_NAME
1800 *
1801 * @hide
1802 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001803 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001804 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1806 "android.intent.action.MANAGE_APP_PERMISSIONS";
1807
1808 /**
Joel Galenson035dfd92019-02-08 13:58:51 -08001809 * Activity action: Launch UI to manage a specific permissions of an app.
1810 * <p>
1811 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1812 * will be managed by the launched UI.
1813 * </p>
1814 * <p>
1815 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1816 * that should be managed by the launched UI.
1817 * </p>
1818 * <p>
1819 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1820 * </p>
1821 * <p>
1822 * Output: Nothing.
1823 * </p>
1824 *
1825 * @see #EXTRA_PACKAGE_NAME
1826 * @see #EXTRA_PERMISSION_NAME
1827 * @see #EXTRA_USER
1828 *
1829 * @hide
1830 */
1831 @SystemApi
1832 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1833 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1834 public static final String ACTION_MANAGE_APP_PERMISSION =
1835 "android.intent.action.MANAGE_APP_PERMISSION";
1836
1837 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001838 * Activity action: Launch UI to manage permissions.
1839 * <p>
1840 * Input: Nothing.
1841 * </p>
1842 * <p>
1843 * Output: Nothing.
1844 * </p>
1845 *
1846 * @hide
1847 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001848 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001849 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1850 public static final String ACTION_MANAGE_PERMISSIONS =
1851 "android.intent.action.MANAGE_PERMISSIONS";
1852
1853 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001854 * Activity action: Launch UI to review permissions for an app.
1855 * The system uses this intent if permission review for apps not
1856 * supporting the new runtime permissions model is enabled. In
1857 * this mode a permission review is required before any of the
1858 * app components can run.
1859 * <p>
1860 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1861 * permissions will be reviewed (mandatory).
1862 * </p>
1863 * <p>
1864 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1865 * be fired after the permission review (optional).
1866 * </p>
1867 * <p>
1868 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1869 * be invoked after the permission review (optional).
1870 * </p>
1871 * <p>
1872 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1873 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1874 * </p>
1875 * <p>
1876 * Output: Nothing.
1877 * </p>
1878 *
1879 * @see #EXTRA_PACKAGE_NAME
1880 * @see #EXTRA_INTENT
1881 * @see #EXTRA_REMOTE_CALLBACK
1882 * @see #EXTRA_RESULT_NEEDED
1883 *
1884 * @hide
1885 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001886 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001887 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1888 public static final String ACTION_REVIEW_PERMISSIONS =
1889 "android.intent.action.REVIEW_PERMISSIONS";
1890
1891 /**
Svet Ganov810d4842019-05-01 12:17:09 -07001892 * Activity action: Launch UI to show information about the usage
1893 * of a given permission. This action would be handled by apps that
1894 * want to show details about how and why given permission is being
1895 * used.
1896 * <p>
1897 * <strong>Important:</strong>You must protect the activity that handles
1898 * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
1899 * START_VIEW_PERMISSION_USAGE} permission to ensure that only the
1900 * system can launch this activity. The system will not launch
1901 * activities that are not properly protected.
1902 *
1903 * <p>
1904 * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission
1905 * for which the launched UI would be targeted.
1906 * </p>
1907 * <p>
1908 * Output: Nothing.
1909 * </p>
1910 */
1911 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1912 @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
1913 public static final String ACTION_VIEW_PERMISSION_USAGE =
1914 "android.intent.action.VIEW_PERMISSION_USAGE";
1915
1916 /**
Hai Zhang3a212892019-01-11 15:21:17 -08001917 * Activity action: Launch UI to manage a default app.
1918 * <p>
1919 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1920 * by the launched UI.
1921 * </p>
1922 * <p>
1923 * Output: Nothing.
1924 * </p>
1925 *
1926 * @hide
1927 */
1928 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1929 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1930 @SystemApi
1931 public static final String ACTION_MANAGE_DEFAULT_APP =
1932 "android.intent.action.MANAGE_DEFAULT_APP";
1933
1934 /**
1935 * Intent extra: A role name.
1936 * <p>
1937 * Type: String
1938 * </p>
1939 *
1940 * @see android.app.role.RoleManager
1941 *
1942 * @hide
1943 */
1944 @SystemApi
Hai Zhang22435862019-02-26 16:57:47 -08001945 @TestApi
Hai Zhang3a212892019-01-11 15:21:17 -08001946 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1947
1948 /**
Hai Zhang1d792322019-01-07 13:51:52 -08001949 * Activity action: Launch UI to manage special app accesses.
1950 * <p>
1951 * Input: Nothing.
1952 * </p>
1953 * <p>
1954 * Output: Nothing.
1955 * </p>
1956 *
1957 * @hide
1958 */
1959 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1960 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1961 @SystemApi
1962 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
1963 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
1964
1965 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001966 * Intent extra: A callback for reporting remote result as a bundle.
1967 * <p>
1968 * Type: IRemoteCallback
1969 * </p>
1970 *
1971 * @hide
1972 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001973 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001974 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1975
1976 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001977 * Intent extra: An app package name.
1978 * <p>
1979 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001980 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001981 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001982 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001983 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1984
1985 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001986 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1987 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1988 *
1989 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1990 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1991 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001992 *
1993 * @see #ACTION_MY_PACKAGE_SUSPENDED
1994 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1995 * @see PackageManager#isPackageSuspended()
1996 * @see PackageManager#getSuspendedPackageAppExtras()
1997 */
1998 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1999
2000 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07002001 * Intent extra: An app split name.
2002 * <p>
2003 * Type: String
2004 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07002005 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07002006 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2007
2008 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06002009 * Intent extra: A {@link ComponentName} value.
2010 * <p>
2011 * Type: String
2012 * </p>
2013 */
2014 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2015
2016 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08002017 * Intent extra: An extra for specifying whether a result is needed.
2018 * <p>
2019 * Type: boolean
2020 * </p>
2021 *
2022 * @hide
2023 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002024 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08002025 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2026
2027 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002028 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
2029 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
2030 *
2031 * @see PackageManager#isPackageSuspended()
2032 * @see #ACTION_PACKAGES_SUSPENDED
2033 *
2034 * @hide
2035 */
2036 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
2037
2038 /**
Mehdi Alizadehf99986a2019-03-13 15:56:06 -07002039 * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2040 * {@link #ACTION_SEND}.
Mehdi Alizadeh406e8b32018-12-11 18:21:49 -08002041 *
2042 * @see ShortcutInfo#getId()
2043 *
2044 * <p>
2045 * Type: String
2046 * </p>
2047 */
2048 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2049
2050 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07002051 * Activity action: Launch UI to manage which apps have a given permission.
2052 * <p>
Philip P. Moltmanned988282018-11-07 16:19:42 -08002053 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2054 * which will be managed by the launched UI.
Svet Ganov3695b8a2015-03-24 16:30:25 -07002055 * </p>
2056 * <p>
2057 * Output: Nothing.
2058 * </p>
2059 *
2060 * @see #EXTRA_PERMISSION_NAME
2061 *
2062 * @hide
2063 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002064 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07002065 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2066 public static final String ACTION_MANAGE_PERMISSION_APPS =
2067 "android.intent.action.MANAGE_PERMISSION_APPS";
2068
2069 /**
2070 * Intent extra: The name of a permission.
2071 * <p>
2072 * Type: String
2073 * </p>
2074 *
2075 * @hide
2076 */
2077 @SystemApi
2078 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2079
Joel Galenson13096ea2018-09-27 11:18:44 -07002080 /**
Joel Galenson029aac72019-01-07 10:31:28 -08002081 * Intent extra: The name of a permission group.
2082 * <p>
2083 * Type: String
2084 * </p>
2085 *
2086 * @hide
2087 */
2088 @SystemApi
2089 public static final String EXTRA_PERMISSION_GROUP_NAME =
2090 "android.intent.extra.PERMISSION_GROUP_NAME";
2091
2092 /**
Joel Galensonc857f022019-01-22 10:01:00 -08002093 * Intent extra: The number of milliseconds.
2094 * <p>
2095 * Type: long
2096 * </p>
2097 */
2098 public static final String EXTRA_DURATION_MILLIS =
2099 "android.intent.extra.DURATION_MILLIS";
2100
2101 /**
Joel Galenson13096ea2018-09-27 11:18:44 -07002102 * Activity action: Launch UI to review app uses of permissions.
2103 * <p>
Joel Galensonb995eda2018-12-04 16:28:04 -08002104 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
Joel Galenson029aac72019-01-07 10:31:28 -08002105 * that will be displayed by the launched UI. Do not pass both this and
2106 * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2107 * </p>
2108 * <p>
2109 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2110 * that will be displayed by the launched UI. Do not pass both this and
2111 * {@link #EXTRA_PERMISSION_NAME}.
Joel Galenson13096ea2018-09-27 11:18:44 -07002112 * </p>
2113 * <p>
Joel Galensonc857f022019-01-22 10:01:00 -08002114 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2115 * activity to show (optional). Must be non-negative.
2116 * </p>
2117 * <p>
Joel Galenson13096ea2018-09-27 11:18:44 -07002118 * Output: Nothing.
2119 * </p>
Joel Galenson37f8b722019-03-14 08:43:26 -07002120 * <p class="note">
2121 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2122 * </p>
Joel Galenson13096ea2018-09-27 11:18:44 -07002123 *
Joel Galensonb995eda2018-12-04 16:28:04 -08002124 * @see #EXTRA_PERMISSION_NAME
Joel Galenson029aac72019-01-07 10:31:28 -08002125 * @see #EXTRA_PERMISSION_GROUP_NAME
Joel Galensonc857f022019-01-22 10:01:00 -08002126 * @see #EXTRA_DURATION_MILLIS
Joel Galensonb995eda2018-12-04 16:28:04 -08002127 *
Joel Galenson13096ea2018-09-27 11:18:44 -07002128 * @hide
2129 */
2130 @SystemApi
Joel Galenson37f8b722019-03-14 08:43:26 -07002131 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
Joel Galenson13096ea2018-09-27 11:18:44 -07002132 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2133 public static final String ACTION_REVIEW_PERMISSION_USAGE =
2134 "android.intent.action.REVIEW_PERMISSION_USAGE";
2135
Joel Galenson78ec58d2018-10-24 10:06:25 -07002136 /**
Joel Galenson37f8b722019-03-14 08:43:26 -07002137 * Activity action: Launch UI to review ongoing app uses of permissions.
2138 * <p>
2139 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2140 * activity to show (optional). Must be non-negative.
2141 * </p>
2142 * <p>
2143 * Output: Nothing.
2144 * </p>
2145 * <p class="note">
2146 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2147 * </p>
2148 *
2149 * @see #EXTRA_DURATION_MILLIS
2150 *
2151 * @hide
2152 */
2153 @SystemApi
2154 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2155 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2156 public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2157 "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2158
2159 /**
Joel Galenson95628242019-02-05 14:15:05 -08002160 * Activity action: Launch UI to review running accessibility services.
2161 * <p>
2162 * Input: Nothing.
2163 * </p>
2164 * <p>
2165 * Output: Nothing.
2166 * </p>
2167 *
2168 * @hide
2169 */
2170 @SystemApi
Joel Galenson3f5c6992019-03-01 17:51:51 -08002171 @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
Joel Galenson95628242019-02-05 14:15:05 -08002172 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2173 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2174 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2175
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002176 // ---------------------------------------------------------------------
2177 // ---------------------------------------------------------------------
2178 // Standard intent broadcast actions (see action variable).
2179
2180 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002181 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2182 * <p>
2183 * For historical reasons, the name of this broadcast action refers to the power
2184 * state of the screen but it is actually sent in response to changes in the
2185 * overall interactive state of the device.
2186 * </p><p>
2187 * This broadcast is sent when the device becomes non-interactive which may have
2188 * nothing to do with the screen turning off. To determine the
2189 * actual state of the screen, use {@link android.view.Display#getState}.
2190 * </p><p>
2191 * See {@link android.os.PowerManager#isInteractive} for details.
2192 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002193 * You <em>cannot</em> receive this through components declared in
2194 * manifests, only by explicitly registering for it with
2195 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2196 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002197 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002198 * <p class="note">This is a protected intent that can only be sent
2199 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002200 */
2201 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2202 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07002203
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002204 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002205 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2206 * <p>
2207 * For historical reasons, the name of this broadcast action refers to the power
2208 * state of the screen but it is actually sent in response to changes in the
2209 * overall interactive state of the device.
2210 * </p><p>
2211 * This broadcast is sent when the device becomes interactive which may have
2212 * nothing to do with the screen turning on. To determine the
2213 * actual state of the screen, use {@link android.view.Display#getState}.
2214 * </p><p>
2215 * See {@link android.os.PowerManager#isInteractive} for details.
2216 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002217 * You <em>cannot</em> receive this through components declared in
2218 * manifests, only by explicitly registering for it with
2219 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2220 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002221 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002222 * <p class="note">This is a protected intent that can only be sent
2223 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002224 */
2225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002227
2228 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07002229 * Broadcast Action: Sent after the system stops dreaming.
2230 *
2231 * <p class="note">This is a protected intent that can only be sent by the system.
2232 * It is only sent to registered receivers.</p>
2233 */
2234 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2235 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2236
2237 /**
2238 * Broadcast Action: Sent after the system starts dreaming.
2239 *
2240 * <p class="note">This is a protected intent that can only be sent by the system.
2241 * It is only sent to registered receivers.</p>
2242 */
2243 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2244 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2245
2246 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07002247 * 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 -07002248 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002249 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002250 * <p class="note">This is a protected intent that can only be sent
2251 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002252 */
2253 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002254 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002255
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002256 /**
2257 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002258 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002259 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002260 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2261 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002262 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002263 * <p class="note">This is a protected intent that can only be sent
2264 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002265 */
2266 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2267 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2268 /**
2269 * Broadcast Action: The time was set.
2270 */
2271 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2273 /**
2274 * Broadcast Action: The date has changed.
2275 */
2276 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2277 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2278 /**
2279 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2280 * <ul>
2281 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2282 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002283 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002284 * <p class="note">This is a protected intent that can only be sent
2285 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002286 */
2287 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2289 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002290 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2291 * DNS entries should be tossed.
2292 * @hide
2293 */
2294 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2295 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2296 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002297 * Alarm Changed Action: This is broadcast when the AlarmClock
2298 * application's alarm is set or unset. It is used by the
2299 * AlarmClock application and the StatusBar service.
2300 * @hide
2301 */
2302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002303 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002304 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002305
2306 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002307 * Broadcast Action: This is broadcast once, after the user has finished
2308 * booting, but while still in the "locked" state. It can be used to perform
2309 * application-specific initialization, such as installing alarms. You must
2310 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2311 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002312 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002313 * This broadcast is sent immediately at boot by all devices (regardless of
2314 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2315 * higher. Upon receipt of this broadcast, the user is still locked and only
2316 * device-protected storage can be accessed safely. If you want to access
2317 * credential-protected storage, you need to wait for the user to be
2318 * unlocked (typically by entering their lock pattern or PIN for the first
2319 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2320 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2321 * <p>
2322 * To receive this broadcast, your receiver component must be marked as
2323 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002324 * <p class="note">
2325 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002326 *
2327 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002328 */
2329 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2330 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2331
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002332 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002333 * Broadcast Action: This is broadcast once, after the user has finished
2334 * booting. It can be used to perform application-specific initialization,
2335 * such as installing alarms. You must hold the
2336 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2337 * order to receive this broadcast.
2338 * <p>
2339 * This broadcast is sent at boot by all devices (both with and without
2340 * direct boot support). Upon receipt of this broadcast, the user is
2341 * unlocked and both device-protected and credential-protected storage can
2342 * accessed safely.
2343 * <p>
2344 * If you need to run while the user is still locked (before they've entered
2345 * their lock pattern or PIN for the first time), you can listen for the
2346 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2347 * <p class="note">
2348 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002349 */
2350 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002351 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002352 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002353
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002354 /**
2355 * Broadcast Action: This is broadcast when a user action should request a
2356 * temporary system dialog to dismiss. Some examples of temporary system
2357 * dialogs are the notification window-shade and the recent tasks dialog.
2358 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002359 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002360 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2361 /**
2362 * Broadcast Action: Trigger the download and eventual installation
2363 * of a package.
2364 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002365 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002366 * <p class="note">This is a protected intent that can only be sent
2367 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002368 *
2369 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002370 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002371 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2374 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002375 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002376 * device. The data contains the name of the package. Note that the
2377 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002378 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002379 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002380 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2381 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002382 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2383 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002384 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002385 * <p class="note">This is a protected intent that can only be sent
2386 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002387 */
2388 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2389 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2390 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002391 * Broadcast Action: A new version of an application package has been
2392 * installed, replacing an existing version that was previously installed.
2393 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002394 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002395 * <ul>
2396 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2397 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002398 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002399 * <p class="note">This is a protected intent that can only be sent
2400 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002401 */
2402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2403 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2404 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002405 * Broadcast Action: A new version of your application has been installed
2406 * over an existing one. This is only sent to the application that was
2407 * replaced. It does not contain any additional data; to receive it, just
2408 * use an intent filter for this action.
2409 *
2410 * <p class="note">This is a protected intent that can only be sent
2411 * by the system.
2412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2415 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002416 * Broadcast Action: An existing application package has been removed from
2417 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002418 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002419 * <ul>
2420 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2421 * to the package.
2422 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2423 * application -- data and code -- is being removed.
2424 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2425 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2426 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002427 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002428 * <p class="note">This is a protected intent that can only be sent
2429 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002430 */
2431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2432 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2433 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002434 * Broadcast Action: An existing application package has been completely
2435 * removed from the device. The data contains the name of the package.
2436 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2437 * {@link #EXTRA_DATA_REMOVED} is true and
2438 * {@link #EXTRA_REPLACING} is false of that broadcast.
2439 *
2440 * <ul>
2441 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2442 * to the package.
2443 * </ul>
2444 *
2445 * <p class="note">This is a protected intent that can only be sent
2446 * by the system.
2447 */
2448 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2449 public static final String ACTION_PACKAGE_FULLY_REMOVED
2450 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2451 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002452 * Broadcast Action: An existing application package has been changed (for
2453 * example, a component has been enabled or disabled). The data contains
2454 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002455 * <ul>
2456 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002457 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002458 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002459 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2460 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002461 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002462 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002463 * <p class="note">This is a protected intent that can only be sent
2464 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002465 */
2466 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2467 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2468 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +01002469 * Broadcast Action: Sent to the system rollback manager when a package
2470 * needs to have rollback enabled.
2471 * <p class="note">
2472 * This is a protected intent that can only be sent by the system.
2473 * </p>
2474 *
2475 * @hide This broadcast is used internally by the system.
2476 */
2477 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2478 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2479 "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2480 /**
shafik4831ad72019-05-03 17:36:42 +01002481 * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2482 * package needs to be cancelled.
2483 *
2484 * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2485 * that enabling a specific rollback has timed out.
2486 *
2487 * @hide
2488 */
2489 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2490 public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2491 "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2492 /**
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002493 * Broadcast Action: A rollback has been committed.
Richard Uhlerb29f1452018-09-12 16:38:15 +01002494 *
2495 * <p class="note">This is a protected intent that can only be sent
shafik74fec182019-03-14 16:29:48 +00002496 * by the system. The receiver must hold MANAGE_ROLLBACK permission.
Richard Uhlerb29f1452018-09-12 16:38:15 +01002497 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +00002498 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +01002499 */
Richard Uhler8a977452019-03-08 13:27:17 +00002500 @SystemApi @TestApi
Richard Uhlerb29f1452018-09-12 16:38:15 +01002501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002502 public static final String ACTION_ROLLBACK_COMMITTED =
2503 "android.intent.action.ROLLBACK_COMMITTED";
Richard Uhlerb29f1452018-09-12 16:38:15 +01002504 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002505 * @hide
2506 * Broadcast Action: Ask system services if there is any reason to
2507 * restart the given package. The data contains the name of the
2508 * package.
2509 * <ul>
2510 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2511 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2512 * </ul>
2513 *
2514 * <p class="note">This is a protected intent that can only be sent
2515 * by the system.
2516 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002517 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002518 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2519 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2520 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002521 * Broadcast Action: The user has restarted a package, and all of its
2522 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002523 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002524 * be removed. Note that the restarted package does <em>not</em>
2525 * receive this broadcast.
2526 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002527 * <ul>
2528 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2529 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002530 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002531 * <p class="note">This is a protected intent that can only be sent
2532 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002533 */
2534 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2536 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002537 * Broadcast Action: The user has cleared the data of a package. This should
2538 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002539 * its persistent data is erased and this broadcast sent.
2540 * Note that the cleared package does <em>not</em>
2541 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002542 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002543 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2544 * package whose data was cleared is an uninstalled instant app, then the UID
2545 * will be -1. The platform keeps some meta-data associated with instant apps
2546 * after they are uninstalled.
2547 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2548 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002549 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002550 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002551 * <p class="note">This is a protected intent that can only be sent
2552 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002553 */
2554 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2556 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002557 * Broadcast Action: Packages have been suspended.
2558 * <p>Includes the following extras:
2559 * <ul>
2560 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002561 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002562 * </ul>
2563 *
2564 * <p class="note">This is a protected intent that can only be sent
2565 * by the system. It is only sent to registered receivers.
2566 */
2567 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2569 /**
2570 * Broadcast Action: Packages have been unsuspended.
2571 * <p>Includes the following extras:
2572 * <ul>
2573 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002574 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002575 * </ul>
2576 *
2577 * <p class="note">This is a protected intent that can only be sent
2578 * by the system. It is only sent to registered receivers.
2579 */
2580 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2581 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002582
2583 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08002584 * Broadcast Action: Distracting packages have been changed.
2585 * <p>Includes the following extras:
2586 * <ul>
2587 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2588 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2589 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2590 * </ul>
2591 *
2592 * <p class="note">This is a protected intent that can only be sent
2593 * by the system. It is only sent to registered receivers.
2594 *
2595 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2596 * @hide
2597 */
2598 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2600 "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2601
2602 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002603 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002604 * whenever a package is put into a suspended state or any of its app extras change while in the
2605 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002606 * <p> Optionally includes the following extras:
2607 * <ul>
2608 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2609 * useful information for the app being suspended.
2610 * </ul>
2611 * <p class="note">This is a protected intent that can only be sent
2612 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2613 * the manifest.</em>
2614 *
2615 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2616 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2617 * @see PackageManager#isPackageSuspended()
2618 * @see PackageManager#getSuspendedPackageAppExtras()
2619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2622
2623 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002624 * Activity Action: Started to show more details about why an application was suspended.
2625 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002626 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2627 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002628 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002629 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2630 * handling this intent and protect it with
2631 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2632 *
2633 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2634 *
2635 * <p class="note">This is a protected intent that can only be sent
2636 * by the system.
2637 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002638 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2639 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002640 * @see PackageManager#isPackageSuspended()
2641 * @see #ACTION_PACKAGES_SUSPENDED
2642 *
2643 * @hide
2644 */
2645 @SystemApi
2646 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2647 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2648 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2649
2650 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002651 * Broadcast Action: Sent to a package that has been unsuspended.
2652 *
2653 * <p class="note">This is a protected intent that can only be sent
2654 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2655 * the manifest.</em>
2656 *
2657 * @see #ACTION_MY_PACKAGE_SUSPENDED
2658 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2659 * @see PackageManager#isPackageSuspended()
2660 * @see PackageManager#getSuspendedPackageAppExtras()
2661 */
2662 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2664
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002665 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002666 * Broadcast Action: A user ID has been removed from the system. The user
2667 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002668 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002669 * <p class="note">This is a protected intent that can only be sent
2670 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002671 */
2672 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2673 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002674
2675 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002676 * Broadcast Action: Sent to the installer package of an application when
2677 * that application is first launched (that is the first time it is moved
2678 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002679 *
Kevin Hufnagle49d171d2019-10-15 19:47:35 +00002680 * <p>When the application is first launched, the application itself doesn't receive this
2681 * broadcast.</p>
2682 *
Dianne Hackborne7f97212011-02-24 14:40:20 -08002683 * <p class="note">This is a protected intent that can only be sent
2684 * by the system.
2685 */
2686 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2687 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2688
2689 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002690 * Broadcast Action: Sent to the system package verifier when a package
2691 * needs to be verified. The data contains the package URI.
2692 * <p class="note">
2693 * This is a protected intent that can only be sent by the system.
2694 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002695 */
2696 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2697 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2698
2699 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002700 * Broadcast Action: Sent to the system package verifier when a package is
2701 * verified. The data contains the package URI.
2702 * <p class="note">
2703 * This is a protected intent that can only be sent by the system.
2704 */
2705 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2706 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2707
2708 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002709 * Broadcast Action: Sent to the system intent filter verifier when an
2710 * intent filter needs to be verified. The data contains the filter data
2711 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002712 * <p class="note">
2713 * This is a protected intent that can only be sent by the system.
2714 * </p>
2715 *
2716 * @hide
2717 */
2718 @SystemApi
2719 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2720 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2721
2722 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002723 * Broadcast Action: Resources for a set of packages (which were
2724 * previously unavailable) are currently
2725 * available since the media on which they exist is available.
2726 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2727 * list of packages whose availability changed.
2728 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2729 * list of uids of packages whose availability changed.
2730 * Note that the
2731 * packages in this list do <em>not</em> receive this broadcast.
2732 * The specified set of packages are now available on the system.
2733 * <p>Includes the following extras:
2734 * <ul>
2735 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2736 * whose resources(were previously unavailable) are currently available.
2737 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2738 * packages whose resources(were previously unavailable)
2739 * are currently available.
2740 * </ul>
2741 *
2742 * <p class="note">This is a protected intent that can only be sent
2743 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002744 */
2745 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002746 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2747 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002748
2749 /**
2750 * Broadcast Action: Resources for a set of packages are currently
2751 * unavailable since the media on which they exist is unavailable.
2752 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2753 * list of packages whose availability changed.
2754 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2755 * list of uids of packages whose availability changed.
2756 * The specified set of packages can no longer be
2757 * launched and are practically unavailable on the system.
2758 * <p>Inclues the following extras:
2759 * <ul>
2760 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2761 * whose resources are no longer available.
2762 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2763 * whose resources are no longer available.
2764 * </ul>
2765 *
2766 * <p class="note">This is a protected intent that can only be sent
2767 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002768 */
2769 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002770 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002771 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002772
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002773 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002774 * Broadcast Action: preferred activities have changed *explicitly*.
2775 *
2776 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2777 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2778 * be sent.
2779 *
2780 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2781 *
2782 * @hide
2783 */
2784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2785 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2786 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2787
2788
2789 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002790 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002791 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002792 * This should <em>only</em> be used to determine when the wallpaper
2793 * has changed to show the new wallpaper to the user. You should certainly
2794 * never, in response to this, change the wallpaper or other attributes of
2795 * it such as the suggested size. That would be crazy, right? You'd cause
2796 * all kinds of loops, especially if other apps are doing similar things,
2797 * right? Of course. So please don't do this.
2798 *
2799 * @deprecated Modern applications should use
2800 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2801 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2802 * shown behind their UI, rather than watching for this broadcast and
2803 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002804 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002805 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002806 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2807 /**
2808 * Broadcast Action: The current device {@link android.content.res.Configuration}
2809 * (orientation, locale, etc) has changed. When such a change happens, the
2810 * UIs (view hierarchy) will need to be rebuilt based on this new
2811 * information; for the most part, applications don't need to worry about
2812 * this, because the system will take care of stopping and restarting the
2813 * application to make sure it sees the new changes. Some system code that
2814 * can not be restarted will need to watch for this action and handle it
2815 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002816 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002817 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002818 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002819 * in manifests, only by explicitly registering for it with
2820 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2821 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002822 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002823 * <p class="note">This is a protected intent that can only be sent
2824 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002825 *
2826 * @see android.content.res.Configuration
2827 */
2828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2829 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002830
2831 /**
2832 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2833 * such that the device may be eligible for the installation of additional configuration splits.
2834 * Configuration properties that can trigger this broadcast include locale and display density.
2835 *
2836 * <p class="note">
2837 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2838 * components declared in manifests. However, the receiver <em>must</em> hold the
2839 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2840 *
2841 * <p class="note">
2842 * This is a protected intent that can only be sent by the system.
2843 *
2844 * @hide
2845 */
2846 @SystemApi
2847 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2848 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2849 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002850 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002851 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002852 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002853 * <p class="note">This is a protected intent that can only be sent
2854 * by the system.
2855 */
2856 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2857 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2858 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002859 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2860 * charging state, level, and other information about the battery.
2861 * See {@link android.os.BatteryManager} for documentation on the
2862 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002863 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002864 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002865 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002866 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002867 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002868 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2869 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2870 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2871 * broadcasts that are sent and can be received through manifest
2872 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002873 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002874 * <p class="note">This is a protected intent that can only be sent
2875 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002876 */
2877 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2878 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002879
2880
2881 /**
2882 * Broadcast Action: Sent when the current battery level changes.
2883 *
2884 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2885 * instances representing individual battery level changes with associated
2886 * extras from {@link #ACTION_BATTERY_CHANGED}.
2887 *
2888 * <p class="note">
2889 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2890 *
2891 * @hide
2892 */
2893 @SystemApi
2894 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2895 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002896 /**
2897 * Broadcast Action: Indicates low battery condition on the device.
2898 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002899 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002900 * <p class="note">This is a protected intent that can only be sent
2901 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002902 */
2903 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2904 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2905 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002906 * Broadcast Action: Indicates the battery is now okay after being low.
2907 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2908 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002909 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002910 * <p class="note">This is a protected intent that can only be sent
2911 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002912 */
2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2915 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002916 * Broadcast Action: External power has been connected to the device.
2917 * This is intended for applications that wish to register specifically to this notification.
2918 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2919 * stay active to receive this notification. This action can be used to implement actions
2920 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002921 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002922 * <p class="note">This is a protected intent that can only be sent
2923 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002924 */
2925 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002926 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002927 /**
2928 * Broadcast Action: External power has been removed from the device.
2929 * This is intended for applications that wish to register specifically to this notification.
2930 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2931 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002932 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002933 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002934 * <p class="note">This is a protected intent that can only be sent
2935 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002936 */
2937 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002938 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002939 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002940 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002941 * Broadcast Action: Device is shutting down.
2942 * This is broadcast when the device is being shut down (completely turned
2943 * off, not sleeping). Once the broadcast is complete, the final shutdown
2944 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002945 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002946 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2947 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2948 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002949 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002950 * <p class="note">This is a protected intent that can only be sent
2951 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002952 * <p>May include the following extras:
2953 * <ul>
2954 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2955 * shutdown is only for userspace processes. If not set, assumed to be false.
2956 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002957 */
2958 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002959 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002960 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002961 * Activity Action: Start this activity to request system shutdown.
2962 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002963 * to request confirmation from the user before shutting down. The optional boolean
2964 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2965 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002966 *
2967 * <p class="note">This is a protected intent that can only be sent
2968 * by the system.
2969 *
2970 * {@hide}
2971 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002972 public static final String ACTION_REQUEST_SHUTDOWN
2973 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002974 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002975 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002976 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002977 * <p class="note">
2978 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002979 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002980 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2981 * or above, this broadcast will no longer be delivered to any
2982 * {@link BroadcastReceiver} defined in your manifest. Instead,
2983 * apps are strongly encouraged to use the improved
2984 * {@link Context#getCacheDir()} behavior so the system can
2985 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002986 */
2987 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002988 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002989 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2990 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002991 * Broadcast Action: Indicates low storage space condition on the device no
2992 * longer exists
2993 * <p class="note">
2994 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002995 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002996 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2997 * or above, this broadcast will no longer be delivered to any
2998 * {@link BroadcastReceiver} defined in your manifest. Instead,
2999 * apps are strongly encouraged to use the improved
3000 * {@link Context#getCacheDir()} behavior so the system can
3001 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003002 */
3003 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003004 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003005 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3006 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003007 * Broadcast Action: A sticky broadcast that indicates a storage space full
3008 * condition on the device. This is intended for activities that want to be
3009 * able to fill the data partition completely, leaving only enough free
3010 * space to prevent system-wide SQLite failures.
3011 * <p class="note">
3012 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07003013 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003014 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3015 * or above, this broadcast will no longer be delivered to any
3016 * {@link BroadcastReceiver} defined in your manifest. Instead,
3017 * apps are strongly encouraged to use the improved
3018 * {@link Context#getCacheDir()} behavior so the system can
3019 * automatically free up storage when needed.
3020 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07003021 */
3022 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003023 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07003024 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3025 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003026 * Broadcast Action: Indicates storage space full condition on the device no
3027 * longer exists.
3028 * <p class="note">
3029 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07003030 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003031 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3032 * or above, this broadcast will no longer be delivered to any
3033 * {@link BroadcastReceiver} defined in your manifest. Instead,
3034 * apps are strongly encouraged to use the improved
3035 * {@link Context#getCacheDir()} behavior so the system can
3036 * automatically free up storage when needed.
3037 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07003038 */
3039 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06003040 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07003041 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3042 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003043 * Broadcast Action: Indicates low memory condition notification acknowledged by user
3044 * and package management should be started.
3045 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3046 * notification.
3047 */
3048 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3049 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3050 /**
3051 * Broadcast Action: The device has entered USB Mass Storage mode.
3052 * This is used mainly for the USB Settings panel.
3053 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3054 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07003055 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003056 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07003057 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06003058 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003059 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3060
3061 /**
3062 * Broadcast Action: The device has exited USB Mass Storage mode.
3063 * This is used mainly for the USB Settings panel.
3064 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3065 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07003066 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003067 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07003068 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06003069 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003070 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3071
3072 /**
3073 * Broadcast Action: External media has been removed.
3074 * The path to the mount point for the removed media is contained in the Intent.mData field.
3075 */
3076 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3077 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3078
3079 /**
3080 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003081 * 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 -07003082 */
3083 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3084 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3085
3086 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003087 * Broadcast Action: External media is present, and being disk-checked
3088 * 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 -08003089 */
3090 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3091 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3092
3093 /**
3094 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
3095 * 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 -08003096 */
3097 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3098 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3099
3100 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003101 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003102 * 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 -07003103 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3104 * media was mounted read only.
3105 */
3106 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3107 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3108
3109 /**
3110 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003111 * 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 -07003112 */
3113 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3114 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3115
3116 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003117 * Broadcast Action: External media is no longer being shared via USB mass storage.
3118 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3119 *
3120 * @hide
3121 */
3122 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3123
3124 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003125 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
3126 * The path to the mount point for the removed media is contained in the Intent.mData field.
3127 */
3128 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3129 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3130
3131 /**
3132 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08003133 * 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 -07003134 */
3135 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3136 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3137
3138 /**
3139 * Broadcast Action: User has expressed the desire to remove the external storage media.
3140 * Applications should close all files they have open within the mount point when they receive this intent.
3141 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3142 */
3143 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3144 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3145
3146 /**
3147 * Broadcast Action: The media scanner has started scanning a directory.
3148 * The path to the directory being scanned is contained in the Intent.mData field.
3149 */
3150 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3151 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3152
3153 /**
3154 * Broadcast Action: The media scanner has finished scanning a directory.
3155 * The path to the scanned directory is contained in the Intent.mData field.
3156 */
3157 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3158 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3159
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003160 /**
3161 * Broadcast Action: Request the media scanner to scan a file and add it to
3162 * the media database.
3163 * <p>
3164 * The path to the file is contained in {@link Intent#getData()}.
3165 *
Jeff Sharkey4b457c32019-03-25 10:29:29 -06003166 * @deprecated Callers should migrate to inserting items directly into
3167 * {@link MediaStore}, where they will be automatically scanned
3168 * after each mutation.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003169 */
3170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003171 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003172 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3173
3174 /**
3175 * Broadcast Action: The "Media Button" was pressed. Includes a single
3176 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3177 * caused the broadcast.
3178 */
3179 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3180 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3181
3182 /**
3183 * Broadcast Action: The "Camera Button" was pressed. Includes a single
3184 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3185 * caused the broadcast.
3186 */
3187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3188 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3189
3190 // *** NOTE: @todo(*) The following really should go into a more domain-specific
3191 // location; they are not general-purpose actions.
3192
3193 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003194 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003195 */
3196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3197 public static final String ACTION_GTALK_SERVICE_CONNECTED =
3198 "android.intent.action.GTALK_CONNECTED";
3199
3200 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003201 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003202 */
3203 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3204 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3205 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003206
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003207 /**
3208 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003209 */
3210 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3211 public static final String ACTION_INPUT_METHOD_CHANGED =
3212 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003213
3214 /**
3215 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3216 * more radios have been turned off or on. The intent will have the following extra value:</p>
3217 * <ul>
3218 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3219 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3220 * turned off</li>
3221 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08003222 *
Peng Xua35b5532016-01-20 00:05:45 -08003223 * <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 -07003224 */
3225 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3226 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3227
3228 /**
3229 * Broadcast Action: Some content providers have parts of their namespace
3230 * where they publish new events or items that the user may be especially
3231 * interested in. For these things, they may broadcast this action when the
3232 * set of interesting items change.
3233 *
3234 * For example, GmailProvider sends this notification when the set of unread
3235 * mail in the inbox changes.
3236 *
3237 * <p>The data of the intent identifies which part of which provider
3238 * changed. When queried through the content resolver, the data URI will
3239 * return the data set in question.
3240 *
3241 * <p>The intent will have the following extra values:
3242 * <ul>
3243 * <li><em>count</em> - The number of items in the data set. This is the
3244 * same as the number of items in the cursor returned by querying the
3245 * data URI. </li>
3246 * </ul>
3247 *
3248 * This intent will be sent at boot (if the count is non-zero) and when the
3249 * data set changes. It is possible for the data set to change without the
3250 * count changing (for example, if a new unread message arrives in the same
3251 * sync operation in which a message is archived). The phone should still
3252 * ring/vibrate/etc as normal in this case.
3253 */
3254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3255 public static final String ACTION_PROVIDER_CHANGED =
3256 "android.intent.action.PROVIDER_CHANGED";
3257
3258 /**
3259 * Broadcast Action: Wired Headset plugged in or unplugged.
3260 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003261 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3262 * and documentation.
3263 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07003264 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003265 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003266 */
3267 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003268 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07003269
3270 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07003271 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3272 * <ul>
3273 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3274 * </ul>
3275 *
3276 * <p class="note">This is a protected intent that can only be sent
3277 * by the system.
3278 *
3279 * @hide
3280 */
3281 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3282 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3283 = "android.intent.action.ADVANCED_SETTINGS";
3284
3285 /**
Robin Lee66e5d962014-04-09 16:44:21 +01003286 * Broadcast Action: Sent after application restrictions are changed.
3287 *
3288 * <p class="note">This is a protected intent that can only be sent
3289 * by the system.</p>
3290 */
3291 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3292 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3293 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3294
3295 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003296 * Broadcast Action: An outgoing call is about to be placed.
3297 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07003298 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003299 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07003300 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003301 * the phone number originally intended to be dialed.</li>
3302 * </ul>
3303 * <p>Once the broadcast is finished, the resultData is used as the actual
3304 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07003305 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003306 * outgoing call in turn: for example, a parental control application
3307 * might verify that the user is authorized to place the call at that
3308 * time, then a number-rewriting application might add an area code if
3309 * one was not specified.</p>
3310 * <p>For consistency, any receiver whose purpose is to prohibit phone
3311 * calls should have a priority of 0, to ensure it will see the final
3312 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07003313 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003314 * should have a positive priority.
3315 * Negative priorities are reserved for the system for this broadcast;
3316 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003317 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3318 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003319 * <p>Emergency calls cannot be intercepted using this mechanism, and
3320 * other calls cannot be modified to call emergency numbers using this
3321 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003322 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3323 * call to use their own service instead. Those apps should first prevent
3324 * the call from being placed by setting resultData to <code>null</code>
3325 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003326 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003327 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3328 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003329 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003330 * <p class="note">This is a protected intent that can only be sent
3331 * by the system.
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003332 *
3333 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3334 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3335 * This means that attempts to re-write the outgoing call by other apps using this intent will
3336 * be ignored.
3337 * </p>
3338 *
3339 * @deprecated Apps that redirect outgoing calls should use the
3340 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3341 * should use the {@link android.telecom.CallScreeningService} API.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003342 */
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003343 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003344 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3345 public static final String ACTION_NEW_OUTGOING_CALL =
3346 "android.intent.action.NEW_OUTGOING_CALL";
3347
3348 /**
3349 * Broadcast Action: Have the device reboot. This is only for use by
3350 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003351 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003352 * <p class="note">This is a protected intent that can only be sent
3353 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003354 */
3355 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3356 public static final String ACTION_REBOOT =
3357 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003358
Wei Huang97ecc9c2009-05-11 17:44:20 -07003359 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003360 * Broadcast Action: A sticky broadcast for changes in the physical
3361 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003362 *
3363 * <p>The intent will have the following extra values:
3364 * <ul>
3365 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003366 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003367 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003368 * <p>This is intended for monitoring the current physical dock state.
3369 * See {@link android.app.UiModeManager} for the normal API dealing with
3370 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003371 */
3372 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3373 public static final String ACTION_DOCK_EVENT =
3374 "android.intent.action.DOCK_EVENT";
3375
3376 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003377 * Broadcast Action: A broadcast when idle maintenance can be started.
3378 * This means that the user is not interacting with the device and is
3379 * not expected to do so soon. Typical use of the idle maintenance is
3380 * to perform somehow expensive tasks that can be postponed at a moment
3381 * when they will not degrade user experience.
3382 * <p>
3383 * <p class="note">In order to keep the device responsive in case of an
3384 * unexpected user interaction, implementations of a maintenance task
3385 * should be interruptible. In such a scenario a broadcast with action
3386 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3387 * should not do the maintenance work in
3388 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3389 * maintenance service by {@link Context#startService(Intent)}. Also
3390 * you should hold a wake lock while your maintenance service is running
3391 * to prevent the device going to sleep.
3392 * </p>
3393 * <p>
3394 * <p class="note">This is a protected intent that can only be sent by
3395 * the system.
3396 * </p>
3397 *
3398 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003399 *
3400 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003401 */
3402 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3403 public static final String ACTION_IDLE_MAINTENANCE_START =
3404 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3405
3406 /**
3407 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3408 * This means that the user was not interacting with the device as a result
3409 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3410 * was sent and now the user started interacting with the device. Typical
3411 * use of the idle maintenance is to perform somehow expensive tasks that
3412 * can be postponed at a moment when they will not degrade user experience.
3413 * <p>
3414 * <p class="note">In order to keep the device responsive in case of an
3415 * unexpected user interaction, implementations of a maintenance task
3416 * should be interruptible. Hence, on receiving a broadcast with this
3417 * action, the maintenance task should be interrupted as soon as possible.
3418 * In other words, you should not do the maintenance work in
3419 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3420 * maintenance service that was started on receiving of
3421 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3422 * lock you acquired when your maintenance service started.
3423 * </p>
3424 * <p class="note">This is a protected intent that can only be sent
3425 * by the system.
3426 *
3427 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003428 *
3429 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003430 */
3431 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3432 public static final String ACTION_IDLE_MAINTENANCE_END =
3433 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3434
3435 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003436 * Broadcast Action: a remote intent is to be broadcasted.
3437 *
3438 * A remote intent is used for remote RPC between devices. The remote intent
3439 * is serialized and sent from one device to another device. The receiving
3440 * device parses the remote intent and broadcasts it. Note that anyone can
3441 * broadcast a remote intent. However, if the intent receiver of the remote intent
3442 * does not trust intent broadcasts from arbitrary intent senders, it should require
3443 * the sender to hold certain permissions so only trusted sender's broadcast will be
3444 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003445 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003446 */
3447 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003448 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003449
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003450 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003451 * Broadcast Action: This is broadcast once when the user is booting after a
3452 * system update. It can be used to perform cleanup or upgrades after a
3453 * system update.
3454 * <p>
3455 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3456 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3457 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3458 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003459 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003460 * @hide
3461 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003462 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003463 public static final String ACTION_PRE_BOOT_COMPLETED =
3464 "android.intent.action.PRE_BOOT_COMPLETED";
3465
Amith Yamasani13593602012-03-22 16:16:17 -07003466 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003467 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003468 * on restricted users. The broadcast intent contains an extra
3469 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3470 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3471 * String[] depending on the restriction type.<p/>
3472 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003473 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3474 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3475 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003476 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3477 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003478 * @see RestrictionEntry
3479 */
3480 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3481 "android.intent.action.GET_RESTRICTION_ENTRIES";
3482
3483 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003484 * Sent the first time a user is starting, to allow system apps to
3485 * perform one time initialization. (This will not be seen by third
3486 * party applications because a newly initialized user does not have any
3487 * third party applications installed for it.) This is sent early in
3488 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003489 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3490 * broadcast, since it is part of a visible user interaction; be as quick
3491 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003492 */
3493 public static final String ACTION_USER_INITIALIZE =
3494 "android.intent.action.USER_INITIALIZE";
3495
3496 /**
3497 * Sent when a user switch is happening, causing the process's user to be
3498 * brought to the foreground. This is only sent to receivers registered
3499 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3500 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003501 * foreground. This is sent as a foreground
3502 * broadcast, since it is part of a visible user interaction; be as quick
3503 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003504 */
3505 public static final String ACTION_USER_FOREGROUND =
3506 "android.intent.action.USER_FOREGROUND";
3507
3508 /**
3509 * Sent when a user switch is happening, causing the process's user to be
3510 * sent to the background. This is only sent to receivers registered
3511 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3512 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003513 * background. This is sent as a foreground
3514 * broadcast, since it is part of a visible user interaction; be as quick
3515 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003516 */
3517 public static final String ACTION_USER_BACKGROUND =
3518 "android.intent.action.USER_BACKGROUND";
3519
3520 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003521 * Broadcast sent to the system when a user is added. Carries an extra
3522 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3523 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003524 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003525 * @hide
3526 */
Philip P. Moltmannc586a5c2019-03-20 15:51:42 -07003527 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003528 public static final String ACTION_USER_ADDED =
3529 "android.intent.action.USER_ADDED";
3530
3531 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003532 * Broadcast sent by the system when a user is started. Carries an extra
3533 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003534 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003535 * that has been started. This is sent as a foreground
3536 * broadcast, since it is part of a visible user interaction; be as quick
3537 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003538 * @hide
3539 */
3540 public static final String ACTION_USER_STARTED =
3541 "android.intent.action.USER_STARTED";
3542
3543 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003544 * Broadcast sent when a user is in the process of starting. Carries an extra
3545 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3546 * sent to registered receivers, not manifest receivers. It is sent to all
3547 * users (including the one that is being started). You must hold
3548 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3549 * this broadcast. This is sent as a background broadcast, since
3550 * its result is not part of the primary UX flow; to safely keep track of
3551 * started/stopped state of a user you can use this in conjunction with
3552 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3553 * other user state broadcasts since those are foreground broadcasts so can
3554 * execute in a different order.
3555 * @hide
3556 */
3557 public static final String ACTION_USER_STARTING =
3558 "android.intent.action.USER_STARTING";
3559
3560 /**
3561 * Broadcast sent when a user is going to be stopped. Carries an extra
3562 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3563 * sent to registered receivers, not manifest receivers. It is sent to all
3564 * users (including the one that is being stopped). You must hold
3565 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3566 * this broadcast. The user will not stop until all receivers have
3567 * handled the broadcast. This is sent as a background broadcast, since
3568 * its result is not part of the primary UX flow; to safely keep track of
3569 * started/stopped state of a user you can use this in conjunction with
3570 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3571 * other user state broadcasts since those are foreground broadcasts so can
3572 * execute in a different order.
3573 * @hide
3574 */
3575 public static final String ACTION_USER_STOPPING =
3576 "android.intent.action.USER_STOPPING";
3577
3578 /**
3579 * Broadcast sent to the system when a user is stopped. Carries an extra
3580 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3581 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3582 * specific package. This is only sent to registered receivers, not manifest
3583 * receivers. It is sent to all running users <em>except</em> the one that
3584 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003585 * @hide
3586 */
3587 public static final String ACTION_USER_STOPPED =
3588 "android.intent.action.USER_STOPPED";
3589
3590 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003591 * 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 -07003592 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003593 * one that has been removed. The user will not be completely removed until all receivers have
3594 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003595 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003596 * @hide
3597 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003598 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003599 public static final String ACTION_USER_REMOVED =
3600 "android.intent.action.USER_REMOVED";
3601
3602 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003603 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003604 * the userHandle of the user to become the current one. This is only sent to
3605 * registered receivers, not manifest receivers. It is sent to all running users.
3606 * You must hold
3607 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003608 * @hide
3609 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003610 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003611 public static final String ACTION_USER_SWITCHED =
3612 "android.intent.action.USER_SWITCHED";
3613
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003614 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003615 * Broadcast Action: Sent when the credential-encrypted private storage has
3616 * become unlocked for the target user. This is only sent to registered
3617 * receivers, not manifest receivers.
3618 */
3619 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3620 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3621
3622 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003623 * Broadcast sent to the system when a user's information changes. Carries an extra
3624 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003625 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003626 * @hide
3627 */
3628 public static final String ACTION_USER_INFO_CHANGED =
3629 "android.intent.action.USER_INFO_CHANGED";
3630
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003631 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003632 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3633 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003634 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3635 * that need to display merged content across both primary and managed profiles need to
3636 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003637 * not manifest receivers.
3638 */
3639 public static final String ACTION_MANAGED_PROFILE_ADDED =
3640 "android.intent.action.MANAGED_PROFILE_ADDED";
3641
3642 /**
3643 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003644 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3645 * Only applications (for example Launchers) that need to display merged content across both
3646 * primary and managed profiles need to worry about this broadcast. This is only sent to
3647 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003648 */
3649 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3650 "android.intent.action.MANAGED_PROFILE_REMOVED";
3651
3652 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003653 * Broadcast sent to the primary user when the credential-encrypted private storage for
3654 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3655 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3656 * Launchers) that need to display merged content across both primary and managed profiles
3657 * need to worry about this broadcast. This is only sent to registered receivers,
3658 * not manifest receivers.
3659 */
3660 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3661 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3662
3663 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003664 * Broadcast sent to the primary user when an associated managed profile has become available.
3665 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003666 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3667 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3668 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003669 */
Rubin Xue95057a2016-04-01 16:49:25 +01003670 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3671 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3672
3673 /**
3674 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3675 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3676 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3677 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3678 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3679 */
3680 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3681 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003682
3683 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003684 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3685 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3686 * the device was locked or unlocked.
3687 *
3688 * This is only sent to registered receivers.
3689 *
3690 * @hide
3691 */
3692 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3693 "android.intent.action.DEVICE_LOCKED_CHANGED";
3694
3695 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003696 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3697 */
3698 public static final String ACTION_QUICK_CLOCK =
3699 "android.intent.action.QUICK_CLOCK";
3700
Michael Wright0087a142013-02-05 16:29:39 -08003701 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003702 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003703 * @hide
3704 */
3705 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003706 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003707
Justin Kohd378ad72013-04-01 12:18:26 -07003708 /**
3709 * Broadcast Action: A global button was pressed. Includes a single
3710 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3711 * caused the broadcast.
3712 * @hide
3713 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003714 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003715 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3716
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003717 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003718 * Broadcast Action: Sent when media resource is granted.
3719 * <p>
3720 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3721 * granted.
3722 * </p>
3723 * <p class="note">
3724 * This is a protected intent that can only be sent by the system.
3725 * </p>
3726 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003727 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003728 * </p>
3729 *
3730 * @hide
3731 */
3732 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3733 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3734
3735 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003736 * Broadcast Action: An overlay package has changed. The data contains the
3737 * name of the overlay package which has changed. This is broadcast on all
3738 * changes to the OverlayInfo returned by {@link
3739 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3740 * most common change is a state change that will change whether the
3741 * overlay is enabled or not.
3742 * @hide
3743 */
3744 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3745
3746 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003747 * Activity Action: Allow the user to select and return one or more existing
3748 * documents. When invoked, the system will display the various
3749 * {@link DocumentsProvider} instances installed on the device, letting the
3750 * user interactively navigate through them. These documents include local
3751 * media, such as photos and video, and documents provided by installed
3752 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003753 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003754 * Each document is represented as a {@code content://} URI backed by a
3755 * {@link DocumentsProvider}, which can be opened as a stream with
3756 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3757 * {@link android.provider.DocumentsContract.Document} metadata.
3758 * <p>
3759 * All selected documents are returned to the calling application with
3760 * persistable read and write permission grants. If you want to maintain
3761 * access to the documents across device reboots, you need to explicitly
3762 * take the persistable permissions using
3763 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3764 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003765 * Callers must indicate the acceptable document MIME types through
3766 * {@link #setType(String)}. For example, to select photos, use
3767 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3768 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3769 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003770 * <p>
3771 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003772 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3773 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003774 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003775 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3776 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003777 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003778 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003779 * Callers can set a document URI through
3780 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3781 * location of documents navigator. System will do its best to launch the
3782 * navigator in the specified document if it's a folder, or the folder that
3783 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003784 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003785 * Output: The URI of the item that was picked, returned in
3786 * {@link #getData()}. This must be a {@code content://} URI so that any
3787 * receiver can access it. If multiple documents were selected, they are
3788 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003789 *
3790 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003791 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003792 * @see #ACTION_CREATE_DOCUMENT
3793 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003794 */
3795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3796 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3797
3798 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003799 * Activity Action: Allow the user to create a new document. When invoked,
3800 * the system will display the various {@link DocumentsProvider} instances
3801 * installed on the device, letting the user navigate through them. The
3802 * returned document may be a newly created document with no content, or it
3803 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003804 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003805 * Each document is represented as a {@code content://} URI backed by a
3806 * {@link DocumentsProvider}, which can be opened as a stream with
3807 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3808 * {@link android.provider.DocumentsContract.Document} metadata.
3809 * <p>
3810 * Callers must indicate the concrete MIME type of the document being
3811 * created by setting {@link #setType(String)}. This MIME type cannot be
3812 * changed after the document is created.
3813 * <p>
3814 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3815 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003816 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003817 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3818 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003819 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003820 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003821 * Callers can set a document URI through
3822 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3823 * location of documents navigator. System will do its best to launch the
3824 * navigator in the specified document if it's a folder, or the folder that
3825 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003826 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003827 * Output: The URI of the item that was created. This must be a
3828 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003829 *
3830 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003831 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003832 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003833 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003834 */
3835 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3836 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3837
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003838 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003839 * Activity Action: Allow the user to pick a directory subtree. When
3840 * invoked, the system will display the various {@link DocumentsProvider}
3841 * instances installed on the device, letting the user navigate through
3842 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003843 * <p>
3844 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003845 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3846 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3847 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003848 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003849 * Callers can set a document URI through
3850 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3851 * location of documents navigator. System will do its best to launch the
3852 * navigator in the specified document if it's a folder, or the folder that
3853 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003854 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003855 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003856 *
3857 * @see DocumentsContract
3858 */
3859 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003860 public static final String
3861 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003862
Abodunrinwa Toki4bad09c2018-10-25 18:12:28 +01003863
3864 /**
3865 * Activity Action: Perform text translation.
3866 * <p>
3867 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3868 * <p>
3869 * Output: nothing.
3870 */
3871 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3872 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3873
Felipe Lemec7b1f892016-01-15 15:02:31 -08003874 /**
Tony Make1f3ac062018-11-27 14:30:21 +00003875 * Activity Action: Define the meaning of the selected word(s).
3876 * <p>
3877 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3878 * <p>
3879 * Output: nothing.
3880 */
3881 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3882 public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3883
3884 /**
Peng Xua35b5532016-01-20 00:05:45 -08003885 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3886 * exisiting sensor being disconnected.
3887 *
3888 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3889 *
3890 * {@hide}
3891 */
3892 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3893 public static final String
3894 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3895
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003896 /**
Sam Line707f832017-04-13 17:00:55 -07003897 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003898 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003899 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003900 */
3901 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003902 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003903 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3904
Christopher Tate6597e342015-02-17 12:15:25 -08003905 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003906 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3907 * is about to be performed.
3908 * @hide
3909 */
3910 @SystemApi
3911 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3912 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3913 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3914
3915 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003916 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3917 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3918 *
3919 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3920 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003921 * @hide
3922 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003923 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003924 public static final String EXTRA_FORCE_MASTER_CLEAR =
3925 "android.intent.extra.FORCE_MASTER_CLEAR";
3926
3927 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003928 * A broadcast action to trigger a factory reset.
3929 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003930 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3931 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003932 *
3933 * <p>Not for use by third-party applications.
3934 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003935 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003936 *
3937 * {@hide}
3938 */
3939 @SystemApi
3940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3941 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3942
3943 /**
3944 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3945 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3946 *
3947 * <p>Not for use by third-party applications.
3948 *
3949 * @hide
3950 */
3951 @SystemApi
3952 public static final String EXTRA_FORCE_FACTORY_RESET =
3953 "android.intent.extra.FORCE_FACTORY_RESET";
3954
3955 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003956 * Broadcast action: report that a settings element is being restored from backup. The intent
3957 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3958 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3959 * is the value of that settings entry prior to the restore operation, and
3960 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3961 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3962 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003963 *
3964 * <p>This broadcast is sent only for settings provider entries known to require special handling
3965 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3966 * the provider's backup agent implementation.
3967 *
3968 * @see #EXTRA_SETTING_NAME
3969 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3970 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003971 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003972 * {@hide}
3973 */
3974 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3975
3976 /** {@hide} */
3977 public static final String EXTRA_SETTING_NAME = "setting_name";
3978 /** {@hide} */
3979 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3980 /** {@hide} */
3981 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003982 /** {@hide} */
3983 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003984
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003985 /**
3986 * Activity Action: Process a piece of text.
3987 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3988 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3989 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3990 */
3991 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3992 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003993
3994 /**
3995 * Broadcast Action: The sim card state has changed.
3996 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3997 * because TelephonyIntents is an internal class.
3998 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003999 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4000 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08004001 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08004002 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08004003 @SystemApi
4004 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4005 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4006
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004007 /**
fionaxu90fee272017-03-31 12:45:12 -07004008 * Broadcast Action: indicate that the phone service state has changed.
4009 * The intent will have the following extra values:</p>
4010 * <p>
4011 * @see #EXTRA_VOICE_REG_STATE
4012 * @see #EXTRA_DATA_REG_STATE
4013 * @see #EXTRA_VOICE_ROAMING_TYPE
4014 * @see #EXTRA_DATA_ROAMING_TYPE
4015 * @see #EXTRA_OPERATOR_ALPHA_LONG
4016 * @see #EXTRA_OPERATOR_ALPHA_SHORT
4017 * @see #EXTRA_OPERATOR_NUMERIC
4018 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4019 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4020 * @see #EXTRA_DATA_OPERATOR_NUMERIC
4021 * @see #EXTRA_MANUAL
4022 * @see #EXTRA_VOICE_RADIO_TECH
4023 * @see #EXTRA_DATA_RADIO_TECH
4024 * @see #EXTRA_CSS_INDICATOR
4025 * @see #EXTRA_NETWORK_ID
4026 * @see #EXTRA_SYSTEM_ID
4027 * @see #EXTRA_CDMA_ROAMING_INDICATOR
4028 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4029 * @see #EXTRA_EMERGENCY_ONLY
4030 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4031 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4032 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4033 *
4034 * <p class="note">
4035 * Requires the READ_PHONE_STATE permission.
4036 *
4037 * <p class="note">This is a protected intent that can only be sent by the system.
4038 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004039 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004040 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4041 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4042 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4043 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07004044 */
4045 @Deprecated
4046 @SystemApi
4047 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4048 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4049
4050 /**
4051 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4052 * state.
4053 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4054 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4055 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4056 * @see android.telephony.ServiceState#STATE_POWER_OFF
4057 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004058 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004059 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07004060 */
4061 @Deprecated
4062 @SystemApi
4063 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4064
4065 /**
4066 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4067 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4068 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4069 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4070 * @see android.telephony.ServiceState#STATE_POWER_OFF
4071 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004072 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004073 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07004074 */
4075 @Deprecated
4076 @SystemApi
4077 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4078
4079 /**
4080 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4081 * type.
4082 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004083 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004084 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004085 */
4086 @Deprecated
4087 @SystemApi
4088 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4089
4090 /**
4091 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4092 * type.
4093 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004094 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004095 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004096 */
4097 @Deprecated
4098 @SystemApi
4099 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4100
4101 /**
4102 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4103 * registered voice operator name in long alphanumeric format.
4104 * {@code null} if the operator name is not known or unregistered.
4105 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004106 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004107 * @deprecated Use
4108 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004109 */
4110 @Deprecated
4111 @SystemApi
4112 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4113
4114 /**
4115 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4116 * registered voice operator name in short alphanumeric format.
4117 * {@code null} if the operator name is not known or unregistered.
4118 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004119 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004120 * @deprecated Use
4121 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004122 */
4123 @Deprecated
4124 @SystemApi
4125 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4126
4127 /**
4128 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4129 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4130 * network.
4131 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004132 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004133 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004134 */
4135 @Deprecated
4136 @SystemApi
4137 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4138
4139 /**
4140 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4141 * registered data operator name in long alphanumeric format.
4142 * {@code null} if the operator name is not known or unregistered.
4143 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004144 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004145 * @deprecated Use
4146 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004147 */
4148 @Deprecated
4149 @SystemApi
4150 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4151
4152 /**
4153 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4154 * registered data operator name in short alphanumeric format.
4155 * {@code null} if the operator name is not known or unregistered.
4156 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004157 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004158 * @deprecated Use
4159 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004160 */
4161 @Deprecated
4162 @SystemApi
4163 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4164
4165 /**
4166 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4167 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4168 * data operator.
4169 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004170 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004171 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004172 */
4173 @Deprecated
4174 @SystemApi
4175 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4176
4177 /**
4178 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4179 * network selection mode is manual.
4180 * Will be {@code true} if manual mode, {@code false} if automatic mode.
4181 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004182 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004183 * @deprecated Use
4184 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07004185 */
4186 @Deprecated
4187 @SystemApi
4188 public static final String EXTRA_MANUAL = "manual";
4189
4190 /**
4191 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4192 * radio technology.
4193 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004194 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004195 * @deprecated Use
4196 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004197 */
4198 @Deprecated
4199 @SystemApi
4200 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4201
4202 /**
4203 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4204 * radio technology.
4205 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004206 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004207 * @deprecated Use
4208 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004209 */
4210 @Deprecated
4211 @SystemApi
4212 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4213
4214 /**
4215 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4216 * support on CDMA network.
4217 * Will be {@code true} if support, {@code false} otherwise.
4218 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004219 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004220 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004221 */
4222 @Deprecated
4223 @SystemApi
4224 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4225
4226 /**
4227 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4228 * id. {@code Integer.MAX_VALUE} if unknown.
4229 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004230 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004231 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004232 */
4233 @Deprecated
4234 @SystemApi
4235 public static final String EXTRA_NETWORK_ID = "networkId";
4236
4237 /**
4238 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4239 * {@code Integer.MAX_VALUE} if unknown.
4240 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004241 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004242 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004243 */
4244 @Deprecated
4245 @SystemApi
4246 public static final String EXTRA_SYSTEM_ID = "systemId";
4247
4248 /**
4249 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4250 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4251 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004252 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004253 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004254 */
4255 @Deprecated
4256 @SystemApi
4257 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4258
4259 /**
4260 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4261 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4262 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004263 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004264 * @deprecated Use
4265 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004266 */
4267 @Deprecated
4268 @SystemApi
4269 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4270
4271 /**
4272 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4273 * only mode.
4274 * {@code true} if in emergency only mode, {@code false} otherwise.
4275 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004276 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004277 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07004278 */
4279 @Deprecated
4280 @SystemApi
4281 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4282
4283 /**
4284 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4285 * registration state is roaming.
4286 * {@code true} if registration indicates roaming, {@code false} otherwise
4287 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004288 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004289 * @deprecated Use
4290 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07004291 */
4292 @Deprecated
4293 @SystemApi
4294 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4295 "isDataRoamingFromRegistration";
4296
4297 /**
4298 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4299 * aggregation is in use.
4300 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4301 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004302 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004303 * @deprecated Use
4304 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07004305 */
4306 @Deprecated
4307 @SystemApi
4308 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4309
4310 /**
4311 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4312 * is reduced from the rsrp threshold while calculating signal strength level.
4313 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004314 * @removed
fionaxu90fee272017-03-31 12:45:12 -07004315 */
4316 @Deprecated
4317 @SystemApi
4318 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4319
4320 /**
chen xu02811692018-10-03 19:07:09 -07004321 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
4322 * @hide
4323 */
4324 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4325
4326 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004327 * The name of the extra used to define the text to be processed, as a
4328 * CharSequence. Note that this may be a styled CharSequence, so you must use
4329 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004330 */
4331 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4332 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004333 * 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 +00004334 */
4335 public static final String EXTRA_PROCESS_TEXT_READONLY =
4336 "android.intent.extra.PROCESS_TEXT_READONLY";
4337
Bryce Leebc58f592015-09-25 16:43:01 -07004338 /**
4339 * Broadcast action: reports when a new thermal event has been reached. When the device
4340 * is reaching its maximum temperatue, the thermal level reported
4341 * {@hide}
4342 */
4343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4344 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4345
4346 /** {@hide} */
4347 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4348
4349 /**
4350 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004351 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004352 * {@hide}
4353 */
4354 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4355
4356 /**
4357 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004358 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004359 * {@hide}
4360 */
4361 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4362
4363 /**
4364 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004365 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004366 * {@hide}
4367 */
4368 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4369
lpeter318abc92018-05-04 16:13:14 +08004370 /**
4371 * Broadcast Action: Indicates the dock in idle state while device is docked.
4372 *
4373 * <p class="note">This is a protected intent that can only be sent
4374 * by the system.
4375 *
4376 * @hide
4377 */
4378 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4379
4380 /**
4381 * Broadcast Action: Indicates the dock in active state while device is docked.
4382 *
4383 * <p class="note">This is a protected intent that can only be sent
4384 * by the system.
4385 *
4386 * @hide
4387 */
4388 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4389
MÃ¥rten Kongstadfd20b832018-10-26 15:36:20 +02004390 /**
4391 * Broadcast Action: Indicates that a new device customization has been
4392 * downloaded and applied (packages installed, runtime resource overlays
4393 * enabled, xml files copied, ...), and that it is time for components that
4394 * need to for example clear their caches to do so now.
4395 *
4396 * @hide
4397 */
4398 @SystemApi
4399 public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4400 "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4401
Bryce Leebc58f592015-09-25 16:43:01 -07004402
Felipe Leme044c63b2019-02-12 14:35:20 -08004403 /**
4404 * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4405 *
4406 * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4407 *
4408 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4409 * app domain. Should be stable across reboots and backup / restore.
4410 * <p>Output: nothing.
4411 */
4412 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4413 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4414
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004415 // ---------------------------------------------------------------------
4416 // ---------------------------------------------------------------------
4417 // Standard intent categories (see addCategory()).
4418
4419 /**
4420 * Set if the activity should be an option for the default action
4421 * (center press) to perform on a piece of data. Setting this will
4422 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004423 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004424 * Intent when initiating an action -- it is for use in intent filters
4425 * specified in packages.
4426 */
4427 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4428 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4429 /**
4430 * Activities that can be safely invoked from a browser must support this
4431 * category. For example, if the user is viewing a web page or an e-mail
4432 * and clicks on a link in the text, the Intent generated execute that
4433 * link will require the BROWSABLE category, so that only activities
4434 * supporting this category will be considered as possible actions. By
4435 * supporting this category, you are promising that there is nothing
4436 * damaging (without user intervention) that can happen by invoking any
4437 * matching Intent.
4438 */
4439 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4440 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4441 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004442 * Categories for activities that can participate in voice interaction.
4443 * An activity that supports this category must be prepared to run with
4444 * no UI shown at all (though in some case it may have a UI shown), and
4445 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4446 */
4447 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4448 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4449 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004450 * Set if the activity should be considered as an alternative action to
4451 * the data the user is currently viewing. See also
4452 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4453 * applies to the selection in a list of items.
4454 *
4455 * <p>Supporting this category means that you would like your activity to be
4456 * displayed in the set of alternative things the user can do, usually as
4457 * part of the current activity's options menu. You will usually want to
4458 * include a specific label in the &lt;intent-filter&gt; of this action
4459 * describing to the user what it does.
4460 *
4461 * <p>The action of IntentFilter with this category is important in that it
4462 * describes the specific action the target will perform. This generally
4463 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4464 * a specific name such as "com.android.camera.action.CROP. Only one
4465 * alternative of any particular action will be shown to the user, so using
4466 * a specific action like this makes sure that your alternative will be
4467 * displayed while also allowing other applications to provide their own
4468 * overrides of that particular action.
4469 */
4470 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4471 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4472 /**
4473 * Set if the activity should be considered as an alternative selection
4474 * action to the data the user has currently selected. This is like
4475 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4476 * of items from which the user can select, giving them alternatives to the
4477 * default action that will be performed on it.
4478 */
4479 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4480 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4481 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004482 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004483 */
4484 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4485 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4486 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004487 * Should be displayed in the top-level launcher.
4488 */
4489 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4490 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4491 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004492 * Indicates an activity optimized for Leanback mode, and that should
4493 * be displayed in the Leanback launcher.
4494 */
4495 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4496 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4497 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004498 * Indicates the preferred entry-point activity when an application is launched from a Car
4499 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4500 * fallback, or exclude the application entirely.
4501 * @hide
4502 */
4503 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4504 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4505 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004506 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4507 * @hide
4508 */
4509 @SystemApi
4510 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4511 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004512 * Provides information about the package it is in; typically used if
4513 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4514 * a front-door to the user without having to be shown in the all apps list.
4515 */
4516 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4517 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4518 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004519 * This is the home activity, that is the first activity that is displayed
4520 * when the device boots.
4521 */
4522 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4523 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4524 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004525 * This is the home activity that is displayed when the device is finished setting up and ready
4526 * for use.
4527 * @hide
4528 */
4529 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4530 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4531 /**
Chilun2ef71f72018-11-16 17:57:15 +08004532 * The home activity shown on secondary displays that support showing home activities.
4533 */
4534 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4535 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4536 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004537 * This is the setup wizard activity, that is the first activity that is displayed
4538 * when the user sets up the device for the first time.
4539 * @hide
4540 */
4541 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4542 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4543 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004544 * This is the home activity, that is the activity that serves as the launcher app
4545 * from there the user can start other apps. Often components with lower/higher
4546 * priority intent filters handle the home intent, for example SetupWizard, to
4547 * setup the device and we need to be able to distinguish the home app from these
4548 * setup helpers.
4549 * @hide
4550 */
4551 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4552 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4553 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004554 * This activity is a preference panel.
4555 */
4556 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4557 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4558 /**
4559 * This activity is a development preference panel.
4560 */
4561 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4562 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4563 /**
4564 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004565 */
4566 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4567 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4568 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004569 * This activity allows the user to browse and download new applications.
4570 */
4571 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4572 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4573 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004574 * This activity may be exercised by the monkey or other automated test tools.
4575 */
4576 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4577 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4578 /**
4579 * To be used as a test (not part of the normal user experience).
4580 */
4581 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4582 /**
4583 * To be used as a unit test (run through the Test Harness).
4584 */
4585 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4586 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004587 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004588 * experience).
4589 */
4590 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004591
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004592 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004593 * Used to indicate that an intent only wants URIs that can be opened with
4594 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4595 * must support at least the columns defined in {@link OpenableColumns} when
4596 * queried.
4597 *
4598 * @see #ACTION_GET_CONTENT
4599 * @see #ACTION_OPEN_DOCUMENT
4600 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004601 */
4602 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4603 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4604
4605 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004606 * Used to indicate that an intent filter can accept files which are not necessarily
4607 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4608 * at least streamable via
4609 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4610 * using one of the stream types exposed via
4611 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4612 *
4613 * @see #ACTION_SEND
4614 * @see #ACTION_SEND_MULTIPLE
4615 */
4616 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4617 public static final String CATEGORY_TYPED_OPENABLE =
4618 "android.intent.category.TYPED_OPENABLE";
4619
4620 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004621 * To be used as code under test for framework instrumentation tests.
4622 */
4623 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4624 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004625 /**
4626 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004627 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4628 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004629 */
4630 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4631 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4632 /**
4633 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004634 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4635 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004636 */
4637 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4638 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004639 /**
4640 * An activity to run when device is inserted into a analog (low end) dock.
4641 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4642 * information, see {@link android.app.UiModeManager}.
4643 */
4644 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4645 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4646
4647 /**
4648 * An activity to run when device is inserted into a digital (high end) dock.
4649 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4650 * information, see {@link android.app.UiModeManager}.
4651 */
4652 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4653 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004654
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004655 /**
4656 * Used to indicate that the activity can be used in a car environment.
4657 */
4658 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4659 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4660
Zak Cohendb6ca492017-01-26 14:09:00 -08004661 /**
4662 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4663 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4664 * information, see {@link android.app.UiModeManager}.
4665 */
4666 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4667 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004668 // ---------------------------------------------------------------------
4669 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004670 // Application launch intent categories (see addCategory()).
4671
4672 /**
4673 * Used with {@link #ACTION_MAIN} to launch the browser application.
4674 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004675 * <p>NOTE: This should not be used as the primary key of an Intent,
4676 * since it will not result in the app launching with the correct
4677 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004678 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004679 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004680 */
4681 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4682 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4683
4684 /**
4685 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4686 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004687 * <p>NOTE: This should not be used as the primary key of an Intent,
4688 * since it will not result in the app launching with the correct
4689 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004690 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004691 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004692 */
4693 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4694 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4695
4696 /**
4697 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4698 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004699 * <p>NOTE: This should not be used as the primary key of an Intent,
4700 * since it will not result in the app launching with the correct
4701 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004702 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004703 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004704 */
4705 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4706 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4707
4708 /**
4709 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4710 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004711 * <p>NOTE: This should not be used as the primary key of an Intent,
4712 * since it will not result in the app launching with the correct
4713 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004714 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004715 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004716 */
4717 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4718 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4719
4720 /**
4721 * Used with {@link #ACTION_MAIN} to launch the email application.
4722 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004723 * <p>NOTE: This should not be used as the primary key of an Intent,
4724 * since it will not result in the app launching with the correct
4725 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004726 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004727 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004728 */
4729 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4730 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4731
4732 /**
4733 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4734 * The activity should be able to view and manipulate image and video files
4735 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004736 * <p>NOTE: This should not be used as the primary key of an Intent,
4737 * since it will not result in the app launching with the correct
4738 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004739 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004740 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004741 */
4742 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4743 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4744
4745 /**
4746 * Used with {@link #ACTION_MAIN} to launch the maps application.
4747 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004748 * <p>NOTE: This should not be used as the primary key of an Intent,
4749 * since it will not result in the app launching with the correct
4750 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004751 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004752 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004753 */
4754 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4755 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4756
4757 /**
4758 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4759 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004760 * <p>NOTE: This should not be used as the primary key of an Intent,
4761 * since it will not result in the app launching with the correct
4762 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004763 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004764 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004765 */
4766 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4767 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4768
4769 /**
4770 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004771 * The activity should be able to play, browse, or manipulate music files
4772 * stored on the device.
4773 * <p>NOTE: This should not be used as the primary key of an Intent,
4774 * since it will not result in the app launching with the correct
4775 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004776 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004777 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004778 */
4779 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4780 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4781
Jeff Sharkey2e4832f2019-04-09 09:23:48 -06004782 /**
4783 * Used with {@link #ACTION_MAIN} to launch the files application.
4784 * The activity should be able to browse and manage files stored on the device.
4785 * <p>NOTE: This should not be used as the primary key of an Intent,
4786 * since it will not result in the app launching with the correct
4787 * action and category. Instead, use this with
4788 * {@link #makeMainSelectorActivity(String, String)} to generate a main
4789 * Intent with this category in the selector.</p>
4790 */
4791 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4792 public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
4793
Jeff Brown6651a632011-11-28 12:59:11 -08004794 // ---------------------------------------------------------------------
4795 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004796 // Standard extra data keys.
4797
4798 /**
4799 * The initial data to place in a newly created record. Use with
4800 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4801 * fields as would be given to the underlying ContentProvider.insert()
4802 * call.
4803 */
4804 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4805
4806 /**
4807 * A constant CharSequence that is associated with the Intent, used with
4808 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4809 * this may be a styled CharSequence, so you must use
4810 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4811 * retrieve it.
4812 */
4813 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4814
4815 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004816 * A constant String that is associated with the Intent, used with
4817 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4818 * as HTML formatted text. Note that you <em>must</em> also supply
4819 * {@link #EXTRA_TEXT}.
4820 */
4821 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4822
4823 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004824 * A content: URI holding a stream of data associated with the Intent,
4825 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004826 */
4827 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4828
4829 /**
4830 * A String[] holding e-mail addresses that should be delivered to.
4831 */
4832 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4833
4834 /**
4835 * A String[] holding e-mail addresses that should be carbon copied.
4836 */
4837 public static final String EXTRA_CC = "android.intent.extra.CC";
4838
4839 /**
4840 * A String[] holding e-mail addresses that should be blind carbon copied.
4841 */
4842 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4843
4844 /**
4845 * A constant string holding the desired subject line of a message.
4846 */
4847 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4848
4849 /**
4850 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004851 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004852 */
4853 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4854
4855 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004856 * An int representing the user id to be used.
4857 *
4858 * @hide
4859 */
4860 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4861
4862 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004863 * An int representing the task id to be retrieved. This is used when a launch from recents is
4864 * intercepted by another action such as credentials confirmation to remember which task should
4865 * be resumed when complete.
4866 *
4867 * @hide
4868 */
4869 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4870
4871 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004872 * An Intent[] describing additional, alternate choices you would like shown with
4873 * {@link #ACTION_CHOOSER}.
4874 *
4875 * <p>An app may be capable of providing several different payload types to complete a
4876 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4877 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4878 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4879 * photo data or a hosted link where the photos can be viewed.</p>
4880 *
4881 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4882 * first/primary/preferred intent in the set. Additional intents specified in
4883 * this extra are ordered; by default intents that appear earlier in the array will be
4884 * preferred over intents that appear later in the array as matches for the same
4885 * target component. To alter this preference, a calling app may also supply
4886 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4887 */
4888 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4889
4890 /**
Adam Powell52c39212016-04-07 15:14:18 -07004891 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4892 * and omitted from a list of components presented to the user.
4893 *
4894 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4895 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4896 * from your own package or other apps from your organization if the idea of sending to those
4897 * targets would be redundant with other app functionality. Filtered components will not
4898 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4899 */
4900 public static final String EXTRA_EXCLUDE_COMPONENTS
4901 = "android.intent.extra.EXCLUDE_COMPONENTS";
4902
4903 /**
4904 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4905 * describing additional high-priority deep-link targets for the chooser to present to the user.
4906 *
4907 * <p>Targets provided in this way will be presented inline with all other targets provided
4908 * by services from other apps. They will be prioritized before other service targets, but
4909 * after those targets provided by sources that the user has manually pinned to the front.</p>
4910 *
4911 * @see #ACTION_CHOOSER
4912 */
4913 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4914
4915 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004916 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4917 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4918 *
4919 * <p>An app preparing an action for another app to complete may wish to allow the user to
4920 * disambiguate between several options for completing the action based on the chosen target
4921 * or otherwise refine the action before it is invoked.
4922 * </p>
4923 *
4924 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4925 * <ul>
4926 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4927 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4928 * chosen target beyond the first</li>
4929 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4930 * should fill in and send once the disambiguation is complete</li>
4931 * </ul>
4932 */
4933 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4934 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4935
4936 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004937 * An {@code ArrayList} of {@code String} annotations describing content for
4938 * {@link #ACTION_CHOOSER}.
4939 *
4940 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4941 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4942 *
4943 * <p>Annotations should describe the major components or topics of the content. It is up to
4944 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4945 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004946 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4947 * character. Performance on customized annotations can suffer, if they are rarely used for
4948 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4949 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004950 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004951 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004952 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004953 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004954 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004955 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004956 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004957 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004958 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004959 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4960 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4961 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4962 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4963 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004964 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004965 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4966 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004967 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004968 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004969 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004970 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004971 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004972 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004973 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004974 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004975 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004976 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004977 * Christmas and Thanksgiving.</li>
4978 * </ul>
4979 */
4980 public static final String EXTRA_CONTENT_ANNOTATIONS
4981 = "android.intent.extra.CONTENT_ANNOTATIONS";
4982
4983 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004984 * A {@link ResultReceiver} used to return data back to the sender.
4985 *
4986 * <p>Used to complete an app-specific
4987 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4988 *
4989 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4990 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4991 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4992 * when the user selects a target component from the chooser. It is up to the recipient
4993 * to send a result to this ResultReceiver to signal that disambiguation is complete
4994 * and that the chooser should invoke the user's choice.</p>
4995 *
4996 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4997 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4998 * to match and fill in the final Intent or ChooserTarget before starting it.
4999 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
5000 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
5001 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
5002 *
5003 * <p>The result code passed to the ResultReceiver should be
5004 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5005 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5006 * the chooser should finish without starting a target.</p>
5007 */
5008 public static final String EXTRA_RESULT_RECEIVER
5009 = "android.intent.extra.RESULT_RECEIVER";
5010
5011 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005012 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00005013 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005014 */
5015 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5016
5017 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07005018 * A Parcelable[] of {@link Intent} or
5019 * {@link android.content.pm.LabeledIntent} objects as set with
5020 * {@link #putExtra(String, Parcelable[])} of additional activities to place
5021 * a the front of the list of choices, when shown to the user with a
5022 * {@link #ACTION_CHOOSER}.
5023 */
5024 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5025
5026 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005027 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08005028 * @hide
5029 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005030 @SystemApi
5031 public static final String EXTRA_INSTANT_APP_SUCCESS =
5032 "android.intent.extra.INSTANT_APP_SUCCESS";
5033
5034 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005035 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08005036 * @hide
5037 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005038 @SystemApi
5039 public static final String EXTRA_INSTANT_APP_FAILURE =
5040 "android.intent.extra.INSTANT_APP_FAILURE";
5041
5042 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005043 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08005044 * @hide
5045 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005046 @SystemApi
5047 public static final String EXTRA_INSTANT_APP_HOSTNAME =
5048 "android.intent.extra.INSTANT_APP_HOSTNAME";
5049
5050 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005051 * An opaque token to track instant app resolution.
5052 * @hide
5053 */
5054 @SystemApi
5055 public static final String EXTRA_INSTANT_APP_TOKEN =
5056 "android.intent.extra.INSTANT_APP_TOKEN";
5057
5058 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08005059 * The action that triggered an instant application resolution.
5060 * @hide
5061 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005062 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08005063 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5064
5065 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00005066 * An array of {@link Bundle}s containing details about resolved instant apps..
5067 * @hide
5068 */
5069 @SystemApi
5070 public static final String EXTRA_INSTANT_APP_BUNDLES =
5071 "android.intent.extra.INSTANT_APP_BUNDLES";
5072
5073 /**
5074 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08005075 * installed. This data is populated from the response to
5076 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5077 * instant application resolver.
5078 * @hide
5079 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005080 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08005081 public static final String EXTRA_INSTANT_APP_EXTRAS =
5082 "android.intent.extra.INSTANT_APP_EXTRAS";
5083
5084 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00005085 * A boolean value indicating that the instant app resolver was unable to state with certainty
5086 * that it did or did not have an app for the sanitized {@link Intent} defined at
5087 * {@link #EXTRA_INTENT}.
5088 * @hide
5089 */
5090 @SystemApi
5091 public static final String EXTRA_UNKNOWN_INSTANT_APP =
5092 "android.intent.extra.UNKNOWN_INSTANT_APP";
5093
5094 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08005095 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07005096 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08005097 * @hide
5098 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07005099 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08005100 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5101
5102 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07005103 * The version code of the app to install components from.
5104 * @hide
5105 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005106 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07005107 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5108
5109 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005110 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07005111 * @hide
5112 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005113 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005114 public static final String EXTRA_CALLING_PACKAGE
5115 = "android.intent.extra.CALLING_PACKAGE";
5116
5117 /**
5118 * Optional calling app provided bundle containing additional launch information the
5119 * installer may use.
5120 * @hide
5121 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005122 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005123 public static final String EXTRA_VERIFICATION_BUNDLE
5124 = "android.intent.extra.VERIFICATION_BUNDLE";
5125
5126 /**
Adam Powelle49d9392014-07-17 18:45:19 -07005127 * A Bundle forming a mapping of potential target package names to different extras Bundles
5128 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5129 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5130 * be currently installed on the device.
5131 *
5132 * <p>An application may choose to provide alternate extras for the case where a user
5133 * selects an activity from a predetermined set of target packages. If the activity
5134 * the user selects from the chooser belongs to a package with its package name as
5135 * a key in this bundle, the corresponding extras for that package will be merged with
5136 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5137 * extra has the same key as an extra already present in the intent it will overwrite
5138 * the extra from the intent.</p>
5139 *
5140 * <p><em>Examples:</em>
5141 * <ul>
5142 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
5143 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5144 * parameters for that target.</li>
5145 * <li>An application may offer additional metadata for known targets of a given intent
5146 * to pass along information only relevant to that target such as account or content
5147 * identifiers already known to that application.</li>
5148 * </ul></p>
5149 */
5150 public static final String EXTRA_REPLACEMENT_EXTRAS =
5151 "android.intent.extra.REPLACEMENT_EXTRAS";
5152
5153 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07005154 * An {@link IntentSender} that will be notified if a user successfully chooses a target
5155 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5156 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5157 * {@link ComponentName} of the chosen component.
5158 *
5159 * <p>In some situations this callback may never come, for example if the user abandons
5160 * the chooser, switches to another task or any number of other reasons. Apps should not
5161 * be written assuming that this callback will always occur.</p>
5162 */
5163 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5164 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5165
5166 /**
5167 * The {@link ComponentName} chosen by the user to complete an action.
5168 *
5169 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5170 */
5171 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5172
5173 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005174 * A {@link android.view.KeyEvent} object containing the event that
5175 * triggered the creation of the Intent it is in.
5176 */
5177 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5178
5179 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07005180 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5181 * before shutting down.
5182 *
5183 * {@hide}
5184 */
5185 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5186
5187 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07005188 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5189 * requested by the user.
5190 *
5191 * {@hide}
5192 */
5193 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5194 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5195
5196 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005197 * 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 -07005198 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5199 * of restarting the application.
5200 */
5201 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5202
5203 /**
5204 * A String holding the phone number originally entered in
5205 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5206 * number to call in a {@link android.content.Intent#ACTION_CALL}.
5207 */
5208 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02005209
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005210 /**
5211 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5212 * intents to supply the uid the package had been assigned. Also an optional
5213 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5214 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5215 * purpose.
5216 */
5217 public static final String EXTRA_UID = "android.intent.extra.UID";
5218
5219 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005220 * @hide String array of package names.
5221 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08005222 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005223 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5224
5225 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005226 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5227 * intents to indicate whether this represents a full uninstall (removing
5228 * both the code and its data) or a partial uninstall (leaving its data,
5229 * implying that this is an update).
5230 */
5231 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07005232
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005233 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07005234 * @hide
5235 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5236 * intents to indicate that at this point the package has been removed for
5237 * all users on the device.
5238 */
5239 public static final String EXTRA_REMOVED_FOR_ALL_USERS
5240 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5241
5242 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005243 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5244 * intents to indicate that this is a replacement of the package, so this
5245 * broadcast will immediately be followed by an add broadcast for a
5246 * different version of the same package.
5247 */
5248 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07005249
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005250 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005251 * Used as an int extra field in {@link android.app.AlarmManager} intents
5252 * to tell the application being invoked how many pending alarms are being
5253 * delievered with the intent. For one-shot alarms this will always be 1.
5254 * For recurring alarms, this might be greater than 1 if the device was
5255 * asleep or powered off at the time an earlier alarm would have been
5256 * delivered.
5257 */
5258 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07005259
Jacek Surazski86b6c532009-05-13 14:38:28 +02005260 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005261 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5262 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07005263 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5264 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005265 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5266 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5267 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005268 */
5269 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5270
5271 /**
5272 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5273 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005274 */
5275 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5276
5277 /**
5278 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5279 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005280 */
5281 public static final int EXTRA_DOCK_STATE_DESK = 1;
5282
5283 /**
5284 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5285 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005286 */
5287 public static final int EXTRA_DOCK_STATE_CAR = 2;
5288
5289 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005290 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5291 * to represent that the phone is in a analog (low end) dock.
5292 */
5293 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5294
5295 /**
5296 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5297 * to represent that the phone is in a digital (high end) dock.
5298 */
5299 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5300
5301 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005302 * Boolean that can be supplied as meta-data with a dock activity, to
5303 * indicate that the dock should take over the home key when it is active.
5304 */
5305 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08005306
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005307 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02005308 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5309 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02005310 */
5311 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5312
5313 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07005314 * Used in the extra field in the remote intent. It's astring token passed with the
5315 * remote intent.
5316 */
5317 public static final String EXTRA_REMOTE_INTENT_TOKEN =
5318 "android.intent.extra.remote_intent_token";
5319
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005320 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005321 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005322 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005323 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005324 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005325 "android.intent.extra.changed_component_name";
5326
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005327 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005328 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08005329 * and contains a string array of all of the components that have changed. If
5330 * the state of the overall package has changed, then it will contain an entry
5331 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005332 */
5333 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5334 "android.intent.extra.changed_component_name_list";
5335
5336 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005337 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005338 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00005339 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5340 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5341 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005342 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005343 */
5344 public static final String EXTRA_CHANGED_PACKAGE_LIST =
5345 "android.intent.extra.changed_package_list";
5346
5347 /**
5348 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005349 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5350 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005351 * and contains an integer array of uids of all of the components
5352 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005353 */
5354 public static final String EXTRA_CHANGED_UID_LIST =
5355 "android.intent.extra.changed_uid_list";
5356
5357 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08005358 * An integer denoting a bitwise combination of restrictions set on distracting packages via
5359 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5360 *
5361 * @hide
5362 * @see PackageManager.DistractionRestriction
5363 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5364 */
5365 public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5366 "android.intent.extra.distraction_restrictions";
5367
5368 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005369 * @hide
5370 * Magic extra system code can use when binding, to give a label for
5371 * who it is that has bound to a service. This is an integer giving
5372 * a framework string resource that can be displayed to the user.
5373 */
5374 public static final String EXTRA_CLIENT_LABEL =
5375 "android.intent.extra.client_label";
5376
5377 /**
5378 * @hide
5379 * Magic extra system code can use when binding, to give a PendingIntent object
5380 * that can be launched for the user to disable the system's use of this
5381 * service.
5382 */
5383 public static final String EXTRA_CLIENT_INTENT =
5384 "android.intent.extra.client_intent";
5385
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005386 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005387 * Extra used to indicate that an intent should only return data that is on
5388 * the local device. This is a boolean extra; the default is false. If true,
5389 * an implementation should only allow the user to select data that is
5390 * already on the device, not requiring it be downloaded from a remote
5391 * service when opened.
5392 *
5393 * @see #ACTION_GET_CONTENT
5394 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005395 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005396 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005397 */
5398 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005399 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005400
Amith Yamasani13593602012-03-22 16:16:17 -07005401 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005402 * Extra used to indicate that an intent can allow the user to select and
5403 * return multiple items. This is a boolean extra; the default is false. If
5404 * true, an implementation is allowed to present the user with a UI where
5405 * they can pick multiple items that are all returned to the caller. When
5406 * this happens, they should be returned as the {@link #getClipData()} part
5407 * of the result Intent.
5408 *
5409 * @see #ACTION_GET_CONTENT
5410 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005411 */
5412 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005413 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005414
5415 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005416 * The integer userHandle carried with broadcast intents related to addition, removal and
5417 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5418 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5419 *
Amith Yamasani13593602012-03-22 16:16:17 -07005420 * @hide
5421 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005422 public static final String EXTRA_USER_HANDLE =
5423 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005424
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005425 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005426 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005427 */
5428 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005429 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005430
5431 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005432 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005433 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5434 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005435 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005436 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5437
5438 /**
5439 * Extra sent in the intent to the BroadcastReceiver that handles
5440 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5441 * the restrictions as key/value pairs.
5442 */
5443 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5444 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005445
Amith Yamasani86118ba2013-03-28 14:33:16 -07005446 /**
5447 * Extra used in the response from a BroadcastReceiver that handles
5448 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5449 */
5450 public static final String EXTRA_RESTRICTIONS_INTENT =
5451 "android.intent.extra.restrictions_intent";
5452
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005453 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005454 * Extra used to communicate a set of acceptable MIME types. The type of the
5455 * extra is {@code String[]}. Values may be a combination of concrete MIME
5456 * types (such as "image/png") and/or partial MIME types (such as
5457 * "audio/*").
5458 *
5459 * @see #ACTION_GET_CONTENT
5460 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005461 */
5462 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5463
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005464 /**
5465 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5466 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005467 * When this is true, hardware devices can use this information to determine that
5468 * they shouldn't do a complete shutdown of their device since this is not a
5469 * complete shutdown down to the kernel, but only user space restarting.
5470 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005471 */
5472 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5473 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5474
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005475 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005476 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5477 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5478 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5479 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005480 *
5481 * @hide for internal use only.
5482 */
5483 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5484 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005485 /** @hide */
5486 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5487 /** @hide */
5488 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5489 /** @hide */
5490 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005491
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005492 /**
5493 * Intent extra: the reason that the operation associated with this intent is being performed.
5494 *
5495 * <p>Type: String
5496 * @hide
5497 */
5498 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005499 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5500
qingxi240c2bb2017-04-12 17:31:18 -07005501 /**
5502 * {@hide}
5503 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5504 */
Rubin Xue8490f12015-06-25 12:17:48 +01005505 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5506
Santos Cordon15a13782015-03-31 18:32:31 -07005507 /**
qingxi240c2bb2017-04-12 17:31:18 -07005508 * {@hide}
5509 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5510 * reset for the device with eSIM. This extra will be sent together with
5511 * {@link #ACTION_FACTORY_RESET}
5512 */
5513 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5514
5515 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005516 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5517 * activation request.
5518 * TODO: Add information about the structure and response data used with the pending intent.
5519 * @hide
5520 */
5521 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5522 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5523
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005524 /**
5525 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005526 *
5527 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005528 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005529 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005530 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5531
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005532 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005533 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5534 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5535 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005536 *
5537 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005538 * @see #ACTION_QUICK_VIEW
5539 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005540 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005541 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005542 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5543 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005544
5545 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005546 * An optional extra of {@code String[]} indicating which quick view features should be made
5547 * available to the user in the quick view UI while handing a
5548 * {@link Intent#ACTION_QUICK_VIEW} intent.
5549 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5550 * Quick viewer can implement features not listed below.
5551 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005552 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5553 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5554 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005555 * <p>
5556 * Requirements:
5557 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5558 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5559 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5560 * internal policies.
5561 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5562 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5563 * disable or hide features.
5564 *
5565 * @see #ACTION_QUICK_VIEW
5566 */
5567 public static final String EXTRA_QUICK_VIEW_FEATURES =
5568 "android.intent.extra.QUICK_VIEW_FEATURES";
5569
5570 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005571 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005572 * When a profile goes into quiet mode, all apps in the profile are killed and the
5573 * profile user is stopped. Widgets originating from the profile are masked, and app
5574 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005575 */
5576 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005577
5578 /**
Amin Shaikh710d1232018-11-14 16:58:13 -05005579 * Optional CharSequence extra to provide a search query.
Amin Shaikh5fdc89c2018-12-06 15:50:21 -05005580 * The format of this query is dependent on the receiving application.
Amin Shaikh710d1232018-11-14 16:58:13 -05005581 *
5582 * <p>Applicable to {@link Intent} with actions:
5583 * <ul>
5584 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
5585 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5586 * </ul>
5587 */
5588 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5589
5590 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005591 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005592 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005593 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5594 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005595 *
5596 * @hide
5597 */
5598 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5599 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5600
5601 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005602 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5603 * whether to show the chooser or not when there is only one application available
5604 * to choose from.
Ben Lin145b0ca2016-10-14 14:23:40 -07005605 */
5606 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5607 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5608
5609 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005610 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005611 * to represent that a video codec is allowed to use.
5612 *
5613 * @hide
5614 */
5615 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5616
5617 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005618 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005619 * to represent that a audio codec is allowed to use.
5620 *
5621 * @hide
5622 */
5623 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5624
Felipe Leme044c63b2019-02-12 14:35:20 -08005625 /**
5626 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
5627 *
5628 * <p>
5629 * Type: {@link LocusId}
5630 * </p>
5631 */
5632 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
5633
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005634 // ---------------------------------------------------------------------
5635 // ---------------------------------------------------------------------
5636 // Intent flags (see mFlags variable).
5637
Tor Norbyed9273d62013-05-30 15:59:53 -07005638 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005639 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005640 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5641 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005642 @Retention(RetentionPolicy.SOURCE)
5643 public @interface GrantUriMode {}
5644
Jeff Sharkey846318a2014-04-04 12:12:41 -07005645 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005646 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005647 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5648 @Retention(RetentionPolicy.SOURCE)
5649 public @interface AccessUriMode {}
5650
5651 /**
5652 * Test if given mode flags specify an access mode, which must be at least
5653 * read and/or write.
5654 *
5655 * @hide
5656 */
5657 public static boolean isAccessUriMode(int modeFlags) {
5658 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5659 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5660 }
5661
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005662 /** @hide */
5663 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5664 FLAG_GRANT_READ_URI_PERMISSION,
5665 FLAG_GRANT_WRITE_URI_PERMISSION,
5666 FLAG_FROM_BACKGROUND,
5667 FLAG_DEBUG_LOG_RESOLUTION,
5668 FLAG_EXCLUDE_STOPPED_PACKAGES,
5669 FLAG_INCLUDE_STOPPED_PACKAGES,
5670 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5671 FLAG_GRANT_PREFIX_URI_PERMISSION,
5672 FLAG_DEBUG_TRIAGED_MISSING,
5673 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005674 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005675 FLAG_ACTIVITY_NO_HISTORY,
5676 FLAG_ACTIVITY_SINGLE_TOP,
5677 FLAG_ACTIVITY_NEW_TASK,
5678 FLAG_ACTIVITY_MULTIPLE_TASK,
5679 FLAG_ACTIVITY_CLEAR_TOP,
5680 FLAG_ACTIVITY_FORWARD_RESULT,
5681 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5682 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5683 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5684 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5685 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5686 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5687 FLAG_ACTIVITY_NEW_DOCUMENT,
5688 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5689 FLAG_ACTIVITY_NO_USER_ACTION,
5690 FLAG_ACTIVITY_REORDER_TO_FRONT,
5691 FLAG_ACTIVITY_NO_ANIMATION,
5692 FLAG_ACTIVITY_CLEAR_TASK,
5693 FLAG_ACTIVITY_TASK_ON_HOME,
5694 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5695 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5696 FLAG_RECEIVER_REGISTERED_ONLY,
5697 FLAG_RECEIVER_REPLACE_PENDING,
5698 FLAG_RECEIVER_FOREGROUND,
5699 FLAG_RECEIVER_NO_ABORT,
5700 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5701 FLAG_RECEIVER_BOOT_UPGRADE,
5702 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5703 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5704 FLAG_RECEIVER_FROM_SHELL,
5705 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005706 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005707 })
5708 @Retention(RetentionPolicy.SOURCE)
5709 public @interface Flags {}
5710
5711 /** @hide */
5712 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5713 FLAG_FROM_BACKGROUND,
5714 FLAG_DEBUG_LOG_RESOLUTION,
5715 FLAG_EXCLUDE_STOPPED_PACKAGES,
5716 FLAG_INCLUDE_STOPPED_PACKAGES,
5717 FLAG_DEBUG_TRIAGED_MISSING,
5718 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005719 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005720 FLAG_ACTIVITY_NO_HISTORY,
5721 FLAG_ACTIVITY_SINGLE_TOP,
5722 FLAG_ACTIVITY_NEW_TASK,
5723 FLAG_ACTIVITY_MULTIPLE_TASK,
5724 FLAG_ACTIVITY_CLEAR_TOP,
5725 FLAG_ACTIVITY_FORWARD_RESULT,
5726 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5727 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5728 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5729 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5730 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5731 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5732 FLAG_ACTIVITY_NEW_DOCUMENT,
5733 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5734 FLAG_ACTIVITY_NO_USER_ACTION,
5735 FLAG_ACTIVITY_REORDER_TO_FRONT,
5736 FLAG_ACTIVITY_NO_ANIMATION,
5737 FLAG_ACTIVITY_CLEAR_TASK,
5738 FLAG_ACTIVITY_TASK_ON_HOME,
5739 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5740 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5741 FLAG_RECEIVER_REGISTERED_ONLY,
5742 FLAG_RECEIVER_REPLACE_PENDING,
5743 FLAG_RECEIVER_FOREGROUND,
5744 FLAG_RECEIVER_NO_ABORT,
5745 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5746 FLAG_RECEIVER_BOOT_UPGRADE,
5747 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5748 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5749 FLAG_RECEIVER_FROM_SHELL,
5750 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005751 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005752 })
5753 @Retention(RetentionPolicy.SOURCE)
5754 public @interface MutableFlags {}
5755
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 /**
5757 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005758 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005759 * specified in its ClipData. When applying to an Intent's ClipData,
5760 * all URIs as well as recursive traversals through data or other ClipData
5761 * in Intent items will be granted; only the grant flags of the top-level
5762 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005763 */
5764 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5765 /**
5766 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005767 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005768 * specified in its ClipData. When applying to an Intent's ClipData,
5769 * all URIs as well as recursive traversals through data or other ClipData
5770 * in Intent items will be granted; only the grant flags of the top-level
5771 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005772 */
5773 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5774 /**
5775 * Can be set by the caller to indicate that this Intent is coming from
5776 * a background operation, not from direct user interaction.
5777 */
5778 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5779 /**
5780 * A flag you can enable for debugging: when set, log messages will be
5781 * printed during the resolution of this intent to show you what has
5782 * been found to create the final resolved list.
5783 */
5784 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005785 /**
5786 * If set, this intent will not match any components in packages that
5787 * are currently stopped. If this is not set, then the default behavior
5788 * is to include such applications in the result.
5789 */
5790 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5791 /**
5792 * If set, this intent will always match any components in packages that
5793 * are currently stopped. This is the default behavior when
5794 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5795 * flags are set, this one wins (it allows overriding of exclude for
5796 * places where the framework may automatically set the exclude flag).
5797 */
5798 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005799
5800 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005801 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005802 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005803 * persisted across device reboots until explicitly revoked with
5804 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5805 * grant for possible persisting; the receiving application must call
5806 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5807 * actually persist.
5808 *
5809 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5810 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5811 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005812 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005813 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005814 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005815
5816 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005817 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5818 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5819 * applies to any URI that is a prefix match against the original granted
5820 * URI. (Without this flag, the URI must match exactly for access to be
5821 * granted.) Another URI is considered a prefix match only when scheme,
5822 * authority, and all path segments defined by the prefix are an exact
5823 * match.
5824 */
5825 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5826
5827 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005828 * Flag used to automatically match intents based on their Direct Boot
5829 * awareness and the current user state.
5830 * <p>
5831 * Since the default behavior is to automatically apply the current user
5832 * state, this is effectively a sentinel value that doesn't change the
5833 * output of any queries based on its presence or absence.
5834 * <p>
5835 * Instead, this value can be useful in conjunction with
5836 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5837 * to detect when a caller is relying on implicit automatic matching,
5838 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005839 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005840 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5841
5842 /** {@hide} */
5843 @Deprecated
5844 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005845
5846 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005847 * Internal flag used to indicate ephemeral applications should not be
5848 * considered when resolving the intent.
5849 *
5850 * @hide
5851 */
5852 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5853
5854 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005855 * If set, the new activity is not kept in the history stack. As soon as
5856 * the user navigates away from it, the activity is finished. This may also
5857 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5858 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005859 *
5860 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5861 * is never invoked when the current activity starts a new activity which
5862 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005863 */
5864 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5865 /**
5866 * If set, the activity will not be launched if it is already running
5867 * at the top of the history stack.
5868 */
5869 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5870 /**
5871 * If set, this activity will become the start of a new task on this
5872 * history stack. A task (from the activity that started it to the
5873 * next task activity) defines an atomic group of activities that the
5874 * user can move to. Tasks can be moved to the foreground and background;
5875 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005876 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005877 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5878 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005879 *
5880 * <p>This flag is generally used by activities that want
5881 * to present a "launcher" style behavior: they give the user a list of
5882 * separate things that can be done, which otherwise run completely
5883 * independently of the activity launching them.
5884 *
5885 * <p>When using this flag, if a task is already running for the activity
5886 * you are now starting, then a new activity will not be started; instead,
5887 * the current task will simply be brought to the front of the screen with
5888 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5889 * to disable this behavior.
5890 *
5891 * <p>This flag can not be used when the caller is requesting a result from
5892 * the activity being launched.
5893 */
5894 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5895 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005896 * This flag is used to create a new task and launch an activity into it.
5897 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5898 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5899 * search through existing tasks for ones matching this Intent. Only if no such
5900 * task is found would a new task be created. When paired with
5901 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5902 * the search for a matching task and unconditionally start a new task.
5903 *
5904 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5905 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005906 * top-level application launcher.</strong> Used in conjunction with
5907 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5908 * behavior of bringing an existing task to the foreground. When set,
5909 * a new task is <em>always</em> started to host the Activity for the
5910 * Intent, regardless of whether there is already an existing task running
5911 * the same thing.
5912 *
5913 * <p><strong>Because the default system does not include graphical task management,
5914 * you should not use this flag unless you provide some way for a user to
5915 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005916 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005917 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5918 * creating new document tasks.
5919 *
5920 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005921 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005922 *
Scott Main7aee61f2011-02-08 11:25:01 -08005923 * <p>See
5924 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5925 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005926 *
5927 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5928 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005929 */
5930 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5931 /**
5932 * If set, and the activity being launched is already running in the
5933 * current task, then instead of launching a new instance of that activity,
5934 * all of the other activities on top of it will be closed and this Intent
5935 * will be delivered to the (now on top) old activity as a new Intent.
5936 *
5937 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5938 * If D calls startActivity() with an Intent that resolves to the component
5939 * of activity B, then C and D will be finished and B receive the given
5940 * Intent, resulting in the stack now being: A, B.
5941 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005942 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005943 * either receive the new intent you are starting here in its
5944 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005945 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005946 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5947 * the same intent, then it will be finished and re-created; for all other
5948 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5949 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005950 *
5951 * <p>This launch mode can also be used to good effect in conjunction with
5952 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5953 * of a task, it will bring any currently running instance of that task
5954 * to the foreground, and then clear it to its root state. This is
5955 * especially useful, for example, when launching an activity from the
5956 * notification manager.
5957 *
Scott Main7aee61f2011-02-08 11:25:01 -08005958 * <p>See
5959 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5960 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005961 */
5962 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5963 /**
5964 * If set and this intent is being used to launch a new activity from an
5965 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005966 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005967 * {@link android.app.Activity#setResult} and have that result sent back to
5968 * the reply target of the original activity.
5969 */
5970 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5971 /**
5972 * If set and this intent is being used to launch a new activity from an
5973 * existing one, the current activity will not be counted as the top
5974 * activity for deciding whether the new intent should be delivered to
5975 * the top instead of starting a new one. The previous activity will
5976 * be used as the top, with the assumption being that the current activity
5977 * will finish itself immediately.
5978 */
5979 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5980 /**
5981 * If set, the new activity is not kept in the list of recently launched
5982 * activities.
5983 */
5984 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5985 /**
5986 * This flag is not normally set by application code, but set for you by
5987 * the system as described in the
5988 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5989 * launchMode} documentation for the singleTask mode.
5990 */
5991 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5992 /**
5993 * If set, and this activity is either being started in a new task or
5994 * bringing to the top an existing task, then it will be launched as
5995 * the front door of the task. This will result in the application of
5996 * any affinities needed to have that task in the proper state (either
5997 * moving activities to or from it), or simply resetting that task to
5998 * its initial state if needed.
5999 */
6000 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
6001 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006002 * This flag is not normally set by application code, but set for you by
6003 * the system if this activity is being launched from history
6004 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 */
6006 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006007 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07006008 * @deprecated As of API 21 this performs identically to
6009 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006010 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07006011 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08006012 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006013 /**
Craig Mautner026596b2014-05-21 15:35:44 -07006014 * This flag is used to open a document into a new task rooted at the activity launched
6015 * by this Intent. Through the use of this flag, or its equivalent attribute,
6016 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00006017 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07006018 *
Craig Mautner026596b2014-05-21 15:35:44 -07006019 * <p>The use of the activity attribute form of this,
6020 * {@link android.R.attr#documentLaunchMode}, is
6021 * preferred over the Intent flag described here. The attribute form allows the
6022 * Activity to specify multiple document behavior for all launchers of the Activity
6023 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07006024 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07006025 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6026 * it is kept after the activity is finished is different than the use of
6027 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6028 * this flag is being used to create a new recents entry, then by default that entry
6029 * will be removed once the activity is finished. You can modify this behavior with
6030 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6031 *
Craig Mautner026596b2014-05-21 15:35:44 -07006032 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6033 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6034 * equivalent of the Activity manifest specifying {@link
6035 * android.R.attr#documentLaunchMode}="intoExisting". When used with
6036 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6037 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07006038 *
Craig Mautner026596b2014-05-21 15:35:44 -07006039 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07006040 *
Craig Mautner026596b2014-05-21 15:35:44 -07006041 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07006042 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6043 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07006044 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07006045 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006046 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006047 * callback from occurring on the current frontmost activity before it is
6048 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07006049 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006050 * <p>Typically, an activity can rely on that callback to indicate that an
6051 * explicit user action has caused their activity to be moved out of the
6052 * foreground. The callback marks an appropriate point in the activity's
6053 * lifecycle for it to dismiss any notifications that it intends to display
6054 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07006055 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006056 * <p>If an activity is ever started via any non-user-driven events such as
6057 * phone-call receipt or an alarm handler, this flag should be passed to {@link
6058 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07006059 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08006060 */
6061 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006062 /**
6063 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6064 * this flag will cause the launched activity to be brought to the front of its
6065 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07006066 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006067 * <p>For example, consider a task consisting of four activities: A, B, C, D.
6068 * If D calls startActivity() with an Intent that resolves to the component
6069 * of activity B, then B will be brought to the front of the history stack,
6070 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07006071 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006072 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07006073 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006074 */
6075 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006076 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07006077 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6078 * this flag will prevent the system from applying an activity transition
6079 * animation to go to the next activity state. This doesn't mean an
6080 * animation will never run -- if another activity change happens that doesn't
6081 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006082 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07006083 * when you are going to do a series of activity operations but the
6084 * animation seen by the user shouldn't be driven by the first activity
6085 * change but rather a later one.
6086 */
6087 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6088 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006089 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6090 * this flag will cause any existing task that would be associated with the
6091 * activity to be cleared before the activity is started. That is, the activity
6092 * becomes the new root of an otherwise empty task, and any old activities
6093 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6094 */
6095 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6096 /**
6097 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6098 * this flag will cause a newly launching task to be placed on top of the current
6099 * home activity task (if there is one). That is, pressing back from the task
6100 * will always return the user to home even if that was not the last activity they
6101 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6102 */
6103 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6104 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07006105 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6106 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006107 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07006108 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006109 * this flag. When set and the task's activity is finished, the recents
6110 * entry will remain in the interface for the user to re-launch it, like a
6111 * recents entry for a top-level application.
6112 * <p>
6113 * The receiving activity can override this request with
6114 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6115 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07006116 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07006117 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07006118 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07006119
6120 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006121 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
6122 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08006123 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6124 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006125 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006126 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006127
Patrick Baumann577d4022018-01-31 16:55:10 +00006128
6129 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07006130 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6131 * this flag will attempt to launch an instant app if no full app on the device can already
6132 * handle the intent.
6133 * <p>
6134 * When attempting to resolve instant apps externally, the following {@link Intent} properties
6135 * are supported:
6136 * <ul>
6137 * <li>{@link Intent#setAction(String)}</li>
6138 * <li>{@link Intent#addCategory(String)}</li>
6139 * <li>{@link Intent#setData(Uri)}</li>
6140 * <li>{@link Intent#setType(String)}</li>
6141 * <li>{@link Intent#setPackage(String)}</li>
6142 * <li>{@link Intent#addFlags(int)}</li>
6143 * </ul>
6144 * <p>
6145 * In the case that no instant app can be found, the installer will be launched to notify the
6146 * user that the intent could not be resolved. On devices that do not support instant apps,
6147 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00006148 */
6149 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6150
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006151 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006152 * If set, when sending a broadcast only registered receivers will be
6153 * called -- no BroadcastReceiver components will be launched.
6154 */
6155 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006156 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006157 * If set, when sending a broadcast the new broadcast will replace
6158 * any existing pending broadcast that matches it. Matching is defined
6159 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6160 * true for the intents of the two broadcasts. When a match is found,
6161 * the new broadcast (and receivers associated with it) will replace the
6162 * existing one in the pending broadcast list, remaining at the same
6163 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08006164 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006165 * <p>This flag is most typically used with sticky broadcasts, which
6166 * only care about delivering the most recent values of the broadcast
6167 * to their receivers.
6168 */
6169 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6170 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08006171 * If set, when sending a broadcast the recipient is allowed to run at
6172 * foreground priority, with a shorter timeout interval. During normal
6173 * broadcasts the receivers are not automatically hoisted out of the
6174 * background priority class.
6175 */
6176 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6177 /**
Ng Zhi An150a6ba2018-08-13 09:08:11 -07006178 * If set, when sending a broadcast the recipient will be run on the offload queue.
6179 *
6180 * @hide
6181 */
6182 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6183 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07006184 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6185 * They can still propagate results through to later receivers, but they can not prevent
6186 * later receivers from seeing the broadcast.
6187 */
6188 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6189 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006190 * If set, when sending a broadcast <i>before boot has completed</i> only
6191 * registered receivers will be called -- no BroadcastReceiver components
6192 * will be launched. Sticky intent state will be recorded properly even
6193 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6194 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07006195 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006196 * <p>This flag is only for use by system sevices as a convenience to
6197 * avoid having to implement a more complex mechanism around detection
6198 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07006199 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006200 * @hide
6201 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006202 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07006203 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07006204 /**
6205 * Set when this broadcast is for a boot upgrade, a special mode that
6206 * allows the broadcast to be sent before the system is ready and launches
6207 * the app process with no providers running in it.
6208 * @hide
6209 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07006210 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006211 /**
6212 * If set, the broadcast will always go to manifest receivers in background (cached
6213 * or not running) apps, regardless of whether that would be done by default. By
6214 * default they will only receive broadcasts if the broadcast has specified an
6215 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08006216 *
6217 * NOTE: dumpstate uses this flag numerically, so when its value is changed
6218 * the broadcast code there must also be changed to match.
6219 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006220 * @hide
6221 */
6222 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6223 /**
6224 * If set, the broadcast will never go to manifest receivers in background (cached
6225 * or not running) apps, regardless of whether that would be done by default. By
6226 * default they will receive broadcasts if the broadcast has specified an
6227 * explicit component or package name.
6228 * @hide
6229 */
6230 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07006231 /**
6232 * If set, this broadcast is being sent from the shell.
6233 * @hide
6234 */
6235 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006236
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006237 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08006238 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6239 * will not receive broadcasts.
6240 *
6241 * <em>This flag has no effect when used by an Instant App.</em>
6242 */
6243 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6244
6245 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006246 * @hide Flags that can't be changed with PendingIntent.
6247 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07006248 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6249 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6250 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08006251
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006252 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006253 // ---------------------------------------------------------------------
6254 // toUri() and parseUri() options.
6255
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006256 /** @hide */
6257 @IntDef(flag = true, prefix = { "URI_" }, value = {
6258 URI_ALLOW_UNSAFE,
6259 URI_ANDROID_APP_SCHEME,
6260 URI_INTENT_SCHEME,
6261 })
6262 @Retention(RetentionPolicy.SOURCE)
6263 public @interface UriFlags {}
6264
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006265 /**
6266 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6267 * always has the "intent:" scheme. This syntax can be used when you want
6268 * to later disambiguate between URIs that are intended to describe an
6269 * Intent vs. all others that should be treated as raw URIs. When used
6270 * with {@link #parseUri}, any other scheme will result in a generic
6271 * VIEW action for that raw URI.
6272 */
6273 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08006274
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006275 /**
6276 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6277 * always has the "android-app:" scheme. This is a variation of
6278 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6279 * http/https URI being delivered to a specific package name. The format
6280 * is:
6281 *
6282 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006283 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006284 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006285 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
6286 * you must also include a scheme; including a path also requires both a host and a scheme.
6287 * The final #Intent; fragment can be used without a scheme, host, or path.
6288 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006289 * used with intents that have a {@link #setSelector}, since the base intent
6290 * will always have an explicit package name.</p>
6291 *
6292 * <p>Some examples of how this scheme maps to Intent objects:</p>
6293 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6294 * <colgroup align="left" />
6295 * <colgroup align="left" />
6296 * <thead>
6297 * <tr><th>URI</th> <th>Intent</th></tr>
6298 * </thead>
6299 *
6300 * <tbody>
6301 * <tr><td><code>android-app://com.example.app</code></td>
6302 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6303 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6304 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6305 * </table></td>
6306 * </tr>
6307 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6308 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6309 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6310 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6311 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6312 * </table></td>
6313 * </tr>
6314 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6315 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6316 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6317 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6318 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6319 * </table></td>
6320 * </tr>
6321 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6322 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6323 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6324 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6325 * </table></td>
6326 * </tr>
6327 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6328 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6329 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6330 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6331 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6332 * </table></td>
6333 * </tr>
6334 * <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>
6335 * <td><table border="" style="margin:0" >
6336 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6337 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6338 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6339 * </table></td>
6340 * </tr>
6341 * </tbody>
6342 * </table>
6343 */
6344 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6345
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006346 /**
6347 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6348 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6349 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6350 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6351 * generated Intent can not cause unexpected data access to happen.
6352 *
6353 * <p>If you do not trust the source of the URI being parsed, you should still do further
6354 * processing to protect yourself from it. In particular, when using it to start an
6355 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6356 * that can handle it.</p>
6357 */
6358 public static final int URI_ALLOW_UNSAFE = 1<<2;
6359
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006360 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006361
6362 private String mAction;
6363 private Uri mData;
6364 private String mType;
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07006365 private String mIdentifier;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006366 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006367 private ComponentName mComponent;
6368 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006369 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006370 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006371 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006372 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006373 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006374 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006375 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07006376 /** Token to track instant app launches. Local only; do not copy cross-process. */
6377 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006378
6379 // ---------------------------------------------------------------------
6380
Makoto Onuki97f82f22017-05-31 16:20:21 -07006381 private static final int COPY_MODE_ALL = 0;
6382 private static final int COPY_MODE_FILTER = 1;
6383 private static final int COPY_MODE_HISTORY = 2;
6384
6385 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07006386 @IntDef(prefix = { "COPY_MODE_" }, value = {
6387 COPY_MODE_ALL,
6388 COPY_MODE_FILTER,
6389 COPY_MODE_HISTORY
6390 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07006391 @Retention(RetentionPolicy.SOURCE)
6392 public @interface CopyMode {}
6393
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006394 /**
6395 * Create an empty intent.
6396 */
6397 public Intent() {
6398 }
6399
6400 /**
6401 * Copy constructor.
6402 */
6403 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006404 this(o, COPY_MODE_ALL);
6405 }
6406
6407 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006408 this.mAction = o.mAction;
6409 this.mData = o.mData;
6410 this.mType = o.mType;
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07006411 this.mIdentifier = o.mIdentifier;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006412 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006413 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006414
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006415 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006416 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006417 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006418
6419 if (copyMode != COPY_MODE_FILTER) {
6420 this.mFlags = o.mFlags;
6421 this.mContentUserHint = o.mContentUserHint;
6422 this.mLaunchToken = o.mLaunchToken;
6423 if (o.mSourceBounds != null) {
6424 this.mSourceBounds = new Rect(o.mSourceBounds);
6425 }
6426 if (o.mSelector != null) {
6427 this.mSelector = new Intent(o.mSelector);
6428 }
6429
6430 if (copyMode != COPY_MODE_HISTORY) {
6431 if (o.mExtras != null) {
6432 this.mExtras = new Bundle(o.mExtras);
6433 }
6434 if (o.mClipData != null) {
6435 this.mClipData = new ClipData(o.mClipData);
6436 }
6437 } else {
6438 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6439 this.mExtras = Bundle.STRIPPED;
6440 }
6441
6442 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6443 // history.
6444 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006445 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006446 }
6447
6448 @Override
6449 public Object clone() {
6450 return new Intent(this);
6451 }
6452
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006453 /**
6454 * Make a clone of only the parts of the Intent that are relevant for
6455 * filter matching: the action, data, type, component, and categories.
6456 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006457 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006458 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006459 }
6460
6461 /**
6462 * Create an intent with a given action. All other fields (data, type,
6463 * class) are null. Note that the action <em>must</em> be in a
6464 * namespace because Intents are used globally in the system -- for
6465 * example the system VIEW action is android.intent.action.VIEW; an
6466 * application's custom action would be something like
6467 * com.google.app.myapp.CUSTOM_ACTION.
6468 *
6469 * @param action The Intent action, such as ACTION_VIEW.
6470 */
6471 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006472 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006473 }
6474
6475 /**
6476 * Create an intent with a given action and for a given data url. Note
6477 * that the action <em>must</em> be in a namespace because Intents are
6478 * used globally in the system -- for example the system VIEW action is
6479 * android.intent.action.VIEW; an application's custom action would be
6480 * something like com.google.app.myapp.CUSTOM_ACTION.
6481 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006482 * <p><em>Note: scheme and host name matching in the Android framework is
6483 * case-sensitive, unlike the formal RFC. As a result,
6484 * you should always ensure that you write your Uri with these elements
6485 * using lower case letters, and normalize any Uris you receive from
6486 * outside of Android to ensure the scheme and host is lower case.</em></p>
6487 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006488 * @param action The Intent action, such as ACTION_VIEW.
6489 * @param uri The Intent data URI.
6490 */
6491 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006492 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006493 mData = uri;
6494 }
6495
6496 /**
6497 * Create an intent for a specific component. All other fields (action, data,
6498 * type, class) are null, though they can be modified later with explicit
6499 * calls. This provides a convenient way to create an intent that is
6500 * intended to execute a hard-coded class name, rather than relying on the
6501 * system to find an appropriate class for you; see {@link #setComponent}
6502 * for more information on the repercussions of this.
6503 *
6504 * @param packageContext A Context of the application package implementing
6505 * this class.
6506 * @param cls The component class that is to be used for the intent.
6507 *
6508 * @see #setClass
6509 * @see #setComponent
6510 * @see #Intent(String, android.net.Uri , Context, Class)
6511 */
6512 public Intent(Context packageContext, Class<?> cls) {
6513 mComponent = new ComponentName(packageContext, cls);
6514 }
6515
6516 /**
6517 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006518 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006519 * construct the Intent and then calling {@link #setClass} to set its
6520 * class.
6521 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006522 * <p><em>Note: scheme and host name matching in the Android framework is
6523 * case-sensitive, unlike the formal RFC. As a result,
6524 * you should always ensure that you write your Uri with these elements
6525 * using lower case letters, and normalize any Uris you receive from
6526 * outside of Android to ensure the scheme and host is lower case.</em></p>
6527 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006528 * @param action The Intent action, such as ACTION_VIEW.
6529 * @param uri The Intent data URI.
6530 * @param packageContext A Context of the application package implementing
6531 * this class.
6532 * @param cls The component class that is to be used for the intent.
6533 *
6534 * @see #Intent(String, android.net.Uri)
6535 * @see #Intent(Context, Class)
6536 * @see #setClass
6537 * @see #setComponent
6538 */
6539 public Intent(String action, Uri uri,
6540 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006541 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006542 mData = uri;
6543 mComponent = new ComponentName(packageContext, cls);
6544 }
6545
6546 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006547 * Create an intent to launch the main (root) activity of a task. This
6548 * is the Intent that is started when the application's is launched from
6549 * Home. For anything else that wants to launch an application in the
6550 * same way, it is important that they use an Intent structured the same
6551 * way, and can use this function to ensure this is the case.
6552 *
6553 * <p>The returned Intent has the given Activity component as its explicit
6554 * component, {@link #ACTION_MAIN} as its action, and includes the
6555 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6556 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6557 * to do that through {@link #addFlags(int)} on the returned Intent.
6558 *
6559 * @param mainActivity The main activity component that this Intent will
6560 * launch.
6561 * @return Returns a newly created Intent that can be used to launch the
6562 * activity as a main application entry.
6563 *
6564 * @see #setClass
6565 * @see #setComponent
6566 */
6567 public static Intent makeMainActivity(ComponentName mainActivity) {
6568 Intent intent = new Intent(ACTION_MAIN);
6569 intent.setComponent(mainActivity);
6570 intent.addCategory(CATEGORY_LAUNCHER);
6571 return intent;
6572 }
6573
6574 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006575 * Make an Intent for the main activity of an application, without
6576 * specifying a specific activity to run but giving a selector to find
6577 * the activity. This results in a final Intent that is structured
6578 * the same as when the application is launched from
6579 * Home. For anything else that wants to launch an application in the
6580 * same way, it is important that they use an Intent structured the same
6581 * way, and can use this function to ensure this is the case.
6582 *
6583 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6584 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6585 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6586 * to do that through {@link #addFlags(int)} on the returned Intent.
6587 *
6588 * @param selectorAction The action name of the Intent's selector.
6589 * @param selectorCategory The name of a category to add to the Intent's
6590 * selector.
6591 * @return Returns a newly created Intent that can be used to launch the
6592 * activity as a main application entry.
6593 *
6594 * @see #setSelector(Intent)
6595 */
6596 public static Intent makeMainSelectorActivity(String selectorAction,
6597 String selectorCategory) {
6598 Intent intent = new Intent(ACTION_MAIN);
6599 intent.addCategory(CATEGORY_LAUNCHER);
6600 Intent selector = new Intent();
6601 selector.setAction(selectorAction);
6602 selector.addCategory(selectorCategory);
6603 intent.setSelector(selector);
6604 return intent;
6605 }
6606
6607 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006608 * Make an Intent that can be used to re-launch an application's task
6609 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6610 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6611 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6612 *
6613 * @param mainActivity The activity component that is the root of the
6614 * task; this is the activity that has been published in the application's
6615 * manifest as the main launcher icon.
6616 *
6617 * @return Returns a newly created Intent that can be used to relaunch the
6618 * activity's task in its root state.
6619 */
6620 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6621 Intent intent = makeMainActivity(mainActivity);
6622 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6623 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6624 return intent;
6625 }
6626
6627 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006628 * Call {@link #parseUri} with 0 flags.
6629 * @deprecated Use {@link #parseUri} instead.
6630 */
6631 @Deprecated
6632 public static Intent getIntent(String uri) throws URISyntaxException {
6633 return parseUri(uri, 0);
6634 }
Tom Taylord4a47292009-12-21 13:59:18 -08006635
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006636 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006637 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006638 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006639 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006640 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006641 *
6642 * <p>The URI given here must not be relative -- that is, it must include
6643 * the scheme and full path.
6644 *
6645 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006646 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006647 *
6648 * @return Intent The newly created Intent object.
6649 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006650 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6651 * it bad (as parsed by the Uri class) or the Intent data within the
6652 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006653 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006654 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006655 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006656 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006657 int i = 0;
6658 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006659 final boolean androidApp = uri.startsWith("android-app:");
6660
6661 // Validate intent scheme if requested.
6662 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6663 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006664 Intent intent = new Intent(ACTION_VIEW);
6665 try {
6666 intent.setData(Uri.parse(uri));
6667 } catch (IllegalArgumentException e) {
6668 throw new URISyntaxException(uri, e.getMessage());
6669 }
6670 return intent;
6671 }
6672 }
Tom Taylord4a47292009-12-21 13:59:18 -08006673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006674 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006675 // simple case
6676 if (i == -1) {
6677 if (!androidApp) {
6678 return new Intent(ACTION_VIEW, Uri.parse(uri));
6679 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006680
6681 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006682 } else if (!uri.startsWith("#Intent;", i)) {
6683 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006684 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006685 } else {
6686 i = -1;
6687 }
6688 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006689
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006690 // new format
6691 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006692 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006693 boolean explicitAction = false;
6694 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006695
6696 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006697 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006698 String data;
6699 if (i >= 0) {
6700 data = uri.substring(0, i);
6701 i += 8; // length of "#Intent;"
6702 } else {
6703 data = uri;
6704 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006705
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006706 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006707 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006708 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006709 if (eq < 0) eq = i-1;
6710 int semi = uri.indexOf(';', i);
6711 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006712
6713 // action
6714 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006715 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006716 if (!inSelector) {
6717 explicitAction = true;
6718 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006719 }
6720
6721 // categories
6722 else if (uri.startsWith("category=", i)) {
6723 intent.addCategory(value);
6724 }
6725
6726 // type
6727 else if (uri.startsWith("type=", i)) {
6728 intent.mType = value;
6729 }
6730
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07006731 // identifier
6732 else if (uri.startsWith("identifier=", i)) {
6733 intent.mIdentifier = value;
6734 }
6735
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006736 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006737 else if (uri.startsWith("launchFlags=", i)) {
6738 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006739 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6740 intent.mFlags &= ~IMMUTABLE_FLAGS;
6741 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006742 }
6743
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006744 // package
6745 else if (uri.startsWith("package=", i)) {
6746 intent.mPackage = value;
6747 }
6748
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006749 // component
6750 else if (uri.startsWith("component=", i)) {
6751 intent.mComponent = ComponentName.unflattenFromString(value);
6752 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006753
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006754 // scheme
6755 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006756 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006757 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006758 } else {
6759 scheme = value;
6760 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006761 }
6762
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006763 // source bounds
6764 else if (uri.startsWith("sourceBounds=", i)) {
6765 intent.mSourceBounds = Rect.unflattenFromString(value);
6766 }
6767
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006768 // selector
6769 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6770 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006771 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006772 }
6773
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006774 // extra
6775 else {
6776 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006777 // create Bundle if it doesn't already exist
6778 if (intent.mExtras == null) intent.mExtras = new Bundle();
6779 Bundle b = intent.mExtras;
6780 // add EXTRA
6781 if (uri.startsWith("S.", i)) b.putString(key, value);
6782 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6783 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6784 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6785 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6786 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6787 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6788 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6789 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6790 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6791 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 // move to the next item
6794 i = semi + 1;
6795 }
6796
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006797 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006798 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006799 if (baseIntent.mPackage == null) {
6800 baseIntent.setSelector(intent);
6801 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006802 intent = baseIntent;
6803 }
6804
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006805 if (data != null) {
6806 if (data.startsWith("intent:")) {
6807 data = data.substring(7);
6808 if (scheme != null) {
6809 data = scheme + ':' + data;
6810 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006811 } else if (data.startsWith("android-app:")) {
6812 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6813 // Correctly formed android-app, first part is package name.
6814 int end = data.indexOf('/', 14);
6815 if (end < 0) {
6816 // All we have is a package name.
6817 intent.mPackage = data.substring(14);
6818 if (!explicitAction) {
6819 intent.setAction(ACTION_MAIN);
6820 }
6821 data = "";
6822 } else {
6823 // Target the Intent at the given package name always.
6824 String authority = null;
6825 intent.mPackage = data.substring(14, end);
6826 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006827 if ((end+1) < data.length()) {
6828 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6829 // Found a scheme, remember it.
6830 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006831 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006832 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6833 // Found a authority, remember it.
6834 authority = data.substring(end+1, newEnd);
6835 end = newEnd;
6836 }
6837 } else {
6838 // All we have is a scheme.
6839 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006840 }
6841 }
6842 if (scheme == null) {
6843 // If there was no scheme, then this just targets the package.
6844 if (!explicitAction) {
6845 intent.setAction(ACTION_MAIN);
6846 }
6847 data = "";
6848 } else if (authority == null) {
6849 data = scheme + ":";
6850 } else {
6851 data = scheme + "://" + authority + data.substring(end);
6852 }
6853 }
6854 } else {
6855 data = "";
6856 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006857 }
Tom Taylord4a47292009-12-21 13:59:18 -08006858
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006859 if (data.length() > 0) {
6860 try {
6861 intent.mData = Uri.parse(data);
6862 } catch (IllegalArgumentException e) {
6863 throw new URISyntaxException(uri, e.getMessage());
6864 }
6865 }
6866 }
Tom Taylord4a47292009-12-21 13:59:18 -08006867
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006868 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006869
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006870 } catch (IndexOutOfBoundsException e) {
6871 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6872 }
6873 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006874
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006875 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006876 return getIntentOld(uri, 0);
6877 }
6878
6879 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006880 Intent intent;
6881
6882 int i = uri.lastIndexOf('#');
6883 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006884 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006885 final int intentFragmentStart = i;
6886 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006887
6888 i++;
6889
6890 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006891 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006892 i += 7;
6893 int j = uri.indexOf(')', i);
6894 action = uri.substring(i, j);
6895 i = j + 1;
6896 }
6897
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006898 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006899
6900 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006901 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006902 i += 11;
6903 int j = uri.indexOf(')', i);
6904 while (i < j) {
6905 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006906 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006907 if (i < sep) {
6908 intent.addCategory(uri.substring(i, sep));
6909 }
6910 i = sep + 1;
6911 }
6912 i = j + 1;
6913 }
6914
6915 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006916 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006917 i += 5;
6918 int j = uri.indexOf(')', i);
6919 intent.mType = uri.substring(i, j);
6920 i = j + 1;
6921 }
6922
6923 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006924 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006925 i += 12;
6926 int j = uri.indexOf(')', i);
6927 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006928 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6929 intent.mFlags &= ~IMMUTABLE_FLAGS;
6930 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006931 i = j + 1;
6932 }
6933
6934 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006935 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006936 i += 10;
6937 int j = uri.indexOf(')', i);
6938 int sep = uri.indexOf('!', i);
6939 if (sep >= 0 && sep < j) {
6940 String pkg = uri.substring(i, sep);
6941 String cls = uri.substring(sep + 1, j);
6942 intent.mComponent = new ComponentName(pkg, cls);
6943 }
6944 i = j + 1;
6945 }
6946
6947 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006948 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006949 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006950
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006951 final int closeParen = uri.indexOf(')', i);
6952 if (closeParen == -1) throw new URISyntaxException(uri,
6953 "EXTRA missing trailing ')'", i);
6954
6955 while (i < closeParen) {
6956 // fetch the key value
6957 int j = uri.indexOf('=', i);
6958 if (j <= i + 1 || i >= closeParen) {
6959 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6960 }
6961 char type = uri.charAt(i);
6962 i++;
6963 String key = uri.substring(i, j);
6964 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006965
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006966 // get type-value
6967 j = uri.indexOf('!', i);
6968 if (j == -1 || j >= closeParen) j = closeParen;
6969 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6970 String value = uri.substring(i, j);
6971 i = j;
6972
6973 // create Bundle if it doesn't already exist
6974 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006975
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006976 // add item to bundle
6977 try {
6978 switch (type) {
6979 case 'S':
6980 intent.mExtras.putString(key, Uri.decode(value));
6981 break;
6982 case 'B':
6983 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6984 break;
6985 case 'b':
6986 intent.mExtras.putByte(key, Byte.parseByte(value));
6987 break;
6988 case 'c':
6989 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6990 break;
6991 case 'd':
6992 intent.mExtras.putDouble(key, Double.parseDouble(value));
6993 break;
6994 case 'f':
6995 intent.mExtras.putFloat(key, Float.parseFloat(value));
6996 break;
6997 case 'i':
6998 intent.mExtras.putInt(key, Integer.parseInt(value));
6999 break;
7000 case 'l':
7001 intent.mExtras.putLong(key, Long.parseLong(value));
7002 break;
7003 case 's':
7004 intent.mExtras.putShort(key, Short.parseShort(value));
7005 break;
7006 default:
7007 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7008 }
7009 } catch (NumberFormatException e) {
7010 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7011 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007012
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007013 char ch = uri.charAt(i);
7014 if (ch == ')') break;
7015 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7016 i++;
7017 }
7018 }
7019
Dianne Hackborn6cca1592009-09-20 12:40:03 -07007020 if (isIntentFragment) {
7021 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7022 } else {
7023 intent.mData = Uri.parse(uri);
7024 }
Tom Taylord4a47292009-12-21 13:59:18 -08007025
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007026 if (intent.mAction == null) {
7027 // By default, if no action is specified, then use VIEW.
7028 intent.mAction = ACTION_VIEW;
7029 }
7030
7031 } else {
7032 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7033 }
7034
7035 return intent;
7036 }
7037
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007038 /** @hide */
7039 public interface CommandOptionHandler {
7040 boolean handleOption(String opt, ShellCommand cmd);
7041 }
7042
7043 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007044 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007045 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7046 throws URISyntaxException {
7047 Intent intent = new Intent();
7048 Intent baseIntent = intent;
7049 boolean hasIntentInfo = false;
7050
7051 Uri data = null;
7052 String type = null;
7053
7054 String opt;
7055 while ((opt=cmd.getNextOption()) != null) {
7056 switch (opt) {
7057 case "-a":
7058 intent.setAction(cmd.getNextArgRequired());
7059 if (intent == baseIntent) {
7060 hasIntentInfo = true;
7061 }
7062 break;
7063 case "-d":
7064 data = Uri.parse(cmd.getNextArgRequired());
7065 if (intent == baseIntent) {
7066 hasIntentInfo = true;
7067 }
7068 break;
7069 case "-t":
7070 type = cmd.getNextArgRequired();
7071 if (intent == baseIntent) {
7072 hasIntentInfo = true;
7073 }
7074 break;
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07007075 case "-i":
7076 intent.setIdentifier(cmd.getNextArgRequired());
7077 if (intent == baseIntent) {
7078 hasIntentInfo = true;
7079 }
7080 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007081 case "-c":
7082 intent.addCategory(cmd.getNextArgRequired());
7083 if (intent == baseIntent) {
7084 hasIntentInfo = true;
7085 }
7086 break;
7087 case "-e":
7088 case "--es": {
7089 String key = cmd.getNextArgRequired();
7090 String value = cmd.getNextArgRequired();
7091 intent.putExtra(key, value);
7092 }
7093 break;
7094 case "--esn": {
7095 String key = cmd.getNextArgRequired();
7096 intent.putExtra(key, (String) null);
7097 }
7098 break;
7099 case "--ei": {
7100 String key = cmd.getNextArgRequired();
7101 String value = cmd.getNextArgRequired();
7102 intent.putExtra(key, Integer.decode(value));
7103 }
7104 break;
7105 case "--eu": {
7106 String key = cmd.getNextArgRequired();
7107 String value = cmd.getNextArgRequired();
7108 intent.putExtra(key, Uri.parse(value));
7109 }
7110 break;
7111 case "--ecn": {
7112 String key = cmd.getNextArgRequired();
7113 String value = cmd.getNextArgRequired();
7114 ComponentName cn = ComponentName.unflattenFromString(value);
7115 if (cn == null)
7116 throw new IllegalArgumentException("Bad component name: " + value);
7117 intent.putExtra(key, cn);
7118 }
7119 break;
7120 case "--eia": {
7121 String key = cmd.getNextArgRequired();
7122 String value = cmd.getNextArgRequired();
7123 String[] strings = value.split(",");
7124 int[] list = new int[strings.length];
7125 for (int i = 0; i < strings.length; i++) {
7126 list[i] = Integer.decode(strings[i]);
7127 }
7128 intent.putExtra(key, list);
7129 }
7130 break;
7131 case "--eial": {
7132 String key = cmd.getNextArgRequired();
7133 String value = cmd.getNextArgRequired();
7134 String[] strings = value.split(",");
7135 ArrayList<Integer> list = new ArrayList<>(strings.length);
7136 for (int i = 0; i < strings.length; i++) {
7137 list.add(Integer.decode(strings[i]));
7138 }
7139 intent.putExtra(key, list);
7140 }
7141 break;
7142 case "--el": {
7143 String key = cmd.getNextArgRequired();
7144 String value = cmd.getNextArgRequired();
7145 intent.putExtra(key, Long.valueOf(value));
7146 }
7147 break;
7148 case "--ela": {
7149 String key = cmd.getNextArgRequired();
7150 String value = cmd.getNextArgRequired();
7151 String[] strings = value.split(",");
7152 long[] list = new long[strings.length];
7153 for (int i = 0; i < strings.length; i++) {
7154 list[i] = Long.valueOf(strings[i]);
7155 }
7156 intent.putExtra(key, list);
7157 hasIntentInfo = true;
7158 }
7159 break;
7160 case "--elal": {
7161 String key = cmd.getNextArgRequired();
7162 String value = cmd.getNextArgRequired();
7163 String[] strings = value.split(",");
7164 ArrayList<Long> list = new ArrayList<>(strings.length);
7165 for (int i = 0; i < strings.length; i++) {
7166 list.add(Long.valueOf(strings[i]));
7167 }
7168 intent.putExtra(key, list);
7169 hasIntentInfo = true;
7170 }
7171 break;
7172 case "--ef": {
7173 String key = cmd.getNextArgRequired();
7174 String value = cmd.getNextArgRequired();
7175 intent.putExtra(key, Float.valueOf(value));
7176 hasIntentInfo = true;
7177 }
7178 break;
7179 case "--efa": {
7180 String key = cmd.getNextArgRequired();
7181 String value = cmd.getNextArgRequired();
7182 String[] strings = value.split(",");
7183 float[] list = new float[strings.length];
7184 for (int i = 0; i < strings.length; i++) {
7185 list[i] = Float.valueOf(strings[i]);
7186 }
7187 intent.putExtra(key, list);
7188 hasIntentInfo = true;
7189 }
7190 break;
7191 case "--efal": {
7192 String key = cmd.getNextArgRequired();
7193 String value = cmd.getNextArgRequired();
7194 String[] strings = value.split(",");
7195 ArrayList<Float> list = new ArrayList<>(strings.length);
7196 for (int i = 0; i < strings.length; i++) {
7197 list.add(Float.valueOf(strings[i]));
7198 }
7199 intent.putExtra(key, list);
7200 hasIntentInfo = true;
7201 }
7202 break;
7203 case "--esa": {
7204 String key = cmd.getNextArgRequired();
7205 String value = cmd.getNextArgRequired();
7206 // Split on commas unless they are preceeded by an escape.
7207 // The escape character must be escaped for the string and
7208 // again for the regex, thus four escape characters become one.
7209 String[] strings = value.split("(?<!\\\\),");
7210 intent.putExtra(key, strings);
7211 hasIntentInfo = true;
7212 }
7213 break;
7214 case "--esal": {
7215 String key = cmd.getNextArgRequired();
7216 String value = cmd.getNextArgRequired();
7217 // Split on commas unless they are preceeded by an escape.
7218 // The escape character must be escaped for the string and
7219 // again for the regex, thus four escape characters become one.
7220 String[] strings = value.split("(?<!\\\\),");
7221 ArrayList<String> list = new ArrayList<>(strings.length);
7222 for (int i = 0; i < strings.length; i++) {
7223 list.add(strings[i]);
7224 }
7225 intent.putExtra(key, list);
7226 hasIntentInfo = true;
7227 }
7228 break;
7229 case "--ez": {
7230 String key = cmd.getNextArgRequired();
7231 String value = cmd.getNextArgRequired().toLowerCase();
7232 // Boolean.valueOf() results in false for anything that is not "true", which is
7233 // error-prone in shell commands
7234 boolean arg;
7235 if ("true".equals(value) || "t".equals(value)) {
7236 arg = true;
7237 } else if ("false".equals(value) || "f".equals(value)) {
7238 arg = false;
7239 } else {
7240 try {
7241 arg = Integer.decode(value) != 0;
7242 } catch (NumberFormatException ex) {
7243 throw new IllegalArgumentException("Invalid boolean value: " + value);
7244 }
7245 }
7246
7247 intent.putExtra(key, arg);
7248 }
7249 break;
7250 case "-n": {
7251 String str = cmd.getNextArgRequired();
7252 ComponentName cn = ComponentName.unflattenFromString(str);
7253 if (cn == null)
7254 throw new IllegalArgumentException("Bad component name: " + str);
7255 intent.setComponent(cn);
7256 if (intent == baseIntent) {
7257 hasIntentInfo = true;
7258 }
7259 }
7260 break;
7261 case "-p": {
7262 String str = cmd.getNextArgRequired();
7263 intent.setPackage(str);
7264 if (intent == baseIntent) {
7265 hasIntentInfo = true;
7266 }
7267 }
7268 break;
7269 case "-f":
7270 String str = cmd.getNextArgRequired();
7271 intent.setFlags(Integer.decode(str).intValue());
7272 break;
7273 case "--grant-read-uri-permission":
7274 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7275 break;
7276 case "--grant-write-uri-permission":
7277 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7278 break;
7279 case "--grant-persistable-uri-permission":
7280 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7281 break;
7282 case "--grant-prefix-uri-permission":
7283 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7284 break;
7285 case "--exclude-stopped-packages":
7286 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7287 break;
7288 case "--include-stopped-packages":
7289 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7290 break;
7291 case "--debug-log-resolution":
7292 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7293 break;
7294 case "--activity-brought-to-front":
7295 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7296 break;
7297 case "--activity-clear-top":
7298 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7299 break;
7300 case "--activity-clear-when-task-reset":
7301 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7302 break;
7303 case "--activity-exclude-from-recents":
7304 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7305 break;
7306 case "--activity-launched-from-history":
7307 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7308 break;
7309 case "--activity-multiple-task":
7310 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7311 break;
7312 case "--activity-no-animation":
7313 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7314 break;
7315 case "--activity-no-history":
7316 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7317 break;
7318 case "--activity-no-user-action":
7319 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7320 break;
7321 case "--activity-previous-is-top":
7322 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7323 break;
7324 case "--activity-reorder-to-front":
7325 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7326 break;
7327 case "--activity-reset-task-if-needed":
7328 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7329 break;
7330 case "--activity-single-top":
7331 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7332 break;
7333 case "--activity-clear-task":
7334 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7335 break;
7336 case "--activity-task-on-home":
7337 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7338 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07007339 case "--activity-match-external":
7340 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7341 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007342 case "--receiver-registered-only":
7343 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7344 break;
7345 case "--receiver-replace-pending":
7346 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7347 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08007348 case "--receiver-foreground":
7349 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7350 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08007351 case "--receiver-no-abort":
7352 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7353 break;
7354 case "--receiver-include-background":
7355 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7356 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007357 case "--selector":
7358 intent.setDataAndType(data, type);
7359 intent = new Intent();
7360 break;
7361 default:
7362 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7363 // Okay, caller handled this option.
7364 } else {
7365 throw new IllegalArgumentException("Unknown option: " + opt);
7366 }
7367 break;
7368 }
7369 }
7370 intent.setDataAndType(data, type);
7371
7372 final boolean hasSelector = intent != baseIntent;
7373 if (hasSelector) {
7374 // A selector was specified; fix up.
7375 baseIntent.setSelector(intent);
7376 intent = baseIntent;
7377 }
7378
7379 String arg = cmd.getNextArg();
7380 baseIntent = null;
7381 if (arg == null) {
7382 if (hasSelector) {
7383 // If a selector has been specified, and no arguments
7384 // have been supplied for the main Intent, then we can
7385 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7386 // need to have a component name specified yet, the
7387 // selector will take care of that.
7388 baseIntent = new Intent(Intent.ACTION_MAIN);
7389 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7390 }
7391 } else if (arg.indexOf(':') >= 0) {
7392 // The argument is a URI. Fully parse it, and use that result
7393 // to fill in any data not specified so far.
7394 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7395 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7396 } else if (arg.indexOf('/') >= 0) {
7397 // The argument is a component name. Build an Intent to launch
7398 // it.
7399 baseIntent = new Intent(Intent.ACTION_MAIN);
7400 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7401 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7402 } else {
7403 // Assume the argument is a package name.
7404 baseIntent = new Intent(Intent.ACTION_MAIN);
7405 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7406 baseIntent.setPackage(arg);
7407 }
7408 if (baseIntent != null) {
7409 Bundle extras = intent.getExtras();
7410 intent.replaceExtras((Bundle)null);
7411 Bundle uriExtras = baseIntent.getExtras();
7412 baseIntent.replaceExtras((Bundle)null);
7413 if (intent.getAction() != null && baseIntent.getCategories() != null) {
7414 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7415 for (String c : cats) {
7416 baseIntent.removeCategory(c);
7417 }
7418 }
7419 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7420 if (extras == null) {
7421 extras = uriExtras;
7422 } else if (uriExtras != null) {
7423 uriExtras.putAll(extras);
7424 extras = uriExtras;
7425 }
7426 intent.replaceExtras(extras);
7427 hasIntentInfo = true;
7428 }
7429
7430 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7431 return intent;
7432 }
7433
7434 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007435 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007436 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7437 final String[] lines = new String[] {
7438 "<INTENT> specifications include these flags and arguments:",
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07007439 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007440 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007441 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007442 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7443 " [--esn <EXTRA_KEY> ...]",
7444 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7445 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7446 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7447 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7448 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7449 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7450 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7451 " (mutiple extras passed as Integer[])",
7452 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7453 " (mutiple extras passed as List<Integer>)",
7454 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7455 " (mutiple extras passed as Long[])",
7456 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7457 " (mutiple extras passed as List<Long>)",
7458 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7459 " (mutiple extras passed as Float[])",
7460 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7461 " (mutiple extras passed as List<Float>)",
7462 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7463 " (mutiple extras passed as String[]; to embed a comma into a string,",
7464 " escape it using \"\\,\")",
7465 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7466 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7467 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007468 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007469 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7470 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7471 " [--debug-log-resolution] [--exclude-stopped-packages]",
7472 " [--include-stopped-packages]",
7473 " [--activity-brought-to-front] [--activity-clear-top]",
7474 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7475 " [--activity-launched-from-history] [--activity-multiple-task]",
7476 " [--activity-no-animation] [--activity-no-history]",
7477 " [--activity-no-user-action] [--activity-previous-is-top]",
7478 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7479 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007480 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007481 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007482 " [--receiver-foreground] [--receiver-no-abort]",
7483 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007484 " [--selector]",
7485 " [<URI> | <PACKAGE> | <COMPONENT>]"
7486 };
7487 for (String line : lines) {
7488 pw.print(prefix);
7489 pw.println(line);
7490 }
7491 }
7492
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007493 /**
7494 * Retrieve the general action to be performed, such as
7495 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7496 * the information in the intent should be interpreted -- most importantly,
7497 * what to do with the data returned by {@link #getData}.
7498 *
7499 * @return The action of this intent or null if none is specified.
7500 *
7501 * @see #setAction
7502 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007503 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007504 return mAction;
7505 }
7506
7507 /**
7508 * Retrieve data this intent is operating on. This URI specifies the name
7509 * of the data; often it uses the content: scheme, specifying data in a
7510 * content provider. Other schemes may be handled by specific activities,
7511 * such as http: by the web browser.
7512 *
7513 * @return The URI of the data this intent is targeting or null.
7514 *
7515 * @see #getScheme
7516 * @see #setData
7517 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007518 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007519 return mData;
7520 }
7521
7522 /**
7523 * The same as {@link #getData()}, but returns the URI as an encoded
7524 * String.
7525 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007526 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007527 return mData != null ? mData.toString() : null;
7528 }
7529
7530 /**
7531 * Return the scheme portion of the intent's data. If the data is null or
7532 * does not include a scheme, null is returned. Otherwise, the scheme
7533 * prefix without the final ':' is returned, i.e. "http".
7534 *
7535 * <p>This is the same as calling getData().getScheme() (and checking for
7536 * null data).
7537 *
7538 * @return The scheme of this intent.
7539 *
7540 * @see #getData
7541 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007542 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007543 return mData != null ? mData.getScheme() : null;
7544 }
7545
7546 /**
7547 * Retrieve any explicit MIME type included in the intent. This is usually
7548 * null, as the type is determined by the intent data.
7549 *
7550 * @return If a type was manually set, it is returned; else null is
7551 * returned.
7552 *
7553 * @see #resolveType(ContentResolver)
7554 * @see #setType
7555 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007556 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007557 return mType;
7558 }
7559
7560 /**
7561 * Return the MIME data type of this intent. If the type field is
7562 * explicitly set, that is simply returned. Otherwise, if the data is set,
7563 * the type of that data is returned. If neither fields are set, a null is
7564 * returned.
7565 *
7566 * @return The MIME type of this intent.
7567 *
7568 * @see #getType
7569 * @see #resolveType(ContentResolver)
7570 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007571 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007572 return resolveType(context.getContentResolver());
7573 }
7574
7575 /**
7576 * Return the MIME data type of this intent. If the type field is
7577 * explicitly set, that is simply returned. Otherwise, if the data is set,
7578 * the type of that data is returned. If neither fields are set, a null is
7579 * returned.
7580 *
7581 * @param resolver A ContentResolver that can be used to determine the MIME
7582 * type of the intent's data.
7583 *
7584 * @return The MIME type of this intent.
7585 *
7586 * @see #getType
7587 * @see #resolveType(Context)
7588 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007589 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007590 if (mType != null) {
7591 return mType;
7592 }
7593 if (mData != null) {
7594 if ("content".equals(mData.getScheme())) {
7595 return resolver.getType(mData);
7596 }
7597 }
7598 return null;
7599 }
7600
7601 /**
7602 * Return the MIME data type of this intent, only if it will be needed for
7603 * intent resolution. This is not generally useful for application code;
7604 * it is used by the frameworks for communicating with back-end system
7605 * services.
7606 *
7607 * @param resolver A ContentResolver that can be used to determine the MIME
7608 * type of the intent's data.
7609 *
7610 * @return The MIME type of this intent, or null if it is unknown or not
7611 * needed.
7612 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007613 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007614 if (mComponent != null) {
7615 return mType;
7616 }
7617 return resolveType(resolver);
7618 }
7619
7620 /**
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07007621 * Retrieve the identifier for this Intent. If non-null, this is an arbitrary identity
7622 * of the Intent to distinguish it from other Intents.
7623 *
7624 * @return The identifier of this intent or null if none is specified.
7625 *
7626 * @see #setIdentifier
7627 */
7628 public @Nullable String getIdentifier() {
7629 return mIdentifier;
7630 }
7631
7632 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007633 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007634 *
7635 * @param category The category to check.
7636 *
7637 * @return boolean True if the intent contains the category, else false.
7638 *
7639 * @see #getCategories
7640 * @see #addCategory
7641 */
7642 public boolean hasCategory(String category) {
7643 return mCategories != null && mCategories.contains(category);
7644 }
7645
7646 /**
7647 * Return the set of all categories in the intent. If there are no categories,
7648 * returns NULL.
7649 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007650 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007651 *
7652 * @see #hasCategory
7653 * @see #addCategory
7654 */
7655 public Set<String> getCategories() {
7656 return mCategories;
7657 }
7658
7659 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007660 * Return the specific selector associated with this Intent. If there is
7661 * none, returns null. See {@link #setSelector} for more information.
7662 *
7663 * @see #setSelector
7664 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007665 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007666 return mSelector;
7667 }
7668
7669 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007670 * Return the {@link ClipData} associated with this Intent. If there is
7671 * none, returns null. See {@link #setClipData} for more information.
7672 *
John Spurlock125d1332013-11-25 11:58:37 -05007673 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007674 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007675 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007676 return mClipData;
7677 }
7678
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007679 /** @hide */
7680 public int getContentUserHint() {
7681 return mContentUserHint;
7682 }
7683
Todd Kennedyb3b431302017-03-20 16:05:48 -07007684 /** @hide */
7685 public String getLaunchToken() {
7686 return mLaunchToken;
7687 }
7688
7689 /** @hide */
7690 public void setLaunchToken(String launchToken) {
7691 mLaunchToken = launchToken;
7692 }
7693
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007694 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007695 * Sets the ClassLoader that will be used when unmarshalling
7696 * any Parcelable values from the extras of this Intent.
7697 *
7698 * @param loader a ClassLoader, or null to use the default loader
7699 * at the time of unmarshalling.
7700 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007701 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007702 if (mExtras != null) {
7703 mExtras.setClassLoader(loader);
7704 }
7705 }
7706
7707 /**
7708 * Returns true if an extra value is associated with the given name.
7709 * @param name the extra's name
7710 * @return true if the given extra is present.
7711 */
7712 public boolean hasExtra(String name) {
7713 return mExtras != null && mExtras.containsKey(name);
7714 }
7715
7716 /**
7717 * Returns true if the Intent's extras contain a parcelled file descriptor.
7718 * @return true if the Intent contains a parcelled file descriptor.
7719 */
7720 public boolean hasFileDescriptors() {
7721 return mExtras != null && mExtras.hasFileDescriptors();
7722 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007723
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007724 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007725 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007726 public void setAllowFds(boolean allowFds) {
7727 if (mExtras != null) {
7728 mExtras.setAllowFds(allowFds);
7729 }
7730 }
7731
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007732 /** {@hide} */
7733 public void setDefusable(boolean defusable) {
7734 if (mExtras != null) {
7735 mExtras.setDefusable(defusable);
7736 }
7737 }
7738
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007739 /**
7740 * Retrieve extended data from the intent.
7741 *
7742 * @param name The name of the desired item.
7743 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007744 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007745 * or null if none was found.
7746 *
7747 * @deprecated
7748 * @hide
7749 */
7750 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007751 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007752 public Object getExtra(String name) {
7753 return getExtra(name, null);
7754 }
7755
7756 /**
7757 * Retrieve extended data from the intent.
7758 *
7759 * @param name The name of the desired item.
7760 * @param defaultValue the value to be returned if no value of the desired
7761 * type is stored with the given name.
7762 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007763 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007764 * or the default value if none was found.
7765 *
7766 * @see #putExtra(String, boolean)
7767 */
7768 public boolean getBooleanExtra(String name, boolean defaultValue) {
7769 return mExtras == null ? defaultValue :
7770 mExtras.getBoolean(name, defaultValue);
7771 }
7772
7773 /**
7774 * Retrieve extended data from the intent.
7775 *
7776 * @param name The name of the desired item.
7777 * @param defaultValue the value to be returned if no value of the desired
7778 * type is stored with the given name.
7779 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007780 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 * or the default value if none was found.
7782 *
7783 * @see #putExtra(String, byte)
7784 */
7785 public byte getByteExtra(String name, byte defaultValue) {
7786 return mExtras == null ? defaultValue :
7787 mExtras.getByte(name, defaultValue);
7788 }
7789
7790 /**
7791 * Retrieve extended data from the intent.
7792 *
7793 * @param name The name of the desired item.
7794 * @param defaultValue the value to be returned if no value of the desired
7795 * type is stored with the given name.
7796 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007797 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007798 * or the default value if none was found.
7799 *
7800 * @see #putExtra(String, short)
7801 */
7802 public short getShortExtra(String name, short defaultValue) {
7803 return mExtras == null ? defaultValue :
7804 mExtras.getShort(name, defaultValue);
7805 }
7806
7807 /**
7808 * Retrieve extended data from the intent.
7809 *
7810 * @param name The name of the desired item.
7811 * @param defaultValue the value to be returned if no value of the desired
7812 * type is stored with the given name.
7813 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007814 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007815 * or the default value if none was found.
7816 *
7817 * @see #putExtra(String, char)
7818 */
7819 public char getCharExtra(String name, char defaultValue) {
7820 return mExtras == null ? defaultValue :
7821 mExtras.getChar(name, defaultValue);
7822 }
7823
7824 /**
7825 * Retrieve extended data from the intent.
7826 *
7827 * @param name The name of the desired item.
7828 * @param defaultValue the value to be returned if no value of the desired
7829 * type is stored with the given name.
7830 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007831 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007832 * or the default value if none was found.
7833 *
7834 * @see #putExtra(String, int)
7835 */
7836 public int getIntExtra(String name, int defaultValue) {
7837 return mExtras == null ? defaultValue :
7838 mExtras.getInt(name, defaultValue);
7839 }
7840
7841 /**
7842 * Retrieve extended data from the intent.
7843 *
7844 * @param name The name of the desired item.
7845 * @param defaultValue the value to be returned if no value of the desired
7846 * type is stored with the given name.
7847 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007848 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007849 * or the default value if none was found.
7850 *
7851 * @see #putExtra(String, long)
7852 */
7853 public long getLongExtra(String name, long defaultValue) {
7854 return mExtras == null ? defaultValue :
7855 mExtras.getLong(name, defaultValue);
7856 }
7857
7858 /**
7859 * Retrieve extended data from the intent.
7860 *
7861 * @param name The name of the desired item.
7862 * @param defaultValue the value to be returned if no value of the desired
7863 * type is stored with the given name.
7864 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007865 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007866 * or the default value if no such item is present
7867 *
7868 * @see #putExtra(String, float)
7869 */
7870 public float getFloatExtra(String name, float defaultValue) {
7871 return mExtras == null ? defaultValue :
7872 mExtras.getFloat(name, defaultValue);
7873 }
7874
7875 /**
7876 * Retrieve extended data from the intent.
7877 *
7878 * @param name The name of the desired item.
7879 * @param defaultValue the value to be returned if no value of the desired
7880 * type is stored with the given name.
7881 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007882 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007883 * or the default value if none was found.
7884 *
7885 * @see #putExtra(String, double)
7886 */
7887 public double getDoubleExtra(String name, double defaultValue) {
7888 return mExtras == null ? defaultValue :
7889 mExtras.getDouble(name, defaultValue);
7890 }
7891
7892 /**
7893 * Retrieve extended data from the intent.
7894 *
7895 * @param name The name of the desired item.
7896 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007897 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007898 * or null if no String value was found.
7899 *
7900 * @see #putExtra(String, String)
7901 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007902 public @Nullable String getStringExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007903 return mExtras == null ? null : mExtras.getString(name);
7904 }
7905
7906 /**
7907 * Retrieve extended data from the intent.
7908 *
7909 * @param name The name of the desired item.
7910 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007911 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007912 * or null if no CharSequence value was found.
7913 *
7914 * @see #putExtra(String, CharSequence)
7915 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007916 public @Nullable CharSequence getCharSequenceExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007917 return mExtras == null ? null : mExtras.getCharSequence(name);
7918 }
7919
7920 /**
7921 * Retrieve extended data from the intent.
7922 *
7923 * @param name The name of the desired item.
7924 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007925 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007926 * or null if no Parcelable value was found.
7927 *
7928 * @see #putExtra(String, Parcelable)
7929 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007930 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007931 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7932 }
7933
7934 /**
7935 * Retrieve extended data from the intent.
7936 *
7937 * @param name The name of the desired item.
7938 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007939 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007940 * or null if no Parcelable[] value was found.
7941 *
7942 * @see #putExtra(String, Parcelable[])
7943 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007944 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007945 return mExtras == null ? null : mExtras.getParcelableArray(name);
7946 }
7947
7948 /**
7949 * Retrieve extended data from the intent.
7950 *
7951 * @param name The name of the desired item.
7952 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007953 * @return the value of an item previously added with
7954 * putParcelableArrayListExtra(), or null if no
7955 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007956 *
7957 * @see #putParcelableArrayListExtra(String, ArrayList)
7958 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007959 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007960 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7961 }
7962
7963 /**
7964 * Retrieve extended data from the intent.
7965 *
7966 * @param name The name of the desired item.
7967 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007968 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007969 * or null if no Serializable value was found.
7970 *
7971 * @see #putExtra(String, Serializable)
7972 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007973 public @Nullable Serializable getSerializableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007974 return mExtras == null ? null : mExtras.getSerializable(name);
7975 }
7976
7977 /**
7978 * Retrieve extended data from the intent.
7979 *
7980 * @param name The name of the desired item.
7981 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007982 * @return the value of an item previously added with
7983 * putIntegerArrayListExtra(), or null if no
7984 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007985 *
7986 * @see #putIntegerArrayListExtra(String, ArrayList)
7987 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007988 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007989 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7990 }
7991
7992 /**
7993 * Retrieve extended data from the intent.
7994 *
7995 * @param name The name of the desired item.
7996 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007997 * @return the value of an item previously added with
7998 * putStringArrayListExtra(), or null if no
7999 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008000 *
8001 * @see #putStringArrayListExtra(String, ArrayList)
8002 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008003 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008004 return mExtras == null ? null : mExtras.getStringArrayList(name);
8005 }
8006
8007 /**
8008 * Retrieve extended data from the intent.
8009 *
8010 * @param name The name of the desired item.
8011 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008012 * @return the value of an item previously added with
8013 * putCharSequenceArrayListExtra, or null if no
8014 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008015 *
8016 * @see #putCharSequenceArrayListExtra(String, ArrayList)
8017 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008018 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008019 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
8020 }
8021
8022 /**
8023 * Retrieve extended data from the intent.
8024 *
8025 * @param name The name of the desired item.
8026 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008027 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008028 * or null if no boolean array value was found.
8029 *
8030 * @see #putExtra(String, boolean[])
8031 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008032 public @Nullable boolean[] getBooleanArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008033 return mExtras == null ? null : mExtras.getBooleanArray(name);
8034 }
8035
8036 /**
8037 * Retrieve extended data from the intent.
8038 *
8039 * @param name The name of the desired item.
8040 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008041 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008042 * or null if no byte array value was found.
8043 *
8044 * @see #putExtra(String, byte[])
8045 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008046 public @Nullable byte[] getByteArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008047 return mExtras == null ? null : mExtras.getByteArray(name);
8048 }
8049
8050 /**
8051 * Retrieve extended data from the intent.
8052 *
8053 * @param name The name of the desired item.
8054 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008055 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008056 * or null if no short array value was found.
8057 *
8058 * @see #putExtra(String, short[])
8059 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008060 public @Nullable short[] getShortArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008061 return mExtras == null ? null : mExtras.getShortArray(name);
8062 }
8063
8064 /**
8065 * Retrieve extended data from the intent.
8066 *
8067 * @param name The name of the desired item.
8068 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008069 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008070 * or null if no char array value was found.
8071 *
8072 * @see #putExtra(String, char[])
8073 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008074 public @Nullable char[] getCharArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008075 return mExtras == null ? null : mExtras.getCharArray(name);
8076 }
8077
8078 /**
8079 * Retrieve extended data from the intent.
8080 *
8081 * @param name The name of the desired item.
8082 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008083 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008084 * or null if no int array value was found.
8085 *
8086 * @see #putExtra(String, int[])
8087 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008088 public @Nullable int[] getIntArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008089 return mExtras == null ? null : mExtras.getIntArray(name);
8090 }
8091
8092 /**
8093 * Retrieve extended data from the intent.
8094 *
8095 * @param name The name of the desired item.
8096 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008097 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008098 * or null if no long array value was found.
8099 *
8100 * @see #putExtra(String, long[])
8101 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008102 public @Nullable long[] getLongArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008103 return mExtras == null ? null : mExtras.getLongArray(name);
8104 }
8105
8106 /**
8107 * Retrieve extended data from the intent.
8108 *
8109 * @param name The name of the desired item.
8110 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008111 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008112 * or null if no float array value was found.
8113 *
8114 * @see #putExtra(String, float[])
8115 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008116 public @Nullable float[] getFloatArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008117 return mExtras == null ? null : mExtras.getFloatArray(name);
8118 }
8119
8120 /**
8121 * Retrieve extended data from the intent.
8122 *
8123 * @param name The name of the desired item.
8124 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008125 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008126 * or null if no double array value was found.
8127 *
8128 * @see #putExtra(String, double[])
8129 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008130 public @Nullable double[] getDoubleArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008131 return mExtras == null ? null : mExtras.getDoubleArray(name);
8132 }
8133
8134 /**
8135 * Retrieve extended data from the intent.
8136 *
8137 * @param name The name of the desired item.
8138 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008139 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008140 * or null if no String array value was found.
8141 *
8142 * @see #putExtra(String, String[])
8143 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008144 public @Nullable String[] getStringArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008145 return mExtras == null ? null : mExtras.getStringArray(name);
8146 }
8147
8148 /**
8149 * Retrieve extended data from the intent.
8150 *
8151 * @param name The name of the desired item.
8152 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008153 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008154 * or null if no CharSequence array value was found.
8155 *
8156 * @see #putExtra(String, CharSequence[])
8157 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008158 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008159 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8160 }
8161
8162 /**
8163 * Retrieve extended data from the intent.
8164 *
8165 * @param name The name of the desired item.
8166 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008167 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008168 * or null if no Bundle value was found.
8169 *
8170 * @see #putExtra(String, Bundle)
8171 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008172 public @Nullable Bundle getBundleExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008173 return mExtras == null ? null : mExtras.getBundle(name);
8174 }
8175
8176 /**
8177 * Retrieve extended data from the intent.
8178 *
8179 * @param name The name of the desired item.
8180 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008181 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008182 * or null if no IBinder value was found.
8183 *
8184 * @see #putExtra(String, IBinder)
8185 *
8186 * @deprecated
8187 * @hide
8188 */
8189 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008190 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008191 public IBinder getIBinderExtra(String name) {
8192 return mExtras == null ? null : mExtras.getIBinder(name);
8193 }
8194
8195 /**
8196 * Retrieve extended data from the intent.
8197 *
8198 * @param name The name of the desired item.
8199 * @param defaultValue The default value to return in case no item is
8200 * associated with the key 'name'
8201 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008202 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008203 * or defaultValue if none was found.
8204 *
8205 * @see #putExtra
8206 *
8207 * @deprecated
8208 * @hide
8209 */
8210 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008211 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008212 public Object getExtra(String name, Object defaultValue) {
8213 Object result = defaultValue;
8214 if (mExtras != null) {
8215 Object result2 = mExtras.get(name);
8216 if (result2 != null) {
8217 result = result2;
8218 }
8219 }
8220
8221 return result;
8222 }
8223
8224 /**
8225 * Retrieves a map of extended data from the intent.
8226 *
8227 * @return the map of all extras previously added with putExtra(),
8228 * or null if none have been added.
8229 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008230 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008231 return (mExtras != null)
8232 ? new Bundle(mExtras)
8233 : null;
8234 }
8235
8236 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008237 * Filter extras to only basic types.
8238 * @hide
8239 */
8240 public void removeUnsafeExtras() {
8241 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07008242 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008243 }
8244 }
8245
8246 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07008247 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8248 * return itself as-is.
8249 * @hide
8250 */
8251 public boolean canStripForHistory() {
8252 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8253 }
8254
8255 /**
8256 * Call it when the system needs to keep an intent for logging purposes to remove fields
8257 * that are not needed for logging.
8258 * @hide
8259 */
8260 public Intent maybeStripForHistory() {
8261 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8262
8263 if (!canStripForHistory()) {
8264 return this;
8265 }
8266 return new Intent(this, COPY_MODE_HISTORY);
8267 }
8268
8269 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008270 * Retrieve any special flags associated with this intent. You will
8271 * normally just set them with {@link #setFlags} and let the system
8272 * take the appropriate action with them.
8273 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008274 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008275 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008276 * @see #addFlags
8277 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008278 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008279 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008280 return mFlags;
8281 }
8282
Dianne Hackborne7f97212011-02-24 14:40:20 -08008283 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008284 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08008285 public boolean isExcludingStopped() {
8286 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8287 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8288 }
8289
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008290 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008291 * Retrieve the application package name this Intent is limited to. When
8292 * resolving an Intent, if non-null this limits the resolution to only
8293 * components in the given application package.
8294 *
8295 * @return The name of the application package for the Intent.
8296 *
8297 * @see #resolveActivity
8298 * @see #setPackage
8299 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008300 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008301 return mPackage;
8302 }
8303
8304 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008305 * Retrieve the concrete component associated with the intent. When receiving
8306 * an intent, this is the component that was found to best handle it (that is,
8307 * yourself) and will always be non-null; in all other cases it will be
8308 * null unless explicitly set.
8309 *
8310 * @return The name of the application component to handle the intent.
8311 *
8312 * @see #resolveActivity
8313 * @see #setComponent
8314 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008315 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008316 return mComponent;
8317 }
8318
8319 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008320 * Get the bounds of the sender of this intent, in screen coordinates. This can be
8321 * used as a hint to the receiver for animations and the like. Null means that there
8322 * is no source bounds.
8323 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008324 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008325 return mSourceBounds;
8326 }
8327
8328 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008329 * Return the Activity component that should be used to handle this intent.
8330 * The appropriate component is determined based on the information in the
8331 * intent, evaluated as follows:
8332 *
8333 * <p>If {@link #getComponent} returns an explicit class, that is returned
8334 * without any further consideration.
8335 *
8336 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8337 * category to be considered.
8338 *
8339 * <p>If {@link #getAction} is non-NULL, the activity must handle this
8340 * action.
8341 *
8342 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8343 * this type.
8344 *
8345 * <p>If {@link #addCategory} has added any categories, the activity must
8346 * handle ALL of the categories specified.
8347 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008348 * <p>If {@link #getPackage} is non-NULL, only activity components in
8349 * that application package will be considered.
8350 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008351 * <p>If there are no activities that satisfy all of these conditions, a
8352 * null string is returned.
8353 *
8354 * <p>If multiple activities are found to satisfy the intent, the one with
8355 * the highest priority will be used. If there are multiple activities
8356 * with the same priority, the system will either pick the best activity
8357 * based on user preference, or resolve to a system class that will allow
8358 * the user to pick an activity and forward from there.
8359 *
8360 * <p>This method is implemented simply by calling
8361 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8362 * true.</p>
8363 * <p> This API is called for you as part of starting an activity from an
8364 * intent. You do not normally need to call it yourself.</p>
8365 *
8366 * @param pm The package manager with which to resolve the Intent.
8367 *
8368 * @return Name of the component implementing an activity that can
8369 * display the intent.
8370 *
8371 * @see #setComponent
8372 * @see #getComponent
8373 * @see #resolveActivityInfo
8374 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008375 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008376 if (mComponent != null) {
8377 return mComponent;
8378 }
8379
8380 ResolveInfo info = pm.resolveActivity(
8381 this, PackageManager.MATCH_DEFAULT_ONLY);
8382 if (info != null) {
8383 return new ComponentName(
8384 info.activityInfo.applicationInfo.packageName,
8385 info.activityInfo.name);
8386 }
8387
8388 return null;
8389 }
8390
8391 /**
8392 * Resolve the Intent into an {@link ActivityInfo}
8393 * describing the activity that should execute the intent. Resolution
8394 * follows the same rules as described for {@link #resolveActivity}, but
8395 * you get back the completely information about the resolved activity
8396 * instead of just its class name.
8397 *
8398 * @param pm The package manager with which to resolve the Intent.
8399 * @param flags Addition information to retrieve as per
8400 * {@link PackageManager#getActivityInfo(ComponentName, int)
8401 * PackageManager.getActivityInfo()}.
8402 *
8403 * @return PackageManager.ActivityInfo
8404 *
8405 * @see #resolveActivity
8406 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008407 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8408 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008409 ActivityInfo ai = null;
8410 if (mComponent != null) {
8411 try {
8412 ai = pm.getActivityInfo(mComponent, flags);
8413 } catch (PackageManager.NameNotFoundException e) {
8414 // ignore
8415 }
8416 } else {
8417 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07008418 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008419 if (info != null) {
8420 ai = info.activityInfo;
8421 }
8422 }
8423
8424 return ai;
8425 }
8426
8427 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07008428 * Special function for use by the system to resolve service
8429 * intents to system apps. Throws an exception if there are
8430 * multiple potential matches to the Intent. Returns null if
8431 * there are no matches.
8432 * @hide
8433 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008434 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008435 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8436 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008437 if (mComponent != null) {
8438 return mComponent;
8439 }
8440
8441 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8442 if (results == null) {
8443 return null;
8444 }
8445 ComponentName comp = null;
8446 for (int i=0; i<results.size(); i++) {
8447 ResolveInfo ri = results.get(i);
8448 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8449 continue;
8450 }
8451 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8452 ri.serviceInfo.name);
8453 if (comp != null) {
8454 throw new IllegalStateException("Multiple system services handle " + this
8455 + ": " + comp + ", " + foundComp);
8456 }
8457 comp = foundComp;
8458 }
8459 return comp;
8460 }
8461
8462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008463 * Set the general action to be performed.
8464 *
8465 * @param action An action name, such as ACTION_VIEW. Application-specific
8466 * actions should be prefixed with the vendor's package name.
8467 *
8468 * @return Returns the same Intent object, for chaining multiple calls
8469 * into a single statement.
8470 *
8471 * @see #getAction
8472 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008473 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008474 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008475 return this;
8476 }
8477
8478 /**
8479 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008480 * clears any type that was previously set by {@link #setType} or
8481 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008482 *
Nick Pellyccae4122012-01-09 14:12:58 -08008483 * <p><em>Note: scheme matching in the Android framework is
8484 * case-sensitive, unlike the formal RFC. As a result,
8485 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008486 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008487 * {@link #setDataAndNormalize}
8488 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008489 *
Nick Pellyccae4122012-01-09 14:12:58 -08008490 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008491 *
8492 * @return Returns the same Intent object, for chaining multiple calls
8493 * into a single statement.
8494 *
8495 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008496 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008497 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008498 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008499 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008500 mData = data;
8501 mType = null;
8502 return this;
8503 }
8504
8505 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008506 * Normalize and set the data this intent is operating on.
8507 *
8508 * <p>This method automatically clears any type that was
8509 * previously set (for example, by {@link #setType}).
8510 *
8511 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008512 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008513 * so really this is just a convenience method for
8514 * <pre>
8515 * setData(data.normalize())
8516 * </pre>
8517 *
8518 * @param data The Uri of the data this intent is now targeting.
8519 *
8520 * @return Returns the same Intent object, for chaining multiple calls
8521 * into a single statement.
8522 *
8523 * @see #getData
8524 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008525 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008526 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008527 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008528 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008529 }
8530
8531 /**
8532 * Set an explicit MIME data type.
8533 *
8534 * <p>This is used to create intents that only specify a type and not data,
8535 * for example to indicate the type of data to return.
8536 *
8537 * <p>This method automatically clears any data that was
8538 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008539 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008540 * <p><em>Note: MIME type matching in the Android framework is
8541 * case-sensitive, unlike formal RFC MIME types. As a result,
8542 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008543 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8544 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008545 *
8546 * @param type The MIME type of the data being handled by this intent.
8547 *
8548 * @return Returns the same Intent object, for chaining multiple calls
8549 * into a single statement.
8550 *
8551 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008552 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008553 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008554 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008556 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008557 mData = null;
8558 mType = type;
8559 return this;
8560 }
8561
8562 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008563 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008564 *
Nick Pellyccae4122012-01-09 14:12:58 -08008565 * <p>This is used to create intents that only specify a type and not data,
8566 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008567 *
Nick Pellyccae4122012-01-09 14:12:58 -08008568 * <p>This method automatically clears any data that was
8569 * previously set (for example by {@link #setData}).
8570 *
8571 * <p>The MIME type is normalized using
8572 * {@link #normalizeMimeType} before it is set,
8573 * so really this is just a convenience method for
8574 * <pre>
8575 * setType(Intent.normalizeMimeType(type))
8576 * </pre>
8577 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008578 * @param type The MIME type of the data being handled by this intent.
8579 *
8580 * @return Returns the same Intent object, for chaining multiple calls
8581 * into a single statement.
8582 *
Nick Pellyccae4122012-01-09 14:12:58 -08008583 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008584 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008585 * @see #normalizeMimeType
8586 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008587 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008588 return setType(normalizeMimeType(type));
8589 }
8590
8591 /**
8592 * (Usually optional) Set the data for the intent along with an explicit
8593 * MIME data type. This method should very rarely be used -- it allows you
8594 * to override the MIME type that would ordinarily be inferred from the
8595 * data with your own type given here.
8596 *
8597 * <p><em>Note: MIME type and Uri scheme matching in the
8598 * Android framework is case-sensitive, unlike the formal RFC definitions.
8599 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008600 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008601 * {@link #setDataAndTypeAndNormalize}
8602 * to ensure that they are converted to lower case.</em>
8603 *
8604 * @param data The Uri of the data this intent is now targeting.
8605 * @param type The MIME type of the data being handled by this intent.
8606 *
8607 * @return Returns the same Intent object, for chaining multiple calls
8608 * into a single statement.
8609 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008610 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008611 * @see #setData
8612 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008613 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008614 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008615 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008616 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008617 mData = data;
8618 mType = type;
8619 return this;
8620 }
8621
8622 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008623 * (Usually optional) Normalize and set both the data Uri and an explicit
8624 * MIME data type. This method should very rarely be used -- it allows you
8625 * to override the MIME type that would ordinarily be inferred from the
8626 * data with your own type given here.
8627 *
8628 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008629 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008630 * before they are set, so really this is just a convenience method for
8631 * <pre>
8632 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8633 * </pre>
8634 *
8635 * @param data The Uri of the data this intent is now targeting.
8636 * @param type The MIME type of the data being handled by this intent.
8637 *
8638 * @return Returns the same Intent object, for chaining multiple calls
8639 * into a single statement.
8640 *
8641 * @see #setType
8642 * @see #setData
8643 * @see #setDataAndType
8644 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008645 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008646 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008647 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008648 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008649 }
8650
8651 /**
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07008652 * Set an identifier for this Intent. If set, this provides a unique identity for this Intent,
8653 * allowing it to be unique from other Intents that would otherwise look the same. In
8654 * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
8655 * Intents are the same as with other fields like {@link #setAction}. However, unlike those
8656 * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
8657 * it is as if the identifier has not been set on the Intent.
8658 *
Dianne Hackborn100838d2019-04-19 12:39:26 -07008659 * <p>This can be used, for example, to make this Intent unique from other Intents that
8660 * are otherwise the same, for use in creating a {@link android.app.PendingIntent}. (Be aware
8661 * however that the receiver of the PendingIntent will see whatever you put in here.) The
8662 * structure of this string is completely undefined by the platform, however if you are going
8663 * to be exposing identifier strings across different applications you may need to define
8664 * your own structure if there is no central party defining the contents of this field.</p>
8665 *
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07008666 * @param identifier The identifier for this Intent. The contents of the string have no
8667 * meaning to the system, except whether they are exactly the same as
8668 * another identifier.
8669 *
8670 * @return Returns the same Intent object, for chaining multiple calls
8671 * into a single statement.
8672 *
8673 * @see #getIdentifier
8674 */
8675 public @NonNull Intent setIdentifier(@Nullable String identifier) {
8676 mIdentifier = identifier;
8677 return this;
8678 }
8679
8680 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008681 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008682 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008683 * activities that provide <em>all</em> of the requested categories will be
8684 * used.
8685 *
8686 * @param category The desired category. This can be either one of the
8687 * predefined Intent categories, or a custom category in your own
8688 * namespace.
8689 *
8690 * @return Returns the same Intent object, for chaining multiple calls
8691 * into a single statement.
8692 *
8693 * @see #hasCategory
8694 * @see #removeCategory
8695 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008696 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008697 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008698 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008699 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008700 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008701 return this;
8702 }
8703
8704 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008705 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008706 *
8707 * @param category The category to remove.
8708 *
8709 * @see #addCategory
8710 */
8711 public void removeCategory(String category) {
8712 if (mCategories != null) {
8713 mCategories.remove(category);
8714 if (mCategories.size() == 0) {
8715 mCategories = null;
8716 }
8717 }
8718 }
8719
8720 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008721 * Set a selector for this Intent. This is a modification to the kinds of
8722 * things the Intent will match. If the selector is set, it will be used
8723 * when trying to find entities that can handle the Intent, instead of the
8724 * main contents of the Intent. This allows you build an Intent containing
8725 * a generic protocol while targeting it more specifically.
8726 *
8727 * <p>An example of where this may be used is with things like
8728 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8729 * Intent that will launch the Browser application. However, the correct
8730 * main entry point of an application is actually {@link #ACTION_MAIN}
8731 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8732 * used to specify the actual Activity to launch. If you launch the browser
8733 * with something different, undesired behavior may happen if the user has
8734 * previously or later launches it the normal way, since they do not match.
8735 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8736 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8737 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8738 *
8739 * <p>Setting a selector does not impact the behavior of
8740 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8741 * desired behavior of a selector -- it does not impact the base meaning
8742 * of the Intent, just what kinds of things will be matched against it
8743 * when determining who can handle it.</p>
8744 *
8745 * <p>You can not use both a selector and {@link #setPackage(String)} on
8746 * the same base Intent.</p>
8747 *
8748 * @param selector The desired selector Intent; set to null to not use
8749 * a special selector.
8750 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008751 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008752 if (selector == this) {
8753 throw new IllegalArgumentException(
8754 "Intent being set as a selector of itself");
8755 }
8756 if (selector != null && mPackage != null) {
8757 throw new IllegalArgumentException(
8758 "Can't set selector when package name is already set");
8759 }
8760 mSelector = selector;
8761 }
8762
8763 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008764 * Set a {@link ClipData} associated with this Intent. This replaces any
8765 * previously set ClipData.
8766 *
8767 * <p>The ClipData in an intent is not used for Intent matching or other
8768 * such operations. Semantically it is like extras, used to transmit
8769 * additional data with the Intent. The main feature of using this over
8770 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8771 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8772 * items included in the clip data. This is useful, in particular, if
8773 * you want to transmit an Intent containing multiple <code>content:</code>
8774 * URIs for which the recipient may not have global permission to access the
8775 * content provider.
8776 *
8777 * <p>If the ClipData contains items that are themselves Intents, any
8778 * grant flags in those Intents will be ignored. Only the top-level flags
8779 * of the main Intent are respected, and will be applied to all Uri or
8780 * Intent items in the clip (or sub-items of the clip).
8781 *
8782 * <p>The MIME type, label, and icon in the ClipData object are not
8783 * directly used by Intent. Applications should generally rely on the
8784 * MIME type of the Intent itself, not what it may find in the ClipData.
8785 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008786 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008787 *
8788 * @param clip The new clip to set. May be null to clear the current clip.
8789 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008790 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008791 mClipData = clip;
8792 }
8793
8794 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008795 * This is NOT a secure mechanism to identify the user who sent the intent.
8796 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8797 * who sent the intent.
8798 * @hide
8799 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008800 public void prepareToLeaveUser(int userId) {
8801 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8802 // We want mContentUserHint to refer to the original user, so don't do anything.
8803 if (mContentUserHint == UserHandle.USER_CURRENT) {
8804 mContentUserHint = userId;
8805 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008806 }
8807
8808 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008809 * Add extended data to the intent. The name must include a package
8810 * prefix, for example the app com.android.contacts would use names
8811 * like "com.android.contacts.ShowAll".
8812 *
8813 * @param name The name of the extra data, with package prefix.
8814 * @param value The boolean data value.
8815 *
8816 * @return Returns the same Intent object, for chaining multiple calls
8817 * into a single statement.
8818 *
8819 * @see #putExtras
8820 * @see #removeExtra
8821 * @see #getBooleanExtra(String, boolean)
8822 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008823 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008824 if (mExtras == null) {
8825 mExtras = new Bundle();
8826 }
8827 mExtras.putBoolean(name, value);
8828 return this;
8829 }
8830
8831 /**
8832 * Add extended data to the intent. The name must include a package
8833 * prefix, for example the app com.android.contacts would use names
8834 * like "com.android.contacts.ShowAll".
8835 *
8836 * @param name The name of the extra data, with package prefix.
8837 * @param value The byte data value.
8838 *
8839 * @return Returns the same Intent object, for chaining multiple calls
8840 * into a single statement.
8841 *
8842 * @see #putExtras
8843 * @see #removeExtra
8844 * @see #getByteExtra(String, byte)
8845 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008846 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008847 if (mExtras == null) {
8848 mExtras = new Bundle();
8849 }
8850 mExtras.putByte(name, value);
8851 return this;
8852 }
8853
8854 /**
8855 * Add extended data to the intent. The name must include a package
8856 * prefix, for example the app com.android.contacts would use names
8857 * like "com.android.contacts.ShowAll".
8858 *
8859 * @param name The name of the extra data, with package prefix.
8860 * @param value The char data value.
8861 *
8862 * @return Returns the same Intent object, for chaining multiple calls
8863 * into a single statement.
8864 *
8865 * @see #putExtras
8866 * @see #removeExtra
8867 * @see #getCharExtra(String, char)
8868 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008869 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008870 if (mExtras == null) {
8871 mExtras = new Bundle();
8872 }
8873 mExtras.putChar(name, value);
8874 return this;
8875 }
8876
8877 /**
8878 * Add extended data to the intent. The name must include a package
8879 * prefix, for example the app com.android.contacts would use names
8880 * like "com.android.contacts.ShowAll".
8881 *
8882 * @param name The name of the extra data, with package prefix.
8883 * @param value The short data value.
8884 *
8885 * @return Returns the same Intent object, for chaining multiple calls
8886 * into a single statement.
8887 *
8888 * @see #putExtras
8889 * @see #removeExtra
8890 * @see #getShortExtra(String, short)
8891 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008892 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008893 if (mExtras == null) {
8894 mExtras = new Bundle();
8895 }
8896 mExtras.putShort(name, value);
8897 return this;
8898 }
8899
8900 /**
8901 * Add extended data to the intent. The name must include a package
8902 * prefix, for example the app com.android.contacts would use names
8903 * like "com.android.contacts.ShowAll".
8904 *
8905 * @param name The name of the extra data, with package prefix.
8906 * @param value The integer data value.
8907 *
8908 * @return Returns the same Intent object, for chaining multiple calls
8909 * into a single statement.
8910 *
8911 * @see #putExtras
8912 * @see #removeExtra
8913 * @see #getIntExtra(String, int)
8914 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008915 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008916 if (mExtras == null) {
8917 mExtras = new Bundle();
8918 }
8919 mExtras.putInt(name, value);
8920 return this;
8921 }
8922
8923 /**
8924 * Add extended data to the intent. The name must include a package
8925 * prefix, for example the app com.android.contacts would use names
8926 * like "com.android.contacts.ShowAll".
8927 *
8928 * @param name The name of the extra data, with package prefix.
8929 * @param value The long data value.
8930 *
8931 * @return Returns the same Intent object, for chaining multiple calls
8932 * into a single statement.
8933 *
8934 * @see #putExtras
8935 * @see #removeExtra
8936 * @see #getLongExtra(String, long)
8937 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008938 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008939 if (mExtras == null) {
8940 mExtras = new Bundle();
8941 }
8942 mExtras.putLong(name, value);
8943 return this;
8944 }
8945
8946 /**
8947 * Add extended data to the intent. The name must include a package
8948 * prefix, for example the app com.android.contacts would use names
8949 * like "com.android.contacts.ShowAll".
8950 *
8951 * @param name The name of the extra data, with package prefix.
8952 * @param value The float data value.
8953 *
8954 * @return Returns the same Intent object, for chaining multiple calls
8955 * into a single statement.
8956 *
8957 * @see #putExtras
8958 * @see #removeExtra
8959 * @see #getFloatExtra(String, float)
8960 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008961 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008962 if (mExtras == null) {
8963 mExtras = new Bundle();
8964 }
8965 mExtras.putFloat(name, value);
8966 return this;
8967 }
8968
8969 /**
8970 * Add extended data to the intent. The name must include a package
8971 * prefix, for example the app com.android.contacts would use names
8972 * like "com.android.contacts.ShowAll".
8973 *
8974 * @param name The name of the extra data, with package prefix.
8975 * @param value The double data value.
8976 *
8977 * @return Returns the same Intent object, for chaining multiple calls
8978 * into a single statement.
8979 *
8980 * @see #putExtras
8981 * @see #removeExtra
8982 * @see #getDoubleExtra(String, double)
8983 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008984 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008985 if (mExtras == null) {
8986 mExtras = new Bundle();
8987 }
8988 mExtras.putDouble(name, value);
8989 return this;
8990 }
8991
8992 /**
8993 * Add extended data to the intent. The name must include a package
8994 * prefix, for example the app com.android.contacts would use names
8995 * like "com.android.contacts.ShowAll".
8996 *
8997 * @param name The name of the extra data, with package prefix.
8998 * @param value The String data value.
8999 *
9000 * @return Returns the same Intent object, for chaining multiple calls
9001 * into a single statement.
9002 *
9003 * @see #putExtras
9004 * @see #removeExtra
9005 * @see #getStringExtra(String)
9006 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009007 public @NonNull Intent putExtra(String name, @Nullable String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009008 if (mExtras == null) {
9009 mExtras = new Bundle();
9010 }
9011 mExtras.putString(name, value);
9012 return this;
9013 }
9014
9015 /**
9016 * Add extended data to the intent. The name must include a package
9017 * prefix, for example the app com.android.contacts would use names
9018 * like "com.android.contacts.ShowAll".
9019 *
9020 * @param name The name of the extra data, with package prefix.
9021 * @param value The CharSequence data value.
9022 *
9023 * @return Returns the same Intent object, for chaining multiple calls
9024 * into a single statement.
9025 *
9026 * @see #putExtras
9027 * @see #removeExtra
9028 * @see #getCharSequenceExtra(String)
9029 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009030 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009031 if (mExtras == null) {
9032 mExtras = new Bundle();
9033 }
9034 mExtras.putCharSequence(name, value);
9035 return this;
9036 }
9037
9038 /**
9039 * Add extended data to the intent. The name must include a package
9040 * prefix, for example the app com.android.contacts would use names
9041 * like "com.android.contacts.ShowAll".
9042 *
9043 * @param name The name of the extra data, with package prefix.
9044 * @param value The Parcelable data value.
9045 *
9046 * @return Returns the same Intent object, for chaining multiple calls
9047 * into a single statement.
9048 *
9049 * @see #putExtras
9050 * @see #removeExtra
9051 * @see #getParcelableExtra(String)
9052 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009053 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009054 if (mExtras == null) {
9055 mExtras = new Bundle();
9056 }
9057 mExtras.putParcelable(name, value);
9058 return this;
9059 }
9060
9061 /**
9062 * Add extended data to the intent. The name must include a package
9063 * prefix, for example the app com.android.contacts would use names
9064 * like "com.android.contacts.ShowAll".
9065 *
9066 * @param name The name of the extra data, with package prefix.
9067 * @param value The Parcelable[] data value.
9068 *
9069 * @return Returns the same Intent object, for chaining multiple calls
9070 * into a single statement.
9071 *
9072 * @see #putExtras
9073 * @see #removeExtra
9074 * @see #getParcelableArrayExtra(String)
9075 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009076 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009077 if (mExtras == null) {
9078 mExtras = new Bundle();
9079 }
9080 mExtras.putParcelableArray(name, value);
9081 return this;
9082 }
9083
9084 /**
9085 * Add extended data to the intent. The name must include a package
9086 * prefix, for example the app com.android.contacts would use names
9087 * like "com.android.contacts.ShowAll".
9088 *
9089 * @param name The name of the extra data, with package prefix.
9090 * @param value The ArrayList<Parcelable> data value.
9091 *
9092 * @return Returns the same Intent object, for chaining multiple calls
9093 * into a single statement.
9094 *
9095 * @see #putExtras
9096 * @see #removeExtra
9097 * @see #getParcelableArrayListExtra(String)
9098 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009099 public @NonNull Intent putParcelableArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009100 @Nullable ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009101 if (mExtras == null) {
9102 mExtras = new Bundle();
9103 }
9104 mExtras.putParcelableArrayList(name, value);
9105 return this;
9106 }
9107
9108 /**
9109 * Add extended data to the intent. The name must include a package
9110 * prefix, for example the app com.android.contacts would use names
9111 * like "com.android.contacts.ShowAll".
9112 *
9113 * @param name The name of the extra data, with package prefix.
9114 * @param value The ArrayList<Integer> data value.
9115 *
9116 * @return Returns the same Intent object, for chaining multiple calls
9117 * into a single statement.
9118 *
9119 * @see #putExtras
9120 * @see #removeExtra
9121 * @see #getIntegerArrayListExtra(String)
9122 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009123 public @NonNull Intent putIntegerArrayListExtra(String name,
9124 @Nullable ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009125 if (mExtras == null) {
9126 mExtras = new Bundle();
9127 }
9128 mExtras.putIntegerArrayList(name, value);
9129 return this;
9130 }
9131
9132 /**
9133 * Add extended data to the intent. The name must include a package
9134 * prefix, for example the app com.android.contacts would use names
9135 * like "com.android.contacts.ShowAll".
9136 *
9137 * @param name The name of the extra data, with package prefix.
9138 * @param value The ArrayList<String> data value.
9139 *
9140 * @return Returns the same Intent object, for chaining multiple calls
9141 * into a single statement.
9142 *
9143 * @see #putExtras
9144 * @see #removeExtra
9145 * @see #getStringArrayListExtra(String)
9146 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009147 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009148 if (mExtras == null) {
9149 mExtras = new Bundle();
9150 }
9151 mExtras.putStringArrayList(name, value);
9152 return this;
9153 }
9154
9155 /**
9156 * Add extended data to the intent. The name must include a package
9157 * prefix, for example the app com.android.contacts would use names
9158 * like "com.android.contacts.ShowAll".
9159 *
9160 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009161 * @param value The ArrayList<CharSequence> data value.
9162 *
9163 * @return Returns the same Intent object, for chaining multiple calls
9164 * into a single statement.
9165 *
9166 * @see #putExtras
9167 * @see #removeExtra
9168 * @see #getCharSequenceArrayListExtra(String)
9169 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009170 public @NonNull Intent putCharSequenceArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009171 @Nullable ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009172 if (mExtras == null) {
9173 mExtras = new Bundle();
9174 }
9175 mExtras.putCharSequenceArrayList(name, value);
9176 return this;
9177 }
9178
9179 /**
9180 * Add extended data to the intent. The name must include a package
9181 * prefix, for example the app com.android.contacts would use names
9182 * like "com.android.contacts.ShowAll".
9183 *
9184 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009185 * @param value The Serializable data value.
9186 *
9187 * @return Returns the same Intent object, for chaining multiple calls
9188 * into a single statement.
9189 *
9190 * @see #putExtras
9191 * @see #removeExtra
9192 * @see #getSerializableExtra(String)
9193 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009194 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009195 if (mExtras == null) {
9196 mExtras = new Bundle();
9197 }
9198 mExtras.putSerializable(name, value);
9199 return this;
9200 }
9201
9202 /**
9203 * Add extended data to the intent. The name must include a package
9204 * prefix, for example the app com.android.contacts would use names
9205 * like "com.android.contacts.ShowAll".
9206 *
9207 * @param name The name of the extra data, with package prefix.
9208 * @param value The boolean array data value.
9209 *
9210 * @return Returns the same Intent object, for chaining multiple calls
9211 * into a single statement.
9212 *
9213 * @see #putExtras
9214 * @see #removeExtra
9215 * @see #getBooleanArrayExtra(String)
9216 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009217 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009218 if (mExtras == null) {
9219 mExtras = new Bundle();
9220 }
9221 mExtras.putBooleanArray(name, value);
9222 return this;
9223 }
9224
9225 /**
9226 * Add extended data to the intent. The name must include a package
9227 * prefix, for example the app com.android.contacts would use names
9228 * like "com.android.contacts.ShowAll".
9229 *
9230 * @param name The name of the extra data, with package prefix.
9231 * @param value The byte array data value.
9232 *
9233 * @return Returns the same Intent object, for chaining multiple calls
9234 * into a single statement.
9235 *
9236 * @see #putExtras
9237 * @see #removeExtra
9238 * @see #getByteArrayExtra(String)
9239 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009240 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009241 if (mExtras == null) {
9242 mExtras = new Bundle();
9243 }
9244 mExtras.putByteArray(name, value);
9245 return this;
9246 }
9247
9248 /**
9249 * Add extended data to the intent. The name must include a package
9250 * prefix, for example the app com.android.contacts would use names
9251 * like "com.android.contacts.ShowAll".
9252 *
9253 * @param name The name of the extra data, with package prefix.
9254 * @param value The short array data value.
9255 *
9256 * @return Returns the same Intent object, for chaining multiple calls
9257 * into a single statement.
9258 *
9259 * @see #putExtras
9260 * @see #removeExtra
9261 * @see #getShortArrayExtra(String)
9262 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009263 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009264 if (mExtras == null) {
9265 mExtras = new Bundle();
9266 }
9267 mExtras.putShortArray(name, value);
9268 return this;
9269 }
9270
9271 /**
9272 * Add extended data to the intent. The name must include a package
9273 * prefix, for example the app com.android.contacts would use names
9274 * like "com.android.contacts.ShowAll".
9275 *
9276 * @param name The name of the extra data, with package prefix.
9277 * @param value The char array data value.
9278 *
9279 * @return Returns the same Intent object, for chaining multiple calls
9280 * into a single statement.
9281 *
9282 * @see #putExtras
9283 * @see #removeExtra
9284 * @see #getCharArrayExtra(String)
9285 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009286 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009287 if (mExtras == null) {
9288 mExtras = new Bundle();
9289 }
9290 mExtras.putCharArray(name, value);
9291 return this;
9292 }
9293
9294 /**
9295 * Add extended data to the intent. The name must include a package
9296 * prefix, for example the app com.android.contacts would use names
9297 * like "com.android.contacts.ShowAll".
9298 *
9299 * @param name The name of the extra data, with package prefix.
9300 * @param value The int array data value.
9301 *
9302 * @return Returns the same Intent object, for chaining multiple calls
9303 * into a single statement.
9304 *
9305 * @see #putExtras
9306 * @see #removeExtra
9307 * @see #getIntArrayExtra(String)
9308 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009309 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009310 if (mExtras == null) {
9311 mExtras = new Bundle();
9312 }
9313 mExtras.putIntArray(name, value);
9314 return this;
9315 }
9316
9317 /**
9318 * Add extended data to the intent. The name must include a package
9319 * prefix, for example the app com.android.contacts would use names
9320 * like "com.android.contacts.ShowAll".
9321 *
9322 * @param name The name of the extra data, with package prefix.
9323 * @param value The byte array data value.
9324 *
9325 * @return Returns the same Intent object, for chaining multiple calls
9326 * into a single statement.
9327 *
9328 * @see #putExtras
9329 * @see #removeExtra
9330 * @see #getLongArrayExtra(String)
9331 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009332 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009333 if (mExtras == null) {
9334 mExtras = new Bundle();
9335 }
9336 mExtras.putLongArray(name, value);
9337 return this;
9338 }
9339
9340 /**
9341 * Add extended data to the intent. The name must include a package
9342 * prefix, for example the app com.android.contacts would use names
9343 * like "com.android.contacts.ShowAll".
9344 *
9345 * @param name The name of the extra data, with package prefix.
9346 * @param value The float array data value.
9347 *
9348 * @return Returns the same Intent object, for chaining multiple calls
9349 * into a single statement.
9350 *
9351 * @see #putExtras
9352 * @see #removeExtra
9353 * @see #getFloatArrayExtra(String)
9354 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009355 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009356 if (mExtras == null) {
9357 mExtras = new Bundle();
9358 }
9359 mExtras.putFloatArray(name, value);
9360 return this;
9361 }
9362
9363 /**
9364 * Add extended data to the intent. The name must include a package
9365 * prefix, for example the app com.android.contacts would use names
9366 * like "com.android.contacts.ShowAll".
9367 *
9368 * @param name The name of the extra data, with package prefix.
9369 * @param value The double array data value.
9370 *
9371 * @return Returns the same Intent object, for chaining multiple calls
9372 * into a single statement.
9373 *
9374 * @see #putExtras
9375 * @see #removeExtra
9376 * @see #getDoubleArrayExtra(String)
9377 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009378 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009379 if (mExtras == null) {
9380 mExtras = new Bundle();
9381 }
9382 mExtras.putDoubleArray(name, value);
9383 return this;
9384 }
9385
9386 /**
9387 * Add extended data to the intent. The name must include a package
9388 * prefix, for example the app com.android.contacts would use names
9389 * like "com.android.contacts.ShowAll".
9390 *
9391 * @param name The name of the extra data, with package prefix.
9392 * @param value The String array data value.
9393 *
9394 * @return Returns the same Intent object, for chaining multiple calls
9395 * into a single statement.
9396 *
9397 * @see #putExtras
9398 * @see #removeExtra
9399 * @see #getStringArrayExtra(String)
9400 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009401 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009402 if (mExtras == null) {
9403 mExtras = new Bundle();
9404 }
9405 mExtras.putStringArray(name, value);
9406 return this;
9407 }
9408
9409 /**
9410 * Add extended data to the intent. The name must include a package
9411 * prefix, for example the app com.android.contacts would use names
9412 * like "com.android.contacts.ShowAll".
9413 *
9414 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009415 * @param value The CharSequence array data value.
9416 *
9417 * @return Returns the same Intent object, for chaining multiple calls
9418 * into a single statement.
9419 *
9420 * @see #putExtras
9421 * @see #removeExtra
9422 * @see #getCharSequenceArrayExtra(String)
9423 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009424 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009425 if (mExtras == null) {
9426 mExtras = new Bundle();
9427 }
9428 mExtras.putCharSequenceArray(name, value);
9429 return this;
9430 }
9431
9432 /**
9433 * Add extended data to the intent. The name must include a package
9434 * prefix, for example the app com.android.contacts would use names
9435 * like "com.android.contacts.ShowAll".
9436 *
9437 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009438 * @param value The Bundle data value.
9439 *
9440 * @return Returns the same Intent object, for chaining multiple calls
9441 * into a single statement.
9442 *
9443 * @see #putExtras
9444 * @see #removeExtra
9445 * @see #getBundleExtra(String)
9446 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009447 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009448 if (mExtras == null) {
9449 mExtras = new Bundle();
9450 }
9451 mExtras.putBundle(name, value);
9452 return this;
9453 }
9454
9455 /**
9456 * Add extended data to the intent. The name must include a package
9457 * prefix, for example the app com.android.contacts would use names
9458 * like "com.android.contacts.ShowAll".
9459 *
9460 * @param name The name of the extra data, with package prefix.
9461 * @param value The IBinder data value.
9462 *
9463 * @return Returns the same Intent object, for chaining multiple calls
9464 * into a single statement.
9465 *
9466 * @see #putExtras
9467 * @see #removeExtra
9468 * @see #getIBinderExtra(String)
9469 *
9470 * @deprecated
9471 * @hide
9472 */
9473 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009474 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009475 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009476 if (mExtras == null) {
9477 mExtras = new Bundle();
9478 }
9479 mExtras.putIBinder(name, value);
9480 return this;
9481 }
9482
9483 /**
9484 * Copy all extras in 'src' in to this intent.
9485 *
9486 * @param src Contains the extras to copy.
9487 *
9488 * @see #putExtra
9489 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009490 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009491 if (src.mExtras != null) {
9492 if (mExtras == null) {
9493 mExtras = new Bundle(src.mExtras);
9494 } else {
9495 mExtras.putAll(src.mExtras);
9496 }
9497 }
9498 return this;
9499 }
9500
9501 /**
9502 * Add a set of extended data to the intent. The keys must include a package
9503 * prefix, for example the app com.android.contacts would use names
9504 * like "com.android.contacts.ShowAll".
9505 *
9506 * @param extras The Bundle of extras to add to this intent.
9507 *
9508 * @see #putExtra
9509 * @see #removeExtra
9510 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009511 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009512 if (mExtras == null) {
9513 mExtras = new Bundle();
9514 }
9515 mExtras.putAll(extras);
9516 return this;
9517 }
9518
9519 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009520 * Completely replace the extras in the Intent with the extras in the
9521 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009522 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009523 * @param src The exact extras contained in this Intent are copied
9524 * into the target intent, replacing any that were previously there.
9525 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009526 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009527 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9528 return this;
9529 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009530
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009531 /**
9532 * Completely replace the extras in the Intent with the given Bundle of
9533 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009534 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009535 * @param extras The new set of extras in the Intent, or null to erase
9536 * all extras.
9537 */
Tobias Thierer13991172018-12-23 14:25:58 +00009538 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009539 mExtras = extras != null ? new Bundle(extras) : null;
9540 return this;
9541 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009542
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009543 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009544 * Remove extended data from the intent.
9545 *
9546 * @see #putExtra
9547 */
9548 public void removeExtra(String name) {
9549 if (mExtras != null) {
9550 mExtras.remove(name);
9551 if (mExtras.size() == 0) {
9552 mExtras = null;
9553 }
9554 }
9555 }
9556
9557 /**
9558 * Set special flags controlling how this intent is handled. Most values
9559 * here depend on the type of component being executed by the Intent,
9560 * specifically the FLAG_ACTIVITY_* flags are all for use with
9561 * {@link Context#startActivity Context.startActivity()} and the
9562 * FLAG_RECEIVER_* flags are all for use with
9563 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9564 *
Scott Main7aee61f2011-02-08 11:25:01 -08009565 * <p>See the
9566 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9567 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009568 * the behavior of your application.
9569 *
9570 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009571 * @return Returns the same Intent object, for chaining multiple calls
9572 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009573 * @see #getFlags
9574 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009575 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009576 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009577 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009578 mFlags = flags;
9579 return this;
9580 }
9581
9582 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009583 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009584 *
9585 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009586 * @return Returns the same Intent object, for chaining multiple calls into
9587 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009588 * @see #setFlags
9589 * @see #getFlags
9590 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009591 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009592 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009593 mFlags |= flags;
9594 return this;
9595 }
9596
9597 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009598 * Remove these flags from the intent.
9599 *
9600 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009601 * @see #setFlags
9602 * @see #getFlags
9603 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009604 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009605 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009606 mFlags &= ~flags;
9607 }
9608
9609 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009610 * (Usually optional) Set an explicit application package name that limits
9611 * the components this Intent will resolve to. If left to the default
9612 * value of null, all components in all applications will considered.
9613 * If non-null, the Intent can only match the components in the given
9614 * application package.
9615 *
9616 * @param packageName The name of the application package to handle the
9617 * intent, or null to allow any application package.
9618 *
9619 * @return Returns the same Intent object, for chaining multiple calls
9620 * into a single statement.
9621 *
9622 * @see #getPackage
9623 * @see #resolveActivity
9624 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009625 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009626 if (packageName != null && mSelector != null) {
9627 throw new IllegalArgumentException(
9628 "Can't set package name when selector is already set");
9629 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009630 mPackage = packageName;
9631 return this;
9632 }
9633
9634 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009635 * (Usually optional) Explicitly set the component to handle the intent.
9636 * If left with the default value of null, the system will determine the
9637 * appropriate class to use based on the other fields (action, data,
9638 * type, categories) in the Intent. If this class is defined, the
9639 * specified class will always be used regardless of the other fields. You
9640 * should only set this value when you know you absolutely want a specific
9641 * class to be used; otherwise it is better to let the system find the
9642 * appropriate class so that you will respect the installed applications
9643 * and user preferences.
9644 *
9645 * @param component The name of the application component to handle the
9646 * intent, or null to let the system find one for you.
9647 *
9648 * @return Returns the same Intent object, for chaining multiple calls
9649 * into a single statement.
9650 *
9651 * @see #setClass
9652 * @see #setClassName(Context, String)
9653 * @see #setClassName(String, String)
9654 * @see #getComponent
9655 * @see #resolveActivity
9656 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009657 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009658 mComponent = component;
9659 return this;
9660 }
9661
9662 /**
9663 * Convenience for calling {@link #setComponent} with an
9664 * explicit class name.
9665 *
9666 * @param packageContext A Context of the application package implementing
9667 * this class.
9668 * @param className The name of a class inside of the application package
9669 * that will be used as the component for this Intent.
9670 *
9671 * @return Returns the same Intent object, for chaining multiple calls
9672 * into a single statement.
9673 *
9674 * @see #setComponent
9675 * @see #setClass
9676 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009677 public @NonNull Intent setClassName(@NonNull Context packageContext,
9678 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009679 mComponent = new ComponentName(packageContext, className);
9680 return this;
9681 }
9682
9683 /**
9684 * Convenience for calling {@link #setComponent} with an
9685 * explicit application package name and class name.
9686 *
9687 * @param packageName The name of the package implementing the desired
9688 * component.
9689 * @param className The name of a class inside of the application package
9690 * that will be used as the component for this Intent.
9691 *
9692 * @return Returns the same Intent object, for chaining multiple calls
9693 * into a single statement.
9694 *
9695 * @see #setComponent
9696 * @see #setClass
9697 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009698 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009699 mComponent = new ComponentName(packageName, className);
9700 return this;
9701 }
9702
9703 /**
9704 * Convenience for calling {@link #setComponent(ComponentName)} with the
9705 * name returned by a {@link Class} object.
9706 *
9707 * @param packageContext A Context of the application package implementing
9708 * this class.
9709 * @param cls The class name to set, equivalent to
9710 * <code>setClassName(context, cls.getName())</code>.
9711 *
9712 * @return Returns the same Intent object, for chaining multiple calls
9713 * into a single statement.
9714 *
9715 * @see #setComponent
9716 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009717 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009718 mComponent = new ComponentName(packageContext, cls);
9719 return this;
9720 }
9721
9722 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009723 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9724 * used as a hint to the receiver for animations and the like. Null means that there
9725 * is no source bounds.
9726 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009727 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009728 if (r != null) {
9729 mSourceBounds = new Rect(r);
9730 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009731 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009732 }
9733 }
9734
Tor Norbyed9273d62013-05-30 15:59:53 -07009735 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009736 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9737 FILL_IN_ACTION,
9738 FILL_IN_DATA,
9739 FILL_IN_CATEGORIES,
9740 FILL_IN_COMPONENT,
9741 FILL_IN_PACKAGE,
9742 FILL_IN_SOURCE_BOUNDS,
9743 FILL_IN_SELECTOR,
9744 FILL_IN_CLIP_DATA
9745 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009746 @Retention(RetentionPolicy.SOURCE)
9747 public @interface FillInFlags {}
9748
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009749 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009750 * Use with {@link #fillIn} to allow the current action value to be
9751 * overwritten, even if it is already set.
9752 */
9753 public static final int FILL_IN_ACTION = 1<<0;
9754
9755 /**
9756 * Use with {@link #fillIn} to allow the current data or type value
9757 * overwritten, even if it is already set.
9758 */
9759 public static final int FILL_IN_DATA = 1<<1;
9760
9761 /**
9762 * Use with {@link #fillIn} to allow the current categories to be
9763 * overwritten, even if they are already set.
9764 */
9765 public static final int FILL_IN_CATEGORIES = 1<<2;
9766
9767 /**
9768 * Use with {@link #fillIn} to allow the current component value to be
9769 * overwritten, even if it is already set.
9770 */
9771 public static final int FILL_IN_COMPONENT = 1<<3;
9772
9773 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009774 * Use with {@link #fillIn} to allow the current package value to be
9775 * overwritten, even if it is already set.
9776 */
9777 public static final int FILL_IN_PACKAGE = 1<<4;
9778
9779 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009780 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009781 * overwritten, even if it is already set.
9782 */
9783 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9784
9785 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009786 * Use with {@link #fillIn} to allow the current selector to be
9787 * overwritten, even if it is already set.
9788 */
9789 public static final int FILL_IN_SELECTOR = 1<<6;
9790
9791 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009792 * Use with {@link #fillIn} to allow the current ClipData to be
9793 * overwritten, even if it is already set.
9794 */
9795 public static final int FILL_IN_CLIP_DATA = 1<<7;
9796
9797 /**
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009798 * Use with {@link #fillIn} to allow the current identifier value to be
9799 * overwritten, even if it is already set.
9800 */
9801 public static final int FILL_IN_IDENTIFIER = 1<<8;
9802
9803 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009804 * Copy the contents of <var>other</var> in to this object, but only
9805 * where fields are not defined by this object. For purposes of a field
9806 * being defined, the following pieces of data in the Intent are
9807 * considered to be separate fields:
9808 *
9809 * <ul>
9810 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009811 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009812 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009813 * <li> identifier, as set by {@link #setIdentifier}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009814 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009815 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009816 * <li> component, as set by {@link #setComponent(ComponentName)} or
9817 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009818 * <li> source bounds, as set by {@link #setSourceBounds}.
9819 * <li> selector, as set by {@link #setSelector(Intent)}.
9820 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009821 * <li> each top-level name in the associated extras.
9822 * </ul>
9823 *
9824 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009825 * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
9826 * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009827 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9828 * the restriction where the corresponding field will not be replaced if
9829 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009830 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009831 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9832 * is explicitly specified. The selector will only be copied if
9833 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009834 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009835 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9836 * and Intent B with {action="gotit", data-type="some/thing",
9837 * categories="one","two"}.
9838 *
9839 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9840 * containing: {action="gotit", data-type="some/thing",
9841 * categories="bar"}.
9842 *
9843 * @param other Another Intent whose values are to be used to fill in
9844 * the current one.
9845 * @param flags Options to control which fields can be filled in.
9846 *
9847 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009848 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009849 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009850 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009851 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009852 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009853 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009854 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009855 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009856 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009857 if (other.mAction != null
9858 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009859 mAction = other.mAction;
9860 changes |= FILL_IN_ACTION;
9861 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009862 if ((other.mData != null || other.mType != null)
9863 && ((mData == null && mType == null)
9864 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009865 mData = other.mData;
9866 mType = other.mType;
9867 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009868 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009869 }
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009870 if (other.mIdentifier != null
9871 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
9872 mIdentifier = other.mIdentifier;
9873 changes |= FILL_IN_IDENTIFIER;
9874 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009875 if (other.mCategories != null
9876 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009877 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009878 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009879 }
9880 changes |= FILL_IN_CATEGORIES;
9881 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009882 if (other.mPackage != null
9883 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009884 // Only do this if mSelector is not set.
9885 if (mSelector == null) {
9886 mPackage = other.mPackage;
9887 changes |= FILL_IN_PACKAGE;
9888 }
9889 }
9890 // Selector is special: it can only be set if explicitly allowed,
9891 // for the same reason as the component name.
9892 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9893 if (mPackage == null) {
9894 mSelector = new Intent(other.mSelector);
9895 mPackage = null;
9896 changes |= FILL_IN_SELECTOR;
9897 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009898 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009899 if (other.mClipData != null
9900 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9901 mClipData = other.mClipData;
9902 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009903 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009904 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009905 // Component is special: it can -only- be set if explicitly allowed,
9906 // since otherwise the sender could force the intent somewhere the
9907 // originator didn't intend.
9908 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009909 mComponent = other.mComponent;
9910 changes |= FILL_IN_COMPONENT;
9911 }
9912 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009913 if (other.mSourceBounds != null
9914 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9915 mSourceBounds = new Rect(other.mSourceBounds);
9916 changes |= FILL_IN_SOURCE_BOUNDS;
9917 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009918 if (mExtras == null) {
9919 if (other.mExtras != null) {
9920 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009921 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009922 }
9923 } else if (other.mExtras != null) {
9924 try {
9925 Bundle newb = new Bundle(other.mExtras);
9926 newb.putAll(mExtras);
9927 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009928 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009929 } catch (RuntimeException e) {
9930 // Modifying the extras can cause us to unparcel the contents
9931 // of the bundle, and if we do this in the system process that
9932 // may fail. We really should handle this (i.e., the Bundle
9933 // impl shouldn't be on top of a plain map), but for now just
9934 // ignore it and keep the original contents. :(
Jeff Sharkey9c9ee952019-03-22 17:18:38 -06009935 Log.w(TAG, "Failure filling in extras", e);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009936 }
9937 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009938 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9939 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9940 mContentUserHint = other.mContentUserHint;
9941 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009942 return changes;
9943 }
9944
9945 /**
9946 * Wrapper class holding an Intent and implementing comparisons on it for
9947 * the purpose of filtering. The class implements its
9948 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9949 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9950 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9951 * on the wrapped Intent.
9952 */
9953 public static final class FilterComparison {
9954 private final Intent mIntent;
9955 private final int mHashCode;
9956
9957 public FilterComparison(Intent intent) {
9958 mIntent = intent;
9959 mHashCode = intent.filterHashCode();
9960 }
9961
9962 /**
9963 * Return the Intent that this FilterComparison represents.
9964 * @return Returns the Intent held by the FilterComparison. Do
9965 * not modify!
9966 */
9967 public Intent getIntent() {
9968 return mIntent;
9969 }
9970
9971 @Override
9972 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009973 if (obj instanceof FilterComparison) {
9974 Intent other = ((FilterComparison)obj).mIntent;
9975 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009976 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009977 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009978 }
9979
9980 @Override
9981 public int hashCode() {
9982 return mHashCode;
9983 }
9984 }
9985
9986 /**
9987 * Determine if two intents are the same for the purposes of intent
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009988 * resolution (filtering). That is, if their action, data, type, identity,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009989 * class, and categories are the same. This does <em>not</em> compare
Dianne Hackborn3c2758d2019-04-11 13:18:58 -07009990 * any extra data included in the intents. Note that technically when actually
9991 * matching against an {@link IntentFilter} the identifier is ignored, while here
9992 * it is directly compared for equality like the other fields.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009993 *
9994 * @param other The other Intent to compare against.
9995 *
9996 * @return Returns true if action, data, type, class, and categories
9997 * are the same.
9998 */
9999 public boolean filterEquals(Intent other) {
10000 if (other == null) {
10001 return false;
10002 }
Christopher Tate63d9ae12014-06-19 19:07:26 -070010003 if (!Objects.equals(this.mAction, other.mAction)) return false;
10004 if (!Objects.equals(this.mData, other.mData)) return false;
10005 if (!Objects.equals(this.mType, other.mType)) return false;
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010006 if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
Christopher Tate63d9ae12014-06-19 19:07:26 -070010007 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
10008 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
10009 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010010
10011 return true;
10012 }
10013
10014 /**
10015 * Generate hash code that matches semantics of filterEquals().
10016 *
10017 * @return Returns the hash value of the action, data, type, class, and
10018 * categories.
10019 *
10020 * @see #filterEquals
10021 */
10022 public int filterHashCode() {
10023 int code = 0;
10024 if (mAction != null) {
10025 code += mAction.hashCode();
10026 }
10027 if (mData != null) {
10028 code += mData.hashCode();
10029 }
10030 if (mType != null) {
10031 code += mType.hashCode();
10032 }
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010033 if (mIdentifier != null) {
10034 code += mIdentifier.hashCode();
10035 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010036 if (mPackage != null) {
10037 code += mPackage.hashCode();
10038 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010039 if (mComponent != null) {
10040 code += mComponent.hashCode();
10041 }
10042 if (mCategories != null) {
10043 code += mCategories.hashCode();
10044 }
10045 return code;
10046 }
10047
10048 @Override
10049 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010050 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010051
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010052 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010053 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010054 b.append(" }");
10055
10056 return b.toString();
10057 }
10058
10059 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010060 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010061 public String toInsecureString() {
10062 StringBuilder b = new StringBuilder(128);
10063
10064 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010065 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010066 b.append(" }");
10067
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010068 return b.toString();
10069 }
Romain Guy4969af72009-06-17 10:53:19 -070010070
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010071 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010072 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010073 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010074
10075 b.append("Intent { ");
10076 toShortString(b, false, true, true, true);
10077 b.append(" }");
10078
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010079 return b.toString();
10080 }
10081
10082 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010083 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
10084 StringBuilder b = new StringBuilder(128);
10085 toShortString(b, secure, comp, extras, clip);
10086 return b.toString();
10087 }
10088
10089 /** @hide */
10090 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
10091 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010092 boolean first = true;
10093 if (mAction != null) {
10094 b.append("act=").append(mAction);
10095 first = false;
10096 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010097 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010098 if (!first) {
10099 b.append(' ');
10100 }
10101 first = false;
10102 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010103 for (int i=0; i<mCategories.size(); i++) {
10104 if (i > 0) b.append(',');
10105 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010106 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010107 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010108 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010109 if (mData != null) {
10110 if (!first) {
10111 b.append(' ');
10112 }
10113 first = false;
Wink Savillea4288072010-10-12 12:36:38 -070010114 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -070010115 if (secure) {
10116 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -070010117 } else {
10118 b.append(mData);
10119 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010120 }
10121 if (mType != null) {
10122 if (!first) {
10123 b.append(' ');
10124 }
10125 first = false;
10126 b.append("typ=").append(mType);
10127 }
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010128 if (mIdentifier != null) {
10129 if (!first) {
10130 b.append(' ');
10131 }
10132 first = false;
10133 b.append("id=").append(mIdentifier);
10134 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010135 if (mFlags != 0) {
10136 if (!first) {
10137 b.append(' ');
10138 }
10139 first = false;
10140 b.append("flg=0x").append(Integer.toHexString(mFlags));
10141 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010142 if (mPackage != null) {
10143 if (!first) {
10144 b.append(' ');
10145 }
10146 first = false;
10147 b.append("pkg=").append(mPackage);
10148 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010149 if (comp && mComponent != null) {
10150 if (!first) {
10151 b.append(' ');
10152 }
10153 first = false;
10154 b.append("cmp=").append(mComponent.flattenToShortString());
10155 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010156 if (mSourceBounds != null) {
10157 if (!first) {
10158 b.append(' ');
10159 }
10160 first = false;
10161 b.append("bnds=").append(mSourceBounds.toShortString());
10162 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010163 if (mClipData != null) {
10164 if (!first) {
10165 b.append(' ');
10166 }
Dianne Hackbornae498722015-08-14 13:29:47 -070010167 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010168 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010169 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010170 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -070010171 if (mClipData.getDescription() != null) {
10172 first = !mClipData.getDescription().toShortStringTypesOnly(b);
10173 } else {
10174 first = true;
10175 }
10176 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010177 }
Dianne Hackbornae498722015-08-14 13:29:47 -070010178 first = false;
10179 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010180 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010181 if (extras && mExtras != null) {
10182 if (!first) {
10183 b.append(' ');
10184 }
10185 first = false;
10186 b.append("(has extras)");
10187 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010188 if (mContentUserHint != UserHandle.USER_CURRENT) {
10189 if (!first) {
10190 b.append(' ');
10191 }
10192 first = false;
10193 b.append("u=").append(mContentUserHint);
10194 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010195 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010196 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010197 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010198 b.append("}");
10199 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010200 }
10201
Yi Jin129fc6c2017-09-28 15:48:38 -070010202 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -080010203 public void writeToProto(ProtoOutputStream proto, long fieldId) {
10204 // Same input parameters that toString() gives to toShortString().
10205 writeToProto(proto, fieldId, true, true, true, false);
10206 }
10207
10208 /** @hide */
Igor Murashkine9e439a2019-01-22 13:12:06 -080010209 public void writeToProto(ProtoOutputStream proto) {
10210 // Same input parameters that toString() gives to toShortString().
10211 writeToProtoWithoutFieldId(proto, true, true, true, false);
10212 }
10213
10214 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -070010215 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10216 boolean extras, boolean clip) {
10217 long token = proto.start(fieldId);
Igor Murashkine9e439a2019-01-22 13:12:06 -080010218 writeToProtoWithoutFieldId(proto, secure, comp, extras, clip);
10219 proto.end(token);
10220 }
10221
10222 private void writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10223 boolean extras, boolean clip) {
Yi Jin129fc6c2017-09-28 15:48:38 -070010224 if (mAction != null) {
10225 proto.write(IntentProto.ACTION, mAction);
10226 }
10227 if (mCategories != null) {
10228 for (String category : mCategories) {
10229 proto.write(IntentProto.CATEGORIES, category);
10230 }
10231 }
10232 if (mData != null) {
10233 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10234 }
10235 if (mType != null) {
10236 proto.write(IntentProto.TYPE, mType);
10237 }
Dianne Hackborn100838d2019-04-19 12:39:26 -070010238 if (mIdentifier != null) {
10239 proto.write(IntentProto.IDENTIFIER, mIdentifier);
10240 }
Yi Jin129fc6c2017-09-28 15:48:38 -070010241 if (mFlags != 0) {
10242 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10243 }
10244 if (mPackage != null) {
10245 proto.write(IntentProto.PACKAGE, mPackage);
10246 }
10247 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -080010248 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -070010249 }
10250 if (mSourceBounds != null) {
10251 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10252 }
10253 if (mClipData != null) {
10254 StringBuilder b = new StringBuilder();
10255 if (clip) {
10256 mClipData.toShortString(b);
10257 } else {
10258 mClipData.toShortStringShortItems(b, false);
10259 }
10260 proto.write(IntentProto.CLIP_DATA, b.toString());
10261 }
10262 if (extras && mExtras != null) {
10263 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10264 }
10265 if (mContentUserHint != 0) {
10266 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10267 }
10268 if (mSelector != null) {
10269 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10270 }
Yi Jin129fc6c2017-09-28 15:48:38 -070010271 }
10272
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010273 /**
10274 * Call {@link #toUri} with 0 flags.
10275 * @deprecated Use {@link #toUri} instead.
10276 */
10277 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010278 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010279 return toUri(0);
10280 }
10281
10282 /**
10283 * Convert this Intent into a String holding a URI representation of it.
10284 * The returned URI string has been properly URI encoded, so it can be
10285 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
10286 * Intent's data as the base URI, with an additional fragment describing
10287 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -080010288 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010289 * <p>You can convert the returned string back to an Intent with
10290 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -080010291 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010292 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -080010293 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010294 * @return Returns a URI encoding URI string describing the entire contents
10295 * of the Intent.
10296 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010297 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010298 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010299 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10300 if (mPackage == null) {
10301 throw new IllegalArgumentException(
10302 "Intent must include an explicit package name to build an android-app: "
10303 + this);
10304 }
10305 uri.append("android-app://");
10306 uri.append(mPackage);
10307 String scheme = null;
10308 if (mData != null) {
10309 scheme = mData.getScheme();
10310 if (scheme != null) {
10311 uri.append('/');
10312 uri.append(scheme);
10313 String authority = mData.getEncodedAuthority();
10314 if (authority != null) {
10315 uri.append('/');
10316 uri.append(authority);
10317 String path = mData.getEncodedPath();
10318 if (path != null) {
10319 uri.append(path);
10320 }
10321 String queryParams = mData.getEncodedQuery();
10322 if (queryParams != null) {
10323 uri.append('?');
10324 uri.append(queryParams);
10325 }
10326 String fragment = mData.getEncodedFragment();
10327 if (fragment != null) {
10328 uri.append('#');
10329 uri.append(fragment);
10330 }
10331 }
10332 }
10333 }
10334 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10335 mPackage, flags);
10336 return uri.toString();
10337 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010338 String scheme = null;
10339 if (mData != null) {
10340 String data = mData.toString();
10341 if ((flags&URI_INTENT_SCHEME) != 0) {
10342 final int N = data.length();
10343 for (int i=0; i<N; i++) {
10344 char c = data.charAt(i);
10345 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -070010346 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010347 continue;
10348 }
10349 if (c == ':' && i > 0) {
10350 // Valid scheme.
10351 scheme = data.substring(0, i);
10352 uri.append("intent:");
10353 data = data.substring(i+1);
10354 break;
10355 }
Tom Taylord4a47292009-12-21 13:59:18 -080010356
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010357 // No scheme.
10358 break;
10359 }
10360 }
10361 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -080010362
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010363 } else if ((flags&URI_INTENT_SCHEME) != 0) {
10364 uri.append("intent:");
10365 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010366
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010367 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010368
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010369 return uri.toString();
10370 }
10371
10372 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10373 String defPackage, int flags) {
10374 StringBuilder frag = new StringBuilder(128);
10375
10376 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010377 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -080010378 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010379 // Note that for now we are not going to try to handle the
10380 // data part; not clear how to represent this as a URI, and
10381 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010382 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10383 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010384 }
10385
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010386 if (frag.length() > 0) {
10387 uri.append("#Intent;");
10388 uri.append(frag);
10389 uri.append("end");
10390 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010391 }
10392
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010393 private void toUriInner(StringBuilder uri, String scheme, String defAction,
10394 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010395 if (scheme != null) {
10396 uri.append("scheme=").append(scheme).append(';');
10397 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010398 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010399 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010400 }
10401 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010402 for (int i=0; i<mCategories.size(); i++) {
10403 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010404 }
10405 }
10406 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010407 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010408 }
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010409 if (mIdentifier != null) {
10410 uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
10411 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010412 if (mFlags != 0) {
10413 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10414 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010415 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010416 uri.append("package=").append(Uri.encode(mPackage)).append(';');
10417 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010418 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010419 uri.append("component=").append(Uri.encode(
10420 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010421 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010422 if (mSourceBounds != null) {
10423 uri.append("sourceBounds=")
10424 .append(Uri.encode(mSourceBounds.flattenToString()))
10425 .append(';');
10426 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010427 if (mExtras != null) {
10428 for (String key : mExtras.keySet()) {
10429 final Object value = mExtras.get(key);
10430 char entryType =
10431 value instanceof String ? 'S' :
10432 value instanceof Boolean ? 'B' :
10433 value instanceof Byte ? 'b' :
10434 value instanceof Character ? 'c' :
10435 value instanceof Double ? 'd' :
10436 value instanceof Float ? 'f' :
10437 value instanceof Integer ? 'i' :
10438 value instanceof Long ? 'l' :
10439 value instanceof Short ? 's' :
10440 '\0';
10441
10442 if (entryType != '\0') {
10443 uri.append(entryType);
10444 uri.append('.');
10445 uri.append(Uri.encode(key));
10446 uri.append('=');
10447 uri.append(Uri.encode(value.toString()));
10448 uri.append(';');
10449 }
10450 }
10451 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010452 }
The Android Open Source Project10592532009-03-18 17:39:46 -070010453
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010454 public int describeContents() {
10455 return (mExtras != null) ? mExtras.describeContents() : 0;
10456 }
10457
10458 public void writeToParcel(Parcel out, int flags) {
10459 out.writeString(mAction);
10460 Uri.writeToParcel(out, mData);
10461 out.writeString(mType);
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010462 out.writeString(mIdentifier);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010463 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010464 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010465 ComponentName.writeToParcel(mComponent, out);
10466
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010467 if (mSourceBounds != null) {
10468 out.writeInt(1);
10469 mSourceBounds.writeToParcel(out, flags);
10470 } else {
10471 out.writeInt(0);
10472 }
10473
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010474 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010475 final int N = mCategories.size();
10476 out.writeInt(N);
10477 for (int i=0; i<N; i++) {
10478 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010479 }
10480 } else {
10481 out.writeInt(0);
10482 }
10483
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010484 if (mSelector != null) {
10485 out.writeInt(1);
10486 mSelector.writeToParcel(out, flags);
10487 } else {
10488 out.writeInt(0);
10489 }
10490
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010491 if (mClipData != null) {
10492 out.writeInt(1);
10493 mClipData.writeToParcel(out, flags);
10494 } else {
10495 out.writeInt(0);
10496 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010497 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010498 out.writeBundle(mExtras);
10499 }
10500
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070010501 public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010502 = new Parcelable.Creator<Intent>() {
10503 public Intent createFromParcel(Parcel in) {
10504 return new Intent(in);
10505 }
10506 public Intent[] newArray(int size) {
10507 return new Intent[size];
10508 }
10509 };
10510
Dianne Hackborneb034652009-09-07 00:49:58 -070010511 /** @hide */
10512 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010513 readFromParcel(in);
10514 }
10515
10516 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010517 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010518 mData = Uri.CREATOR.createFromParcel(in);
10519 mType = in.readString();
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010520 mIdentifier = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010521 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010522 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010523 mComponent = ComponentName.readFromParcel(in);
10524
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010525 if (in.readInt() != 0) {
10526 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10527 }
10528
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010529 int N = in.readInt();
10530 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010531 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010532 int i;
10533 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010534 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010535 }
10536 } else {
10537 mCategories = null;
10538 }
10539
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010540 if (in.readInt() != 0) {
10541 mSelector = new Intent(in);
10542 }
10543
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010544 if (in.readInt() != 0) {
10545 mClipData = new ClipData(in);
10546 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010547 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010548 mExtras = in.readBundle();
10549 }
10550
10551 /**
10552 * Parses the "intent" element (and its children) from XML and instantiates
10553 * an Intent object. The given XML parser should be located at the tag
10554 * where parsing should start (often named "intent"), from which the
10555 * basic action, data, type, and package and class name will be
10556 * retrieved. The function will then parse in to any child elements,
10557 * looking for <category android:name="xxx"> tags to add categories and
10558 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10559 * to the intent.
10560 *
10561 * @param resources The Resources to use when inflating resources.
10562 * @param parser The XML parser pointing at an "intent" tag.
10563 * @param attrs The AttributeSet interface for retrieving extended
10564 * attribute data at the current <var>parser</var> location.
10565 * @return An Intent object matching the XML data.
10566 * @throws XmlPullParserException If there was an XML parsing error.
10567 * @throws IOException If there was an I/O error.
10568 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010569 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10570 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010571 throws XmlPullParserException, IOException {
10572 Intent intent = new Intent();
10573
10574 TypedArray sa = resources.obtainAttributes(attrs,
10575 com.android.internal.R.styleable.Intent);
10576
10577 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10578
10579 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10580 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10581 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10582
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010583 intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
10584
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010585 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10586 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10587 if (packageName != null && className != null) {
10588 intent.setComponent(new ComponentName(packageName, className));
10589 }
10590
10591 sa.recycle();
10592
10593 int outerDepth = parser.getDepth();
10594 int type;
10595 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10596 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10597 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10598 continue;
10599 }
10600
10601 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010602 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010603 sa = resources.obtainAttributes(attrs,
10604 com.android.internal.R.styleable.IntentCategory);
10605 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10606 sa.recycle();
10607
10608 if (cat != null) {
10609 intent.addCategory(cat);
10610 }
10611 XmlUtils.skipCurrentTag(parser);
10612
Craig Mautner21d24a22014-04-23 11:45:37 -070010613 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010614 if (intent.mExtras == null) {
10615 intent.mExtras = new Bundle();
10616 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010617 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010618 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010619
10620 } else {
10621 XmlUtils.skipCurrentTag(parser);
10622 }
10623 }
10624
10625 return intent;
10626 }
Nick Pellyccae4122012-01-09 14:12:58 -080010627
Craig Mautner21d24a22014-04-23 11:45:37 -070010628 /** @hide */
10629 public void saveToXml(XmlSerializer out) throws IOException {
10630 if (mAction != null) {
10631 out.attribute(null, ATTR_ACTION, mAction);
10632 }
10633 if (mData != null) {
10634 out.attribute(null, ATTR_DATA, mData.toString());
10635 }
10636 if (mType != null) {
10637 out.attribute(null, ATTR_TYPE, mType);
10638 }
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010639 if (mIdentifier != null) {
10640 out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
10641 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010642 if (mComponent != null) {
10643 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10644 }
10645 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10646
10647 if (mCategories != null) {
10648 out.startTag(null, TAG_CATEGORIES);
10649 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10650 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10651 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010652 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010653 }
10654 }
10655
10656 /** @hide */
10657 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10658 XmlPullParserException {
10659 Intent intent = new Intent();
10660 final int outerDepth = in.getDepth();
10661
10662 int attrCount = in.getAttributeCount();
10663 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10664 final String attrName = in.getAttributeName(attrNdx);
10665 final String attrValue = in.getAttributeValue(attrNdx);
10666 if (ATTR_ACTION.equals(attrName)) {
10667 intent.setAction(attrValue);
10668 } else if (ATTR_DATA.equals(attrName)) {
10669 intent.setData(Uri.parse(attrValue));
10670 } else if (ATTR_TYPE.equals(attrName)) {
10671 intent.setType(attrValue);
Dianne Hackborn3c2758d2019-04-11 13:18:58 -070010672 } else if (ATTR_IDENTIFIER.equals(attrName)) {
10673 intent.setIdentifier(attrValue);
Craig Mautner21d24a22014-04-23 11:45:37 -070010674 } else if (ATTR_COMPONENT.equals(attrName)) {
10675 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10676 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010677 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010678 } else {
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060010679 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
Craig Mautner21d24a22014-04-23 11:45:37 -070010680 }
10681 }
10682
10683 int event;
10684 String name;
10685 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10686 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10687 if (event == XmlPullParser.START_TAG) {
10688 name = in.getName();
10689 if (TAG_CATEGORIES.equals(name)) {
10690 attrCount = in.getAttributeCount();
10691 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10692 intent.addCategory(in.getAttributeValue(attrNdx));
10693 }
10694 } else {
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060010695 Log.w(TAG, "restoreFromXml: unknown name=" + name);
Craig Mautner21d24a22014-04-23 11:45:37 -070010696 XmlUtils.skipCurrentTag(in);
10697 }
10698 }
10699 }
10700
10701 return intent;
10702 }
10703
Nick Pellyccae4122012-01-09 14:12:58 -080010704 /**
10705 * Normalize a MIME data type.
10706 *
10707 * <p>A normalized MIME type has white-space trimmed,
10708 * content-type parameters removed, and is lower-case.
10709 * This aligns the type with Android best practices for
10710 * intent filtering.
10711 *
10712 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10713 * "text/x-vCard" becomes "text/x-vcard".
10714 *
10715 * <p>All MIME types received from outside Android (such as user input,
10716 * or external sources like Bluetooth, NFC, or the Internet) should
10717 * be normalized before they are used to create an Intent.
10718 *
10719 * @param type MIME data type to normalize
10720 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010721 * @see #setType
10722 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010724 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010725 if (type == null) {
10726 return null;
10727 }
10728
Elliott Hughescb64d432013-08-02 10:00:44 -070010729 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010730
10731 final int semicolonIndex = type.indexOf(';');
10732 if (semicolonIndex != -1) {
10733 type = type.substring(0, semicolonIndex);
10734 }
10735 return type;
10736 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010737
10738 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010739 * Prepare this {@link Intent} to leave an app process.
10740 *
10741 * @hide
10742 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010743 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010744 public void prepareToLeaveProcess(Context context) {
10745 final boolean leavingPackage = (mComponent == null)
10746 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10747 prepareToLeaveProcess(leavingPackage);
10748 }
10749
10750 /**
10751 * Prepare this {@link Intent} to leave an app process.
10752 *
10753 * @hide
10754 */
10755 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010756 setAllowFds(false);
10757
10758 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010759 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010760 }
10761 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010762 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010763 }
10764
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010765 if (mExtras != null && !mExtras.isParcelled()) {
10766 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10767 if (intent instanceof Intent) {
10768 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10769 }
10770 }
10771
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010772 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10773 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010774 switch (mAction) {
10775 case ACTION_MEDIA_REMOVED:
10776 case ACTION_MEDIA_UNMOUNTED:
10777 case ACTION_MEDIA_CHECKING:
10778 case ACTION_MEDIA_NOFS:
10779 case ACTION_MEDIA_MOUNTED:
10780 case ACTION_MEDIA_SHARED:
10781 case ACTION_MEDIA_UNSHARED:
10782 case ACTION_MEDIA_BAD_REMOVAL:
10783 case ACTION_MEDIA_UNMOUNTABLE:
10784 case ACTION_MEDIA_EJECT:
10785 case ACTION_MEDIA_SCANNER_STARTED:
10786 case ACTION_MEDIA_SCANNER_FINISHED:
10787 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010788 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10789 case ACTION_PACKAGE_VERIFIED:
Richard Uhlerb29f1452018-09-12 16:38:15 +010010790 case ACTION_PACKAGE_ENABLE_ROLLBACK:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010791 // Ignore legacy actions
10792 break;
10793 default:
10794 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010795 }
10796 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010797
10798 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10799 && leavingPackage) {
10800 switch (mAction) {
10801 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010802 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010803 // Ignore actions that don't need to grant
10804 break;
10805 default:
10806 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10807 }
10808 }
Jeff Sharkey9c9ee952019-03-22 17:18:38 -060010809
10810 // Translate raw filesystem paths out of storage sandbox
10811 if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
10812 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
10813 final StorageManager sm = AppGlobals.getInitialApplication()
10814 .getSystemService(StorageManager.class);
10815 final File before = new File(mData.getPath());
10816 final File after = sm.translateAppToSystem(before,
10817 android.os.Process.myPid(), android.os.Process.myUid());
10818 if (!Objects.equals(before, after)) {
10819 Log.v(TAG, "Translated " + before + " to " + after);
10820 mData = Uri.fromFile(after);
10821 }
10822 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010823 }
10824
10825 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010826 * @hide
10827 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010828 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010829 // We just entered destination process, so we should be able to read all
10830 // parcelables inside.
10831 setDefusable(true);
10832
10833 if (mSelector != null) {
10834 mSelector.prepareToEnterProcess();
10835 }
10836 if (mClipData != null) {
10837 mClipData.prepareToEnterProcess();
10838 }
10839
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010840 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010841 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10842 fixUris(mContentUserHint);
10843 mContentUserHint = UserHandle.USER_CURRENT;
10844 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010845 }
10846 }
10847
Patrick Baumann577d4022018-01-31 16:55:10 +000010848 /** @hide */
10849 public boolean hasWebURI() {
10850 if (getData() == null) {
10851 return false;
10852 }
10853 final String scheme = getScheme();
10854 if (TextUtils.isEmpty(scheme)) {
10855 return false;
10856 }
10857 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10858 }
10859
10860 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010861 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010862 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010863 && hasWebURI();
10864 }
10865
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010866 /**
10867 * @hide
10868 */
10869 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010870 Uri data = getData();
10871 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010872 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010873 }
10874 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010875 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010876 }
10877 String action = getAction();
10878 if (ACTION_SEND.equals(action)) {
10879 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10880 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010881 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010882 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010883 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010884 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10885 if (streams != null) {
10886 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10887 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010888 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010889 }
10890 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10891 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010892 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10893 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10894 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10895 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10896 if (output != null) {
10897 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10898 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010899 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010900 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010901
10902 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010903 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010904 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10905 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010906 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010907 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010908 * @hide
10909 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010910 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010911 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010912 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010913
10914 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010915 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010916
10917 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010918 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010919 // Inspect contained intents to see if we need to migrate extras. We
10920 // don't promote ClipData to the parent, since ChooserActivity will
10921 // already start the picked item as the caller, and we can't combine
10922 // the flags in a safe way.
10923
10924 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010925 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010926 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10927 if (intent != null) {
10928 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010929 }
10930 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010931 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010932 try {
10933 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10934 if (intents != null) {
10935 for (int i = 0; i < intents.length; i++) {
10936 final Intent intent = (Intent) intents[i];
10937 if (intent != null) {
10938 migrated |= intent.migrateExtraStreamToClipData();
10939 }
10940 }
10941 }
10942 } catch (ClassCastException e) {
10943 }
10944 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010945
10946 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010947 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010948 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10949 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10950 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10951 if (stream != null || text != null || htmlText != null) {
10952 final ClipData clipData = new ClipData(
10953 null, new String[] { getType() },
10954 new ClipData.Item(text, htmlText, null, stream));
10955 setClipData(clipData);
10956 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010957 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010958 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010959 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010960 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010961
10962 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010963 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010964 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10965 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10966 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10967 int num = -1;
10968 if (streams != null) {
10969 num = streams.size();
10970 }
10971 if (texts != null) {
10972 if (num >= 0 && num != texts.size()) {
10973 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010974 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010975 }
10976 num = texts.size();
10977 }
10978 if (htmlTexts != null) {
10979 if (num >= 0 && num != htmlTexts.size()) {
10980 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010981 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010982 }
10983 num = htmlTexts.size();
10984 }
10985 if (num > 0) {
10986 final ClipData clipData = new ClipData(
10987 null, new String[] { getType() },
10988 makeClipItem(streams, texts, htmlTexts, 0));
10989
10990 for (int i = 1; i < num; i++) {
10991 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10992 }
10993
10994 setClipData(clipData);
10995 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010996 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010997 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010998 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010999 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010011000 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
11001 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
11002 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
11003 final Uri output;
11004 try {
11005 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11006 } catch (ClassCastException e) {
11007 return false;
11008 }
11009 if (output != null) {
11010 setClipData(ClipData.newRawUri("", output));
11011 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
11012 return true;
11013 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070011014 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070011015
11016 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070011017 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070011018
Michael Wright19859762017-09-18 20:57:58 +010011019 /**
11020 * Convert the dock state to a human readable format.
11021 * @hide
11022 */
11023 public static String dockStateToString(int dock) {
11024 switch (dock) {
11025 case EXTRA_DOCK_STATE_HE_DESK:
11026 return "EXTRA_DOCK_STATE_HE_DESK";
11027 case EXTRA_DOCK_STATE_LE_DESK:
11028 return "EXTRA_DOCK_STATE_LE_DESK";
11029 case EXTRA_DOCK_STATE_CAR:
11030 return "EXTRA_DOCK_STATE_CAR";
11031 case EXTRA_DOCK_STATE_DESK:
11032 return "EXTRA_DOCK_STATE_DESK";
11033 case EXTRA_DOCK_STATE_UNDOCKED:
11034 return "EXTRA_DOCK_STATE_UNDOCKED";
11035 default:
11036 return Integer.toString(dock);
11037 }
11038 }
11039
Dianne Hackbornac4243f2012-04-13 17:32:18 -070011040 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
11041 ArrayList<String> htmlTexts, int which) {
11042 Uri uri = streams != null ? streams.get(which) : null;
11043 CharSequence text = texts != null ? texts.get(which) : null;
11044 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
11045 return new ClipData.Item(text, htmlText, null, uri);
11046 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070011047
11048 /** @hide */
11049 public boolean isDocument() {
11050 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
11051 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070011052}