blob: a5e7e95f08748d0dc67e6da0d834a6e0e4bc58f7 [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;
Mathew Inwood5c0d3542018-08-14 13:54:31 +010030import android.annotation.UnsupportedAppUsage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070031import android.content.pm.ActivityInfo;
Jason Monk2f68e8a2016-02-23 17:57:28 -050032import android.content.pm.ApplicationInfo;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060033import android.content.pm.ComponentInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070034import android.content.pm.PackageManager;
35import android.content.pm.ResolveInfo;
Mehdi Alizadeh406e8b32018-12-11 18:21:49 -080036import android.content.pm.ShortcutInfo;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070037import android.content.res.Resources;
38import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080039import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070040import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060041import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070042import android.os.Bundle;
43import android.os.IBinder;
44import android.os.Parcel;
45import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070046import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000047import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050048import android.os.ResultReceiver;
49import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070050import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010051import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070052import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070053import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070054import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050055import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070056import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000057import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050058import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070059import android.util.AttributeSet;
60import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070061import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070062
Dianne Hackborn2269d1572010-02-24 19:54:22 -080063import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070064
Jason Monk2f68e8a2016-02-23 17:57:28 -050065import org.xmlpull.v1.XmlPullParser;
66import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070067import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070068
69import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080070import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070071import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070072import java.lang.annotation.Retention;
73import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070074import java.net.URISyntaxException;
75import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080076import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070077import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080078import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070079import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070080import java.util.Set;
81
82/**
83 * An intent is an abstract description of an operation to be performed. It
84 * can be used with {@link Context#startActivity(Intent) startActivity} to
85 * launch an {@link android.app.Activity},
86 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
87 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
88 * and {@link android.content.Context#startService} or
89 * {@link android.content.Context#bindService} to communicate with a
90 * background {@link android.app.Service}.
91 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070092 * <p>An Intent provides a facility for performing late runtime binding between the code in
93 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070094 * can be thought of as the glue between activities. It is basically a passive data structure
95 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070096 *
97 * <div class="special reference">
98 * <h3>Developer Guides</h3>
99 * <p>For information about how to create and resolve intents, read the
100 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
101 * developer guide.</p>
102 * </div>
103 *
104 * <a name="IntentStructure"></a>
105 * <h3>Intent Structure</h3>
106 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700107 *
108 * <ul>
109 * <li> <p><b>action</b> -- The general action to be performed, such as
110 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
111 * etc.</p>
112 * </li>
113 * <li> <p><b>data</b> -- The data to operate on, such as a person record
114 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
115 * </li>
116 * </ul>
117 *
118 *
119 * <p>Some examples of action/data pairs are:</p>
120 *
121 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700122 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700123 * information about the person whose identifier is "1".</p>
124 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700125 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700126 * the phone dialer with the person filled in.</p>
127 * </li>
128 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
129 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700130 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700131 * a particular URI.</p>
132 * </li>
133 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
134 * the phone dialer with the given number filled in.</p>
135 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700136 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700137 * information about the person whose identifier is "1".</p>
138 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700139 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700140 * a list of people, which the user can browse through. This example is a
141 * typical top-level entry into the Contacts application, showing you the
142 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700143 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700144 * being used to start an activity to display that person.</p>
145 * </li>
146 * </ul>
147 *
148 * <p>In addition to these primary attributes, there are a number of secondary
149 * attributes that you can also include with an intent:</p>
150 *
151 * <ul>
152 * <li> <p><b>category</b> -- Gives additional information about the action
153 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
154 * appear in the Launcher as a top-level application, while
155 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
156 * of alternative actions the user can perform on a piece of data.</p>
157 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
158 * intent data. Normally the type is inferred from the data itself.
159 * By setting this attribute, you disable that evaluation and force
160 * an explicit type.</p>
161 * <li> <p><b>component</b> -- Specifies an explicit name of a component
162 * class to use for the intent. Normally this is determined by looking
163 * at the other information in the intent (the action, data/type, and
164 * categories) and matching that with a component that can handle it.
165 * If this attribute is set then none of the evaluation is performed,
166 * and this component is used exactly as is. By specifying this attribute,
167 * all of the other Intent attributes become optional.</p>
168 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
169 * This can be used to provide extended information to the component.
170 * For example, if we have a action to send an e-mail message, we could
171 * also include extra pieces of data here to supply a subject, body,
172 * etc.</p>
173 * </ul>
174 *
175 * <p>Here are some examples of other operations you can specify as intents
176 * using these additional parameters:</p>
177 *
178 * <ul>
179 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
180 * Launch the home screen.</p>
181 * </li>
182 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
183 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
184 * vnd.android.cursor.item/phone}</i></b>
185 * -- Display the list of people's phone numbers, allowing the user to
186 * browse through them and pick one and return it to the parent activity.</p>
187 * </li>
188 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
189 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
190 * -- Display all pickers for data that can be opened with
191 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
192 * allowing the user to pick one of them and then some data inside of it
193 * and returning the resulting URI to the caller. This can be used,
194 * for example, in an e-mail application to allow the user to pick some
195 * data to include as an attachment.</p>
196 * </li>
197 * </ul>
198 *
199 * <p>There are a variety of standard Intent action and category constants
200 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700201 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700202 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700203 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700204 *
205 * <p>Put together, the set of actions, data types, categories, and extra data
206 * defines a language for the system allowing for the expression of phrases
207 * such as "call john smith's cell". As applications are added to the system,
208 * they can extend this language by adding new actions, types, and categories, or
209 * they can modify the behavior of existing phrases by supplying their own
210 * activities that handle them.</p>
211 *
212 * <a name="IntentResolution"></a>
213 * <h3>Intent Resolution</h3>
214 *
215 * <p>There are two primary forms of intents you will use.
216 *
217 * <ul>
218 * <li> <p><b>Explicit Intents</b> have specified a component (via
219 * {@link #setComponent} or {@link #setClass}), which provides the exact
220 * class to be run. Often these will not include any other information,
221 * simply being a way for an application to launch various internal
222 * activities it has as the user interacts with the application.
223 *
224 * <li> <p><b>Implicit Intents</b> have not specified a component;
225 * instead, they must include enough information for the system to
226 * determine which of the available components is best to run for that
227 * intent.
228 * </ul>
229 *
230 * <p>When using implicit intents, given such an arbitrary intent we need to
231 * know what to do with it. This is handled by the process of <em>Intent
232 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
233 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
234 * more activities/receivers) that can handle it.</p>
235 *
236 * <p>The intent resolution mechanism basically revolves around matching an
237 * Intent against all of the &lt;intent-filter&gt; descriptions in the
238 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
239 * objects explicitly registered with {@link Context#registerReceiver}.) More
240 * details on this can be found in the documentation on the {@link
241 * IntentFilter} class.</p>
242 *
243 * <p>There are three pieces of information in the Intent that are used for
244 * resolution: the action, type, and category. Using this information, a query
245 * is done on the {@link PackageManager} for a component that can handle the
246 * intent. The appropriate component is determined based on the intent
247 * information supplied in the <code>AndroidManifest.xml</code> file as
248 * follows:</p>
249 *
250 * <ul>
251 * <li> <p>The <b>action</b>, if given, must be listed by the component as
252 * one it handles.</p>
253 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
254 * already supplied in the Intent. Like the action, if a type is
255 * included in the intent (either explicitly or implicitly in its
256 * data), then this must be listed by the component as one it handles.</p>
257 * <li> For data that is not a <code>content:</code> URI and where no explicit
258 * type is included in the Intent, instead the <b>scheme</b> of the
259 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
260 * considered. Again like the action, if we are matching a scheme it
261 * must be listed by the component as one it can handle.
262 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
263 * by the activity as categories it handles. That is, if you include
264 * the categories {@link #CATEGORY_LAUNCHER} and
265 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
266 * with an intent that lists <em>both</em> of those categories.
267 * Activities will very often need to support the
268 * {@link #CATEGORY_DEFAULT} so that they can be found by
269 * {@link Context#startActivity Context.startActivity()}.</p>
270 * </ul>
271 *
272 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700273 * allows a user to browse through a list of notes data and view details about
274 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700275 * name with one specific to your own package.</p>
276 *
277 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
278 * package="<i>com.android.notepad</i>"&gt;
279 * &lt;application android:icon="@drawable/app_notes"
280 * android:label="@string/app_name"&gt;
281 *
282 * &lt;provider class=".NotePadProvider"
283 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
284 *
285 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
286 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700287 * &lt;action android:name="android.intent.action.MAIN" /&gt;
288 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700289 * &lt;/intent-filter&gt;
290 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700291 * &lt;action android:name="android.intent.action.VIEW" /&gt;
292 * &lt;action android:name="android.intent.action.EDIT" /&gt;
293 * &lt;action android:name="android.intent.action.PICK" /&gt;
294 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
295 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&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.GET_CONTENT" /&gt;
299 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
300 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700301 * &lt;/intent-filter&gt;
302 * &lt;/activity&gt;
303 *
304 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
305 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700306 * &lt;action android:name="android.intent.action.VIEW" /&gt;
307 * &lt;action android:name="android.intent.action.EDIT" /&gt;
308 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
309 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700310 * &lt;/intent-filter&gt;
311 *
312 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700313 * &lt;action android:name="android.intent.action.INSERT" /&gt;
314 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
315 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700316 * &lt;/intent-filter&gt;
317 *
318 * &lt;/activity&gt;
319 *
320 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
321 * android:theme="@android:style/Theme.Dialog"&gt;
322 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700323 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
324 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
325 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
326 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
327 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700328 * &lt;/intent-filter&gt;
329 * &lt;/activity&gt;
330 *
331 * &lt;/application&gt;
332 * &lt;/manifest&gt;</pre>
333 *
334 * <p>The first activity,
335 * <code>com.android.notepad.NotesList</code>, serves as our main
336 * entry into the app. It can do three things as described by its three intent
337 * templates:
338 * <ol>
339 * <li><pre>
340 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700341 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
342 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700343 * &lt;/intent-filter&gt;</pre>
344 * <p>This provides a top-level entry into the NotePad application: the standard
345 * MAIN action is a main entry point (not requiring any other information in
346 * the Intent), and the LAUNCHER category says that this entry point should be
347 * listed in the application launcher.</p>
348 * <li><pre>
349 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700350 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
351 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
352 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
353 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700354 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700355 * &lt;/intent-filter&gt;</pre>
356 * <p>This declares the things that the activity can do on a directory of
357 * notes. The type being supported is given with the &lt;type&gt; tag, where
358 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
359 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
360 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
361 * The activity allows the user to view or edit the directory of data (via
362 * the VIEW and EDIT actions), or to pick a particular note and return it
363 * to the caller (via the PICK action). Note also the DEFAULT category
364 * supplied here: this is <em>required</em> for the
365 * {@link Context#startActivity Context.startActivity} method to resolve your
366 * activity when its component name is not explicitly specified.</p>
367 * <li><pre>
368 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700369 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
370 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
371 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700372 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700373 * <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 -0700374 * the user without needing to know where it came from. The data type
375 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
376 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
377 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
378 * The GET_CONTENT action is similar to the PICK action, where the activity
379 * will return to its caller a piece of data selected by the user. Here,
380 * however, the caller specifies the type of data they desire instead of
381 * the type of data the user will be picking from.</p>
382 * </ol>
383 *
384 * <p>Given these capabilities, the following intents will resolve to the
385 * NotesList activity:</p>
386 *
387 * <ul>
388 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
389 * activities that can be used as top-level entry points into an
390 * application.</p>
391 * <li> <p><b>{ action=android.app.action.MAIN,
392 * category=android.app.category.LAUNCHER }</b> is the actual intent
393 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700394 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700395 * data=content://com.google.provider.NotePad/notes }</b>
396 * displays a list of all the notes under
397 * "content://com.google.provider.NotePad/notes", which
398 * the user can browse through and see the details on.</p>
399 * <li> <p><b>{ action=android.app.action.PICK
400 * data=content://com.google.provider.NotePad/notes }</b>
401 * provides a list of the notes under
402 * "content://com.google.provider.NotePad/notes", from which
403 * the user can pick a note whose data URL is returned back to the caller.</p>
404 * <li> <p><b>{ action=android.app.action.GET_CONTENT
405 * type=vnd.android.cursor.item/vnd.google.note }</b>
406 * is similar to the pick action, but allows the caller to specify the
407 * kind of data they want back so that the system can find the appropriate
408 * activity to pick something of that data type.</p>
409 * </ul>
410 *
411 * <p>The second activity,
412 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
413 * note entry and allows them to edit it. It can do two things as described
414 * by its two intent templates:
415 * <ol>
416 * <li><pre>
417 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700418 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
419 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
420 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
421 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700422 * &lt;/intent-filter&gt;</pre>
423 * <p>The first, primary, purpose of this activity is to let the user interact
424 * with a single note, as decribed by the MIME type
425 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
426 * either VIEW a note or allow the user to EDIT it. Again we support the
427 * DEFAULT category to allow the activity to be launched without explicitly
428 * specifying its component.</p>
429 * <li><pre>
430 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700431 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
432 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
433 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700434 * &lt;/intent-filter&gt;</pre>
435 * <p>The secondary use of this activity is to insert a new note entry into
436 * an existing directory of notes. This is used when the user creates a new
437 * note: the INSERT action is executed on the directory of notes, causing
438 * this activity to run and have the user create the new note data which
439 * it then adds to the content provider.</p>
440 * </ol>
441 *
442 * <p>Given these capabilities, the following intents will resolve to the
443 * NoteEditor activity:</p>
444 *
445 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700446 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700447 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
448 * shows the user the content of note <var>{ID}</var>.</p>
449 * <li> <p><b>{ action=android.app.action.EDIT
450 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
451 * allows the user to edit the content of note <var>{ID}</var>.</p>
452 * <li> <p><b>{ action=android.app.action.INSERT
453 * data=content://com.google.provider.NotePad/notes }</b>
454 * creates a new, empty note in the notes list at
455 * "content://com.google.provider.NotePad/notes"
456 * and allows the user to edit it. If they keep their changes, the URI
457 * of the newly created note is returned to the caller.</p>
458 * </ul>
459 *
460 * <p>The last activity,
461 * <code>com.android.notepad.TitleEditor</code>, allows the user to
462 * edit the title of a note. This could be implemented as a class that the
463 * application directly invokes (by explicitly setting its component in
464 * the Intent), but here we show a way you can publish alternative
465 * operations on existing data:</p>
466 *
467 * <pre>
468 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700469 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
470 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
471 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
472 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
473 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700474 * &lt;/intent-filter&gt;</pre>
475 *
476 * <p>In the single intent template here, we
477 * have created our own private action called
478 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
479 * edit the title of a note. It must be invoked on a specific note
480 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
481 * view and edit actions, but here displays and edits the title contained
482 * in the note data.
483 *
484 * <p>In addition to supporting the default category as usual, our title editor
485 * also supports two other standard categories: ALTERNATIVE and
486 * SELECTED_ALTERNATIVE. Implementing
487 * these categories allows others to find the special action it provides
488 * without directly knowing about it, through the
489 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
490 * more often to build dynamic menu items with
491 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
492 * template here was also supply an explicit name for the template
493 * (via <code>android:label="@string/resolve_title"</code>) to better control
494 * what the user sees when presented with this activity as an alternative
495 * action to the data they are viewing.
496 *
497 * <p>Given these capabilities, the following intent will resolve to the
498 * TitleEditor activity:</p>
499 *
500 * <ul>
501 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
502 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
503 * displays and allows the user to edit the title associated
504 * with note <var>{ID}</var>.</p>
505 * </ul>
506 *
507 * <h3>Standard Activity Actions</h3>
508 *
509 * <p>These are the current standard actions that Intent defines for launching
510 * activities (usually through {@link Context#startActivity}. The most
511 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
512 * {@link #ACTION_EDIT}.
513 *
514 * <ul>
515 * <li> {@link #ACTION_MAIN}
516 * <li> {@link #ACTION_VIEW}
517 * <li> {@link #ACTION_ATTACH_DATA}
518 * <li> {@link #ACTION_EDIT}
519 * <li> {@link #ACTION_PICK}
520 * <li> {@link #ACTION_CHOOSER}
521 * <li> {@link #ACTION_GET_CONTENT}
522 * <li> {@link #ACTION_DIAL}
523 * <li> {@link #ACTION_CALL}
524 * <li> {@link #ACTION_SEND}
525 * <li> {@link #ACTION_SENDTO}
526 * <li> {@link #ACTION_ANSWER}
527 * <li> {@link #ACTION_INSERT}
528 * <li> {@link #ACTION_DELETE}
529 * <li> {@link #ACTION_RUN}
530 * <li> {@link #ACTION_SYNC}
531 * <li> {@link #ACTION_PICK_ACTIVITY}
532 * <li> {@link #ACTION_SEARCH}
533 * <li> {@link #ACTION_WEB_SEARCH}
534 * <li> {@link #ACTION_FACTORY_TEST}
535 * </ul>
536 *
537 * <h3>Standard Broadcast Actions</h3>
538 *
539 * <p>These are the current standard actions that Intent defines for receiving
540 * broadcasts (usually through {@link Context#registerReceiver} or a
541 * &lt;receiver&gt; tag in a manifest).
542 *
543 * <ul>
544 * <li> {@link #ACTION_TIME_TICK}
545 * <li> {@link #ACTION_TIME_CHANGED}
546 * <li> {@link #ACTION_TIMEZONE_CHANGED}
547 * <li> {@link #ACTION_BOOT_COMPLETED}
548 * <li> {@link #ACTION_PACKAGE_ADDED}
549 * <li> {@link #ACTION_PACKAGE_CHANGED}
550 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 * <li> {@link #ACTION_PACKAGE_RESTARTED}
552 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000553 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
554 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700555 * <li> {@link #ACTION_UID_REMOVED}
556 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700557 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700558 * <li> {@link #ACTION_POWER_DISCONNECTED}
559 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700560 * </ul>
561 *
562 * <h3>Standard Categories</h3>
563 *
564 * <p>These are the current standard categories that can be used to further
565 * clarify an Intent via {@link #addCategory}.
566 *
567 * <ul>
568 * <li> {@link #CATEGORY_DEFAULT}
569 * <li> {@link #CATEGORY_BROWSABLE}
570 * <li> {@link #CATEGORY_TAB}
571 * <li> {@link #CATEGORY_ALTERNATIVE}
572 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
573 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800574 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700575 * <li> {@link #CATEGORY_HOME}
576 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700577 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400578 * <li> {@link #CATEGORY_CAR_DOCK}
579 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500580 * <li> {@link #CATEGORY_LE_DESK_DOCK}
581 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200582 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700583 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800584 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700585 * </ul>
586 *
587 * <h3>Standard Extra Data</h3>
588 *
589 * <p>These are the current standard fields that can be used as extra data via
590 * {@link #putExtra}.
591 *
592 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800593 * <li> {@link #EXTRA_ALARM_COUNT}
594 * <li> {@link #EXTRA_BCC}
595 * <li> {@link #EXTRA_CC}
596 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
597 * <li> {@link #EXTRA_DATA_REMOVED}
598 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500599 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
600 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800601 * <li> {@link #EXTRA_DOCK_STATE_CAR}
602 * <li> {@link #EXTRA_DOCK_STATE_DESK}
603 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
604 * <li> {@link #EXTRA_DONT_KILL_APP}
605 * <li> {@link #EXTRA_EMAIL}
606 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700607 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800608 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700609 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800610 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700611 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800612 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
613 * <li> {@link #EXTRA_REPLACING}
614 * <li> {@link #EXTRA_SHORTCUT_ICON}
615 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
616 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700617 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800618 * <li> {@link #EXTRA_SHORTCUT_NAME}
619 * <li> {@link #EXTRA_SUBJECT}
620 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700621 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800622 * <li> {@link #EXTRA_TITLE}
623 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700624 * </ul>
625 *
626 * <h3>Flags</h3>
627 *
628 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800629 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
630 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700631 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800632public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700633 private static final String ATTR_ACTION = "action";
634 private static final String TAG_CATEGORIES = "categories";
635 private static final String ATTR_CATEGORY = "category";
636 private static final String TAG_EXTRA = "extra";
637 private static final String ATTR_TYPE = "type";
638 private static final String ATTR_COMPONENT = "component";
639 private static final String ATTR_DATA = "data";
640 private static final String ATTR_FLAGS = "flags";
641
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700642 // ---------------------------------------------------------------------
643 // ---------------------------------------------------------------------
644 // Standard intent activity actions (see action variable).
645
646 /**
647 * Activity Action: Start as a main entry point, does not expect to
648 * receive data.
649 * <p>Input: nothing
650 * <p>Output: nothing
651 */
652 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
653 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800654
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700655 /**
656 * Activity Action: Display the data to the user. This is the most common
657 * action performed on data -- it is the generic action you can use on
658 * a piece of data to get the most reasonable thing to occur. For example,
659 * when used on a contacts entry it will view the entry; when used on a
660 * mailto: URI it will bring up a compose window filled with the information
661 * supplied by the URI; when used with a tel: URI it will invoke the
662 * dialer.
663 * <p>Input: {@link #getData} is URI from which to retrieve data.
664 * <p>Output: nothing.
665 */
666 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
667 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800668
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700669 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700670 * Extra that can be included on activity intents coming from the storage UI
671 * when it launches sub-activities to manage various types of storage. For example,
672 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
673 * the images on the device, and in that case also include this extra to tell the
674 * app it is coming from the storage UI so should help the user manage storage of
675 * this type.
676 */
677 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
678
679 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700680 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
681 * performed on a piece of data.
682 */
683 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800684
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700685 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900686 * Activity Action: Quick view the data. Launches a quick viewer for
687 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900688 * <p>Activities handling this intent action should handle the vast majority of
689 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700690 * <p>Quick viewers must render the quick view image locally, and must not send
691 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900692 * <p>Input: {@link #getData} is a mandatory content URI of the item to
693 * preview. {@link #getClipData} contains an optional list of content URIs
694 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
695 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700696 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
697 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700698 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900699 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700700 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700701 */
702 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
703 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
704
705 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700706 * Used to indicate that some piece of data should be attached to some other
707 * place. For example, image data could be attached to a contact. It is up
708 * to the recipient to decide where the data should be attached; the intent
709 * does not specify the ultimate destination.
710 * <p>Input: {@link #getData} is URI of data to be attached.
711 * <p>Output: nothing.
712 */
713 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
714 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800715
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700716 /**
717 * Activity Action: Provide explicit editable access to the given data.
718 * <p>Input: {@link #getData} is URI of data to be edited.
719 * <p>Output: nothing.
720 */
721 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
722 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800723
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700724 /**
725 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
726 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
727 * The extras can contain type specific data to pass through to the editing/creating
728 * activity.
729 * <p>Output: The URI of the item that was picked. This must be a content:
730 * URI so that any receiver can access it.
731 */
732 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
733 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800734
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700735 /**
736 * Activity Action: Pick an item from the data, returning what was selected.
737 * <p>Input: {@link #getData} is URI containing a directory of data
738 * (vnd.android.cursor.dir/*) from which to pick an item.
739 * <p>Output: The URI of the item that was picked.
740 */
741 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
742 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800743
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700744 /**
745 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800746 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800747 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
748 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700749 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
750 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800751 * (value: ShortcutIconResource).</p>
752 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800753 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700754 * @see #EXTRA_SHORTCUT_INTENT
755 * @see #EXTRA_SHORTCUT_NAME
756 * @see #EXTRA_SHORTCUT_ICON
757 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
758 * @see android.content.Intent.ShortcutIconResource
759 */
760 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
761 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
762
763 /**
764 * The name of the extra used to define the Intent of a shortcut.
765 *
766 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800767 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700768 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800769 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700770 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
771 /**
772 * The name of the extra used to define the name of a shortcut.
773 *
774 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800775 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700776 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800777 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700778 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
779 /**
780 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
781 *
782 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800783 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700784 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800785 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700786 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
787 /**
788 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
789 *
790 * @see #ACTION_CREATE_SHORTCUT
791 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800792 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700793 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800794 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700795 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
796 "android.intent.extra.shortcut.ICON_RESOURCE";
797
798 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500799 * An activity that provides a user interface for adjusting application preferences.
800 * Optional but recommended settings for all applications which have settings.
801 */
802 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
803 public static final String ACTION_APPLICATION_PREFERENCES
804 = "android.intent.action.APPLICATION_PREFERENCES";
805
806 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700807 * Activity Action: Launch an activity showing the app information.
808 * For applications which install other applications (such as app stores), it is recommended
809 * to handle this action for providing the app information to the user.
810 *
811 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
812 * to be displayed.
813 * <p>Output: Nothing.
814 */
815 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
816 public static final String ACTION_SHOW_APP_INFO
817 = "android.intent.action.SHOW_APP_INFO";
818
819 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800820 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700821 *
822 * @see Intent#ACTION_CREATE_SHORTCUT
823 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800824 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
825 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700826 */
827 public static class ShortcutIconResource implements Parcelable {
828 /**
829 * The package name of the application containing the icon.
830 */
831 public String packageName;
832
833 /**
834 * The resource name of the icon, including package, name and type.
835 */
836 public String resourceName;
837
838 /**
839 * Creates a new ShortcutIconResource for the specified context and resource
840 * identifier.
841 *
842 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700843 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700844 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700845 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700846 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700847 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700848 ShortcutIconResource icon = new ShortcutIconResource();
849 icon.packageName = context.getPackageName();
850 icon.resourceName = context.getResources().getResourceName(resourceId);
851 return icon;
852 }
853
854 /**
855 * Used to read a ShortcutIconResource from a Parcel.
856 */
857 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
858 new Parcelable.Creator<ShortcutIconResource>() {
859
860 public ShortcutIconResource createFromParcel(Parcel source) {
861 ShortcutIconResource icon = new ShortcutIconResource();
862 icon.packageName = source.readString();
863 icon.resourceName = source.readString();
864 return icon;
865 }
866
867 public ShortcutIconResource[] newArray(int size) {
868 return new ShortcutIconResource[size];
869 }
870 };
871
872 /**
873 * No special parcel contents.
874 */
875 public int describeContents() {
876 return 0;
877 }
878
879 public void writeToParcel(Parcel dest, int flags) {
880 dest.writeString(packageName);
881 dest.writeString(resourceName);
882 }
883
884 @Override
885 public String toString() {
886 return resourceName;
887 }
888 }
889
890 /**
891 * Activity Action: Display an activity chooser, allowing the user to pick
892 * what they want to before proceeding. This can be used as an alternative
893 * to the standard activity picker that is displayed by the system when
894 * you try to start an activity with multiple possible matches, with these
895 * differences in behavior:
896 * <ul>
897 * <li>You can specify the title that will appear in the activity chooser.
898 * <li>The user does not have the option to make one of the matching
899 * activities a preferred activity, and all possible activities will
900 * always be shown even if one of them is currently marked as the
901 * preferred activity.
902 * </ul>
903 * <p>
904 * This action should be used when the user will naturally expect to
905 * select an activity in order to proceed. An example if when not to use
906 * it is when the user clicks on a "mailto:" link. They would naturally
907 * expect to go directly to their mail app, so startActivity() should be
908 * called directly: it will
909 * either launch the current preferred app, or put up a dialog allowing the
910 * user to pick an app to use and optionally marking that as preferred.
911 * <p>
912 * In contrast, if the user is selecting a menu item to send a picture
913 * they are viewing to someone else, there are many different things they
914 * may want to do at this point: send it through e-mail, upload it to a
915 * web service, etc. In this case the CHOOSER action should be used, to
916 * always present to the user a list of the things they can do, with a
917 * nice title given by the caller such as "Send this photo with:".
918 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700919 * If you need to grant URI permissions through a chooser, you must specify
920 * the permissions to be granted on the ACTION_CHOOSER Intent
921 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
922 * {@link #setClipData} to specify the URIs to be granted as well as
923 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
924 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
925 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700926 * As a convenience, an Intent of this form can be created with the
927 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700928 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700930 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
931 * and can optionally have a {@link #EXTRA_TITLE} field containing the
932 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700933 * <p>
934 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700935 */
936 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
937 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
938
939 /**
940 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
941 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700942 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
943 * target intent, also optionally supplying a title. If the target
944 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
945 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
946 * set in the returned chooser intent, with its ClipData set appropriately:
947 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500948 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700949 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700950 * @param target The Intent that the user will be selecting an activity
951 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500952 * @param title Optional title that will be displayed in the chooser,
953 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700954 * @return Return a new Intent object that you can hand to
955 * {@link Context#startActivity(Intent) Context.startActivity()} and
956 * related methods.
957 */
958 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700959 return createChooser(target, title, null);
960 }
961
962 /**
963 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
964 *
965 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
966 * target intent, also optionally supplying a title. If the target
967 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
968 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
969 * set in the returned chooser intent, with its ClipData set appropriately:
970 * either a direct reflection of {@link #getClipData()} if that is non-null,
971 * or a new ClipData built from {@link #getData()}.</p>
972 *
973 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
974 * when the user makes a choice. This can be useful if the calling application wants
975 * to remember the last chosen target and surface it as a more prominent or one-touch
976 * affordance elsewhere in the UI for next time.</p>
977 *
978 * @param target The Intent that the user will be selecting an activity
979 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500980 * @param title Optional title that will be displayed in the chooser,
981 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
Adam Powell0b3c1122014-10-09 12:50:14 -0700982 * @param sender Optional IntentSender to be called when a choice is made.
983 * @return Return a new Intent object that you can hand to
984 * {@link Context#startActivity(Intent) Context.startActivity()} and
985 * related methods.
986 */
987 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700988 Intent intent = new Intent(ACTION_CHOOSER);
989 intent.putExtra(EXTRA_INTENT, target);
990 if (title != null) {
991 intent.putExtra(EXTRA_TITLE, title);
992 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700993
Adam Powell0b3c1122014-10-09 12:50:14 -0700994 if (sender != null) {
995 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
996 }
997
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700998 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700999 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1000 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1001 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -07001002 if (permFlags != 0) {
1003 ClipData targetClipData = target.getClipData();
1004 if (targetClipData == null && target.getData() != null) {
1005 ClipData.Item item = new ClipData.Item(target.getData());
1006 String[] mimeTypes;
1007 if (target.getType() != null) {
1008 mimeTypes = new String[] { target.getType() };
1009 } else {
1010 mimeTypes = new String[] { };
1011 }
1012 targetClipData = new ClipData(null, mimeTypes, item);
1013 }
1014 if (targetClipData != null) {
1015 intent.setClipData(targetClipData);
1016 intent.addFlags(permFlags);
1017 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001018 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001019
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 return intent;
1021 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001022
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001023 /**
1024 * Activity Action: Allow the user to select a particular kind of data and
1025 * return it. This is different than {@link #ACTION_PICK} in that here we
1026 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001027 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001028 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001030 * etc.
1031 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001032 * 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 -07001033 * of data, such as a person contact, you set the MIME type to the kind of
1034 * data you want and launch it with {@link Context#startActivity(Intent)}.
1035 * The system will then launch the best application to select that kind
1036 * of data for you.
1037 * <p>
1038 * You may also be interested in any of a set of types of content the user
1039 * can pick. For example, an e-mail application that wants to allow the
1040 * user to add an attachment to an e-mail message can use this action to
1041 * bring up a list of all of the types of content the user can attach.
1042 * <p>
1043 * In this case, you should wrap the GET_CONTENT intent with a chooser
1044 * (through {@link #createChooser}), which will give the proper interface
1045 * for the user to pick how to send your data and allow you to specify
1046 * a prompt indicating what they are doing. You will usually specify a
1047 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1048 * broad range of content types the user can select from.
1049 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001050 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001051 * only pick from data that can be represented as a stream. This is
1052 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1053 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001054 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001055 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001056 * is locally available on the device. For example, if this extra is set
1057 * to true then an image picker should not show any pictures that are available
1058 * from a remote server but not already on the local device (thus requiring
1059 * they be downloaded when opened).
1060 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001061 * If the caller can handle multiple returned items (the user performing
1062 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1063 * to indicate this.
1064 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001065 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1066 * that no URI is supplied in the intent, as there are no constraints on
1067 * where the returned data originally comes from. You may also include the
1068 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001069 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001070 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1071 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001072 * <p>
1073 * Output: The URI of the item that was picked. This must be a content:
1074 * URI so that any receiver can access it.
1075 */
1076 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1077 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1078 /**
1079 * Activity Action: Dial a number as specified by the data. This shows a
1080 * UI with the number being dialed, allowing the user to explicitly
1081 * initiate the call.
1082 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1083 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1084 * number.
1085 * <p>Output: nothing.
1086 */
1087 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1088 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1089 /**
1090 * Activity Action: Perform a call to someone specified by the data.
1091 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1092 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1093 * number.
1094 * <p>Output: nothing.
1095 *
1096 * <p>Note: there will be restrictions on which applications can initiate a
1097 * call; most applications should use the {@link #ACTION_DIAL}.
1098 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1099 * numbers. Applications can <strong>dial</strong> emergency numbers using
1100 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001101 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001102 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001103 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001104 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001105 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001106 */
1107 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1108 public static final String ACTION_CALL = "android.intent.action.CALL";
1109 /**
1110 * Activity Action: Perform a call to an emergency number specified by the
1111 * data.
1112 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1113 * tel: URI of an explicit phone number.
1114 * <p>Output: nothing.
1115 * @hide
1116 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001117 @SystemApi
1118 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001119 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1120 /**
1121 * Activity action: Perform a call to any number (emergency or not)
1122 * specified by the data.
1123 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1124 * tel: URI of an explicit phone number.
1125 * <p>Output: nothing.
1126 * @hide
1127 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001128 @SystemApi
1129 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001130 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001131
Santos Cordon15a13782015-03-31 18:32:31 -07001132 /**
fionaxuadfe7002017-02-17 17:20:46 -08001133 * Activity Action: Main entry point for carrier setup apps.
1134 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1135 * carrier service and typically require
1136 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1137 * fulfill their duties.
1138 */
1139 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1140 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1141 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001142 * Activity Action: Send a message to someone specified by the data.
1143 * <p>Input: {@link #getData} is URI describing the target.
1144 * <p>Output: nothing.
1145 */
1146 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1147 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1148 /**
1149 * Activity Action: Deliver some data to someone else. Who the data is
1150 * being delivered to is not specified; it is up to the receiver of this
1151 * action to ask the user where the data should be sent.
1152 * <p>
1153 * When launching a SEND intent, you should usually wrap it in a chooser
1154 * (through {@link #createChooser}), which will give the proper interface
1155 * for the user to pick how to send your data and allow you to specify
1156 * a prompt indicating what they are doing.
1157 * <p>
1158 * Input: {@link #getType} is the MIME type of the data being sent.
1159 * get*Extra can have either a {@link #EXTRA_TEXT}
1160 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1161 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1162 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1163 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001164 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1165 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1166 * your text with HTML formatting.
1167 * <p>
1168 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1169 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1170 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1171 * content: URIs and other advanced features of {@link ClipData}. If
1172 * using this approach, you still must supply the same data through the
1173 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1174 * for compatibility with old applications. If you don't set a ClipData,
1175 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001176 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001177 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1178 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1179 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1180 * be openable only as asset typed files using
1181 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1182 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001183 * Optional standard extras, which may be interpreted by some recipients as
1184 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1185 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1186 * <p>
1187 * Output: nothing.
1188 */
1189 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1190 public static final String ACTION_SEND = "android.intent.action.SEND";
1191 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001192 * Activity Action: Deliver multiple data to someone else.
1193 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001194 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001195 * <p>
1196 * Input: {@link #getType} is the MIME type of the data being sent.
1197 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001198 * #EXTRA_STREAM} field, containing the data to be sent. If using
1199 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1200 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001201 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001202 * Multiple types are supported, and receivers should handle mixed types
1203 * whenever possible. The right way for the receiver to check them is to
1204 * use the content resolver on each URI. The intent sender should try to
1205 * put the most concrete mime type in the intent type, but it can fall
1206 * back to {@literal <type>/*} or {@literal *}/* as needed.
1207 * <p>
1208 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1209 * be image/jpg, but if you are sending image/jpg and image/png, then the
1210 * intent's type should be image/*.
1211 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001212 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1213 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1214 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1215 * content: URIs and other advanced features of {@link ClipData}. If
1216 * using this approach, you still must supply the same data through the
1217 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1218 * for compatibility with old applications. If you don't set a ClipData,
1219 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1220 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001221 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1222 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1223 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1224 * be openable only as asset typed files using
1225 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1226 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001227 * Optional standard extras, which may be interpreted by some recipients as
1228 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1229 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1230 * <p>
1231 * Output: nothing.
1232 */
1233 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1234 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1235 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001236 * Activity Action: Handle an incoming phone call.
1237 * <p>Input: nothing.
1238 * <p>Output: nothing.
1239 */
1240 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1241 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1242 /**
1243 * Activity Action: Insert an empty item into the given container.
1244 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1245 * in which to place the data.
1246 * <p>Output: URI of the new data that was created.
1247 */
1248 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1249 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1250 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001251 * Activity Action: Create a new item in the given container, initializing it
1252 * from the current contents of the clipboard.
1253 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1254 * in which to place the data.
1255 * <p>Output: URI of the new data that was created.
1256 */
1257 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1258 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1259 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001260 * Activity Action: Delete the given data from its container.
1261 * <p>Input: {@link #getData} is URI of data to be deleted.
1262 * <p>Output: nothing.
1263 */
1264 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1266 /**
1267 * Activity Action: Run the data, whatever that means.
1268 * <p>Input: ? (Note: this is currently specific to the test harness.)
1269 * <p>Output: nothing.
1270 */
1271 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1272 public static final String ACTION_RUN = "android.intent.action.RUN";
1273 /**
1274 * Activity Action: Perform a data synchronization.
1275 * <p>Input: ?
1276 * <p>Output: ?
1277 */
1278 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1279 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1280 /**
1281 * Activity Action: Pick an activity given an intent, returning the class
1282 * selected.
1283 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1284 * used with {@link PackageManager#queryIntentActivities} to determine the
1285 * set of activities from which to pick.
1286 * <p>Output: Class name of the activity that was selected.
1287 */
1288 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1289 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1290 /**
1291 * Activity Action: Perform a search.
1292 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1293 * is the text to search for. If empty, simply
1294 * enter your search results Activity with the search UI activated.
1295 * <p>Output: nothing.
1296 */
1297 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1298 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1299 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001300 * Activity Action: Start the platform-defined tutorial
1301 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1302 * is the text to search for. If empty, simply
1303 * enter your search results Activity with the search UI activated.
1304 * <p>Output: nothing.
1305 */
1306 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1308 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001309 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001310 * <p>
1311 * Input: {@link android.app.SearchManager#QUERY
1312 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1313 * a url starts with http or https, the site will be opened. If it is plain
1314 * text, Google search will be applied.
1315 * <p>
1316 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001317 */
1318 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001320
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001321 /**
Jim Miller07994402012-05-02 14:22:27 -07001322 * Activity Action: Perform assist action.
1323 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001324 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1325 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001326 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1327 * information.
Jim Miller07994402012-05-02 14:22:27 -07001328 * Output: nothing.
1329 */
1330 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001332
1333 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001334 * Activity Action: Perform voice assist action.
1335 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001336 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1337 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001338 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001339 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001340 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001341 */
Amith Yamasani16452032017-03-03 10:15:57 -08001342 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001343 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1344 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1345
1346 /**
Adam Skory7140a252013-09-11 12:04:58 +01001347 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1348 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001349 */
1350 public static final String EXTRA_ASSIST_PACKAGE
1351 = "android.intent.extra.ASSIST_PACKAGE";
1352
1353 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001354 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1355 * application package at the time the assist was invoked.
1356 */
1357 public static final String EXTRA_ASSIST_UID
1358 = "android.intent.extra.ASSIST_UID";
1359
1360 /**
Adam Skory7140a252013-09-11 12:04:58 +01001361 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1362 * information supplied by the current foreground app at the time of the assist request.
1363 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001364 */
1365 public static final String EXTRA_ASSIST_CONTEXT
1366 = "android.intent.extra.ASSIST_CONTEXT";
1367
Jim Miller07994402012-05-02 14:22:27 -07001368 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001369 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1370 * keyboard as the primary input device for assistance.
1371 */
1372 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1373 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1374
1375 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001376 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1377 * that was used to invoke the assist.
1378 */
1379 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1380 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1381
1382 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001383 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001384 * <p>Input: Nothing.
1385 * <p>Output: nothing.
1386 */
1387 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1388 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1389 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001390 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001391 * <p>Input: Nothing.
1392 * <p>Output: Nothing.
1393 */
1394 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1395 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1396
1397 /**
1398 * Activity Action: Show activity for reporting a bug.
1399 * <p>Input: Nothing.
1400 * <p>Output: Nothing.
1401 */
1402 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1403 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1404
1405 /**
1406 * Activity Action: Main entry point for factory tests. Only used when
1407 * the device is booting in factory test node. The implementing package
1408 * must be installed in the system image.
1409 * <p>Input: nothing
1410 * <p>Output: nothing
1411 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001412 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001413 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1414
1415 /**
1416 * Activity Action: The user pressed the "call" button to go to the dialer
1417 * or other appropriate UI for placing a call.
1418 * <p>Input: Nothing.
1419 * <p>Output: Nothing.
1420 */
1421 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1422 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1423
1424 /**
1425 * Activity Action: Start Voice Command.
1426 * <p>Input: Nothing.
1427 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001428 * <p class="note">
1429 * In some cases, a matching Activity may not exist, so ensure you
1430 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001431 */
1432 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1433 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001434
1435 /**
1436 * Activity Action: Start action associated with long pressing on the
1437 * search key.
1438 * <p>Input: Nothing.
1439 * <p>Output: Nothing.
1440 */
1441 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1442 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001443
Jacek Surazski86b6c532009-05-13 14:38:28 +02001444 /**
1445 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1446 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001447 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001448 * <p>Input: No data is specified. The bug report is passed in using
1449 * an {@link #EXTRA_BUG_REPORT} field.
1450 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001451 *
1452 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001453 */
1454 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1455 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001456
1457 /**
Joe Onoratoe21ab7e2018-12-18 15:00:25 -08001458 * An incident or bug report has been taken, and a system app has requested it to be shared,
1459 * so trigger the confirmation screen.
1460 *
1461 * This will be sent directly to the registered receiver with the
1462 * android.permission.APPROVE_INCIDENT_REPORTS permission.
1463 * @hide
1464 */
1465 @SystemApi
1466 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1467 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1468
1469 /**
Joe Onorato8daca752019-01-28 19:41:58 -08001470 * An incident report has been taken, and the user has approved it for sharing.
1471 * <p>
1472 * This will be sent directly to the registered receiver, which must have
1473 * both the DUMP and USAGE_STATS permissions.
1474 * <p>
1475 * After receiving this, the application should wait until a suitable time
1476 * (e.g. network available), get the list of available reports with
1477 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1478 * and then when the reports have been successfully uploaded, call
1479 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1480 *
1481 * @hide
1482 */
1483 @SystemApi
1484 public static final String ACTION_INCIDENT_REPORT_READY =
1485 "android.intent.action.INCIDENT_REPORT_READY";
1486
1487 /**
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001488 * Activity Action: Show power usage information to the user.
1489 * <p>Input: Nothing.
1490 * <p>Output: Nothing.
1491 */
1492 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1493 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001494
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001495 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001496 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1497 * to run.
1498 * <p>Input: Nothing.
1499 * <p>Output: Nothing.
1500 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1501 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1502 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001503 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001504 */
1505 @Deprecated
1506 @SystemApi
1507 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1508 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1509
1510 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001511 * Activity Action: Setup wizard to launch after a platform update. This
1512 * activity should have a string meta-data field associated with it,
1513 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1514 * the platform for setup. The activity will be launched only if
1515 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1516 * same value.
1517 * <p>Input: Nothing.
1518 * <p>Output: Nothing.
1519 * @hide
1520 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001521 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001522 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1523 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001524
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001525 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001526 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1527 * <p>Input: Nothing.
1528 * <p>Output: Nothing.
1529 * @hide
1530 */
1531 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1532 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001533 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001534
1535 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001536 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1537 * <p>Input: Nothing.
1538 * <p>Output: Nothing.
1539 * @hide
1540 */
1541 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1542 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001543 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001544
1545 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001546 * Activity Action: Show settings for managing network data usage of a
1547 * specific application. Applications should define an activity that offers
1548 * options to control data usage.
1549 */
1550 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1551 public static final String ACTION_MANAGE_NETWORK_USAGE =
1552 "android.intent.action.MANAGE_NETWORK_USAGE";
1553
1554 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001555 * Activity Action: Launch application installer.
1556 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001557 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001558 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1559 * you can also use "package:<package-name>" to install an application for the
1560 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001561 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1562 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1563 * <p>
1564 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1565 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001566 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001567 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001568 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1569 * in order to launch the application installer.
1570 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001571 *
1572 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1573 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1574 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001575 *
1576 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001577 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001578 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001579 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1580 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1581
1582 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001583 * Activity Action: Activity to handle split installation failures.
1584 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1585 * but the split that contains the application isn't installed. When a split is
1586 * installed in this manner, the containing package usually doesn't know this is
1587 * happening. However, if an error occurs during installation, the containing
1588 * package can define a single activity handling this action to deal with such
1589 * failures.
1590 * <p>The activity handling this action must be in the base package.
1591 * <p>
1592 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1593 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1594 */
1595 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1596 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1597
1598 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001599 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001600 * <p class="note">
1601 * This is a protected intent that can only be sent by the system.
1602 * </p>
1603 *
1604 * @hide
1605 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001606 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001607 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001608 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1609 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001610
1611 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001612 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001613 * <p>
1614 * The system will have a persistent connection to this service.
1615 * This is a protected intent that can only be sent by the system.
1616 * </p>
1617 *
1618 * @hide
1619 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001620 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001621 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001622 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1623 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001624
1625 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001626 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001627 *
1628 * <p class="note">
1629 * This is a protected intent that can only be sent by the system.
1630 * </p>
1631 *
1632 * @hide
1633 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001634 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001635 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001636 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1637 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001638
1639 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001640 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1641 * package. Specifies the installer package name; this package will receive the
1642 * {@link #ACTION_APP_ERROR} intent.
1643 */
1644 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1645 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1646
1647 /**
1648 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1649 * package. Specifies that the application being installed should not be
1650 * treated as coming from an unknown source, but as coming from the app
1651 * invoking the Intent. For this to work you must start the installer with
1652 * startActivityForResult().
1653 */
1654 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1655 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1656
1657 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001658 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1659 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001660 * data field originated from.
1661 */
rich cannings706e8ba2012-08-20 13:20:14 -07001662 public static final String EXTRA_ORIGINATING_URI
1663 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001664
1665 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001666 * This extra can be used with any Intent used to launch an activity, supplying information
1667 * about who is launching that activity. This field contains a {@link android.net.Uri}
1668 * object, typically an http: or https: URI of the web site that the referral came from;
1669 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1670 * a native application that it came from.
1671 *
1672 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1673 * instead of directly retrieving the extra. It is also valid for applications to
1674 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1675 * a string, not a Uri; the field here, if supplied, will always take precedence,
1676 * however.</p>
1677 *
1678 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001679 */
1680 public static final String EXTRA_REFERRER
1681 = "android.intent.extra.REFERRER";
1682
1683 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001684 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1685 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1686 * not be created, in particular when Intent extras are supplied through the
1687 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1688 * schemes.
1689 *
1690 * @see #EXTRA_REFERRER
1691 */
1692 public static final String EXTRA_REFERRER_NAME
1693 = "android.intent.extra.REFERRER_NAME";
1694
1695 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001696 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001697 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001698 * Currently only a system app that hosts the provider authority "downloads" or holds the
1699 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001700 * @hide
1701 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001702 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001703 public static final String EXTRA_ORIGINATING_UID
1704 = "android.intent.extra.ORIGINATING_UID";
1705
1706 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001707 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1708 * package. Tells the installer UI to skip the confirmation with the user
1709 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001710 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1711 * will no longer show an interstitial message about updating existing
1712 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001713 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001714 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001715 public static final String EXTRA_ALLOW_REPLACE
1716 = "android.intent.extra.ALLOW_REPLACE";
1717
1718 /**
1719 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1720 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1721 * return to the application the result code of the install/uninstall. The returned result
1722 * code will be {@link android.app.Activity#RESULT_OK} on success or
1723 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1724 */
1725 public static final String EXTRA_RETURN_RESULT
1726 = "android.intent.extra.RETURN_RESULT";
1727
1728 /**
1729 * Package manager install result code. @hide because result codes are not
1730 * yet ready to be exposed.
1731 */
1732 public static final String EXTRA_INSTALL_RESULT
1733 = "android.intent.extra.INSTALL_RESULT";
1734
1735 /**
1736 * Activity Action: Launch application uninstaller.
1737 * <p>
1738 * Input: The data must be a package: URI whose scheme specific part is
1739 * the package name of the current installed package to be uninstalled.
1740 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1741 * <p>
1742 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1743 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001744 * <p>
1745 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1746 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001747 *
1748 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1749 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001750 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001751 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001752 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1753 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1754
1755 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001756 * Specify whether the package should be uninstalled for all users.
1757 * @hide because these should not be part of normal application flow.
1758 */
1759 public static final String EXTRA_UNINSTALL_ALL_USERS
1760 = "android.intent.extra.UNINSTALL_ALL_USERS";
1761
1762 /**
Varun Shahb9fd6be2018-10-22 19:16:33 -07001763 * A string that associates with a metadata entry, indicating the last run version of the
1764 * platform that was setup.
1765 *
1766 * @see #ACTION_UPGRADE_SETUP
1767 *
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001768 * @hide
1769 */
Varun Shahb9fd6be2018-10-22 19:16:33 -07001770 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001771 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1772
Svet Ganov3695b8a2015-03-24 16:30:25 -07001773 /**
1774 * Activity action: Launch UI to manage the permissions of an app.
1775 * <p>
1776 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1777 * will be managed by the launched UI.
1778 * </p>
1779 * <p>
1780 * Output: Nothing.
1781 * </p>
1782 *
1783 * @see #EXTRA_PACKAGE_NAME
1784 *
1785 * @hide
1786 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001787 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001788 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1789 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1790 "android.intent.action.MANAGE_APP_PERMISSIONS";
1791
1792 /**
Joel Galenson035dfd92019-02-08 13:58:51 -08001793 * Activity action: Launch UI to manage a specific permissions of an app.
1794 * <p>
1795 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1796 * will be managed by the launched UI.
1797 * </p>
1798 * <p>
1799 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1800 * that should be managed by the launched UI.
1801 * </p>
1802 * <p>
1803 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1804 * </p>
1805 * <p>
1806 * Output: Nothing.
1807 * </p>
1808 *
1809 * @see #EXTRA_PACKAGE_NAME
1810 * @see #EXTRA_PERMISSION_NAME
1811 * @see #EXTRA_USER
1812 *
1813 * @hide
1814 */
1815 @SystemApi
1816 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1817 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1818 public static final String ACTION_MANAGE_APP_PERMISSION =
1819 "android.intent.action.MANAGE_APP_PERMISSION";
1820
1821 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001822 * Activity action: Launch UI to manage permissions.
1823 * <p>
1824 * Input: Nothing.
1825 * </p>
1826 * <p>
1827 * Output: Nothing.
1828 * </p>
1829 *
1830 * @hide
1831 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001832 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001833 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1834 public static final String ACTION_MANAGE_PERMISSIONS =
1835 "android.intent.action.MANAGE_PERMISSIONS";
1836
1837 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001838 * Activity action: Launch UI to review permissions for an app.
1839 * The system uses this intent if permission review for apps not
1840 * supporting the new runtime permissions model is enabled. In
1841 * this mode a permission review is required before any of the
1842 * app components can run.
1843 * <p>
1844 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1845 * permissions will be reviewed (mandatory).
1846 * </p>
1847 * <p>
1848 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1849 * be fired after the permission review (optional).
1850 * </p>
1851 * <p>
1852 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1853 * be invoked after the permission review (optional).
1854 * </p>
1855 * <p>
1856 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1857 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1858 * </p>
1859 * <p>
1860 * Output: Nothing.
1861 * </p>
1862 *
1863 * @see #EXTRA_PACKAGE_NAME
1864 * @see #EXTRA_INTENT
1865 * @see #EXTRA_REMOTE_CALLBACK
1866 * @see #EXTRA_RESULT_NEEDED
1867 *
1868 * @hide
1869 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001870 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001871 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1872 public static final String ACTION_REVIEW_PERMISSIONS =
1873 "android.intent.action.REVIEW_PERMISSIONS";
1874
1875 /**
Hai Zhang3a212892019-01-11 15:21:17 -08001876 * Activity action: Launch UI to manage a default app.
1877 * <p>
1878 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1879 * by the launched UI.
1880 * </p>
1881 * <p>
1882 * Output: Nothing.
1883 * </p>
1884 *
1885 * @hide
1886 */
1887 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1888 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1889 @SystemApi
1890 public static final String ACTION_MANAGE_DEFAULT_APP =
1891 "android.intent.action.MANAGE_DEFAULT_APP";
1892
1893 /**
1894 * Intent extra: A role name.
1895 * <p>
1896 * Type: String
1897 * </p>
1898 *
1899 * @see android.app.role.RoleManager
1900 *
1901 * @hide
1902 */
1903 @SystemApi
1904 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1905
1906 /**
Hai Zhang1d792322019-01-07 13:51:52 -08001907 * Activity action: Launch UI to manage special app accesses.
1908 * <p>
1909 * Input: Nothing.
1910 * </p>
1911 * <p>
1912 * Output: Nothing.
1913 * </p>
1914 *
1915 * @hide
1916 */
1917 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1918 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1919 @SystemApi
1920 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
1921 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
1922
1923 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001924 * Intent extra: A callback for reporting remote result as a bundle.
1925 * <p>
1926 * Type: IRemoteCallback
1927 * </p>
1928 *
1929 * @hide
1930 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001931 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001932 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1933
1934 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001935 * Intent extra: An app package name.
1936 * <p>
1937 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001938 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001939 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001940 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001941 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1942
1943 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001944 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1945 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1946 *
1947 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1948 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1949 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001950 *
1951 * @see #ACTION_MY_PACKAGE_SUSPENDED
1952 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1953 * @see PackageManager#isPackageSuspended()
1954 * @see PackageManager#getSuspendedPackageAppExtras()
1955 */
1956 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1957
1958 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001959 * Intent extra: An app split name.
1960 * <p>
1961 * Type: String
1962 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001963 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001964 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1965
1966 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001967 * Intent extra: A {@link ComponentName} value.
1968 * <p>
1969 * Type: String
1970 * </p>
1971 */
1972 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1973
1974 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001975 * Intent extra: An extra for specifying whether a result is needed.
1976 * <p>
1977 * Type: boolean
1978 * </p>
1979 *
1980 * @hide
1981 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001982 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001983 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1984
1985 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001986 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1987 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1988 *
1989 * @see PackageManager#isPackageSuspended()
1990 * @see #ACTION_PACKAGES_SUSPENDED
1991 *
1992 * @hide
1993 */
1994 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1995
1996 /**
Mehdi Alizadeh406e8b32018-12-11 18:21:49 -08001997 * Intent extra: ID of the shortcut used to send the share intent.
1998 *
1999 * @see ShortcutInfo#getId()
2000 *
2001 * <p>
2002 * Type: String
2003 * </p>
2004 */
2005 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2006
2007 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07002008 * Activity action: Launch UI to manage which apps have a given permission.
2009 * <p>
Philip P. Moltmanned988282018-11-07 16:19:42 -08002010 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2011 * which will be managed by the launched UI.
Svet Ganov3695b8a2015-03-24 16:30:25 -07002012 * </p>
2013 * <p>
2014 * Output: Nothing.
2015 * </p>
2016 *
2017 * @see #EXTRA_PERMISSION_NAME
2018 *
2019 * @hide
2020 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002021 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07002022 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2023 public static final String ACTION_MANAGE_PERMISSION_APPS =
2024 "android.intent.action.MANAGE_PERMISSION_APPS";
2025
2026 /**
2027 * Intent extra: The name of a permission.
2028 * <p>
2029 * Type: String
2030 * </p>
2031 *
2032 * @hide
2033 */
2034 @SystemApi
2035 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2036
Joel Galenson13096ea2018-09-27 11:18:44 -07002037 /**
Joel Galenson029aac72019-01-07 10:31:28 -08002038 * Intent extra: The name of a permission group.
2039 * <p>
2040 * Type: String
2041 * </p>
2042 *
2043 * @hide
2044 */
2045 @SystemApi
2046 public static final String EXTRA_PERMISSION_GROUP_NAME =
2047 "android.intent.extra.PERMISSION_GROUP_NAME";
2048
2049 /**
Joel Galensonc857f022019-01-22 10:01:00 -08002050 * Intent extra: The number of milliseconds.
2051 * <p>
2052 * Type: long
2053 * </p>
2054 */
2055 public static final String EXTRA_DURATION_MILLIS =
2056 "android.intent.extra.DURATION_MILLIS";
2057
2058 /**
Joel Galenson13096ea2018-09-27 11:18:44 -07002059 * Activity action: Launch UI to review app uses of permissions.
2060 * <p>
Joel Galensonb995eda2018-12-04 16:28:04 -08002061 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
Joel Galenson029aac72019-01-07 10:31:28 -08002062 * that will be displayed by the launched UI. Do not pass both this and
2063 * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2064 * </p>
2065 * <p>
2066 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2067 * that will be displayed by the launched UI. Do not pass both this and
2068 * {@link #EXTRA_PERMISSION_NAME}.
Joel Galenson13096ea2018-09-27 11:18:44 -07002069 * </p>
2070 * <p>
Joel Galensonc857f022019-01-22 10:01:00 -08002071 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2072 * activity to show (optional). Must be non-negative.
2073 * </p>
2074 * <p>
Joel Galenson13096ea2018-09-27 11:18:44 -07002075 * Output: Nothing.
2076 * </p>
2077 *
Joel Galensonb995eda2018-12-04 16:28:04 -08002078 * @see #EXTRA_PERMISSION_NAME
Joel Galenson029aac72019-01-07 10:31:28 -08002079 * @see #EXTRA_PERMISSION_GROUP_NAME
Joel Galensonc857f022019-01-22 10:01:00 -08002080 * @see #EXTRA_DURATION_MILLIS
Joel Galensonb995eda2018-12-04 16:28:04 -08002081 *
Joel Galenson13096ea2018-09-27 11:18:44 -07002082 * @hide
2083 */
2084 @SystemApi
2085 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2086 public static final String ACTION_REVIEW_PERMISSION_USAGE =
2087 "android.intent.action.REVIEW_PERMISSION_USAGE";
2088
Joel Galenson78ec58d2018-10-24 10:06:25 -07002089 /**
2090 * Activity action: Launch UI to review uses of permissions for a single app.
2091 * <p>
2092 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
2093 * permissions will be reviewed (mandatory).
2094 * </p>
2095 * <p>
2096 * Output: Nothing.
2097 * </p>
2098 * <p class="note">
2099 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2100 * </p>
2101 *
2102 * @see #EXTRA_PACKAGE_NAME
2103 *
2104 * @hide
2105 */
2106 @SystemApi
2107 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2109 public static final String ACTION_REVIEW_APP_PERMISSION_USAGE =
2110 "android.intent.action.REVIEW_APP_PERMISSION_USAGE";
2111
Joel Galenson95628242019-02-05 14:15:05 -08002112 /**
2113 * Activity action: Launch UI to review running accessibility services.
2114 * <p>
2115 * Input: Nothing.
2116 * </p>
2117 * <p>
2118 * Output: Nothing.
2119 * </p>
2120 *
2121 * @hide
2122 */
2123 @SystemApi
2124 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2125 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2126 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2127
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002128 // ---------------------------------------------------------------------
2129 // ---------------------------------------------------------------------
2130 // Standard intent broadcast actions (see action variable).
2131
2132 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002133 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2134 * <p>
2135 * For historical reasons, the name of this broadcast action refers to the power
2136 * state of the screen but it is actually sent in response to changes in the
2137 * overall interactive state of the device.
2138 * </p><p>
2139 * This broadcast is sent when the device becomes non-interactive which may have
2140 * nothing to do with the screen turning off. To determine the
2141 * actual state of the screen, use {@link android.view.Display#getState}.
2142 * </p><p>
2143 * See {@link android.os.PowerManager#isInteractive} for details.
2144 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002145 * You <em>cannot</em> receive this through components declared in
2146 * manifests, only by explicitly registering for it with
2147 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2148 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002149 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002150 * <p class="note">This is a protected intent that can only be sent
2151 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002152 */
2153 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2154 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07002155
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002156 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002157 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2158 * <p>
2159 * For historical reasons, the name of this broadcast action refers to the power
2160 * state of the screen but it is actually sent in response to changes in the
2161 * overall interactive state of the device.
2162 * </p><p>
2163 * This broadcast is sent when the device becomes interactive which may have
2164 * nothing to do with the screen turning on. To determine the
2165 * actual state of the screen, use {@link android.view.Display#getState}.
2166 * </p><p>
2167 * See {@link android.os.PowerManager#isInteractive} for details.
2168 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002169 * You <em>cannot</em> receive this through components declared in
2170 * manifests, only by explicitly registering for it with
2171 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2172 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002173 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002174 * <p class="note">This is a protected intent that can only be sent
2175 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002176 */
2177 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2178 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002179
2180 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07002181 * Broadcast Action: Sent after the system stops dreaming.
2182 *
2183 * <p class="note">This is a protected intent that can only be sent by the system.
2184 * It is only sent to registered receivers.</p>
2185 */
2186 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2187 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2188
2189 /**
2190 * Broadcast Action: Sent after the system starts dreaming.
2191 *
2192 * <p class="note">This is a protected intent that can only be sent by the system.
2193 * It is only sent to registered receivers.</p>
2194 */
2195 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2196 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2197
2198 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07002199 * 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 -07002200 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002201 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002202 * <p class="note">This is a protected intent that can only be sent
2203 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002204 */
2205 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002206 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002207
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002208 /**
2209 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002210 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002211 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002212 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2213 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002214 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002215 * <p class="note">This is a protected intent that can only be sent
2216 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002217 */
2218 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2219 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2220 /**
2221 * Broadcast Action: The time was set.
2222 */
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2225 /**
2226 * Broadcast Action: The date has changed.
2227 */
2228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2229 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2230 /**
2231 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2232 * <ul>
2233 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2234 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002235 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002236 * <p class="note">This is a protected intent that can only be sent
2237 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002238 */
2239 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2240 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2241 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002242 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2243 * DNS entries should be tossed.
2244 * @hide
2245 */
2246 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2247 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2248 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002249 * Alarm Changed Action: This is broadcast when the AlarmClock
2250 * application's alarm is set or unset. It is used by the
2251 * AlarmClock application and the StatusBar service.
2252 * @hide
2253 */
2254 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002255 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002256 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002257
2258 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002259 * Broadcast Action: This is broadcast once, after the user has finished
2260 * booting, but while still in the "locked" state. It can be used to perform
2261 * application-specific initialization, such as installing alarms. You must
2262 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2263 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002264 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002265 * This broadcast is sent immediately at boot by all devices (regardless of
2266 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2267 * higher. Upon receipt of this broadcast, the user is still locked and only
2268 * device-protected storage can be accessed safely. If you want to access
2269 * credential-protected storage, you need to wait for the user to be
2270 * unlocked (typically by entering their lock pattern or PIN for the first
2271 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2272 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2273 * <p>
2274 * To receive this broadcast, your receiver component must be marked as
2275 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002276 * <p class="note">
2277 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002278 *
2279 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002280 */
2281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2282 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2283
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002284 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002285 * Broadcast Action: This is broadcast once, after the user has finished
2286 * booting. It can be used to perform application-specific initialization,
2287 * such as installing alarms. You must hold the
2288 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2289 * order to receive this broadcast.
2290 * <p>
2291 * This broadcast is sent at boot by all devices (both with and without
2292 * direct boot support). Upon receipt of this broadcast, the user is
2293 * unlocked and both device-protected and credential-protected storage can
2294 * accessed safely.
2295 * <p>
2296 * If you need to run while the user is still locked (before they've entered
2297 * their lock pattern or PIN for the first time), you can listen for the
2298 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2299 * <p class="note">
2300 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002301 */
2302 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002303 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002304 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002305
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002306 /**
2307 * Broadcast Action: This is broadcast when a user action should request a
2308 * temporary system dialog to dismiss. Some examples of temporary system
2309 * dialogs are the notification window-shade and the recent tasks dialog.
2310 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002311 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002312 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2313 /**
2314 * Broadcast Action: Trigger the download and eventual installation
2315 * of a package.
2316 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002317 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002318 * <p class="note">This is a protected intent that can only be sent
2319 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002320 *
2321 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002322 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002323 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002324 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2325 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2326 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002327 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002328 * device. The data contains the name of the package. Note that the
2329 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002330 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002331 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002332 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2333 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002334 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2335 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002336 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002337 * <p class="note">This is a protected intent that can only be sent
2338 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2342 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002343 * Broadcast Action: A new version of an application package has been
2344 * installed, replacing an existing version that was previously installed.
2345 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002346 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002347 * <ul>
2348 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2349 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002350 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002351 * <p class="note">This is a protected intent that can only be sent
2352 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002353 */
2354 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2355 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2356 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002357 * Broadcast Action: A new version of your application has been installed
2358 * over an existing one. This is only sent to the application that was
2359 * replaced. It does not contain any additional data; to receive it, just
2360 * use an intent filter for this action.
2361 *
2362 * <p class="note">This is a protected intent that can only be sent
2363 * by the system.
2364 */
2365 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2366 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2367 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002368 * Broadcast Action: An existing application package has been removed from
2369 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002370 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002371 * <ul>
2372 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2373 * to the package.
2374 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2375 * application -- data and code -- is being removed.
2376 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2377 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2378 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002379 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002380 * <p class="note">This is a protected intent that can only be sent
2381 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002382 */
2383 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2384 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2385 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002386 * Broadcast Action: An existing application package has been completely
2387 * removed from the device. The data contains the name of the package.
2388 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2389 * {@link #EXTRA_DATA_REMOVED} is true and
2390 * {@link #EXTRA_REPLACING} is false of that broadcast.
2391 *
2392 * <ul>
2393 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2394 * to the package.
2395 * </ul>
2396 *
2397 * <p class="note">This is a protected intent that can only be sent
2398 * by the system.
2399 */
2400 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401 public static final String ACTION_PACKAGE_FULLY_REMOVED
2402 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2403 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002404 * Broadcast Action: An existing application package has been changed (for
2405 * example, a component has been enabled or disabled). The data contains
2406 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002407 * <ul>
2408 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002409 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002410 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002411 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2412 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002413 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002414 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002415 * <p class="note">This is a protected intent that can only be sent
2416 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002417 */
2418 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2419 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2420 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +01002421 * Broadcast Action: Sent to the system rollback manager when a package
2422 * needs to have rollback enabled.
2423 * <p class="note">
2424 * This is a protected intent that can only be sent by the system.
2425 * </p>
2426 *
2427 * @hide This broadcast is used internally by the system.
2428 */
2429 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2430 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2431 "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2432 /**
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002433 * Broadcast Action: A rollback has been committed.
Richard Uhlerb29f1452018-09-12 16:38:15 +01002434 *
2435 * <p class="note">This is a protected intent that can only be sent
2436 * by the system.
2437 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +00002438 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +01002439 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +00002440 @SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +01002441 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002442 public static final String ACTION_ROLLBACK_COMMITTED =
2443 "android.intent.action.ROLLBACK_COMMITTED";
Richard Uhlerb29f1452018-09-12 16:38:15 +01002444 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002445 * @hide
2446 * Broadcast Action: Ask system services if there is any reason to
2447 * restart the given package. The data contains the name of the
2448 * package.
2449 * <ul>
2450 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2451 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2452 * </ul>
2453 *
2454 * <p class="note">This is a protected intent that can only be sent
2455 * by the system.
2456 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002457 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002458 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2459 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2460 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002461 * Broadcast Action: The user has restarted a package, and all of its
2462 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002463 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002464 * be removed. Note that the restarted package does <em>not</em>
2465 * receive this broadcast.
2466 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002467 * <ul>
2468 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2469 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002470 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002471 * <p class="note">This is a protected intent that can only be sent
2472 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002473 */
2474 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2475 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2476 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002477 * Broadcast Action: The user has cleared the data of a package. This should
2478 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002479 * its persistent data is erased and this broadcast sent.
2480 * Note that the cleared package does <em>not</em>
2481 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002482 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002483 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2484 * package whose data was cleared is an uninstalled instant app, then the UID
2485 * will be -1. The platform keeps some meta-data associated with instant apps
2486 * after they are uninstalled.
2487 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2488 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002489 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002490 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002491 * <p class="note">This is a protected intent that can only be sent
2492 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002493 */
2494 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2495 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2496 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002497 * Broadcast Action: Packages have been suspended.
2498 * <p>Includes the following extras:
2499 * <ul>
2500 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002501 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002502 * </ul>
2503 *
2504 * <p class="note">This is a protected intent that can only be sent
2505 * by the system. It is only sent to registered receivers.
2506 */
2507 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2508 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2509 /**
2510 * Broadcast Action: Packages have been unsuspended.
2511 * <p>Includes the following extras:
2512 * <ul>
2513 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002514 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002515 * </ul>
2516 *
2517 * <p class="note">This is a protected intent that can only be sent
2518 * by the system. It is only sent to registered receivers.
2519 */
2520 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2521 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002522
2523 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08002524 * Broadcast Action: Distracting packages have been changed.
2525 * <p>Includes the following extras:
2526 * <ul>
2527 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2528 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2529 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2530 * </ul>
2531 *
2532 * <p class="note">This is a protected intent that can only be sent
2533 * by the system. It is only sent to registered receivers.
2534 *
2535 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2536 * @hide
2537 */
2538 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2539 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2540 "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2541
2542 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002543 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002544 * whenever a package is put into a suspended state or any of its app extras change while in the
2545 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002546 * <p> Optionally includes the following extras:
2547 * <ul>
2548 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2549 * useful information for the app being suspended.
2550 * </ul>
2551 * <p class="note">This is a protected intent that can only be sent
2552 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2553 * the manifest.</em>
2554 *
2555 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2556 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2557 * @see PackageManager#isPackageSuspended()
2558 * @see PackageManager#getSuspendedPackageAppExtras()
2559 */
2560 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2561 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2562
2563 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002564 * Activity Action: Started to show more details about why an application was suspended.
2565 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002566 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2567 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002568 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002569 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2570 * handling this intent and protect it with
2571 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2572 *
2573 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2574 *
2575 * <p class="note">This is a protected intent that can only be sent
2576 * by the system.
2577 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002578 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2579 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002580 * @see PackageManager#isPackageSuspended()
2581 * @see #ACTION_PACKAGES_SUSPENDED
2582 *
2583 * @hide
2584 */
2585 @SystemApi
2586 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2587 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2588 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2589
2590 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002591 * Broadcast Action: Sent to a package that has been unsuspended.
2592 *
2593 * <p class="note">This is a protected intent that can only be sent
2594 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2595 * the manifest.</em>
2596 *
2597 * @see #ACTION_MY_PACKAGE_SUSPENDED
2598 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2599 * @see PackageManager#isPackageSuspended()
2600 * @see PackageManager#getSuspendedPackageAppExtras()
2601 */
2602 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2603 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2604
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002605 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002606 * Broadcast Action: A user ID has been removed from the system. The user
2607 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002608 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002609 * <p class="note">This is a protected intent that can only be sent
2610 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002611 */
2612 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2613 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002614
2615 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002616 * Broadcast Action: Sent to the installer package of an application when
2617 * that application is first launched (that is the first time it is moved
2618 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002619 *
2620 * <p class="note">This is a protected intent that can only be sent
2621 * by the system.
2622 */
2623 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2624 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2625
2626 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002627 * Broadcast Action: Sent to the system package verifier when a package
2628 * needs to be verified. The data contains the package URI.
2629 * <p class="note">
2630 * This is a protected intent that can only be sent by the system.
2631 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002632 */
2633 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2634 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2635
2636 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002637 * Broadcast Action: Sent to the system package verifier when a package is
2638 * verified. The data contains the package URI.
2639 * <p class="note">
2640 * This is a protected intent that can only be sent by the system.
2641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2643 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2644
2645 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002646 * Broadcast Action: Sent to the system intent filter verifier when an
2647 * intent filter needs to be verified. The data contains the filter data
2648 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002649 * <p class="note">
2650 * This is a protected intent that can only be sent by the system.
2651 * </p>
2652 *
2653 * @hide
2654 */
2655 @SystemApi
2656 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2657 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2658
2659 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002660 * Broadcast Action: Resources for a set of packages (which were
2661 * previously unavailable) are currently
2662 * available since the media on which they exist is available.
2663 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2664 * list of packages whose availability changed.
2665 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2666 * list of uids of packages whose availability changed.
2667 * Note that the
2668 * packages in this list do <em>not</em> receive this broadcast.
2669 * The specified set of packages are now available on the system.
2670 * <p>Includes the following extras:
2671 * <ul>
2672 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2673 * whose resources(were previously unavailable) are currently available.
2674 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2675 * packages whose resources(were previously unavailable)
2676 * are currently available.
2677 * </ul>
2678 *
2679 * <p class="note">This is a protected intent that can only be sent
2680 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002681 */
2682 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002683 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2684 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002685
2686 /**
2687 * Broadcast Action: Resources for a set of packages are currently
2688 * unavailable since the media on which they exist is unavailable.
2689 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2690 * list of packages whose availability changed.
2691 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2692 * list of uids of packages whose availability changed.
2693 * The specified set of packages can no longer be
2694 * launched and are practically unavailable on the system.
2695 * <p>Inclues the following extras:
2696 * <ul>
2697 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2698 * whose resources are no longer available.
2699 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2700 * whose resources are no longer available.
2701 * </ul>
2702 *
2703 * <p class="note">This is a protected intent that can only be sent
2704 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002705 */
2706 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002707 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002708 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002709
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002710 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002711 * Broadcast Action: preferred activities have changed *explicitly*.
2712 *
2713 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2714 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2715 * be sent.
2716 *
2717 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2718 *
2719 * @hide
2720 */
2721 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2722 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2723 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2724
2725
2726 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002727 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002728 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002729 * This should <em>only</em> be used to determine when the wallpaper
2730 * has changed to show the new wallpaper to the user. You should certainly
2731 * never, in response to this, change the wallpaper or other attributes of
2732 * it such as the suggested size. That would be crazy, right? You'd cause
2733 * all kinds of loops, especially if other apps are doing similar things,
2734 * right? Of course. So please don't do this.
2735 *
2736 * @deprecated Modern applications should use
2737 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2738 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2739 * shown behind their UI, rather than watching for this broadcast and
2740 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002741 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002742 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002743 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2744 /**
2745 * Broadcast Action: The current device {@link android.content.res.Configuration}
2746 * (orientation, locale, etc) has changed. When such a change happens, the
2747 * UIs (view hierarchy) will need to be rebuilt based on this new
2748 * information; for the most part, applications don't need to worry about
2749 * this, because the system will take care of stopping and restarting the
2750 * application to make sure it sees the new changes. Some system code that
2751 * can not be restarted will need to watch for this action and handle it
2752 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002753 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002754 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002755 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002756 * in manifests, only by explicitly registering for it with
2757 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2758 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002759 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002760 * <p class="note">This is a protected intent that can only be sent
2761 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002762 *
2763 * @see android.content.res.Configuration
2764 */
2765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2766 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002767
2768 /**
2769 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2770 * such that the device may be eligible for the installation of additional configuration splits.
2771 * Configuration properties that can trigger this broadcast include locale and display density.
2772 *
2773 * <p class="note">
2774 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2775 * components declared in manifests. However, the receiver <em>must</em> hold the
2776 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2777 *
2778 * <p class="note">
2779 * This is a protected intent that can only be sent by the system.
2780 *
2781 * @hide
2782 */
2783 @SystemApi
2784 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2785 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2786 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002787 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002788 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002789 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002790 * <p class="note">This is a protected intent that can only be sent
2791 * by the system.
2792 */
2793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2794 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2795 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002796 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2797 * charging state, level, and other information about the battery.
2798 * See {@link android.os.BatteryManager} for documentation on the
2799 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002800 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002801 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002802 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002803 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002804 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002805 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2806 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2807 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2808 * broadcasts that are sent and can be received through manifest
2809 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002810 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002811 * <p class="note">This is a protected intent that can only be sent
2812 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002813 */
2814 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2815 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002816
2817
2818 /**
2819 * Broadcast Action: Sent when the current battery level changes.
2820 *
2821 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2822 * instances representing individual battery level changes with associated
2823 * extras from {@link #ACTION_BATTERY_CHANGED}.
2824 *
2825 * <p class="note">
2826 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2827 *
2828 * @hide
2829 */
2830 @SystemApi
2831 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2832 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002833 /**
2834 * Broadcast Action: Indicates low battery condition on the device.
2835 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002836 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002837 * <p class="note">This is a protected intent that can only be sent
2838 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002839 */
2840 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2841 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2842 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002843 * Broadcast Action: Indicates the battery is now okay after being low.
2844 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2845 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002846 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002847 * <p class="note">This is a protected intent that can only be sent
2848 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002849 */
2850 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2851 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2852 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002853 * Broadcast Action: External power has been connected to the device.
2854 * This is intended for applications that wish to register specifically to this notification.
2855 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2856 * stay active to receive this notification. This action can be used to implement actions
2857 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002858 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002859 * <p class="note">This is a protected intent that can only be sent
2860 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002861 */
2862 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002863 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002864 /**
2865 * Broadcast Action: External power has been removed from the device.
2866 * This is intended for applications that wish to register specifically to this notification.
2867 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2868 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002869 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002870 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002871 * <p class="note">This is a protected intent that can only be sent
2872 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002873 */
2874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002875 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002876 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002877 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002878 * Broadcast Action: Device is shutting down.
2879 * This is broadcast when the device is being shut down (completely turned
2880 * off, not sleeping). Once the broadcast is complete, the final shutdown
2881 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002882 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002883 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2884 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2885 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002886 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002887 * <p class="note">This is a protected intent that can only be sent
2888 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002889 * <p>May include the following extras:
2890 * <ul>
2891 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2892 * shutdown is only for userspace processes. If not set, assumed to be false.
2893 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002894 */
2895 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002896 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002897 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002898 * Activity Action: Start this activity to request system shutdown.
2899 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002900 * to request confirmation from the user before shutting down. The optional boolean
2901 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2902 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002903 *
2904 * <p class="note">This is a protected intent that can only be sent
2905 * by the system.
2906 *
2907 * {@hide}
2908 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002909 public static final String ACTION_REQUEST_SHUTDOWN
2910 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002911 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002912 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002913 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002914 * <p class="note">
2915 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002916 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002917 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2918 * or above, this broadcast will no longer be delivered to any
2919 * {@link BroadcastReceiver} defined in your manifest. Instead,
2920 * apps are strongly encouraged to use the improved
2921 * {@link Context#getCacheDir()} behavior so the system can
2922 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002923 */
2924 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002925 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002926 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2927 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002928 * Broadcast Action: Indicates low storage space condition on the device no
2929 * longer exists
2930 * <p class="note">
2931 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002932 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002933 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2934 * or above, this broadcast will no longer be delivered to any
2935 * {@link BroadcastReceiver} defined in your manifest. Instead,
2936 * apps are strongly encouraged to use the improved
2937 * {@link Context#getCacheDir()} behavior so the system can
2938 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002939 */
2940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002941 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002942 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2943 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002944 * Broadcast Action: A sticky broadcast that indicates a storage space full
2945 * condition on the device. This is intended for activities that want to be
2946 * able to fill the data partition completely, leaving only enough free
2947 * space to prevent system-wide SQLite failures.
2948 * <p class="note">
2949 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002950 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002951 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2952 * or above, this broadcast will no longer be delivered to any
2953 * {@link BroadcastReceiver} defined in your manifest. Instead,
2954 * apps are strongly encouraged to use the improved
2955 * {@link Context#getCacheDir()} behavior so the system can
2956 * automatically free up storage when needed.
2957 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002958 */
2959 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002960 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002961 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2962 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002963 * Broadcast Action: Indicates storage space full condition on the device no
2964 * longer exists.
2965 * <p class="note">
2966 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002967 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002968 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2969 * or above, this broadcast will no longer be delivered to any
2970 * {@link BroadcastReceiver} defined in your manifest. Instead,
2971 * apps are strongly encouraged to use the improved
2972 * {@link Context#getCacheDir()} behavior so the system can
2973 * automatically free up storage when needed.
2974 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002975 */
2976 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002977 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002978 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2979 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002980 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2981 * and package management should be started.
2982 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2983 * notification.
2984 */
2985 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2986 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2987 /**
2988 * Broadcast Action: The device has entered USB Mass Storage mode.
2989 * This is used mainly for the USB Settings panel.
2990 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2991 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002992 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002993 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002994 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002995 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002996 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2997
2998 /**
2999 * Broadcast Action: The device has exited USB Mass Storage mode.
3000 * This is used mainly for the USB Settings panel.
3001 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3002 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07003003 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003004 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07003005 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06003006 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003007 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3008
3009 /**
3010 * Broadcast Action: External media has been removed.
3011 * The path to the mount point for the removed media is contained in the Intent.mData field.
3012 */
3013 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3014 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3015
3016 /**
3017 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003018 * 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 -07003019 */
3020 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3021 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3022
3023 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003024 * Broadcast Action: External media is present, and being disk-checked
3025 * 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 -08003026 */
3027 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3028 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3029
3030 /**
3031 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
3032 * 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 -08003033 */
3034 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3035 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3036
3037 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003038 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003039 * 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 -07003040 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3041 * media was mounted read only.
3042 */
3043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3044 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3045
3046 /**
3047 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003048 * 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 -07003049 */
3050 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3051 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3052
3053 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003054 * Broadcast Action: External media is no longer being shared via USB mass storage.
3055 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3056 *
3057 * @hide
3058 */
3059 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3060
3061 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003062 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
3063 * The path to the mount point for the removed media is contained in the Intent.mData field.
3064 */
3065 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3066 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3067
3068 /**
3069 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08003070 * 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 -07003071 */
3072 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3073 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3074
3075 /**
3076 * Broadcast Action: User has expressed the desire to remove the external storage media.
3077 * Applications should close all files they have open within the mount point when they receive this intent.
3078 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3079 */
3080 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3081 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3082
3083 /**
3084 * Broadcast Action: The media scanner has started scanning a directory.
3085 * The path to the directory being scanned is contained in the Intent.mData field.
3086 */
3087 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3088 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3089
3090 /**
3091 * Broadcast Action: The media scanner has finished scanning a directory.
3092 * The path to the scanned directory is contained in the Intent.mData field.
3093 */
3094 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3095 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3096
3097 /**
3098 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
3099 * The path to the file is contained in the Intent.mData field.
3100 */
3101 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3102 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3103
Jeff Sharkey50e74f12019-01-23 22:36:34 -07003104 /**
3105 * Broadcast Action: Request the media scanner to scan a storage volume and add it to the media database.
3106 * The path to the storage volume is contained in the Intent.mData field.
3107 */
3108 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3109 public static final String ACTION_MEDIA_SCANNER_SCAN_VOLUME = "android.intent.action.MEDIA_SCANNER_SCAN_VOLUME";
3110
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003111 /**
3112 * Broadcast Action: The "Media Button" was pressed. Includes a single
3113 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3114 * caused the broadcast.
3115 */
3116 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3117 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3118
3119 /**
3120 * Broadcast Action: The "Camera Button" was pressed. Includes a single
3121 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3122 * caused the broadcast.
3123 */
3124 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3125 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3126
3127 // *** NOTE: @todo(*) The following really should go into a more domain-specific
3128 // location; they are not general-purpose actions.
3129
3130 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003131 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003132 */
3133 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3134 public static final String ACTION_GTALK_SERVICE_CONNECTED =
3135 "android.intent.action.GTALK_CONNECTED";
3136
3137 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003138 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003139 */
3140 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3141 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3142 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003143
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003144 /**
3145 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003146 */
3147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3148 public static final String ACTION_INPUT_METHOD_CHANGED =
3149 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003150
3151 /**
3152 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3153 * more radios have been turned off or on. The intent will have the following extra value:</p>
3154 * <ul>
3155 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3156 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3157 * turned off</li>
3158 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08003159 *
Peng Xua35b5532016-01-20 00:05:45 -08003160 * <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 -07003161 */
3162 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3163 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3164
3165 /**
3166 * Broadcast Action: Some content providers have parts of their namespace
3167 * where they publish new events or items that the user may be especially
3168 * interested in. For these things, they may broadcast this action when the
3169 * set of interesting items change.
3170 *
3171 * For example, GmailProvider sends this notification when the set of unread
3172 * mail in the inbox changes.
3173 *
3174 * <p>The data of the intent identifies which part of which provider
3175 * changed. When queried through the content resolver, the data URI will
3176 * return the data set in question.
3177 *
3178 * <p>The intent will have the following extra values:
3179 * <ul>
3180 * <li><em>count</em> - The number of items in the data set. This is the
3181 * same as the number of items in the cursor returned by querying the
3182 * data URI. </li>
3183 * </ul>
3184 *
3185 * This intent will be sent at boot (if the count is non-zero) and when the
3186 * data set changes. It is possible for the data set to change without the
3187 * count changing (for example, if a new unread message arrives in the same
3188 * sync operation in which a message is archived). The phone should still
3189 * ring/vibrate/etc as normal in this case.
3190 */
3191 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3192 public static final String ACTION_PROVIDER_CHANGED =
3193 "android.intent.action.PROVIDER_CHANGED";
3194
3195 /**
3196 * Broadcast Action: Wired Headset plugged in or unplugged.
3197 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003198 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3199 * and documentation.
3200 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07003201 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003202 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003203 */
3204 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003205 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07003206
3207 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07003208 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3209 * <ul>
3210 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3211 * </ul>
3212 *
3213 * <p class="note">This is a protected intent that can only be sent
3214 * by the system.
3215 *
3216 * @hide
3217 */
3218 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3219 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3220 = "android.intent.action.ADVANCED_SETTINGS";
3221
3222 /**
Robin Lee66e5d962014-04-09 16:44:21 +01003223 * Broadcast Action: Sent after application restrictions are changed.
3224 *
3225 * <p class="note">This is a protected intent that can only be sent
3226 * by the system.</p>
3227 */
3228 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3229 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3230 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3231
3232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003233 * Broadcast Action: An outgoing call is about to be placed.
3234 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07003235 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003236 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07003237 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003238 * the phone number originally intended to be dialed.</li>
3239 * </ul>
3240 * <p>Once the broadcast is finished, the resultData is used as the actual
3241 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07003242 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003243 * outgoing call in turn: for example, a parental control application
3244 * might verify that the user is authorized to place the call at that
3245 * time, then a number-rewriting application might add an area code if
3246 * one was not specified.</p>
3247 * <p>For consistency, any receiver whose purpose is to prohibit phone
3248 * calls should have a priority of 0, to ensure it will see the final
3249 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07003250 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003251 * should have a positive priority.
3252 * Negative priorities are reserved for the system for this broadcast;
3253 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003254 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3255 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003256 * <p>Emergency calls cannot be intercepted using this mechanism, and
3257 * other calls cannot be modified to call emergency numbers using this
3258 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003259 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3260 * call to use their own service instead. Those apps should first prevent
3261 * the call from being placed by setting resultData to <code>null</code>
3262 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003263 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003264 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3265 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003266 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003267 * <p class="note">This is a protected intent that can only be sent
3268 * by the system.
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003269 *
3270 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3271 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3272 * This means that attempts to re-write the outgoing call by other apps using this intent will
3273 * be ignored.
3274 * </p>
3275 *
3276 * @deprecated Apps that redirect outgoing calls should use the
3277 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3278 * should use the {@link android.telecom.CallScreeningService} API.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003279 */
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003280 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003281 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3282 public static final String ACTION_NEW_OUTGOING_CALL =
3283 "android.intent.action.NEW_OUTGOING_CALL";
3284
3285 /**
3286 * Broadcast Action: Have the device reboot. This is only for use by
3287 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003288 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003289 * <p class="note">This is a protected intent that can only be sent
3290 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003291 */
3292 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3293 public static final String ACTION_REBOOT =
3294 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003295
Wei Huang97ecc9c2009-05-11 17:44:20 -07003296 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003297 * Broadcast Action: A sticky broadcast for changes in the physical
3298 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003299 *
3300 * <p>The intent will have the following extra values:
3301 * <ul>
3302 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003303 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003304 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003305 * <p>This is intended for monitoring the current physical dock state.
3306 * See {@link android.app.UiModeManager} for the normal API dealing with
3307 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003308 */
3309 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3310 public static final String ACTION_DOCK_EVENT =
3311 "android.intent.action.DOCK_EVENT";
3312
3313 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003314 * Broadcast Action: A broadcast when idle maintenance can be started.
3315 * This means that the user is not interacting with the device and is
3316 * not expected to do so soon. Typical use of the idle maintenance is
3317 * to perform somehow expensive tasks that can be postponed at a moment
3318 * when they will not degrade user experience.
3319 * <p>
3320 * <p class="note">In order to keep the device responsive in case of an
3321 * unexpected user interaction, implementations of a maintenance task
3322 * should be interruptible. In such a scenario a broadcast with action
3323 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3324 * should not do the maintenance work in
3325 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3326 * maintenance service by {@link Context#startService(Intent)}. Also
3327 * you should hold a wake lock while your maintenance service is running
3328 * to prevent the device going to sleep.
3329 * </p>
3330 * <p>
3331 * <p class="note">This is a protected intent that can only be sent by
3332 * the system.
3333 * </p>
3334 *
3335 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003336 *
3337 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003338 */
3339 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3340 public static final String ACTION_IDLE_MAINTENANCE_START =
3341 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3342
3343 /**
3344 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3345 * This means that the user was not interacting with the device as a result
3346 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3347 * was sent and now the user started interacting with the device. Typical
3348 * use of the idle maintenance is to perform somehow expensive tasks that
3349 * can be postponed at a moment when they will not degrade user experience.
3350 * <p>
3351 * <p class="note">In order to keep the device responsive in case of an
3352 * unexpected user interaction, implementations of a maintenance task
3353 * should be interruptible. Hence, on receiving a broadcast with this
3354 * action, the maintenance task should be interrupted as soon as possible.
3355 * In other words, you should not do the maintenance work in
3356 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3357 * maintenance service that was started on receiving of
3358 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3359 * lock you acquired when your maintenance service started.
3360 * </p>
3361 * <p class="note">This is a protected intent that can only be sent
3362 * by the system.
3363 *
3364 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003365 *
3366 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003367 */
3368 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3369 public static final String ACTION_IDLE_MAINTENANCE_END =
3370 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3371
3372 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003373 * Broadcast Action: a remote intent is to be broadcasted.
3374 *
3375 * A remote intent is used for remote RPC between devices. The remote intent
3376 * is serialized and sent from one device to another device. The receiving
3377 * device parses the remote intent and broadcasts it. Note that anyone can
3378 * broadcast a remote intent. However, if the intent receiver of the remote intent
3379 * does not trust intent broadcasts from arbitrary intent senders, it should require
3380 * the sender to hold certain permissions so only trusted sender's broadcast will be
3381 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003382 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003383 */
3384 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003385 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003386
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003387 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003388 * Broadcast Action: This is broadcast once when the user is booting after a
3389 * system update. It can be used to perform cleanup or upgrades after a
3390 * system update.
3391 * <p>
3392 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3393 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3394 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3395 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003396 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003397 * @hide
3398 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003399 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003400 public static final String ACTION_PRE_BOOT_COMPLETED =
3401 "android.intent.action.PRE_BOOT_COMPLETED";
3402
Amith Yamasani13593602012-03-22 16:16:17 -07003403 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003404 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003405 * on restricted users. The broadcast intent contains an extra
3406 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3407 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3408 * String[] depending on the restriction type.<p/>
3409 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003410 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3411 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3412 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003413 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3414 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003415 * @see RestrictionEntry
3416 */
3417 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3418 "android.intent.action.GET_RESTRICTION_ENTRIES";
3419
3420 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003421 * Sent the first time a user is starting, to allow system apps to
3422 * perform one time initialization. (This will not be seen by third
3423 * party applications because a newly initialized user does not have any
3424 * third party applications installed for it.) This is sent early in
3425 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003426 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3427 * broadcast, since it is part of a visible user interaction; be as quick
3428 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003429 */
3430 public static final String ACTION_USER_INITIALIZE =
3431 "android.intent.action.USER_INITIALIZE";
3432
3433 /**
3434 * Sent when a user switch is happening, causing the process's user to be
3435 * brought to the foreground. This is only sent to receivers registered
3436 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3437 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003438 * foreground. This is sent as a foreground
3439 * broadcast, since it is part of a visible user interaction; be as quick
3440 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003441 */
3442 public static final String ACTION_USER_FOREGROUND =
3443 "android.intent.action.USER_FOREGROUND";
3444
3445 /**
3446 * Sent when a user switch is happening, causing the process's user to be
3447 * sent to the background. This is only sent to receivers registered
3448 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3449 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003450 * background. This is sent as a foreground
3451 * broadcast, since it is part of a visible user interaction; be as quick
3452 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003453 */
3454 public static final String ACTION_USER_BACKGROUND =
3455 "android.intent.action.USER_BACKGROUND";
3456
3457 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003458 * Broadcast sent to the system when a user is added. Carries an extra
3459 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3460 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003461 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003462 * @hide
3463 */
3464 public static final String ACTION_USER_ADDED =
3465 "android.intent.action.USER_ADDED";
3466
3467 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003468 * Broadcast sent by the system when a user is started. Carries an extra
3469 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003470 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003471 * that has been started. This is sent as a foreground
3472 * broadcast, since it is part of a visible user interaction; be as quick
3473 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003474 * @hide
3475 */
3476 public static final String ACTION_USER_STARTED =
3477 "android.intent.action.USER_STARTED";
3478
3479 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003480 * Broadcast sent when a user is in the process of starting. Carries an extra
3481 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3482 * sent to registered receivers, not manifest receivers. It is sent to all
3483 * users (including the one that is being started). You must hold
3484 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3485 * this broadcast. This is sent as a background broadcast, since
3486 * its result is not part of the primary UX flow; to safely keep track of
3487 * started/stopped state of a user you can use this in conjunction with
3488 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3489 * other user state broadcasts since those are foreground broadcasts so can
3490 * execute in a different order.
3491 * @hide
3492 */
3493 public static final String ACTION_USER_STARTING =
3494 "android.intent.action.USER_STARTING";
3495
3496 /**
3497 * Broadcast sent when a user is going to be stopped. Carries an extra
3498 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3499 * sent to registered receivers, not manifest receivers. It is sent to all
3500 * users (including the one that is being stopped). You must hold
3501 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3502 * this broadcast. The user will not stop until all receivers have
3503 * handled the broadcast. This is sent as a background broadcast, since
3504 * its result is not part of the primary UX flow; to safely keep track of
3505 * started/stopped state of a user you can use this in conjunction with
3506 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3507 * other user state broadcasts since those are foreground broadcasts so can
3508 * execute in a different order.
3509 * @hide
3510 */
3511 public static final String ACTION_USER_STOPPING =
3512 "android.intent.action.USER_STOPPING";
3513
3514 /**
3515 * Broadcast sent to the system when a user is stopped. Carries an extra
3516 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3517 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3518 * specific package. This is only sent to registered receivers, not manifest
3519 * receivers. It is sent to all running users <em>except</em> the one that
3520 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003521 * @hide
3522 */
3523 public static final String ACTION_USER_STOPPED =
3524 "android.intent.action.USER_STOPPED";
3525
3526 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003527 * 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 -07003528 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003529 * one that has been removed. The user will not be completely removed until all receivers have
3530 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003531 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003532 * @hide
3533 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003534 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003535 public static final String ACTION_USER_REMOVED =
3536 "android.intent.action.USER_REMOVED";
3537
3538 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003539 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003540 * the userHandle of the user to become the current one. This is only sent to
3541 * registered receivers, not manifest receivers. It is sent to all running users.
3542 * You must hold
3543 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003544 * @hide
3545 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003546 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003547 public static final String ACTION_USER_SWITCHED =
3548 "android.intent.action.USER_SWITCHED";
3549
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003550 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003551 * Broadcast Action: Sent when the credential-encrypted private storage has
3552 * become unlocked for the target user. This is only sent to registered
3553 * receivers, not manifest receivers.
3554 */
3555 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3556 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3557
3558 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003559 * Broadcast sent to the system when a user's information changes. Carries an extra
3560 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003561 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003562 * @hide
3563 */
3564 public static final String ACTION_USER_INFO_CHANGED =
3565 "android.intent.action.USER_INFO_CHANGED";
3566
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003567 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003568 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3569 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003570 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3571 * that need to display merged content across both primary and managed profiles need to
3572 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003573 * not manifest receivers.
3574 */
3575 public static final String ACTION_MANAGED_PROFILE_ADDED =
3576 "android.intent.action.MANAGED_PROFILE_ADDED";
3577
3578 /**
3579 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003580 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3581 * Only applications (for example Launchers) that need to display merged content across both
3582 * primary and managed profiles need to worry about this broadcast. This is only sent to
3583 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003584 */
3585 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3586 "android.intent.action.MANAGED_PROFILE_REMOVED";
3587
3588 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003589 * Broadcast sent to the primary user when the credential-encrypted private storage for
3590 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3591 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3592 * Launchers) that need to display merged content across both primary and managed profiles
3593 * need to worry about this broadcast. This is only sent to registered receivers,
3594 * not manifest receivers.
3595 */
3596 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3597 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3598
3599 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003600 * Broadcast sent to the primary user when an associated managed profile has become available.
3601 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003602 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3603 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3604 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003605 */
Rubin Xue95057a2016-04-01 16:49:25 +01003606 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3607 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3608
3609 /**
3610 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3611 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3612 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3613 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3614 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3615 */
3616 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3617 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003618
3619 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003620 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3621 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3622 * the device was locked or unlocked.
3623 *
3624 * This is only sent to registered receivers.
3625 *
3626 * @hide
3627 */
3628 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3629 "android.intent.action.DEVICE_LOCKED_CHANGED";
3630
3631 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003632 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3633 */
3634 public static final String ACTION_QUICK_CLOCK =
3635 "android.intent.action.QUICK_CLOCK";
3636
Michael Wright0087a142013-02-05 16:29:39 -08003637 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003638 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003639 * @hide
3640 */
3641 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003642 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003643
Justin Kohd378ad72013-04-01 12:18:26 -07003644 /**
3645 * Broadcast Action: A global button was pressed. Includes a single
3646 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3647 * caused the broadcast.
3648 * @hide
3649 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003650 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003651 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3652
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003653 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003654 * Broadcast Action: Sent when media resource is granted.
3655 * <p>
3656 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3657 * granted.
3658 * </p>
3659 * <p class="note">
3660 * This is a protected intent that can only be sent by the system.
3661 * </p>
3662 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003663 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003664 * </p>
3665 *
3666 * @hide
3667 */
3668 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3669 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3670
3671 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003672 * Broadcast Action: An overlay package has changed. The data contains the
3673 * name of the overlay package which has changed. This is broadcast on all
3674 * changes to the OverlayInfo returned by {@link
3675 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3676 * most common change is a state change that will change whether the
3677 * overlay is enabled or not.
3678 * @hide
3679 */
3680 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3681
3682 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003683 * Activity Action: Allow the user to select and return one or more existing
3684 * documents. When invoked, the system will display the various
3685 * {@link DocumentsProvider} instances installed on the device, letting the
3686 * user interactively navigate through them. These documents include local
3687 * media, such as photos and video, and documents provided by installed
3688 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003689 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003690 * Each document is represented as a {@code content://} URI backed by a
3691 * {@link DocumentsProvider}, which can be opened as a stream with
3692 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3693 * {@link android.provider.DocumentsContract.Document} metadata.
3694 * <p>
3695 * All selected documents are returned to the calling application with
3696 * persistable read and write permission grants. If you want to maintain
3697 * access to the documents across device reboots, you need to explicitly
3698 * take the persistable permissions using
3699 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3700 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003701 * Callers must indicate the acceptable document MIME types through
3702 * {@link #setType(String)}. For example, to select photos, use
3703 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3704 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3705 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003706 * <p>
3707 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003708 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3709 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003710 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003711 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3712 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003713 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003714 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003715 * Callers can set a document URI through
3716 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3717 * location of documents navigator. System will do its best to launch the
3718 * navigator in the specified document if it's a folder, or the folder that
3719 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003720 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003721 * Output: The URI of the item that was picked, returned in
3722 * {@link #getData()}. This must be a {@code content://} URI so that any
3723 * receiver can access it. If multiple documents were selected, they are
3724 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003725 *
3726 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003727 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003728 * @see #ACTION_CREATE_DOCUMENT
3729 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003730 */
3731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3732 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3733
3734 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003735 * Activity Action: Allow the user to create a new document. When invoked,
3736 * the system will display the various {@link DocumentsProvider} instances
3737 * installed on the device, letting the user navigate through them. The
3738 * returned document may be a newly created document with no content, or it
3739 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003740 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003741 * Each document is represented as a {@code content://} URI backed by a
3742 * {@link DocumentsProvider}, which can be opened as a stream with
3743 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3744 * {@link android.provider.DocumentsContract.Document} metadata.
3745 * <p>
3746 * Callers must indicate the concrete MIME type of the document being
3747 * created by setting {@link #setType(String)}. This MIME type cannot be
3748 * changed after the document is created.
3749 * <p>
3750 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3751 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003752 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003753 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3754 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003755 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003756 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003757 * Callers can set a document URI through
3758 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3759 * location of documents navigator. System will do its best to launch the
3760 * navigator in the specified document if it's a folder, or the folder that
3761 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003762 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003763 * Output: The URI of the item that was created. This must be a
3764 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003765 *
3766 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003767 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003768 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003769 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003770 */
3771 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3772 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3773
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003774 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003775 * Activity Action: Allow the user to pick a directory subtree. When
3776 * invoked, the system will display the various {@link DocumentsProvider}
3777 * instances installed on the device, letting the user navigate through
3778 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003779 * <p>
3780 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003781 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3782 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3783 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003784 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003785 * Callers can set a document URI through
3786 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3787 * location of documents navigator. System will do its best to launch the
3788 * navigator in the specified document if it's a folder, or the folder that
3789 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003790 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003791 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003792 *
3793 * @see DocumentsContract
3794 */
3795 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003796 public static final String
3797 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003798
Abodunrinwa Toki4bad09c2018-10-25 18:12:28 +01003799
3800 /**
3801 * Activity Action: Perform text translation.
3802 * <p>
3803 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3804 * <p>
3805 * Output: nothing.
3806 */
3807 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3808 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3809
Felipe Lemec7b1f892016-01-15 15:02:31 -08003810 /**
Tony Make1f3ac062018-11-27 14:30:21 +00003811 * Activity Action: Define the meaning of the selected word(s).
3812 * <p>
3813 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3814 * <p>
3815 * Output: nothing.
3816 */
3817 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3818 public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3819
3820 /**
Peng Xua35b5532016-01-20 00:05:45 -08003821 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3822 * exisiting sensor being disconnected.
3823 *
3824 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3825 *
3826 * {@hide}
3827 */
3828 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3829 public static final String
3830 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3831
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003832 /**
Sam Line707f832017-04-13 17:00:55 -07003833 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003834 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003835 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003836 */
3837 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003838 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003839 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3840
Christopher Tate6597e342015-02-17 12:15:25 -08003841 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003842 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3843 * is about to be performed.
3844 * @hide
3845 */
3846 @SystemApi
3847 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3848 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3849 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3850
3851 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003852 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3853 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3854 *
3855 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3856 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003857 * @hide
3858 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003859 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003860 public static final String EXTRA_FORCE_MASTER_CLEAR =
3861 "android.intent.extra.FORCE_MASTER_CLEAR";
3862
3863 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003864 * A broadcast action to trigger a factory reset.
3865 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003866 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3867 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003868 *
3869 * <p>Not for use by third-party applications.
3870 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003871 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003872 *
3873 * {@hide}
3874 */
3875 @SystemApi
3876 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3877 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3878
3879 /**
3880 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3881 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3882 *
3883 * <p>Not for use by third-party applications.
3884 *
3885 * @hide
3886 */
3887 @SystemApi
3888 public static final String EXTRA_FORCE_FACTORY_RESET =
3889 "android.intent.extra.FORCE_FACTORY_RESET";
3890
3891 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003892 * Broadcast action: report that a settings element is being restored from backup. The intent
3893 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3894 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3895 * is the value of that settings entry prior to the restore operation, and
3896 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3897 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3898 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003899 *
3900 * <p>This broadcast is sent only for settings provider entries known to require special handling
3901 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3902 * the provider's backup agent implementation.
3903 *
3904 * @see #EXTRA_SETTING_NAME
3905 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3906 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003907 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003908 * {@hide}
3909 */
3910 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3911
3912 /** {@hide} */
3913 public static final String EXTRA_SETTING_NAME = "setting_name";
3914 /** {@hide} */
3915 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3916 /** {@hide} */
3917 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003918 /** {@hide} */
3919 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003920
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003921 /**
3922 * Activity Action: Process a piece of text.
3923 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3924 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3925 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3926 */
3927 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3928 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003929
3930 /**
3931 * Broadcast Action: The sim card state has changed.
3932 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3933 * because TelephonyIntents is an internal class.
3934 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003935 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3936 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003937 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003938 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003939 @SystemApi
3940 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3941 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3942
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003943 /**
fionaxu90fee272017-03-31 12:45:12 -07003944 * Broadcast Action: indicate that the phone service state has changed.
3945 * The intent will have the following extra values:</p>
3946 * <p>
3947 * @see #EXTRA_VOICE_REG_STATE
3948 * @see #EXTRA_DATA_REG_STATE
3949 * @see #EXTRA_VOICE_ROAMING_TYPE
3950 * @see #EXTRA_DATA_ROAMING_TYPE
3951 * @see #EXTRA_OPERATOR_ALPHA_LONG
3952 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3953 * @see #EXTRA_OPERATOR_NUMERIC
3954 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3955 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3956 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3957 * @see #EXTRA_MANUAL
3958 * @see #EXTRA_VOICE_RADIO_TECH
3959 * @see #EXTRA_DATA_RADIO_TECH
3960 * @see #EXTRA_CSS_INDICATOR
3961 * @see #EXTRA_NETWORK_ID
3962 * @see #EXTRA_SYSTEM_ID
3963 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3964 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3965 * @see #EXTRA_EMERGENCY_ONLY
3966 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3967 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3968 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3969 *
3970 * <p class="note">
3971 * Requires the READ_PHONE_STATE permission.
3972 *
3973 * <p class="note">This is a protected intent that can only be sent by the system.
3974 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003975 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003976 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3977 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3978 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3979 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003980 */
3981 @Deprecated
3982 @SystemApi
3983 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3984 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3985
3986 /**
3987 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3988 * state.
3989 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3990 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3991 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3992 * @see android.telephony.ServiceState#STATE_POWER_OFF
3993 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003994 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003995 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003996 */
3997 @Deprecated
3998 @SystemApi
3999 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4000
4001 /**
4002 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4003 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4004 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4005 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4006 * @see android.telephony.ServiceState#STATE_POWER_OFF
4007 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004008 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004009 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07004010 */
4011 @Deprecated
4012 @SystemApi
4013 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4014
4015 /**
4016 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4017 * type.
4018 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004019 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004020 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004021 */
4022 @Deprecated
4023 @SystemApi
4024 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4025
4026 /**
4027 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4028 * type.
4029 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004030 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004031 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004032 */
4033 @Deprecated
4034 @SystemApi
4035 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4036
4037 /**
4038 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4039 * registered voice operator name in long alphanumeric format.
4040 * {@code null} if the operator name is not known or unregistered.
4041 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004042 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004043 * @deprecated Use
4044 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004045 */
4046 @Deprecated
4047 @SystemApi
4048 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4049
4050 /**
4051 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4052 * registered voice operator name in short alphanumeric format.
4053 * {@code null} if the operator name is not known or unregistered.
4054 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004055 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004056 * @deprecated Use
4057 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004058 */
4059 @Deprecated
4060 @SystemApi
4061 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4062
4063 /**
4064 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4065 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4066 * network.
4067 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004068 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004069 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004070 */
4071 @Deprecated
4072 @SystemApi
4073 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4074
4075 /**
4076 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4077 * registered data operator name in long alphanumeric format.
4078 * {@code null} if the operator name is not known or unregistered.
4079 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004080 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004081 * @deprecated Use
4082 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004083 */
4084 @Deprecated
4085 @SystemApi
4086 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4087
4088 /**
4089 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4090 * registered data operator name in short alphanumeric format.
4091 * {@code null} if the operator name is not known or unregistered.
4092 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004093 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004094 * @deprecated Use
4095 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004096 */
4097 @Deprecated
4098 @SystemApi
4099 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4100
4101 /**
4102 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4103 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4104 * data operator.
4105 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004106 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004107 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004108 */
4109 @Deprecated
4110 @SystemApi
4111 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4112
4113 /**
4114 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4115 * network selection mode is manual.
4116 * Will be {@code true} if manual mode, {@code false} if automatic mode.
4117 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004118 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004119 * @deprecated Use
4120 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07004121 */
4122 @Deprecated
4123 @SystemApi
4124 public static final String EXTRA_MANUAL = "manual";
4125
4126 /**
4127 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4128 * radio technology.
4129 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004130 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004131 * @deprecated Use
4132 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004133 */
4134 @Deprecated
4135 @SystemApi
4136 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4137
4138 /**
4139 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4140 * radio technology.
4141 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004142 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004143 * @deprecated Use
4144 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004145 */
4146 @Deprecated
4147 @SystemApi
4148 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4149
4150 /**
4151 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4152 * support on CDMA network.
4153 * Will be {@code true} if support, {@code false} otherwise.
4154 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004155 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004156 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004157 */
4158 @Deprecated
4159 @SystemApi
4160 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4161
4162 /**
4163 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4164 * id. {@code Integer.MAX_VALUE} if unknown.
4165 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004166 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004167 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004168 */
4169 @Deprecated
4170 @SystemApi
4171 public static final String EXTRA_NETWORK_ID = "networkId";
4172
4173 /**
4174 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4175 * {@code Integer.MAX_VALUE} if unknown.
4176 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004177 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004178 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004179 */
4180 @Deprecated
4181 @SystemApi
4182 public static final String EXTRA_SYSTEM_ID = "systemId";
4183
4184 /**
4185 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4186 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4187 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004188 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004189 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004190 */
4191 @Deprecated
4192 @SystemApi
4193 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4194
4195 /**
4196 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4197 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4198 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004199 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004200 * @deprecated Use
4201 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004202 */
4203 @Deprecated
4204 @SystemApi
4205 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4206
4207 /**
4208 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4209 * only mode.
4210 * {@code true} if in emergency only mode, {@code false} otherwise.
4211 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004212 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004213 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07004214 */
4215 @Deprecated
4216 @SystemApi
4217 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4218
4219 /**
4220 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4221 * registration state is roaming.
4222 * {@code true} if registration indicates roaming, {@code false} otherwise
4223 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004224 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004225 * @deprecated Use
4226 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07004227 */
4228 @Deprecated
4229 @SystemApi
4230 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4231 "isDataRoamingFromRegistration";
4232
4233 /**
4234 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4235 * aggregation is in use.
4236 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4237 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004238 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004239 * @deprecated Use
4240 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07004241 */
4242 @Deprecated
4243 @SystemApi
4244 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4245
4246 /**
4247 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4248 * is reduced from the rsrp threshold while calculating signal strength level.
4249 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004250 * @removed
fionaxu90fee272017-03-31 12:45:12 -07004251 */
4252 @Deprecated
4253 @SystemApi
4254 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4255
4256 /**
chen xu02811692018-10-03 19:07:09 -07004257 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
4258 * @hide
4259 */
4260 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4261
4262 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004263 * The name of the extra used to define the text to be processed, as a
4264 * CharSequence. Note that this may be a styled CharSequence, so you must use
4265 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004266 */
4267 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4268 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004269 * 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 +00004270 */
4271 public static final String EXTRA_PROCESS_TEXT_READONLY =
4272 "android.intent.extra.PROCESS_TEXT_READONLY";
4273
Bryce Leebc58f592015-09-25 16:43:01 -07004274 /**
4275 * Broadcast action: reports when a new thermal event has been reached. When the device
4276 * is reaching its maximum temperatue, the thermal level reported
4277 * {@hide}
4278 */
4279 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4280 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4281
4282 /** {@hide} */
4283 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4284
4285 /**
4286 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004287 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004288 * {@hide}
4289 */
4290 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4291
4292 /**
4293 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004294 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004295 * {@hide}
4296 */
4297 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4298
4299 /**
4300 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004301 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004302 * {@hide}
4303 */
4304 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4305
lpeter318abc92018-05-04 16:13:14 +08004306 /**
4307 * Broadcast Action: Indicates the dock in idle state while device is docked.
4308 *
4309 * <p class="note">This is a protected intent that can only be sent
4310 * by the system.
4311 *
4312 * @hide
4313 */
4314 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4315
4316 /**
4317 * Broadcast Action: Indicates the dock in active state while device is docked.
4318 *
4319 * <p class="note">This is a protected intent that can only be sent
4320 * by the system.
4321 *
4322 * @hide
4323 */
4324 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4325
MÃ¥rten Kongstadfd20b832018-10-26 15:36:20 +02004326 /**
4327 * Broadcast Action: Indicates that a new device customization has been
4328 * downloaded and applied (packages installed, runtime resource overlays
4329 * enabled, xml files copied, ...), and that it is time for components that
4330 * need to for example clear their caches to do so now.
4331 *
4332 * @hide
4333 */
4334 @SystemApi
4335 public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4336 "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4337
Bryce Leebc58f592015-09-25 16:43:01 -07004338
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004339 // ---------------------------------------------------------------------
4340 // ---------------------------------------------------------------------
4341 // Standard intent categories (see addCategory()).
4342
4343 /**
4344 * Set if the activity should be an option for the default action
4345 * (center press) to perform on a piece of data. Setting this will
4346 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004347 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004348 * Intent when initiating an action -- it is for use in intent filters
4349 * specified in packages.
4350 */
4351 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4352 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4353 /**
4354 * Activities that can be safely invoked from a browser must support this
4355 * category. For example, if the user is viewing a web page or an e-mail
4356 * and clicks on a link in the text, the Intent generated execute that
4357 * link will require the BROWSABLE category, so that only activities
4358 * supporting this category will be considered as possible actions. By
4359 * supporting this category, you are promising that there is nothing
4360 * damaging (without user intervention) that can happen by invoking any
4361 * matching Intent.
4362 */
4363 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4364 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4365 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004366 * Categories for activities that can participate in voice interaction.
4367 * An activity that supports this category must be prepared to run with
4368 * no UI shown at all (though in some case it may have a UI shown), and
4369 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4370 */
4371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4372 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4373 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004374 * Set if the activity should be considered as an alternative action to
4375 * the data the user is currently viewing. See also
4376 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4377 * applies to the selection in a list of items.
4378 *
4379 * <p>Supporting this category means that you would like your activity to be
4380 * displayed in the set of alternative things the user can do, usually as
4381 * part of the current activity's options menu. You will usually want to
4382 * include a specific label in the &lt;intent-filter&gt; of this action
4383 * describing to the user what it does.
4384 *
4385 * <p>The action of IntentFilter with this category is important in that it
4386 * describes the specific action the target will perform. This generally
4387 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4388 * a specific name such as "com.android.camera.action.CROP. Only one
4389 * alternative of any particular action will be shown to the user, so using
4390 * a specific action like this makes sure that your alternative will be
4391 * displayed while also allowing other applications to provide their own
4392 * overrides of that particular action.
4393 */
4394 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4395 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4396 /**
4397 * Set if the activity should be considered as an alternative selection
4398 * action to the data the user has currently selected. This is like
4399 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4400 * of items from which the user can select, giving them alternatives to the
4401 * default action that will be performed on it.
4402 */
4403 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4404 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4405 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004406 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004407 */
4408 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4409 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4410 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004411 * Should be displayed in the top-level launcher.
4412 */
4413 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4414 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4415 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004416 * Indicates an activity optimized for Leanback mode, and that should
4417 * be displayed in the Leanback launcher.
4418 */
4419 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4420 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4421 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004422 * Indicates the preferred entry-point activity when an application is launched from a Car
4423 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4424 * fallback, or exclude the application entirely.
4425 * @hide
4426 */
4427 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4428 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4429 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004430 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4431 * @hide
4432 */
4433 @SystemApi
4434 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4435 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004436 * Provides information about the package it is in; typically used if
4437 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4438 * a front-door to the user without having to be shown in the all apps list.
4439 */
4440 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4441 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4442 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004443 * This is the home activity, that is the first activity that is displayed
4444 * when the device boots.
4445 */
4446 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4447 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4448 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004449 * This is the home activity that is displayed when the device is finished setting up and ready
4450 * for use.
4451 * @hide
4452 */
4453 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4454 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4455 /**
Chilun2ef71f72018-11-16 17:57:15 +08004456 * The home activity shown on secondary displays that support showing home activities.
4457 */
4458 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4459 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4460 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004461 * This is the setup wizard activity, that is the first activity that is displayed
4462 * when the user sets up the device for the first time.
4463 * @hide
4464 */
4465 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4466 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4467 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004468 * This is the home activity, that is the activity that serves as the launcher app
4469 * from there the user can start other apps. Often components with lower/higher
4470 * priority intent filters handle the home intent, for example SetupWizard, to
4471 * setup the device and we need to be able to distinguish the home app from these
4472 * setup helpers.
4473 * @hide
4474 */
4475 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4476 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4477 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004478 * This activity is a preference panel.
4479 */
4480 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4481 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4482 /**
4483 * This activity is a development preference panel.
4484 */
4485 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4486 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4487 /**
4488 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004489 */
4490 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4491 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4492 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004493 * This activity allows the user to browse and download new applications.
4494 */
4495 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4496 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4497 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004498 * This activity may be exercised by the monkey or other automated test tools.
4499 */
4500 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4501 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4502 /**
4503 * To be used as a test (not part of the normal user experience).
4504 */
4505 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4506 /**
4507 * To be used as a unit test (run through the Test Harness).
4508 */
4509 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4510 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004511 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004512 * experience).
4513 */
4514 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004515
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004516 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004517 * Used to indicate that an intent only wants URIs that can be opened with
4518 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4519 * must support at least the columns defined in {@link OpenableColumns} when
4520 * queried.
4521 *
4522 * @see #ACTION_GET_CONTENT
4523 * @see #ACTION_OPEN_DOCUMENT
4524 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004525 */
4526 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4527 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4528
4529 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004530 * Used to indicate that an intent filter can accept files which are not necessarily
4531 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4532 * at least streamable via
4533 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4534 * using one of the stream types exposed via
4535 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4536 *
4537 * @see #ACTION_SEND
4538 * @see #ACTION_SEND_MULTIPLE
4539 */
4540 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4541 public static final String CATEGORY_TYPED_OPENABLE =
4542 "android.intent.category.TYPED_OPENABLE";
4543
4544 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004545 * To be used as code under test for framework instrumentation tests.
4546 */
4547 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4548 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004549 /**
4550 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004551 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4552 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004553 */
4554 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4555 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4556 /**
4557 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004558 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4559 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004560 */
4561 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4562 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004563 /**
4564 * An activity to run when device is inserted into a analog (low end) dock.
4565 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4566 * information, see {@link android.app.UiModeManager}.
4567 */
4568 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4569 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4570
4571 /**
4572 * An activity to run when device is inserted into a digital (high end) dock.
4573 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4574 * information, see {@link android.app.UiModeManager}.
4575 */
4576 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4577 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004578
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004579 /**
4580 * Used to indicate that the activity can be used in a car environment.
4581 */
4582 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4583 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4584
Zak Cohendb6ca492017-01-26 14:09:00 -08004585 /**
4586 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4587 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4588 * information, see {@link android.app.UiModeManager}.
4589 */
4590 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4591 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004592 // ---------------------------------------------------------------------
4593 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004594 // Application launch intent categories (see addCategory()).
4595
4596 /**
4597 * Used with {@link #ACTION_MAIN} to launch the browser application.
4598 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004599 * <p>NOTE: This should not be used as the primary key of an Intent,
4600 * since it will not result in the app launching with the correct
4601 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004602 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004603 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004604 */
4605 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4606 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4607
4608 /**
4609 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4610 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004611 * <p>NOTE: This should not be used as the primary key of an Intent,
4612 * since it will not result in the app launching with the correct
4613 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004614 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004615 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004616 */
4617 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4618 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4619
4620 /**
4621 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4622 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004623 * <p>NOTE: This should not be used as the primary key of an Intent,
4624 * since it will not result in the app launching with the correct
4625 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004626 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004627 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004628 */
4629 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4630 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4631
4632 /**
4633 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4634 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004635 * <p>NOTE: This should not be used as the primary key of an Intent,
4636 * since it will not result in the app launching with the correct
4637 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004638 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004639 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004640 */
4641 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4642 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4643
4644 /**
4645 * Used with {@link #ACTION_MAIN} to launch the email application.
4646 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004647 * <p>NOTE: This should not be used as the primary key of an Intent,
4648 * since it will not result in the app launching with the correct
4649 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004650 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004651 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004652 */
4653 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4654 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4655
4656 /**
4657 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4658 * The activity should be able to view and manipulate image and video files
4659 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004660 * <p>NOTE: This should not be used as the primary key of an Intent,
4661 * since it will not result in the app launching with the correct
4662 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004663 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004664 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004665 */
4666 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4667 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4668
4669 /**
4670 * Used with {@link #ACTION_MAIN} to launch the maps application.
4671 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004672 * <p>NOTE: This should not be used as the primary key of an Intent,
4673 * since it will not result in the app launching with the correct
4674 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004675 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004676 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004677 */
4678 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4679 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4680
4681 /**
4682 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4683 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004684 * <p>NOTE: This should not be used as the primary key of an Intent,
4685 * since it will not result in the app launching with the correct
4686 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004687 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004688 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004689 */
4690 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4691 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4692
4693 /**
4694 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004695 * The activity should be able to play, browse, or manipulate music files
4696 * stored on the device.
4697 * <p>NOTE: This should not be used as the primary key of an Intent,
4698 * since it will not result in the app launching with the correct
4699 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004700 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004701 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004702 */
4703 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4704 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4705
4706 // ---------------------------------------------------------------------
4707 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004708 // Standard extra data keys.
4709
4710 /**
4711 * The initial data to place in a newly created record. Use with
4712 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4713 * fields as would be given to the underlying ContentProvider.insert()
4714 * call.
4715 */
4716 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4717
4718 /**
4719 * A constant CharSequence that is associated with the Intent, used with
4720 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4721 * this may be a styled CharSequence, so you must use
4722 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4723 * retrieve it.
4724 */
4725 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4726
4727 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004728 * A constant String that is associated with the Intent, used with
4729 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4730 * as HTML formatted text. Note that you <em>must</em> also supply
4731 * {@link #EXTRA_TEXT}.
4732 */
4733 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4734
4735 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004736 * A content: URI holding a stream of data associated with the Intent,
4737 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004738 */
4739 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4740
4741 /**
4742 * A String[] holding e-mail addresses that should be delivered to.
4743 */
4744 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4745
4746 /**
4747 * A String[] holding e-mail addresses that should be carbon copied.
4748 */
4749 public static final String EXTRA_CC = "android.intent.extra.CC";
4750
4751 /**
4752 * A String[] holding e-mail addresses that should be blind carbon copied.
4753 */
4754 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4755
4756 /**
4757 * A constant string holding the desired subject line of a message.
4758 */
4759 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4760
4761 /**
4762 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004763 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004764 */
4765 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4766
4767 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004768 * An int representing the user id to be used.
4769 *
4770 * @hide
4771 */
4772 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4773
4774 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004775 * An int representing the task id to be retrieved. This is used when a launch from recents is
4776 * intercepted by another action such as credentials confirmation to remember which task should
4777 * be resumed when complete.
4778 *
4779 * @hide
4780 */
4781 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4782
4783 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004784 * An Intent[] describing additional, alternate choices you would like shown with
4785 * {@link #ACTION_CHOOSER}.
4786 *
4787 * <p>An app may be capable of providing several different payload types to complete a
4788 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4789 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4790 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4791 * photo data or a hosted link where the photos can be viewed.</p>
4792 *
4793 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4794 * first/primary/preferred intent in the set. Additional intents specified in
4795 * this extra are ordered; by default intents that appear earlier in the array will be
4796 * preferred over intents that appear later in the array as matches for the same
4797 * target component. To alter this preference, a calling app may also supply
4798 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4799 */
4800 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4801
4802 /**
Adam Powell52c39212016-04-07 15:14:18 -07004803 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4804 * and omitted from a list of components presented to the user.
4805 *
4806 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4807 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4808 * from your own package or other apps from your organization if the idea of sending to those
4809 * targets would be redundant with other app functionality. Filtered components will not
4810 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4811 */
4812 public static final String EXTRA_EXCLUDE_COMPONENTS
4813 = "android.intent.extra.EXCLUDE_COMPONENTS";
4814
4815 /**
4816 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4817 * describing additional high-priority deep-link targets for the chooser to present to the user.
4818 *
4819 * <p>Targets provided in this way will be presented inline with all other targets provided
4820 * by services from other apps. They will be prioritized before other service targets, but
4821 * after those targets provided by sources that the user has manually pinned to the front.</p>
4822 *
4823 * @see #ACTION_CHOOSER
4824 */
4825 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4826
4827 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004828 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4829 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4830 *
4831 * <p>An app preparing an action for another app to complete may wish to allow the user to
4832 * disambiguate between several options for completing the action based on the chosen target
4833 * or otherwise refine the action before it is invoked.
4834 * </p>
4835 *
4836 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4837 * <ul>
4838 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4839 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4840 * chosen target beyond the first</li>
4841 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4842 * should fill in and send once the disambiguation is complete</li>
4843 * </ul>
4844 */
4845 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4846 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4847
4848 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004849 * An {@code ArrayList} of {@code String} annotations describing content for
4850 * {@link #ACTION_CHOOSER}.
4851 *
4852 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4853 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4854 *
4855 * <p>Annotations should describe the major components or topics of the content. It is up to
4856 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4857 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004858 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4859 * character. Performance on customized annotations can suffer, if they are rarely used for
4860 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4861 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004862 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004863 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004864 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004865 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004866 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004867 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004868 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004869 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004870 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004871 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4872 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4873 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4874 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4875 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004876 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004877 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4878 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004879 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004880 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004881 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004882 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004883 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004884 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004885 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004886 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004887 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004888 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004889 * Christmas and Thanksgiving.</li>
4890 * </ul>
4891 */
4892 public static final String EXTRA_CONTENT_ANNOTATIONS
4893 = "android.intent.extra.CONTENT_ANNOTATIONS";
4894
4895 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004896 * A {@link ResultReceiver} used to return data back to the sender.
4897 *
4898 * <p>Used to complete an app-specific
4899 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4900 *
4901 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4902 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4903 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4904 * when the user selects a target component from the chooser. It is up to the recipient
4905 * to send a result to this ResultReceiver to signal that disambiguation is complete
4906 * and that the chooser should invoke the user's choice.</p>
4907 *
4908 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4909 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4910 * to match and fill in the final Intent or ChooserTarget before starting it.
4911 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4912 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4913 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4914 *
4915 * <p>The result code passed to the ResultReceiver should be
4916 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4917 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4918 * the chooser should finish without starting a target.</p>
4919 */
4920 public static final String EXTRA_RESULT_RECEIVER
4921 = "android.intent.extra.RESULT_RECEIVER";
4922
4923 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004924 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004925 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004926 */
4927 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4928
4929 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004930 * A Parcelable[] of {@link Intent} or
4931 * {@link android.content.pm.LabeledIntent} objects as set with
4932 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4933 * a the front of the list of choices, when shown to the user with a
4934 * {@link #ACTION_CHOOSER}.
4935 */
4936 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4937
4938 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004939 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004940 * @hide
4941 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004942 @SystemApi
4943 public static final String EXTRA_INSTANT_APP_SUCCESS =
4944 "android.intent.extra.INSTANT_APP_SUCCESS";
4945
4946 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004947 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004948 * @hide
4949 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004950 @SystemApi
4951 public static final String EXTRA_INSTANT_APP_FAILURE =
4952 "android.intent.extra.INSTANT_APP_FAILURE";
4953
4954 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004955 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004956 * @hide
4957 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004958 @SystemApi
4959 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4960 "android.intent.extra.INSTANT_APP_HOSTNAME";
4961
4962 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004963 * An opaque token to track instant app resolution.
4964 * @hide
4965 */
4966 @SystemApi
4967 public static final String EXTRA_INSTANT_APP_TOKEN =
4968 "android.intent.extra.INSTANT_APP_TOKEN";
4969
4970 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004971 * The action that triggered an instant application resolution.
4972 * @hide
4973 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004974 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004975 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4976
4977 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004978 * An array of {@link Bundle}s containing details about resolved instant apps..
4979 * @hide
4980 */
4981 @SystemApi
4982 public static final String EXTRA_INSTANT_APP_BUNDLES =
4983 "android.intent.extra.INSTANT_APP_BUNDLES";
4984
4985 /**
4986 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004987 * installed. This data is populated from the response to
4988 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4989 * instant application resolver.
4990 * @hide
4991 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004992 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004993 public static final String EXTRA_INSTANT_APP_EXTRAS =
4994 "android.intent.extra.INSTANT_APP_EXTRAS";
4995
4996 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004997 * A boolean value indicating that the instant app resolver was unable to state with certainty
4998 * that it did or did not have an app for the sanitized {@link Intent} defined at
4999 * {@link #EXTRA_INTENT}.
5000 * @hide
5001 */
5002 @SystemApi
5003 public static final String EXTRA_UNKNOWN_INSTANT_APP =
5004 "android.intent.extra.UNKNOWN_INSTANT_APP";
5005
5006 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08005007 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07005008 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08005009 * @hide
5010 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07005011 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08005012 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5013
5014 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07005015 * The version code of the app to install components from.
5016 * @hide
5017 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005018 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07005019 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5020
5021 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005022 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07005023 * @hide
5024 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005025 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005026 public static final String EXTRA_CALLING_PACKAGE
5027 = "android.intent.extra.CALLING_PACKAGE";
5028
5029 /**
5030 * Optional calling app provided bundle containing additional launch information the
5031 * installer may use.
5032 * @hide
5033 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005034 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005035 public static final String EXTRA_VERIFICATION_BUNDLE
5036 = "android.intent.extra.VERIFICATION_BUNDLE";
5037
5038 /**
Adam Powelle49d9392014-07-17 18:45:19 -07005039 * A Bundle forming a mapping of potential target package names to different extras Bundles
5040 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5041 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5042 * be currently installed on the device.
5043 *
5044 * <p>An application may choose to provide alternate extras for the case where a user
5045 * selects an activity from a predetermined set of target packages. If the activity
5046 * the user selects from the chooser belongs to a package with its package name as
5047 * a key in this bundle, the corresponding extras for that package will be merged with
5048 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5049 * extra has the same key as an extra already present in the intent it will overwrite
5050 * the extra from the intent.</p>
5051 *
5052 * <p><em>Examples:</em>
5053 * <ul>
5054 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
5055 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5056 * parameters for that target.</li>
5057 * <li>An application may offer additional metadata for known targets of a given intent
5058 * to pass along information only relevant to that target such as account or content
5059 * identifiers already known to that application.</li>
5060 * </ul></p>
5061 */
5062 public static final String EXTRA_REPLACEMENT_EXTRAS =
5063 "android.intent.extra.REPLACEMENT_EXTRAS";
5064
5065 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07005066 * An {@link IntentSender} that will be notified if a user successfully chooses a target
5067 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5068 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5069 * {@link ComponentName} of the chosen component.
5070 *
5071 * <p>In some situations this callback may never come, for example if the user abandons
5072 * the chooser, switches to another task or any number of other reasons. Apps should not
5073 * be written assuming that this callback will always occur.</p>
5074 */
5075 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5076 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5077
5078 /**
5079 * The {@link ComponentName} chosen by the user to complete an action.
5080 *
5081 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5082 */
5083 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5084
5085 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005086 * A {@link android.view.KeyEvent} object containing the event that
5087 * triggered the creation of the Intent it is in.
5088 */
5089 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5090
5091 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07005092 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5093 * before shutting down.
5094 *
5095 * {@hide}
5096 */
5097 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5098
5099 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07005100 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5101 * requested by the user.
5102 *
5103 * {@hide}
5104 */
5105 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5106 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5107
5108 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005109 * 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 -07005110 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5111 * of restarting the application.
5112 */
5113 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5114
5115 /**
5116 * A String holding the phone number originally entered in
5117 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5118 * number to call in a {@link android.content.Intent#ACTION_CALL}.
5119 */
5120 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02005121
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005122 /**
5123 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5124 * intents to supply the uid the package had been assigned. Also an optional
5125 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5126 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5127 * purpose.
5128 */
5129 public static final String EXTRA_UID = "android.intent.extra.UID";
5130
5131 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005132 * @hide String array of package names.
5133 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08005134 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005135 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5136
5137 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005138 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5139 * intents to indicate whether this represents a full uninstall (removing
5140 * both the code and its data) or a partial uninstall (leaving its data,
5141 * implying that this is an update).
5142 */
5143 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07005144
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005145 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07005146 * @hide
5147 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5148 * intents to indicate that at this point the package has been removed for
5149 * all users on the device.
5150 */
5151 public static final String EXTRA_REMOVED_FOR_ALL_USERS
5152 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5153
5154 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005155 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5156 * intents to indicate that this is a replacement of the package, so this
5157 * broadcast will immediately be followed by an add broadcast for a
5158 * different version of the same package.
5159 */
5160 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07005161
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005162 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005163 * Used as an int extra field in {@link android.app.AlarmManager} intents
5164 * to tell the application being invoked how many pending alarms are being
5165 * delievered with the intent. For one-shot alarms this will always be 1.
5166 * For recurring alarms, this might be greater than 1 if the device was
5167 * asleep or powered off at the time an earlier alarm would have been
5168 * delivered.
5169 */
5170 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07005171
Jacek Surazski86b6c532009-05-13 14:38:28 +02005172 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005173 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5174 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07005175 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5176 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005177 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5178 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5179 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005180 */
5181 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5182
5183 /**
5184 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5185 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005186 */
5187 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5188
5189 /**
5190 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5191 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005192 */
5193 public static final int EXTRA_DOCK_STATE_DESK = 1;
5194
5195 /**
5196 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5197 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005198 */
5199 public static final int EXTRA_DOCK_STATE_CAR = 2;
5200
5201 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005202 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5203 * to represent that the phone is in a analog (low end) dock.
5204 */
5205 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5206
5207 /**
5208 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5209 * to represent that the phone is in a digital (high end) dock.
5210 */
5211 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5212
5213 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005214 * Boolean that can be supplied as meta-data with a dock activity, to
5215 * indicate that the dock should take over the home key when it is active.
5216 */
5217 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08005218
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005219 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02005220 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5221 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02005222 */
5223 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5224
5225 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07005226 * Used in the extra field in the remote intent. It's astring token passed with the
5227 * remote intent.
5228 */
5229 public static final String EXTRA_REMOTE_INTENT_TOKEN =
5230 "android.intent.extra.remote_intent_token";
5231
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005232 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005233 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005234 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005235 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005236 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005237 "android.intent.extra.changed_component_name";
5238
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005239 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005240 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08005241 * and contains a string array of all of the components that have changed. If
5242 * the state of the overall package has changed, then it will contain an entry
5243 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005244 */
5245 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5246 "android.intent.extra.changed_component_name_list";
5247
5248 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005249 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005250 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00005251 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5252 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5253 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005254 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005255 */
5256 public static final String EXTRA_CHANGED_PACKAGE_LIST =
5257 "android.intent.extra.changed_package_list";
5258
5259 /**
5260 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005261 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5262 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005263 * and contains an integer array of uids of all of the components
5264 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005265 */
5266 public static final String EXTRA_CHANGED_UID_LIST =
5267 "android.intent.extra.changed_uid_list";
5268
5269 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08005270 * An integer denoting a bitwise combination of restrictions set on distracting packages via
5271 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5272 *
5273 * @hide
5274 * @see PackageManager.DistractionRestriction
5275 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5276 */
5277 public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5278 "android.intent.extra.distraction_restrictions";
5279
5280 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005281 * @hide
5282 * Magic extra system code can use when binding, to give a label for
5283 * who it is that has bound to a service. This is an integer giving
5284 * a framework string resource that can be displayed to the user.
5285 */
5286 public static final String EXTRA_CLIENT_LABEL =
5287 "android.intent.extra.client_label";
5288
5289 /**
5290 * @hide
5291 * Magic extra system code can use when binding, to give a PendingIntent object
5292 * that can be launched for the user to disable the system's use of this
5293 * service.
5294 */
5295 public static final String EXTRA_CLIENT_INTENT =
5296 "android.intent.extra.client_intent";
5297
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005298 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005299 * Extra used to indicate that an intent should only return data that is on
5300 * the local device. This is a boolean extra; the default is false. If true,
5301 * an implementation should only allow the user to select data that is
5302 * already on the device, not requiring it be downloaded from a remote
5303 * service when opened.
5304 *
5305 * @see #ACTION_GET_CONTENT
5306 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005307 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005308 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005309 */
5310 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005311 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005312
Amith Yamasani13593602012-03-22 16:16:17 -07005313 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005314 * Extra used to indicate that an intent can allow the user to select and
5315 * return multiple items. This is a boolean extra; the default is false. If
5316 * true, an implementation is allowed to present the user with a UI where
5317 * they can pick multiple items that are all returned to the caller. When
5318 * this happens, they should be returned as the {@link #getClipData()} part
5319 * of the result Intent.
5320 *
5321 * @see #ACTION_GET_CONTENT
5322 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005323 */
5324 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005325 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005326
5327 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005328 * The integer userHandle carried with broadcast intents related to addition, removal and
5329 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5330 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5331 *
Amith Yamasani13593602012-03-22 16:16:17 -07005332 * @hide
5333 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005334 public static final String EXTRA_USER_HANDLE =
5335 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005336
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005337 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005338 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005339 */
5340 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005341 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005342
5343 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005344 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005345 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5346 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005347 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005348 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5349
5350 /**
5351 * Extra sent in the intent to the BroadcastReceiver that handles
5352 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5353 * the restrictions as key/value pairs.
5354 */
5355 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5356 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005357
Amith Yamasani86118ba2013-03-28 14:33:16 -07005358 /**
5359 * Extra used in the response from a BroadcastReceiver that handles
5360 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5361 */
5362 public static final String EXTRA_RESTRICTIONS_INTENT =
5363 "android.intent.extra.restrictions_intent";
5364
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005365 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005366 * Extra used to communicate a set of acceptable MIME types. The type of the
5367 * extra is {@code String[]}. Values may be a combination of concrete MIME
5368 * types (such as "image/png") and/or partial MIME types (such as
5369 * "audio/*").
5370 *
5371 * @see #ACTION_GET_CONTENT
5372 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005373 */
5374 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5375
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005376 /**
5377 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5378 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005379 * When this is true, hardware devices can use this information to determine that
5380 * they shouldn't do a complete shutdown of their device since this is not a
5381 * complete shutdown down to the kernel, but only user space restarting.
5382 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005383 */
5384 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5385 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5386
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005387 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005388 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5389 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5390 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5391 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005392 *
5393 * @hide for internal use only.
5394 */
5395 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5396 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005397 /** @hide */
5398 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5399 /** @hide */
5400 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5401 /** @hide */
5402 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005403
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005404 /**
5405 * Intent extra: the reason that the operation associated with this intent is being performed.
5406 *
5407 * <p>Type: String
5408 * @hide
5409 */
5410 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005411 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5412
qingxi240c2bb2017-04-12 17:31:18 -07005413 /**
5414 * {@hide}
5415 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5416 */
Rubin Xue8490f12015-06-25 12:17:48 +01005417 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5418
Santos Cordon15a13782015-03-31 18:32:31 -07005419 /**
qingxi240c2bb2017-04-12 17:31:18 -07005420 * {@hide}
5421 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5422 * reset for the device with eSIM. This extra will be sent together with
5423 * {@link #ACTION_FACTORY_RESET}
5424 */
5425 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5426
5427 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005428 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5429 * activation request.
5430 * TODO: Add information about the structure and response data used with the pending intent.
5431 * @hide
5432 */
5433 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5434 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5435
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005436 /**
5437 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005438 *
5439 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005440 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005441 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005442 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5443
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005444 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005445 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5446 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5447 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005448 *
5449 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005450 * @see #ACTION_QUICK_VIEW
5451 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005452 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005453 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005454 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5455 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005456
5457 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005458 * An optional extra of {@code String[]} indicating which quick view features should be made
5459 * available to the user in the quick view UI while handing a
5460 * {@link Intent#ACTION_QUICK_VIEW} intent.
5461 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5462 * Quick viewer can implement features not listed below.
5463 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005464 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5465 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5466 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005467 * <p>
5468 * Requirements:
5469 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5470 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5471 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5472 * internal policies.
5473 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5474 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5475 * disable or hide features.
5476 *
5477 * @see #ACTION_QUICK_VIEW
5478 */
5479 public static final String EXTRA_QUICK_VIEW_FEATURES =
5480 "android.intent.extra.QUICK_VIEW_FEATURES";
5481
5482 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005483 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005484 * When a profile goes into quiet mode, all apps in the profile are killed and the
5485 * profile user is stopped. Widgets originating from the profile are masked, and app
5486 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005487 */
5488 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005489
5490 /**
Amin Shaikh710d1232018-11-14 16:58:13 -05005491 * Optional CharSequence extra to provide a search query.
Amin Shaikh5fdc89c2018-12-06 15:50:21 -05005492 * The format of this query is dependent on the receiving application.
Amin Shaikh710d1232018-11-14 16:58:13 -05005493 *
5494 * <p>Applicable to {@link Intent} with actions:
5495 * <ul>
5496 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
5497 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5498 * </ul>
5499 */
5500 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5501
5502 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005503 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005504 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005505 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5506 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005507 *
5508 * @hide
5509 */
5510 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5511 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5512
5513 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005514 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5515 * whether to show the chooser or not when there is only one application available
5516 * to choose from.
Ben Lin145b0ca2016-10-14 14:23:40 -07005517 */
5518 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5519 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5520
5521 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005522 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005523 * to represent that a video codec is allowed to use.
5524 *
5525 * @hide
5526 */
5527 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5528
5529 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005530 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005531 * to represent that a audio codec is allowed to use.
5532 *
5533 * @hide
5534 */
5535 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5536
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005537 // ---------------------------------------------------------------------
5538 // ---------------------------------------------------------------------
5539 // Intent flags (see mFlags variable).
5540
Tor Norbyed9273d62013-05-30 15:59:53 -07005541 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005542 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005543 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5544 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005545 @Retention(RetentionPolicy.SOURCE)
5546 public @interface GrantUriMode {}
5547
Jeff Sharkey846318a2014-04-04 12:12:41 -07005548 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005549 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005550 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5551 @Retention(RetentionPolicy.SOURCE)
5552 public @interface AccessUriMode {}
5553
5554 /**
5555 * Test if given mode flags specify an access mode, which must be at least
5556 * read and/or write.
5557 *
5558 * @hide
5559 */
5560 public static boolean isAccessUriMode(int modeFlags) {
5561 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5562 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5563 }
5564
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005565 /** @hide */
5566 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5567 FLAG_GRANT_READ_URI_PERMISSION,
5568 FLAG_GRANT_WRITE_URI_PERMISSION,
5569 FLAG_FROM_BACKGROUND,
5570 FLAG_DEBUG_LOG_RESOLUTION,
5571 FLAG_EXCLUDE_STOPPED_PACKAGES,
5572 FLAG_INCLUDE_STOPPED_PACKAGES,
5573 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5574 FLAG_GRANT_PREFIX_URI_PERMISSION,
5575 FLAG_DEBUG_TRIAGED_MISSING,
5576 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005577 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005578 FLAG_ACTIVITY_NO_HISTORY,
5579 FLAG_ACTIVITY_SINGLE_TOP,
5580 FLAG_ACTIVITY_NEW_TASK,
5581 FLAG_ACTIVITY_MULTIPLE_TASK,
5582 FLAG_ACTIVITY_CLEAR_TOP,
5583 FLAG_ACTIVITY_FORWARD_RESULT,
5584 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5585 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5586 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5587 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5588 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5589 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5590 FLAG_ACTIVITY_NEW_DOCUMENT,
5591 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5592 FLAG_ACTIVITY_NO_USER_ACTION,
5593 FLAG_ACTIVITY_REORDER_TO_FRONT,
5594 FLAG_ACTIVITY_NO_ANIMATION,
5595 FLAG_ACTIVITY_CLEAR_TASK,
5596 FLAG_ACTIVITY_TASK_ON_HOME,
5597 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5598 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5599 FLAG_RECEIVER_REGISTERED_ONLY,
5600 FLAG_RECEIVER_REPLACE_PENDING,
5601 FLAG_RECEIVER_FOREGROUND,
5602 FLAG_RECEIVER_NO_ABORT,
5603 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5604 FLAG_RECEIVER_BOOT_UPGRADE,
5605 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5606 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5607 FLAG_RECEIVER_FROM_SHELL,
5608 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005609 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005610 })
5611 @Retention(RetentionPolicy.SOURCE)
5612 public @interface Flags {}
5613
5614 /** @hide */
5615 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5616 FLAG_FROM_BACKGROUND,
5617 FLAG_DEBUG_LOG_RESOLUTION,
5618 FLAG_EXCLUDE_STOPPED_PACKAGES,
5619 FLAG_INCLUDE_STOPPED_PACKAGES,
5620 FLAG_DEBUG_TRIAGED_MISSING,
5621 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005622 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005623 FLAG_ACTIVITY_NO_HISTORY,
5624 FLAG_ACTIVITY_SINGLE_TOP,
5625 FLAG_ACTIVITY_NEW_TASK,
5626 FLAG_ACTIVITY_MULTIPLE_TASK,
5627 FLAG_ACTIVITY_CLEAR_TOP,
5628 FLAG_ACTIVITY_FORWARD_RESULT,
5629 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5630 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5631 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5632 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5633 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5634 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5635 FLAG_ACTIVITY_NEW_DOCUMENT,
5636 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5637 FLAG_ACTIVITY_NO_USER_ACTION,
5638 FLAG_ACTIVITY_REORDER_TO_FRONT,
5639 FLAG_ACTIVITY_NO_ANIMATION,
5640 FLAG_ACTIVITY_CLEAR_TASK,
5641 FLAG_ACTIVITY_TASK_ON_HOME,
5642 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5643 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5644 FLAG_RECEIVER_REGISTERED_ONLY,
5645 FLAG_RECEIVER_REPLACE_PENDING,
5646 FLAG_RECEIVER_FOREGROUND,
5647 FLAG_RECEIVER_NO_ABORT,
5648 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5649 FLAG_RECEIVER_BOOT_UPGRADE,
5650 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5651 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5652 FLAG_RECEIVER_FROM_SHELL,
5653 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005654 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005655 })
5656 @Retention(RetentionPolicy.SOURCE)
5657 public @interface MutableFlags {}
5658
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005659 /**
5660 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005661 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005662 * specified in its ClipData. When applying to an Intent's ClipData,
5663 * all URIs as well as recursive traversals through data or other ClipData
5664 * in Intent items will be granted; only the grant flags of the top-level
5665 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005666 */
5667 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5668 /**
5669 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005670 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005671 * specified in its ClipData. When applying to an Intent's ClipData,
5672 * all URIs as well as recursive traversals through data or other ClipData
5673 * in Intent items will be granted; only the grant flags of the top-level
5674 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005675 */
5676 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5677 /**
5678 * Can be set by the caller to indicate that this Intent is coming from
5679 * a background operation, not from direct user interaction.
5680 */
5681 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5682 /**
5683 * A flag you can enable for debugging: when set, log messages will be
5684 * printed during the resolution of this intent to show you what has
5685 * been found to create the final resolved list.
5686 */
5687 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005688 /**
5689 * If set, this intent will not match any components in packages that
5690 * are currently stopped. If this is not set, then the default behavior
5691 * is to include such applications in the result.
5692 */
5693 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5694 /**
5695 * If set, this intent will always match any components in packages that
5696 * are currently stopped. This is the default behavior when
5697 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5698 * flags are set, this one wins (it allows overriding of exclude for
5699 * places where the framework may automatically set the exclude flag).
5700 */
5701 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005702
5703 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005704 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005705 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005706 * persisted across device reboots until explicitly revoked with
5707 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5708 * grant for possible persisting; the receiving application must call
5709 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5710 * actually persist.
5711 *
5712 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5713 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5714 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005715 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005716 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005717 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005718
5719 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005720 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5721 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5722 * applies to any URI that is a prefix match against the original granted
5723 * URI. (Without this flag, the URI must match exactly for access to be
5724 * granted.) Another URI is considered a prefix match only when scheme,
5725 * authority, and all path segments defined by the prefix are an exact
5726 * match.
5727 */
5728 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5729
5730 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005731 * Flag used to automatically match intents based on their Direct Boot
5732 * awareness and the current user state.
5733 * <p>
5734 * Since the default behavior is to automatically apply the current user
5735 * state, this is effectively a sentinel value that doesn't change the
5736 * output of any queries based on its presence or absence.
5737 * <p>
5738 * Instead, this value can be useful in conjunction with
5739 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5740 * to detect when a caller is relying on implicit automatic matching,
5741 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005742 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005743 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5744
5745 /** {@hide} */
5746 @Deprecated
5747 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005748
5749 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005750 * Internal flag used to indicate ephemeral applications should not be
5751 * considered when resolving the intent.
5752 *
5753 * @hide
5754 */
5755 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5756
5757 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005758 * If set, the new activity is not kept in the history stack. As soon as
5759 * the user navigates away from it, the activity is finished. This may also
5760 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5761 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005762 *
5763 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5764 * is never invoked when the current activity starts a new activity which
5765 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005766 */
5767 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5768 /**
5769 * If set, the activity will not be launched if it is already running
5770 * at the top of the history stack.
5771 */
5772 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5773 /**
5774 * If set, this activity will become the start of a new task on this
5775 * history stack. A task (from the activity that started it to the
5776 * next task activity) defines an atomic group of activities that the
5777 * user can move to. Tasks can be moved to the foreground and background;
5778 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005779 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005780 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5781 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005782 *
5783 * <p>This flag is generally used by activities that want
5784 * to present a "launcher" style behavior: they give the user a list of
5785 * separate things that can be done, which otherwise run completely
5786 * independently of the activity launching them.
5787 *
5788 * <p>When using this flag, if a task is already running for the activity
5789 * you are now starting, then a new activity will not be started; instead,
5790 * the current task will simply be brought to the front of the screen with
5791 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5792 * to disable this behavior.
5793 *
5794 * <p>This flag can not be used when the caller is requesting a result from
5795 * the activity being launched.
5796 */
5797 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5798 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005799 * This flag is used to create a new task and launch an activity into it.
5800 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5801 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5802 * search through existing tasks for ones matching this Intent. Only if no such
5803 * task is found would a new task be created. When paired with
5804 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5805 * the search for a matching task and unconditionally start a new task.
5806 *
5807 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5808 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005809 * top-level application launcher.</strong> Used in conjunction with
5810 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5811 * behavior of bringing an existing task to the foreground. When set,
5812 * a new task is <em>always</em> started to host the Activity for the
5813 * Intent, regardless of whether there is already an existing task running
5814 * the same thing.
5815 *
5816 * <p><strong>Because the default system does not include graphical task management,
5817 * you should not use this flag unless you provide some way for a user to
5818 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005819 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005820 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5821 * creating new document tasks.
5822 *
5823 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005824 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005825 *
Scott Main7aee61f2011-02-08 11:25:01 -08005826 * <p>See
5827 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5828 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005829 *
5830 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5831 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005832 */
5833 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5834 /**
5835 * If set, and the activity being launched is already running in the
5836 * current task, then instead of launching a new instance of that activity,
5837 * all of the other activities on top of it will be closed and this Intent
5838 * will be delivered to the (now on top) old activity as a new Intent.
5839 *
5840 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5841 * If D calls startActivity() with an Intent that resolves to the component
5842 * of activity B, then C and D will be finished and B receive the given
5843 * Intent, resulting in the stack now being: A, B.
5844 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005845 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005846 * either receive the new intent you are starting here in its
5847 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005848 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005849 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5850 * the same intent, then it will be finished and re-created; for all other
5851 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5852 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005853 *
5854 * <p>This launch mode can also be used to good effect in conjunction with
5855 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5856 * of a task, it will bring any currently running instance of that task
5857 * to the foreground, and then clear it to its root state. This is
5858 * especially useful, for example, when launching an activity from the
5859 * notification manager.
5860 *
Scott Main7aee61f2011-02-08 11:25:01 -08005861 * <p>See
5862 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5863 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005864 */
5865 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5866 /**
5867 * If set and this intent is being used to launch a new activity from an
5868 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005869 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005870 * {@link android.app.Activity#setResult} and have that result sent back to
5871 * the reply target of the original activity.
5872 */
5873 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5874 /**
5875 * If set and this intent is being used to launch a new activity from an
5876 * existing one, the current activity will not be counted as the top
5877 * activity for deciding whether the new intent should be delivered to
5878 * the top instead of starting a new one. The previous activity will
5879 * be used as the top, with the assumption being that the current activity
5880 * will finish itself immediately.
5881 */
5882 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5883 /**
5884 * If set, the new activity is not kept in the list of recently launched
5885 * activities.
5886 */
5887 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5888 /**
5889 * This flag is not normally set by application code, but set for you by
5890 * the system as described in the
5891 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5892 * launchMode} documentation for the singleTask mode.
5893 */
5894 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5895 /**
5896 * If set, and this activity is either being started in a new task or
5897 * bringing to the top an existing task, then it will be launched as
5898 * the front door of the task. This will result in the application of
5899 * any affinities needed to have that task in the proper state (either
5900 * moving activities to or from it), or simply resetting that task to
5901 * its initial state if needed.
5902 */
5903 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5904 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005905 * This flag is not normally set by application code, but set for you by
5906 * the system if this activity is being launched from history
5907 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005908 */
5909 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005910 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005911 * @deprecated As of API 21 this performs identically to
5912 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005913 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005914 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005915 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005916 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005917 * This flag is used to open a document into a new task rooted at the activity launched
5918 * by this Intent. Through the use of this flag, or its equivalent attribute,
5919 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005920 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005921 *
Craig Mautner026596b2014-05-21 15:35:44 -07005922 * <p>The use of the activity attribute form of this,
5923 * {@link android.R.attr#documentLaunchMode}, is
5924 * preferred over the Intent flag described here. The attribute form allows the
5925 * Activity to specify multiple document behavior for all launchers of the Activity
5926 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005927 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005928 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5929 * it is kept after the activity is finished is different than the use of
5930 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5931 * this flag is being used to create a new recents entry, then by default that entry
5932 * will be removed once the activity is finished. You can modify this behavior with
5933 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5934 *
Craig Mautner026596b2014-05-21 15:35:44 -07005935 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5936 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5937 * equivalent of the Activity manifest specifying {@link
5938 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5939 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5940 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005941 *
Craig Mautner026596b2014-05-21 15:35:44 -07005942 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005943 *
Craig Mautner026596b2014-05-21 15:35:44 -07005944 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005945 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5946 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005947 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005948 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005949 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005950 * callback from occurring on the current frontmost activity before it is
5951 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005952 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005953 * <p>Typically, an activity can rely on that callback to indicate that an
5954 * explicit user action has caused their activity to be moved out of the
5955 * foreground. The callback marks an appropriate point in the activity's
5956 * lifecycle for it to dismiss any notifications that it intends to display
5957 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005958 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005959 * <p>If an activity is ever started via any non-user-driven events such as
5960 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5961 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005962 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005963 */
5964 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005965 /**
5966 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5967 * this flag will cause the launched activity to be brought to the front of its
5968 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005969 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005970 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5971 * If D calls startActivity() with an Intent that resolves to the component
5972 * of activity B, then B will be brought to the front of the history stack,
5973 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005974 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005975 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005976 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005977 */
5978 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005979 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005980 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5981 * this flag will prevent the system from applying an activity transition
5982 * animation to go to the next activity state. This doesn't mean an
5983 * animation will never run -- if another activity change happens that doesn't
5984 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005985 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005986 * when you are going to do a series of activity operations but the
5987 * animation seen by the user shouldn't be driven by the first activity
5988 * change but rather a later one.
5989 */
5990 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5991 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005992 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5993 * this flag will cause any existing task that would be associated with the
5994 * activity to be cleared before the activity is started. That is, the activity
5995 * becomes the new root of an otherwise empty task, and any old activities
5996 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5997 */
5998 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5999 /**
6000 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6001 * this flag will cause a newly launching task to be placed on top of the current
6002 * home activity task (if there is one). That is, pressing back from the task
6003 * will always return the user to home even if that was not the last activity they
6004 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6005 */
6006 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6007 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07006008 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6009 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006010 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07006011 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006012 * this flag. When set and the task's activity is finished, the recents
6013 * entry will remain in the interface for the user to re-launch it, like a
6014 * recents entry for a top-level application.
6015 * <p>
6016 * The receiving activity can override this request with
6017 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6018 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07006019 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07006020 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07006021 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07006022
6023 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006024 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
6025 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08006026 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6027 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006028 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006029 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006030
Patrick Baumann577d4022018-01-31 16:55:10 +00006031
6032 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07006033 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6034 * this flag will attempt to launch an instant app if no full app on the device can already
6035 * handle the intent.
6036 * <p>
6037 * When attempting to resolve instant apps externally, the following {@link Intent} properties
6038 * are supported:
6039 * <ul>
6040 * <li>{@link Intent#setAction(String)}</li>
6041 * <li>{@link Intent#addCategory(String)}</li>
6042 * <li>{@link Intent#setData(Uri)}</li>
6043 * <li>{@link Intent#setType(String)}</li>
6044 * <li>{@link Intent#setPackage(String)}</li>
6045 * <li>{@link Intent#addFlags(int)}</li>
6046 * </ul>
6047 * <p>
6048 * In the case that no instant app can be found, the installer will be launched to notify the
6049 * user that the intent could not be resolved. On devices that do not support instant apps,
6050 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00006051 */
6052 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6053
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006054 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006055 * If set, when sending a broadcast only registered receivers will be
6056 * called -- no BroadcastReceiver components will be launched.
6057 */
6058 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006059 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006060 * If set, when sending a broadcast the new broadcast will replace
6061 * any existing pending broadcast that matches it. Matching is defined
6062 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6063 * true for the intents of the two broadcasts. When a match is found,
6064 * the new broadcast (and receivers associated with it) will replace the
6065 * existing one in the pending broadcast list, remaining at the same
6066 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08006067 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006068 * <p>This flag is most typically used with sticky broadcasts, which
6069 * only care about delivering the most recent values of the broadcast
6070 * to their receivers.
6071 */
6072 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6073 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08006074 * If set, when sending a broadcast the recipient is allowed to run at
6075 * foreground priority, with a shorter timeout interval. During normal
6076 * broadcasts the receivers are not automatically hoisted out of the
6077 * background priority class.
6078 */
6079 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6080 /**
Ng Zhi An150a6ba2018-08-13 09:08:11 -07006081 * If set, when sending a broadcast the recipient will be run on the offload queue.
6082 *
6083 * @hide
6084 */
6085 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6086 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07006087 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6088 * They can still propagate results through to later receivers, but they can not prevent
6089 * later receivers from seeing the broadcast.
6090 */
6091 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6092 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006093 * If set, when sending a broadcast <i>before boot has completed</i> only
6094 * registered receivers will be called -- no BroadcastReceiver components
6095 * will be launched. Sticky intent state will be recorded properly even
6096 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6097 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07006098 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006099 * <p>This flag is only for use by system sevices as a convenience to
6100 * avoid having to implement a more complex mechanism around detection
6101 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07006102 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006103 * @hide
6104 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006105 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07006106 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07006107 /**
6108 * Set when this broadcast is for a boot upgrade, a special mode that
6109 * allows the broadcast to be sent before the system is ready and launches
6110 * the app process with no providers running in it.
6111 * @hide
6112 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07006113 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006114 /**
6115 * If set, the broadcast will always go to manifest receivers in background (cached
6116 * or not running) apps, regardless of whether that would be done by default. By
6117 * default they will only receive broadcasts if the broadcast has specified an
6118 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08006119 *
6120 * NOTE: dumpstate uses this flag numerically, so when its value is changed
6121 * the broadcast code there must also be changed to match.
6122 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006123 * @hide
6124 */
6125 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6126 /**
6127 * If set, the broadcast will never go to manifest receivers in background (cached
6128 * or not running) apps, regardless of whether that would be done by default. By
6129 * default they will receive broadcasts if the broadcast has specified an
6130 * explicit component or package name.
6131 * @hide
6132 */
6133 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07006134 /**
6135 * If set, this broadcast is being sent from the shell.
6136 * @hide
6137 */
6138 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006139
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006140 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08006141 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6142 * will not receive broadcasts.
6143 *
6144 * <em>This flag has no effect when used by an Instant App.</em>
6145 */
6146 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6147
6148 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006149 * @hide Flags that can't be changed with PendingIntent.
6150 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07006151 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6152 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6153 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08006154
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006155 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006156 // ---------------------------------------------------------------------
6157 // toUri() and parseUri() options.
6158
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006159 /** @hide */
6160 @IntDef(flag = true, prefix = { "URI_" }, value = {
6161 URI_ALLOW_UNSAFE,
6162 URI_ANDROID_APP_SCHEME,
6163 URI_INTENT_SCHEME,
6164 })
6165 @Retention(RetentionPolicy.SOURCE)
6166 public @interface UriFlags {}
6167
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006168 /**
6169 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6170 * always has the "intent:" scheme. This syntax can be used when you want
6171 * to later disambiguate between URIs that are intended to describe an
6172 * Intent vs. all others that should be treated as raw URIs. When used
6173 * with {@link #parseUri}, any other scheme will result in a generic
6174 * VIEW action for that raw URI.
6175 */
6176 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08006177
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006178 /**
6179 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6180 * always has the "android-app:" scheme. This is a variation of
6181 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6182 * http/https URI being delivered to a specific package name. The format
6183 * is:
6184 *
6185 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006186 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006187 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006188 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
6189 * you must also include a scheme; including a path also requires both a host and a scheme.
6190 * The final #Intent; fragment can be used without a scheme, host, or path.
6191 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006192 * used with intents that have a {@link #setSelector}, since the base intent
6193 * will always have an explicit package name.</p>
6194 *
6195 * <p>Some examples of how this scheme maps to Intent objects:</p>
6196 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6197 * <colgroup align="left" />
6198 * <colgroup align="left" />
6199 * <thead>
6200 * <tr><th>URI</th> <th>Intent</th></tr>
6201 * </thead>
6202 *
6203 * <tbody>
6204 * <tr><td><code>android-app://com.example.app</code></td>
6205 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6206 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6207 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6208 * </table></td>
6209 * </tr>
6210 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6211 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6212 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6213 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6214 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6215 * </table></td>
6216 * </tr>
6217 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6218 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6219 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6220 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6221 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6222 * </table></td>
6223 * </tr>
6224 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6225 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6226 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6227 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6228 * </table></td>
6229 * </tr>
6230 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6231 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6232 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6233 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6234 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6235 * </table></td>
6236 * </tr>
6237 * <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>
6238 * <td><table border="" style="margin:0" >
6239 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6240 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6241 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6242 * </table></td>
6243 * </tr>
6244 * </tbody>
6245 * </table>
6246 */
6247 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6248
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006249 /**
6250 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6251 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6252 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6253 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6254 * generated Intent can not cause unexpected data access to happen.
6255 *
6256 * <p>If you do not trust the source of the URI being parsed, you should still do further
6257 * processing to protect yourself from it. In particular, when using it to start an
6258 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6259 * that can handle it.</p>
6260 */
6261 public static final int URI_ALLOW_UNSAFE = 1<<2;
6262
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006263 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006264
6265 private String mAction;
6266 private Uri mData;
6267 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006268 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006269 private ComponentName mComponent;
6270 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006271 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006272 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006273 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006274 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006275 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006276 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006277 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07006278 /** Token to track instant app launches. Local only; do not copy cross-process. */
6279 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006280
6281 // ---------------------------------------------------------------------
6282
Makoto Onuki97f82f22017-05-31 16:20:21 -07006283 private static final int COPY_MODE_ALL = 0;
6284 private static final int COPY_MODE_FILTER = 1;
6285 private static final int COPY_MODE_HISTORY = 2;
6286
6287 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07006288 @IntDef(prefix = { "COPY_MODE_" }, value = {
6289 COPY_MODE_ALL,
6290 COPY_MODE_FILTER,
6291 COPY_MODE_HISTORY
6292 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07006293 @Retention(RetentionPolicy.SOURCE)
6294 public @interface CopyMode {}
6295
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006296 /**
6297 * Create an empty intent.
6298 */
6299 public Intent() {
6300 }
6301
6302 /**
6303 * Copy constructor.
6304 */
6305 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006306 this(o, COPY_MODE_ALL);
6307 }
6308
6309 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006310 this.mAction = o.mAction;
6311 this.mData = o.mData;
6312 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006313 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006314 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006315
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006316 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006317 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006318 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006319
6320 if (copyMode != COPY_MODE_FILTER) {
6321 this.mFlags = o.mFlags;
6322 this.mContentUserHint = o.mContentUserHint;
6323 this.mLaunchToken = o.mLaunchToken;
6324 if (o.mSourceBounds != null) {
6325 this.mSourceBounds = new Rect(o.mSourceBounds);
6326 }
6327 if (o.mSelector != null) {
6328 this.mSelector = new Intent(o.mSelector);
6329 }
6330
6331 if (copyMode != COPY_MODE_HISTORY) {
6332 if (o.mExtras != null) {
6333 this.mExtras = new Bundle(o.mExtras);
6334 }
6335 if (o.mClipData != null) {
6336 this.mClipData = new ClipData(o.mClipData);
6337 }
6338 } else {
6339 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6340 this.mExtras = Bundle.STRIPPED;
6341 }
6342
6343 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6344 // history.
6345 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006346 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006347 }
6348
6349 @Override
6350 public Object clone() {
6351 return new Intent(this);
6352 }
6353
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006354 /**
6355 * Make a clone of only the parts of the Intent that are relevant for
6356 * filter matching: the action, data, type, component, and categories.
6357 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006358 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006359 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006360 }
6361
6362 /**
6363 * Create an intent with a given action. All other fields (data, type,
6364 * class) are null. Note that the action <em>must</em> be in a
6365 * namespace because Intents are used globally in the system -- for
6366 * example the system VIEW action is android.intent.action.VIEW; an
6367 * application's custom action would be something like
6368 * com.google.app.myapp.CUSTOM_ACTION.
6369 *
6370 * @param action The Intent action, such as ACTION_VIEW.
6371 */
6372 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006373 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006374 }
6375
6376 /**
6377 * Create an intent with a given action and for a given data url. Note
6378 * that the action <em>must</em> be in a namespace because Intents are
6379 * used globally in the system -- for example the system VIEW action is
6380 * android.intent.action.VIEW; an application's custom action would be
6381 * something like com.google.app.myapp.CUSTOM_ACTION.
6382 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006383 * <p><em>Note: scheme and host name matching in the Android framework is
6384 * case-sensitive, unlike the formal RFC. As a result,
6385 * you should always ensure that you write your Uri with these elements
6386 * using lower case letters, and normalize any Uris you receive from
6387 * outside of Android to ensure the scheme and host is lower case.</em></p>
6388 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006389 * @param action The Intent action, such as ACTION_VIEW.
6390 * @param uri The Intent data URI.
6391 */
6392 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006393 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006394 mData = uri;
6395 }
6396
6397 /**
6398 * Create an intent for a specific component. All other fields (action, data,
6399 * type, class) are null, though they can be modified later with explicit
6400 * calls. This provides a convenient way to create an intent that is
6401 * intended to execute a hard-coded class name, rather than relying on the
6402 * system to find an appropriate class for you; see {@link #setComponent}
6403 * for more information on the repercussions of this.
6404 *
6405 * @param packageContext A Context of the application package implementing
6406 * this class.
6407 * @param cls The component class that is to be used for the intent.
6408 *
6409 * @see #setClass
6410 * @see #setComponent
6411 * @see #Intent(String, android.net.Uri , Context, Class)
6412 */
6413 public Intent(Context packageContext, Class<?> cls) {
6414 mComponent = new ComponentName(packageContext, cls);
6415 }
6416
6417 /**
6418 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006419 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006420 * construct the Intent and then calling {@link #setClass} to set its
6421 * class.
6422 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006423 * <p><em>Note: scheme and host name matching in the Android framework is
6424 * case-sensitive, unlike the formal RFC. As a result,
6425 * you should always ensure that you write your Uri with these elements
6426 * using lower case letters, and normalize any Uris you receive from
6427 * outside of Android to ensure the scheme and host is lower case.</em></p>
6428 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006429 * @param action The Intent action, such as ACTION_VIEW.
6430 * @param uri The Intent data URI.
6431 * @param packageContext A Context of the application package implementing
6432 * this class.
6433 * @param cls The component class that is to be used for the intent.
6434 *
6435 * @see #Intent(String, android.net.Uri)
6436 * @see #Intent(Context, Class)
6437 * @see #setClass
6438 * @see #setComponent
6439 */
6440 public Intent(String action, Uri uri,
6441 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006442 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006443 mData = uri;
6444 mComponent = new ComponentName(packageContext, cls);
6445 }
6446
6447 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006448 * Create an intent to launch the main (root) activity of a task. This
6449 * is the Intent that is started when the application's is launched from
6450 * Home. For anything else that wants to launch an application in the
6451 * same way, it is important that they use an Intent structured the same
6452 * way, and can use this function to ensure this is the case.
6453 *
6454 * <p>The returned Intent has the given Activity component as its explicit
6455 * component, {@link #ACTION_MAIN} as its action, and includes the
6456 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6457 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6458 * to do that through {@link #addFlags(int)} on the returned Intent.
6459 *
6460 * @param mainActivity The main activity component that this Intent will
6461 * launch.
6462 * @return Returns a newly created Intent that can be used to launch the
6463 * activity as a main application entry.
6464 *
6465 * @see #setClass
6466 * @see #setComponent
6467 */
6468 public static Intent makeMainActivity(ComponentName mainActivity) {
6469 Intent intent = new Intent(ACTION_MAIN);
6470 intent.setComponent(mainActivity);
6471 intent.addCategory(CATEGORY_LAUNCHER);
6472 return intent;
6473 }
6474
6475 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006476 * Make an Intent for the main activity of an application, without
6477 * specifying a specific activity to run but giving a selector to find
6478 * the activity. This results in a final Intent that is structured
6479 * the same as when the application is launched from
6480 * Home. For anything else that wants to launch an application in the
6481 * same way, it is important that they use an Intent structured the same
6482 * way, and can use this function to ensure this is the case.
6483 *
6484 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6485 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6486 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6487 * to do that through {@link #addFlags(int)} on the returned Intent.
6488 *
6489 * @param selectorAction The action name of the Intent's selector.
6490 * @param selectorCategory The name of a category to add to the Intent's
6491 * selector.
6492 * @return Returns a newly created Intent that can be used to launch the
6493 * activity as a main application entry.
6494 *
6495 * @see #setSelector(Intent)
6496 */
6497 public static Intent makeMainSelectorActivity(String selectorAction,
6498 String selectorCategory) {
6499 Intent intent = new Intent(ACTION_MAIN);
6500 intent.addCategory(CATEGORY_LAUNCHER);
6501 Intent selector = new Intent();
6502 selector.setAction(selectorAction);
6503 selector.addCategory(selectorCategory);
6504 intent.setSelector(selector);
6505 return intent;
6506 }
6507
6508 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006509 * Make an Intent that can be used to re-launch an application's task
6510 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6511 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6512 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6513 *
6514 * @param mainActivity The activity component that is the root of the
6515 * task; this is the activity that has been published in the application's
6516 * manifest as the main launcher icon.
6517 *
6518 * @return Returns a newly created Intent that can be used to relaunch the
6519 * activity's task in its root state.
6520 */
6521 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6522 Intent intent = makeMainActivity(mainActivity);
6523 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6524 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6525 return intent;
6526 }
6527
6528 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006529 * Call {@link #parseUri} with 0 flags.
6530 * @deprecated Use {@link #parseUri} instead.
6531 */
6532 @Deprecated
6533 public static Intent getIntent(String uri) throws URISyntaxException {
6534 return parseUri(uri, 0);
6535 }
Tom Taylord4a47292009-12-21 13:59:18 -08006536
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006537 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006538 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006539 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006540 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006541 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006542 *
6543 * <p>The URI given here must not be relative -- that is, it must include
6544 * the scheme and full path.
6545 *
6546 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006547 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006548 *
6549 * @return Intent The newly created Intent object.
6550 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006551 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6552 * it bad (as parsed by the Uri class) or the Intent data within the
6553 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006554 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006555 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006556 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006557 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006558 int i = 0;
6559 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006560 final boolean androidApp = uri.startsWith("android-app:");
6561
6562 // Validate intent scheme if requested.
6563 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6564 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006565 Intent intent = new Intent(ACTION_VIEW);
6566 try {
6567 intent.setData(Uri.parse(uri));
6568 } catch (IllegalArgumentException e) {
6569 throw new URISyntaxException(uri, e.getMessage());
6570 }
6571 return intent;
6572 }
6573 }
Tom Taylord4a47292009-12-21 13:59:18 -08006574
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006575 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006576 // simple case
6577 if (i == -1) {
6578 if (!androidApp) {
6579 return new Intent(ACTION_VIEW, Uri.parse(uri));
6580 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006581
6582 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006583 } else if (!uri.startsWith("#Intent;", i)) {
6584 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006585 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006586 } else {
6587 i = -1;
6588 }
6589 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006590
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006591 // new format
6592 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006593 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006594 boolean explicitAction = false;
6595 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006596
6597 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006598 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006599 String data;
6600 if (i >= 0) {
6601 data = uri.substring(0, i);
6602 i += 8; // length of "#Intent;"
6603 } else {
6604 data = uri;
6605 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006606
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006607 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006608 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006609 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006610 if (eq < 0) eq = i-1;
6611 int semi = uri.indexOf(';', i);
6612 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006613
6614 // action
6615 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006616 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006617 if (!inSelector) {
6618 explicitAction = true;
6619 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006620 }
6621
6622 // categories
6623 else if (uri.startsWith("category=", i)) {
6624 intent.addCategory(value);
6625 }
6626
6627 // type
6628 else if (uri.startsWith("type=", i)) {
6629 intent.mType = value;
6630 }
6631
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006632 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006633 else if (uri.startsWith("launchFlags=", i)) {
6634 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006635 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6636 intent.mFlags &= ~IMMUTABLE_FLAGS;
6637 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006638 }
6639
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006640 // package
6641 else if (uri.startsWith("package=", i)) {
6642 intent.mPackage = value;
6643 }
6644
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006645 // component
6646 else if (uri.startsWith("component=", i)) {
6647 intent.mComponent = ComponentName.unflattenFromString(value);
6648 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006649
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006650 // scheme
6651 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006652 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006653 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006654 } else {
6655 scheme = value;
6656 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006657 }
6658
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006659 // source bounds
6660 else if (uri.startsWith("sourceBounds=", i)) {
6661 intent.mSourceBounds = Rect.unflattenFromString(value);
6662 }
6663
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006664 // selector
6665 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6666 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006667 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006668 }
6669
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006670 // extra
6671 else {
6672 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006673 // create Bundle if it doesn't already exist
6674 if (intent.mExtras == null) intent.mExtras = new Bundle();
6675 Bundle b = intent.mExtras;
6676 // add EXTRA
6677 if (uri.startsWith("S.", i)) b.putString(key, value);
6678 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6679 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6680 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6681 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6682 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6683 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6684 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6685 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6686 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6687 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006688
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006689 // move to the next item
6690 i = semi + 1;
6691 }
6692
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006693 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006694 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006695 if (baseIntent.mPackage == null) {
6696 baseIntent.setSelector(intent);
6697 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006698 intent = baseIntent;
6699 }
6700
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006701 if (data != null) {
6702 if (data.startsWith("intent:")) {
6703 data = data.substring(7);
6704 if (scheme != null) {
6705 data = scheme + ':' + data;
6706 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006707 } else if (data.startsWith("android-app:")) {
6708 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6709 // Correctly formed android-app, first part is package name.
6710 int end = data.indexOf('/', 14);
6711 if (end < 0) {
6712 // All we have is a package name.
6713 intent.mPackage = data.substring(14);
6714 if (!explicitAction) {
6715 intent.setAction(ACTION_MAIN);
6716 }
6717 data = "";
6718 } else {
6719 // Target the Intent at the given package name always.
6720 String authority = null;
6721 intent.mPackage = data.substring(14, end);
6722 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006723 if ((end+1) < data.length()) {
6724 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6725 // Found a scheme, remember it.
6726 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006727 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006728 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6729 // Found a authority, remember it.
6730 authority = data.substring(end+1, newEnd);
6731 end = newEnd;
6732 }
6733 } else {
6734 // All we have is a scheme.
6735 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006736 }
6737 }
6738 if (scheme == null) {
6739 // If there was no scheme, then this just targets the package.
6740 if (!explicitAction) {
6741 intent.setAction(ACTION_MAIN);
6742 }
6743 data = "";
6744 } else if (authority == null) {
6745 data = scheme + ":";
6746 } else {
6747 data = scheme + "://" + authority + data.substring(end);
6748 }
6749 }
6750 } else {
6751 data = "";
6752 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006753 }
Tom Taylord4a47292009-12-21 13:59:18 -08006754
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006755 if (data.length() > 0) {
6756 try {
6757 intent.mData = Uri.parse(data);
6758 } catch (IllegalArgumentException e) {
6759 throw new URISyntaxException(uri, e.getMessage());
6760 }
6761 }
6762 }
Tom Taylord4a47292009-12-21 13:59:18 -08006763
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006764 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006765
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006766 } catch (IndexOutOfBoundsException e) {
6767 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6768 }
6769 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006770
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006771 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006772 return getIntentOld(uri, 0);
6773 }
6774
6775 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006776 Intent intent;
6777
6778 int i = uri.lastIndexOf('#');
6779 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006780 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006781 final int intentFragmentStart = i;
6782 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006783
6784 i++;
6785
6786 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006787 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006788 i += 7;
6789 int j = uri.indexOf(')', i);
6790 action = uri.substring(i, j);
6791 i = j + 1;
6792 }
6793
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006794 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006795
6796 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006797 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006798 i += 11;
6799 int j = uri.indexOf(')', i);
6800 while (i < j) {
6801 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006802 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006803 if (i < sep) {
6804 intent.addCategory(uri.substring(i, sep));
6805 }
6806 i = sep + 1;
6807 }
6808 i = j + 1;
6809 }
6810
6811 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006812 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006813 i += 5;
6814 int j = uri.indexOf(')', i);
6815 intent.mType = uri.substring(i, j);
6816 i = j + 1;
6817 }
6818
6819 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006820 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006821 i += 12;
6822 int j = uri.indexOf(')', i);
6823 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006824 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6825 intent.mFlags &= ~IMMUTABLE_FLAGS;
6826 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006827 i = j + 1;
6828 }
6829
6830 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006831 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006832 i += 10;
6833 int j = uri.indexOf(')', i);
6834 int sep = uri.indexOf('!', i);
6835 if (sep >= 0 && sep < j) {
6836 String pkg = uri.substring(i, sep);
6837 String cls = uri.substring(sep + 1, j);
6838 intent.mComponent = new ComponentName(pkg, cls);
6839 }
6840 i = j + 1;
6841 }
6842
6843 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006844 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006845 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006846
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006847 final int closeParen = uri.indexOf(')', i);
6848 if (closeParen == -1) throw new URISyntaxException(uri,
6849 "EXTRA missing trailing ')'", i);
6850
6851 while (i < closeParen) {
6852 // fetch the key value
6853 int j = uri.indexOf('=', i);
6854 if (j <= i + 1 || i >= closeParen) {
6855 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6856 }
6857 char type = uri.charAt(i);
6858 i++;
6859 String key = uri.substring(i, j);
6860 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006861
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006862 // get type-value
6863 j = uri.indexOf('!', i);
6864 if (j == -1 || j >= closeParen) j = closeParen;
6865 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6866 String value = uri.substring(i, j);
6867 i = j;
6868
6869 // create Bundle if it doesn't already exist
6870 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006871
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006872 // add item to bundle
6873 try {
6874 switch (type) {
6875 case 'S':
6876 intent.mExtras.putString(key, Uri.decode(value));
6877 break;
6878 case 'B':
6879 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6880 break;
6881 case 'b':
6882 intent.mExtras.putByte(key, Byte.parseByte(value));
6883 break;
6884 case 'c':
6885 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6886 break;
6887 case 'd':
6888 intent.mExtras.putDouble(key, Double.parseDouble(value));
6889 break;
6890 case 'f':
6891 intent.mExtras.putFloat(key, Float.parseFloat(value));
6892 break;
6893 case 'i':
6894 intent.mExtras.putInt(key, Integer.parseInt(value));
6895 break;
6896 case 'l':
6897 intent.mExtras.putLong(key, Long.parseLong(value));
6898 break;
6899 case 's':
6900 intent.mExtras.putShort(key, Short.parseShort(value));
6901 break;
6902 default:
6903 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6904 }
6905 } catch (NumberFormatException e) {
6906 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6907 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006908
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006909 char ch = uri.charAt(i);
6910 if (ch == ')') break;
6911 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6912 i++;
6913 }
6914 }
6915
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006916 if (isIntentFragment) {
6917 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6918 } else {
6919 intent.mData = Uri.parse(uri);
6920 }
Tom Taylord4a47292009-12-21 13:59:18 -08006921
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006922 if (intent.mAction == null) {
6923 // By default, if no action is specified, then use VIEW.
6924 intent.mAction = ACTION_VIEW;
6925 }
6926
6927 } else {
6928 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6929 }
6930
6931 return intent;
6932 }
6933
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006934 /** @hide */
6935 public interface CommandOptionHandler {
6936 boolean handleOption(String opt, ShellCommand cmd);
6937 }
6938
6939 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006940 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006941 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6942 throws URISyntaxException {
6943 Intent intent = new Intent();
6944 Intent baseIntent = intent;
6945 boolean hasIntentInfo = false;
6946
6947 Uri data = null;
6948 String type = null;
6949
6950 String opt;
6951 while ((opt=cmd.getNextOption()) != null) {
6952 switch (opt) {
6953 case "-a":
6954 intent.setAction(cmd.getNextArgRequired());
6955 if (intent == baseIntent) {
6956 hasIntentInfo = true;
6957 }
6958 break;
6959 case "-d":
6960 data = Uri.parse(cmd.getNextArgRequired());
6961 if (intent == baseIntent) {
6962 hasIntentInfo = true;
6963 }
6964 break;
6965 case "-t":
6966 type = cmd.getNextArgRequired();
6967 if (intent == baseIntent) {
6968 hasIntentInfo = true;
6969 }
6970 break;
6971 case "-c":
6972 intent.addCategory(cmd.getNextArgRequired());
6973 if (intent == baseIntent) {
6974 hasIntentInfo = true;
6975 }
6976 break;
6977 case "-e":
6978 case "--es": {
6979 String key = cmd.getNextArgRequired();
6980 String value = cmd.getNextArgRequired();
6981 intent.putExtra(key, value);
6982 }
6983 break;
6984 case "--esn": {
6985 String key = cmd.getNextArgRequired();
6986 intent.putExtra(key, (String) null);
6987 }
6988 break;
6989 case "--ei": {
6990 String key = cmd.getNextArgRequired();
6991 String value = cmd.getNextArgRequired();
6992 intent.putExtra(key, Integer.decode(value));
6993 }
6994 break;
6995 case "--eu": {
6996 String key = cmd.getNextArgRequired();
6997 String value = cmd.getNextArgRequired();
6998 intent.putExtra(key, Uri.parse(value));
6999 }
7000 break;
7001 case "--ecn": {
7002 String key = cmd.getNextArgRequired();
7003 String value = cmd.getNextArgRequired();
7004 ComponentName cn = ComponentName.unflattenFromString(value);
7005 if (cn == null)
7006 throw new IllegalArgumentException("Bad component name: " + value);
7007 intent.putExtra(key, cn);
7008 }
7009 break;
7010 case "--eia": {
7011 String key = cmd.getNextArgRequired();
7012 String value = cmd.getNextArgRequired();
7013 String[] strings = value.split(",");
7014 int[] list = new int[strings.length];
7015 for (int i = 0; i < strings.length; i++) {
7016 list[i] = Integer.decode(strings[i]);
7017 }
7018 intent.putExtra(key, list);
7019 }
7020 break;
7021 case "--eial": {
7022 String key = cmd.getNextArgRequired();
7023 String value = cmd.getNextArgRequired();
7024 String[] strings = value.split(",");
7025 ArrayList<Integer> list = new ArrayList<>(strings.length);
7026 for (int i = 0; i < strings.length; i++) {
7027 list.add(Integer.decode(strings[i]));
7028 }
7029 intent.putExtra(key, list);
7030 }
7031 break;
7032 case "--el": {
7033 String key = cmd.getNextArgRequired();
7034 String value = cmd.getNextArgRequired();
7035 intent.putExtra(key, Long.valueOf(value));
7036 }
7037 break;
7038 case "--ela": {
7039 String key = cmd.getNextArgRequired();
7040 String value = cmd.getNextArgRequired();
7041 String[] strings = value.split(",");
7042 long[] list = new long[strings.length];
7043 for (int i = 0; i < strings.length; i++) {
7044 list[i] = Long.valueOf(strings[i]);
7045 }
7046 intent.putExtra(key, list);
7047 hasIntentInfo = true;
7048 }
7049 break;
7050 case "--elal": {
7051 String key = cmd.getNextArgRequired();
7052 String value = cmd.getNextArgRequired();
7053 String[] strings = value.split(",");
7054 ArrayList<Long> list = new ArrayList<>(strings.length);
7055 for (int i = 0; i < strings.length; i++) {
7056 list.add(Long.valueOf(strings[i]));
7057 }
7058 intent.putExtra(key, list);
7059 hasIntentInfo = true;
7060 }
7061 break;
7062 case "--ef": {
7063 String key = cmd.getNextArgRequired();
7064 String value = cmd.getNextArgRequired();
7065 intent.putExtra(key, Float.valueOf(value));
7066 hasIntentInfo = true;
7067 }
7068 break;
7069 case "--efa": {
7070 String key = cmd.getNextArgRequired();
7071 String value = cmd.getNextArgRequired();
7072 String[] strings = value.split(",");
7073 float[] list = new float[strings.length];
7074 for (int i = 0; i < strings.length; i++) {
7075 list[i] = Float.valueOf(strings[i]);
7076 }
7077 intent.putExtra(key, list);
7078 hasIntentInfo = true;
7079 }
7080 break;
7081 case "--efal": {
7082 String key = cmd.getNextArgRequired();
7083 String value = cmd.getNextArgRequired();
7084 String[] strings = value.split(",");
7085 ArrayList<Float> list = new ArrayList<>(strings.length);
7086 for (int i = 0; i < strings.length; i++) {
7087 list.add(Float.valueOf(strings[i]));
7088 }
7089 intent.putExtra(key, list);
7090 hasIntentInfo = true;
7091 }
7092 break;
7093 case "--esa": {
7094 String key = cmd.getNextArgRequired();
7095 String value = cmd.getNextArgRequired();
7096 // Split on commas unless they are preceeded by an escape.
7097 // The escape character must be escaped for the string and
7098 // again for the regex, thus four escape characters become one.
7099 String[] strings = value.split("(?<!\\\\),");
7100 intent.putExtra(key, strings);
7101 hasIntentInfo = true;
7102 }
7103 break;
7104 case "--esal": {
7105 String key = cmd.getNextArgRequired();
7106 String value = cmd.getNextArgRequired();
7107 // Split on commas unless they are preceeded by an escape.
7108 // The escape character must be escaped for the string and
7109 // again for the regex, thus four escape characters become one.
7110 String[] strings = value.split("(?<!\\\\),");
7111 ArrayList<String> list = new ArrayList<>(strings.length);
7112 for (int i = 0; i < strings.length; i++) {
7113 list.add(strings[i]);
7114 }
7115 intent.putExtra(key, list);
7116 hasIntentInfo = true;
7117 }
7118 break;
7119 case "--ez": {
7120 String key = cmd.getNextArgRequired();
7121 String value = cmd.getNextArgRequired().toLowerCase();
7122 // Boolean.valueOf() results in false for anything that is not "true", which is
7123 // error-prone in shell commands
7124 boolean arg;
7125 if ("true".equals(value) || "t".equals(value)) {
7126 arg = true;
7127 } else if ("false".equals(value) || "f".equals(value)) {
7128 arg = false;
7129 } else {
7130 try {
7131 arg = Integer.decode(value) != 0;
7132 } catch (NumberFormatException ex) {
7133 throw new IllegalArgumentException("Invalid boolean value: " + value);
7134 }
7135 }
7136
7137 intent.putExtra(key, arg);
7138 }
7139 break;
7140 case "-n": {
7141 String str = cmd.getNextArgRequired();
7142 ComponentName cn = ComponentName.unflattenFromString(str);
7143 if (cn == null)
7144 throw new IllegalArgumentException("Bad component name: " + str);
7145 intent.setComponent(cn);
7146 if (intent == baseIntent) {
7147 hasIntentInfo = true;
7148 }
7149 }
7150 break;
7151 case "-p": {
7152 String str = cmd.getNextArgRequired();
7153 intent.setPackage(str);
7154 if (intent == baseIntent) {
7155 hasIntentInfo = true;
7156 }
7157 }
7158 break;
7159 case "-f":
7160 String str = cmd.getNextArgRequired();
7161 intent.setFlags(Integer.decode(str).intValue());
7162 break;
7163 case "--grant-read-uri-permission":
7164 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7165 break;
7166 case "--grant-write-uri-permission":
7167 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7168 break;
7169 case "--grant-persistable-uri-permission":
7170 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7171 break;
7172 case "--grant-prefix-uri-permission":
7173 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7174 break;
7175 case "--exclude-stopped-packages":
7176 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7177 break;
7178 case "--include-stopped-packages":
7179 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7180 break;
7181 case "--debug-log-resolution":
7182 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7183 break;
7184 case "--activity-brought-to-front":
7185 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7186 break;
7187 case "--activity-clear-top":
7188 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7189 break;
7190 case "--activity-clear-when-task-reset":
7191 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7192 break;
7193 case "--activity-exclude-from-recents":
7194 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7195 break;
7196 case "--activity-launched-from-history":
7197 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7198 break;
7199 case "--activity-multiple-task":
7200 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7201 break;
7202 case "--activity-no-animation":
7203 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7204 break;
7205 case "--activity-no-history":
7206 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7207 break;
7208 case "--activity-no-user-action":
7209 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7210 break;
7211 case "--activity-previous-is-top":
7212 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7213 break;
7214 case "--activity-reorder-to-front":
7215 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7216 break;
7217 case "--activity-reset-task-if-needed":
7218 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7219 break;
7220 case "--activity-single-top":
7221 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7222 break;
7223 case "--activity-clear-task":
7224 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7225 break;
7226 case "--activity-task-on-home":
7227 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7228 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07007229 case "--activity-match-external":
7230 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7231 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007232 case "--receiver-registered-only":
7233 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7234 break;
7235 case "--receiver-replace-pending":
7236 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7237 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08007238 case "--receiver-foreground":
7239 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7240 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08007241 case "--receiver-no-abort":
7242 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7243 break;
7244 case "--receiver-include-background":
7245 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7246 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007247 case "--selector":
7248 intent.setDataAndType(data, type);
7249 intent = new Intent();
7250 break;
7251 default:
7252 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7253 // Okay, caller handled this option.
7254 } else {
7255 throw new IllegalArgumentException("Unknown option: " + opt);
7256 }
7257 break;
7258 }
7259 }
7260 intent.setDataAndType(data, type);
7261
7262 final boolean hasSelector = intent != baseIntent;
7263 if (hasSelector) {
7264 // A selector was specified; fix up.
7265 baseIntent.setSelector(intent);
7266 intent = baseIntent;
7267 }
7268
7269 String arg = cmd.getNextArg();
7270 baseIntent = null;
7271 if (arg == null) {
7272 if (hasSelector) {
7273 // If a selector has been specified, and no arguments
7274 // have been supplied for the main Intent, then we can
7275 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7276 // need to have a component name specified yet, the
7277 // selector will take care of that.
7278 baseIntent = new Intent(Intent.ACTION_MAIN);
7279 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7280 }
7281 } else if (arg.indexOf(':') >= 0) {
7282 // The argument is a URI. Fully parse it, and use that result
7283 // to fill in any data not specified so far.
7284 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7285 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7286 } else if (arg.indexOf('/') >= 0) {
7287 // The argument is a component name. Build an Intent to launch
7288 // it.
7289 baseIntent = new Intent(Intent.ACTION_MAIN);
7290 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7291 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7292 } else {
7293 // Assume the argument is a package name.
7294 baseIntent = new Intent(Intent.ACTION_MAIN);
7295 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7296 baseIntent.setPackage(arg);
7297 }
7298 if (baseIntent != null) {
7299 Bundle extras = intent.getExtras();
7300 intent.replaceExtras((Bundle)null);
7301 Bundle uriExtras = baseIntent.getExtras();
7302 baseIntent.replaceExtras((Bundle)null);
7303 if (intent.getAction() != null && baseIntent.getCategories() != null) {
7304 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7305 for (String c : cats) {
7306 baseIntent.removeCategory(c);
7307 }
7308 }
7309 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7310 if (extras == null) {
7311 extras = uriExtras;
7312 } else if (uriExtras != null) {
7313 uriExtras.putAll(extras);
7314 extras = uriExtras;
7315 }
7316 intent.replaceExtras(extras);
7317 hasIntentInfo = true;
7318 }
7319
7320 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7321 return intent;
7322 }
7323
7324 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007325 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007326 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7327 final String[] lines = new String[] {
7328 "<INTENT> specifications include these flags and arguments:",
7329 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7330 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007331 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007332 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7333 " [--esn <EXTRA_KEY> ...]",
7334 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7335 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7336 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7337 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7338 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7339 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7340 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7341 " (mutiple extras passed as Integer[])",
7342 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7343 " (mutiple extras passed as List<Integer>)",
7344 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7345 " (mutiple extras passed as Long[])",
7346 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7347 " (mutiple extras passed as List<Long>)",
7348 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7349 " (mutiple extras passed as Float[])",
7350 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7351 " (mutiple extras passed as List<Float>)",
7352 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7353 " (mutiple extras passed as String[]; to embed a comma into a string,",
7354 " escape it using \"\\,\")",
7355 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7356 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7357 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007358 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007359 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7360 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7361 " [--debug-log-resolution] [--exclude-stopped-packages]",
7362 " [--include-stopped-packages]",
7363 " [--activity-brought-to-front] [--activity-clear-top]",
7364 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7365 " [--activity-launched-from-history] [--activity-multiple-task]",
7366 " [--activity-no-animation] [--activity-no-history]",
7367 " [--activity-no-user-action] [--activity-previous-is-top]",
7368 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7369 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007370 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007371 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007372 " [--receiver-foreground] [--receiver-no-abort]",
7373 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007374 " [--selector]",
7375 " [<URI> | <PACKAGE> | <COMPONENT>]"
7376 };
7377 for (String line : lines) {
7378 pw.print(prefix);
7379 pw.println(line);
7380 }
7381 }
7382
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007383 /**
7384 * Retrieve the general action to be performed, such as
7385 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7386 * the information in the intent should be interpreted -- most importantly,
7387 * what to do with the data returned by {@link #getData}.
7388 *
7389 * @return The action of this intent or null if none is specified.
7390 *
7391 * @see #setAction
7392 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007393 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007394 return mAction;
7395 }
7396
7397 /**
7398 * Retrieve data this intent is operating on. This URI specifies the name
7399 * of the data; often it uses the content: scheme, specifying data in a
7400 * content provider. Other schemes may be handled by specific activities,
7401 * such as http: by the web browser.
7402 *
7403 * @return The URI of the data this intent is targeting or null.
7404 *
7405 * @see #getScheme
7406 * @see #setData
7407 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007408 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007409 return mData;
7410 }
7411
7412 /**
7413 * The same as {@link #getData()}, but returns the URI as an encoded
7414 * String.
7415 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007416 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007417 return mData != null ? mData.toString() : null;
7418 }
7419
7420 /**
7421 * Return the scheme portion of the intent's data. If the data is null or
7422 * does not include a scheme, null is returned. Otherwise, the scheme
7423 * prefix without the final ':' is returned, i.e. "http".
7424 *
7425 * <p>This is the same as calling getData().getScheme() (and checking for
7426 * null data).
7427 *
7428 * @return The scheme of this intent.
7429 *
7430 * @see #getData
7431 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007432 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007433 return mData != null ? mData.getScheme() : null;
7434 }
7435
7436 /**
7437 * Retrieve any explicit MIME type included in the intent. This is usually
7438 * null, as the type is determined by the intent data.
7439 *
7440 * @return If a type was manually set, it is returned; else null is
7441 * returned.
7442 *
7443 * @see #resolveType(ContentResolver)
7444 * @see #setType
7445 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007446 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007447 return mType;
7448 }
7449
7450 /**
7451 * Return the MIME data type of this intent. If the type field is
7452 * explicitly set, that is simply returned. Otherwise, if the data is set,
7453 * the type of that data is returned. If neither fields are set, a null is
7454 * returned.
7455 *
7456 * @return The MIME type of this intent.
7457 *
7458 * @see #getType
7459 * @see #resolveType(ContentResolver)
7460 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007461 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007462 return resolveType(context.getContentResolver());
7463 }
7464
7465 /**
7466 * Return the MIME data type of this intent. If the type field is
7467 * explicitly set, that is simply returned. Otherwise, if the data is set,
7468 * the type of that data is returned. If neither fields are set, a null is
7469 * returned.
7470 *
7471 * @param resolver A ContentResolver that can be used to determine the MIME
7472 * type of the intent's data.
7473 *
7474 * @return The MIME type of this intent.
7475 *
7476 * @see #getType
7477 * @see #resolveType(Context)
7478 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007479 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007480 if (mType != null) {
7481 return mType;
7482 }
7483 if (mData != null) {
7484 if ("content".equals(mData.getScheme())) {
7485 return resolver.getType(mData);
7486 }
7487 }
7488 return null;
7489 }
7490
7491 /**
7492 * Return the MIME data type of this intent, only if it will be needed for
7493 * intent resolution. This is not generally useful for application code;
7494 * it is used by the frameworks for communicating with back-end system
7495 * services.
7496 *
7497 * @param resolver A ContentResolver that can be used to determine the MIME
7498 * type of the intent's data.
7499 *
7500 * @return The MIME type of this intent, or null if it is unknown or not
7501 * needed.
7502 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007503 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007504 if (mComponent != null) {
7505 return mType;
7506 }
7507 return resolveType(resolver);
7508 }
7509
7510 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007511 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007512 *
7513 * @param category The category to check.
7514 *
7515 * @return boolean True if the intent contains the category, else false.
7516 *
7517 * @see #getCategories
7518 * @see #addCategory
7519 */
7520 public boolean hasCategory(String category) {
7521 return mCategories != null && mCategories.contains(category);
7522 }
7523
7524 /**
7525 * Return the set of all categories in the intent. If there are no categories,
7526 * returns NULL.
7527 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007528 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007529 *
7530 * @see #hasCategory
7531 * @see #addCategory
7532 */
7533 public Set<String> getCategories() {
7534 return mCategories;
7535 }
7536
7537 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007538 * Return the specific selector associated with this Intent. If there is
7539 * none, returns null. See {@link #setSelector} for more information.
7540 *
7541 * @see #setSelector
7542 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007543 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007544 return mSelector;
7545 }
7546
7547 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007548 * Return the {@link ClipData} associated with this Intent. If there is
7549 * none, returns null. See {@link #setClipData} for more information.
7550 *
John Spurlock125d1332013-11-25 11:58:37 -05007551 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007552 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007553 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007554 return mClipData;
7555 }
7556
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007557 /** @hide */
7558 public int getContentUserHint() {
7559 return mContentUserHint;
7560 }
7561
Todd Kennedyb3b431302017-03-20 16:05:48 -07007562 /** @hide */
7563 public String getLaunchToken() {
7564 return mLaunchToken;
7565 }
7566
7567 /** @hide */
7568 public void setLaunchToken(String launchToken) {
7569 mLaunchToken = launchToken;
7570 }
7571
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007572 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007573 * Sets the ClassLoader that will be used when unmarshalling
7574 * any Parcelable values from the extras of this Intent.
7575 *
7576 * @param loader a ClassLoader, or null to use the default loader
7577 * at the time of unmarshalling.
7578 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007579 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007580 if (mExtras != null) {
7581 mExtras.setClassLoader(loader);
7582 }
7583 }
7584
7585 /**
7586 * Returns true if an extra value is associated with the given name.
7587 * @param name the extra's name
7588 * @return true if the given extra is present.
7589 */
7590 public boolean hasExtra(String name) {
7591 return mExtras != null && mExtras.containsKey(name);
7592 }
7593
7594 /**
7595 * Returns true if the Intent's extras contain a parcelled file descriptor.
7596 * @return true if the Intent contains a parcelled file descriptor.
7597 */
7598 public boolean hasFileDescriptors() {
7599 return mExtras != null && mExtras.hasFileDescriptors();
7600 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007601
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007602 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007603 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007604 public void setAllowFds(boolean allowFds) {
7605 if (mExtras != null) {
7606 mExtras.setAllowFds(allowFds);
7607 }
7608 }
7609
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007610 /** {@hide} */
7611 public void setDefusable(boolean defusable) {
7612 if (mExtras != null) {
7613 mExtras.setDefusable(defusable);
7614 }
7615 }
7616
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007617 /**
7618 * Retrieve extended data from the intent.
7619 *
7620 * @param name The name of the desired item.
7621 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007622 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007623 * or null if none was found.
7624 *
7625 * @deprecated
7626 * @hide
7627 */
7628 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007629 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007630 public Object getExtra(String name) {
7631 return getExtra(name, null);
7632 }
7633
7634 /**
7635 * Retrieve extended data from the intent.
7636 *
7637 * @param name The name of the desired item.
7638 * @param defaultValue the value to be returned if no value of the desired
7639 * type is stored with the given name.
7640 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007641 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007642 * or the default value if none was found.
7643 *
7644 * @see #putExtra(String, boolean)
7645 */
7646 public boolean getBooleanExtra(String name, boolean defaultValue) {
7647 return mExtras == null ? defaultValue :
7648 mExtras.getBoolean(name, defaultValue);
7649 }
7650
7651 /**
7652 * Retrieve extended data from the intent.
7653 *
7654 * @param name The name of the desired item.
7655 * @param defaultValue the value to be returned if no value of the desired
7656 * type is stored with the given name.
7657 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007658 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007659 * or the default value if none was found.
7660 *
7661 * @see #putExtra(String, byte)
7662 */
7663 public byte getByteExtra(String name, byte defaultValue) {
7664 return mExtras == null ? defaultValue :
7665 mExtras.getByte(name, defaultValue);
7666 }
7667
7668 /**
7669 * Retrieve extended data from the intent.
7670 *
7671 * @param name The name of the desired item.
7672 * @param defaultValue the value to be returned if no value of the desired
7673 * type is stored with the given name.
7674 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007675 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007676 * or the default value if none was found.
7677 *
7678 * @see #putExtra(String, short)
7679 */
7680 public short getShortExtra(String name, short defaultValue) {
7681 return mExtras == null ? defaultValue :
7682 mExtras.getShort(name, defaultValue);
7683 }
7684
7685 /**
7686 * Retrieve extended data from the intent.
7687 *
7688 * @param name The name of the desired item.
7689 * @param defaultValue the value to be returned if no value of the desired
7690 * type is stored with the given name.
7691 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007692 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007693 * or the default value if none was found.
7694 *
7695 * @see #putExtra(String, char)
7696 */
7697 public char getCharExtra(String name, char defaultValue) {
7698 return mExtras == null ? defaultValue :
7699 mExtras.getChar(name, defaultValue);
7700 }
7701
7702 /**
7703 * Retrieve extended data from the intent.
7704 *
7705 * @param name The name of the desired item.
7706 * @param defaultValue the value to be returned if no value of the desired
7707 * type is stored with the given name.
7708 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007709 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007710 * or the default value if none was found.
7711 *
7712 * @see #putExtra(String, int)
7713 */
7714 public int getIntExtra(String name, int defaultValue) {
7715 return mExtras == null ? defaultValue :
7716 mExtras.getInt(name, defaultValue);
7717 }
7718
7719 /**
7720 * Retrieve extended data from the intent.
7721 *
7722 * @param name The name of the desired item.
7723 * @param defaultValue the value to be returned if no value of the desired
7724 * type is stored with the given name.
7725 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007726 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007727 * or the default value if none was found.
7728 *
7729 * @see #putExtra(String, long)
7730 */
7731 public long getLongExtra(String name, long defaultValue) {
7732 return mExtras == null ? defaultValue :
7733 mExtras.getLong(name, defaultValue);
7734 }
7735
7736 /**
7737 * Retrieve extended data from the intent.
7738 *
7739 * @param name The name of the desired item.
7740 * @param defaultValue the value to be returned if no value of the desired
7741 * type is stored with the given name.
7742 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007743 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007744 * or the default value if no such item is present
7745 *
7746 * @see #putExtra(String, float)
7747 */
7748 public float getFloatExtra(String name, float defaultValue) {
7749 return mExtras == null ? defaultValue :
7750 mExtras.getFloat(name, defaultValue);
7751 }
7752
7753 /**
7754 * Retrieve extended data from the intent.
7755 *
7756 * @param name The name of the desired item.
7757 * @param defaultValue the value to be returned if no value of the desired
7758 * type is stored with the given name.
7759 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007760 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007761 * or the default value if none was found.
7762 *
7763 * @see #putExtra(String, double)
7764 */
7765 public double getDoubleExtra(String name, double defaultValue) {
7766 return mExtras == null ? defaultValue :
7767 mExtras.getDouble(name, defaultValue);
7768 }
7769
7770 /**
7771 * Retrieve extended data from the intent.
7772 *
7773 * @param name The name of the desired item.
7774 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007775 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007776 * or null if no String value was found.
7777 *
7778 * @see #putExtra(String, String)
7779 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007780 public @Nullable String getStringExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007781 return mExtras == null ? null : mExtras.getString(name);
7782 }
7783
7784 /**
7785 * Retrieve extended data from the intent.
7786 *
7787 * @param name The name of the desired item.
7788 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007789 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007790 * or null if no CharSequence value was found.
7791 *
7792 * @see #putExtra(String, CharSequence)
7793 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007794 public @Nullable CharSequence getCharSequenceExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007795 return mExtras == null ? null : mExtras.getCharSequence(name);
7796 }
7797
7798 /**
7799 * Retrieve extended data from the intent.
7800 *
7801 * @param name The name of the desired item.
7802 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007803 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 * or null if no Parcelable value was found.
7805 *
7806 * @see #putExtra(String, Parcelable)
7807 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007808 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007809 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7810 }
7811
7812 /**
7813 * Retrieve extended data from the intent.
7814 *
7815 * @param name The name of the desired item.
7816 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007817 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007818 * or null if no Parcelable[] value was found.
7819 *
7820 * @see #putExtra(String, Parcelable[])
7821 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007822 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007823 return mExtras == null ? null : mExtras.getParcelableArray(name);
7824 }
7825
7826 /**
7827 * Retrieve extended data from the intent.
7828 *
7829 * @param name The name of the desired item.
7830 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007831 * @return the value of an item previously added with
7832 * putParcelableArrayListExtra(), or null if no
7833 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007834 *
7835 * @see #putParcelableArrayListExtra(String, ArrayList)
7836 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007837 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7839 }
7840
7841 /**
7842 * Retrieve extended data from the intent.
7843 *
7844 * @param name The name of the desired item.
7845 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007846 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007847 * or null if no Serializable value was found.
7848 *
7849 * @see #putExtra(String, Serializable)
7850 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007851 public @Nullable Serializable getSerializableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 return mExtras == null ? null : mExtras.getSerializable(name);
7853 }
7854
7855 /**
7856 * Retrieve extended data from the intent.
7857 *
7858 * @param name The name of the desired item.
7859 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007860 * @return the value of an item previously added with
7861 * putIntegerArrayListExtra(), or null if no
7862 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007863 *
7864 * @see #putIntegerArrayListExtra(String, ArrayList)
7865 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007866 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007867 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7868 }
7869
7870 /**
7871 * Retrieve extended data from the intent.
7872 *
7873 * @param name The name of the desired item.
7874 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007875 * @return the value of an item previously added with
7876 * putStringArrayListExtra(), or null if no
7877 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007878 *
7879 * @see #putStringArrayListExtra(String, ArrayList)
7880 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007881 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007882 return mExtras == null ? null : mExtras.getStringArrayList(name);
7883 }
7884
7885 /**
7886 * Retrieve extended data from the intent.
7887 *
7888 * @param name The name of the desired item.
7889 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007890 * @return the value of an item previously added with
7891 * putCharSequenceArrayListExtra, or null if no
7892 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007893 *
7894 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7895 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007896 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007897 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7898 }
7899
7900 /**
7901 * Retrieve extended data from the intent.
7902 *
7903 * @param name The name of the desired item.
7904 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007905 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007906 * or null if no boolean array value was found.
7907 *
7908 * @see #putExtra(String, boolean[])
7909 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007910 public @Nullable boolean[] getBooleanArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007911 return mExtras == null ? null : mExtras.getBooleanArray(name);
7912 }
7913
7914 /**
7915 * Retrieve extended data from the intent.
7916 *
7917 * @param name The name of the desired item.
7918 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007919 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007920 * or null if no byte array value was found.
7921 *
7922 * @see #putExtra(String, byte[])
7923 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007924 public @Nullable byte[] getByteArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007925 return mExtras == null ? null : mExtras.getByteArray(name);
7926 }
7927
7928 /**
7929 * Retrieve extended data from the intent.
7930 *
7931 * @param name The name of the desired item.
7932 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007933 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007934 * or null if no short array value was found.
7935 *
7936 * @see #putExtra(String, short[])
7937 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007938 public @Nullable short[] getShortArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007939 return mExtras == null ? null : mExtras.getShortArray(name);
7940 }
7941
7942 /**
7943 * Retrieve extended data from the intent.
7944 *
7945 * @param name The name of the desired item.
7946 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007947 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007948 * or null if no char array value was found.
7949 *
7950 * @see #putExtra(String, char[])
7951 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007952 public @Nullable char[] getCharArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007953 return mExtras == null ? null : mExtras.getCharArray(name);
7954 }
7955
7956 /**
7957 * Retrieve extended data from the intent.
7958 *
7959 * @param name The name of the desired item.
7960 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007961 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007962 * or null if no int array value was found.
7963 *
7964 * @see #putExtra(String, int[])
7965 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007966 public @Nullable int[] getIntArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007967 return mExtras == null ? null : mExtras.getIntArray(name);
7968 }
7969
7970 /**
7971 * Retrieve extended data from the intent.
7972 *
7973 * @param name The name of the desired item.
7974 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007975 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007976 * or null if no long array value was found.
7977 *
7978 * @see #putExtra(String, long[])
7979 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007980 public @Nullable long[] getLongArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007981 return mExtras == null ? null : mExtras.getLongArray(name);
7982 }
7983
7984 /**
7985 * Retrieve extended data from the intent.
7986 *
7987 * @param name The name of the desired item.
7988 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007989 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007990 * or null if no float array value was found.
7991 *
7992 * @see #putExtra(String, float[])
7993 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007994 public @Nullable float[] getFloatArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007995 return mExtras == null ? null : mExtras.getFloatArray(name);
7996 }
7997
7998 /**
7999 * Retrieve extended data from the intent.
8000 *
8001 * @param name The name of the desired item.
8002 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008003 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008004 * or null if no double array value was found.
8005 *
8006 * @see #putExtra(String, double[])
8007 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008008 public @Nullable double[] getDoubleArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008009 return mExtras == null ? null : mExtras.getDoubleArray(name);
8010 }
8011
8012 /**
8013 * Retrieve extended data from the intent.
8014 *
8015 * @param name The name of the desired item.
8016 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008017 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008018 * or null if no String array value was found.
8019 *
8020 * @see #putExtra(String, String[])
8021 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008022 public @Nullable String[] getStringArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008023 return mExtras == null ? null : mExtras.getStringArray(name);
8024 }
8025
8026 /**
8027 * Retrieve extended data from the intent.
8028 *
8029 * @param name The name of the desired item.
8030 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008031 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008032 * or null if no CharSequence array value was found.
8033 *
8034 * @see #putExtra(String, CharSequence[])
8035 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008036 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008037 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8038 }
8039
8040 /**
8041 * Retrieve extended data from the intent.
8042 *
8043 * @param name The name of the desired item.
8044 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008045 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008046 * or null if no Bundle value was found.
8047 *
8048 * @see #putExtra(String, Bundle)
8049 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008050 public @Nullable Bundle getBundleExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008051 return mExtras == null ? null : mExtras.getBundle(name);
8052 }
8053
8054 /**
8055 * Retrieve extended data from the intent.
8056 *
8057 * @param name The name of the desired item.
8058 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008059 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008060 * or null if no IBinder value was found.
8061 *
8062 * @see #putExtra(String, IBinder)
8063 *
8064 * @deprecated
8065 * @hide
8066 */
8067 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008068 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008069 public IBinder getIBinderExtra(String name) {
8070 return mExtras == null ? null : mExtras.getIBinder(name);
8071 }
8072
8073 /**
8074 * Retrieve extended data from the intent.
8075 *
8076 * @param name The name of the desired item.
8077 * @param defaultValue The default value to return in case no item is
8078 * associated with the key 'name'
8079 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008080 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008081 * or defaultValue if none was found.
8082 *
8083 * @see #putExtra
8084 *
8085 * @deprecated
8086 * @hide
8087 */
8088 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008089 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008090 public Object getExtra(String name, Object defaultValue) {
8091 Object result = defaultValue;
8092 if (mExtras != null) {
8093 Object result2 = mExtras.get(name);
8094 if (result2 != null) {
8095 result = result2;
8096 }
8097 }
8098
8099 return result;
8100 }
8101
8102 /**
8103 * Retrieves a map of extended data from the intent.
8104 *
8105 * @return the map of all extras previously added with putExtra(),
8106 * or null if none have been added.
8107 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008108 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008109 return (mExtras != null)
8110 ? new Bundle(mExtras)
8111 : null;
8112 }
8113
8114 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008115 * Filter extras to only basic types.
8116 * @hide
8117 */
8118 public void removeUnsafeExtras() {
8119 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07008120 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008121 }
8122 }
8123
8124 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07008125 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8126 * return itself as-is.
8127 * @hide
8128 */
8129 public boolean canStripForHistory() {
8130 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8131 }
8132
8133 /**
8134 * Call it when the system needs to keep an intent for logging purposes to remove fields
8135 * that are not needed for logging.
8136 * @hide
8137 */
8138 public Intent maybeStripForHistory() {
8139 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8140
8141 if (!canStripForHistory()) {
8142 return this;
8143 }
8144 return new Intent(this, COPY_MODE_HISTORY);
8145 }
8146
8147 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008148 * Retrieve any special flags associated with this intent. You will
8149 * normally just set them with {@link #setFlags} and let the system
8150 * take the appropriate action with them.
8151 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008152 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008153 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008154 * @see #addFlags
8155 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008156 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008157 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008158 return mFlags;
8159 }
8160
Dianne Hackborne7f97212011-02-24 14:40:20 -08008161 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008162 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08008163 public boolean isExcludingStopped() {
8164 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8165 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8166 }
8167
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008168 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008169 * Retrieve the application package name this Intent is limited to. When
8170 * resolving an Intent, if non-null this limits the resolution to only
8171 * components in the given application package.
8172 *
8173 * @return The name of the application package for the Intent.
8174 *
8175 * @see #resolveActivity
8176 * @see #setPackage
8177 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008178 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008179 return mPackage;
8180 }
8181
8182 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 * Retrieve the concrete component associated with the intent. When receiving
8184 * an intent, this is the component that was found to best handle it (that is,
8185 * yourself) and will always be non-null; in all other cases it will be
8186 * null unless explicitly set.
8187 *
8188 * @return The name of the application component to handle the intent.
8189 *
8190 * @see #resolveActivity
8191 * @see #setComponent
8192 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008193 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008194 return mComponent;
8195 }
8196
8197 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008198 * Get the bounds of the sender of this intent, in screen coordinates. This can be
8199 * used as a hint to the receiver for animations and the like. Null means that there
8200 * is no source bounds.
8201 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008202 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008203 return mSourceBounds;
8204 }
8205
8206 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008207 * Return the Activity component that should be used to handle this intent.
8208 * The appropriate component is determined based on the information in the
8209 * intent, evaluated as follows:
8210 *
8211 * <p>If {@link #getComponent} returns an explicit class, that is returned
8212 * without any further consideration.
8213 *
8214 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8215 * category to be considered.
8216 *
8217 * <p>If {@link #getAction} is non-NULL, the activity must handle this
8218 * action.
8219 *
8220 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8221 * this type.
8222 *
8223 * <p>If {@link #addCategory} has added any categories, the activity must
8224 * handle ALL of the categories specified.
8225 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008226 * <p>If {@link #getPackage} is non-NULL, only activity components in
8227 * that application package will be considered.
8228 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008229 * <p>If there are no activities that satisfy all of these conditions, a
8230 * null string is returned.
8231 *
8232 * <p>If multiple activities are found to satisfy the intent, the one with
8233 * the highest priority will be used. If there are multiple activities
8234 * with the same priority, the system will either pick the best activity
8235 * based on user preference, or resolve to a system class that will allow
8236 * the user to pick an activity and forward from there.
8237 *
8238 * <p>This method is implemented simply by calling
8239 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8240 * true.</p>
8241 * <p> This API is called for you as part of starting an activity from an
8242 * intent. You do not normally need to call it yourself.</p>
8243 *
8244 * @param pm The package manager with which to resolve the Intent.
8245 *
8246 * @return Name of the component implementing an activity that can
8247 * display the intent.
8248 *
8249 * @see #setComponent
8250 * @see #getComponent
8251 * @see #resolveActivityInfo
8252 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008253 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008254 if (mComponent != null) {
8255 return mComponent;
8256 }
8257
8258 ResolveInfo info = pm.resolveActivity(
8259 this, PackageManager.MATCH_DEFAULT_ONLY);
8260 if (info != null) {
8261 return new ComponentName(
8262 info.activityInfo.applicationInfo.packageName,
8263 info.activityInfo.name);
8264 }
8265
8266 return null;
8267 }
8268
8269 /**
8270 * Resolve the Intent into an {@link ActivityInfo}
8271 * describing the activity that should execute the intent. Resolution
8272 * follows the same rules as described for {@link #resolveActivity}, but
8273 * you get back the completely information about the resolved activity
8274 * instead of just its class name.
8275 *
8276 * @param pm The package manager with which to resolve the Intent.
8277 * @param flags Addition information to retrieve as per
8278 * {@link PackageManager#getActivityInfo(ComponentName, int)
8279 * PackageManager.getActivityInfo()}.
8280 *
8281 * @return PackageManager.ActivityInfo
8282 *
8283 * @see #resolveActivity
8284 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008285 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8286 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008287 ActivityInfo ai = null;
8288 if (mComponent != null) {
8289 try {
8290 ai = pm.getActivityInfo(mComponent, flags);
8291 } catch (PackageManager.NameNotFoundException e) {
8292 // ignore
8293 }
8294 } else {
8295 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07008296 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008297 if (info != null) {
8298 ai = info.activityInfo;
8299 }
8300 }
8301
8302 return ai;
8303 }
8304
8305 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07008306 * Special function for use by the system to resolve service
8307 * intents to system apps. Throws an exception if there are
8308 * multiple potential matches to the Intent. Returns null if
8309 * there are no matches.
8310 * @hide
8311 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008312 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008313 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8314 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008315 if (mComponent != null) {
8316 return mComponent;
8317 }
8318
8319 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8320 if (results == null) {
8321 return null;
8322 }
8323 ComponentName comp = null;
8324 for (int i=0; i<results.size(); i++) {
8325 ResolveInfo ri = results.get(i);
8326 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8327 continue;
8328 }
8329 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8330 ri.serviceInfo.name);
8331 if (comp != null) {
8332 throw new IllegalStateException("Multiple system services handle " + this
8333 + ": " + comp + ", " + foundComp);
8334 }
8335 comp = foundComp;
8336 }
8337 return comp;
8338 }
8339
8340 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008341 * Set the general action to be performed.
8342 *
8343 * @param action An action name, such as ACTION_VIEW. Application-specific
8344 * actions should be prefixed with the vendor's package name.
8345 *
8346 * @return Returns the same Intent object, for chaining multiple calls
8347 * into a single statement.
8348 *
8349 * @see #getAction
8350 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008351 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008352 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008353 return this;
8354 }
8355
8356 /**
8357 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008358 * clears any type that was previously set by {@link #setType} or
8359 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008360 *
Nick Pellyccae4122012-01-09 14:12:58 -08008361 * <p><em>Note: scheme matching in the Android framework is
8362 * case-sensitive, unlike the formal RFC. As a result,
8363 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008364 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008365 * {@link #setDataAndNormalize}
8366 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008367 *
Nick Pellyccae4122012-01-09 14:12:58 -08008368 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008369 *
8370 * @return Returns the same Intent object, for chaining multiple calls
8371 * into a single statement.
8372 *
8373 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008374 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008375 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008376 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008377 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008378 mData = data;
8379 mType = null;
8380 return this;
8381 }
8382
8383 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008384 * Normalize and set the data this intent is operating on.
8385 *
8386 * <p>This method automatically clears any type that was
8387 * previously set (for example, by {@link #setType}).
8388 *
8389 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008390 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008391 * so really this is just a convenience method for
8392 * <pre>
8393 * setData(data.normalize())
8394 * </pre>
8395 *
8396 * @param data The Uri of the data this intent is now targeting.
8397 *
8398 * @return Returns the same Intent object, for chaining multiple calls
8399 * into a single statement.
8400 *
8401 * @see #getData
8402 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008403 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008404 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008405 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008406 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008407 }
8408
8409 /**
8410 * Set an explicit MIME data type.
8411 *
8412 * <p>This is used to create intents that only specify a type and not data,
8413 * for example to indicate the type of data to return.
8414 *
8415 * <p>This method automatically clears any data that was
8416 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008417 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008418 * <p><em>Note: MIME type matching in the Android framework is
8419 * case-sensitive, unlike formal RFC MIME types. As a result,
8420 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008421 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8422 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008423 *
8424 * @param type The MIME type of the data being handled by this intent.
8425 *
8426 * @return Returns the same Intent object, for chaining multiple calls
8427 * into a single statement.
8428 *
8429 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008430 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008431 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008432 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008433 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008434 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008435 mData = null;
8436 mType = type;
8437 return this;
8438 }
8439
8440 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008441 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008442 *
Nick Pellyccae4122012-01-09 14:12:58 -08008443 * <p>This is used to create intents that only specify a type and not data,
8444 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008445 *
Nick Pellyccae4122012-01-09 14:12:58 -08008446 * <p>This method automatically clears any data that was
8447 * previously set (for example by {@link #setData}).
8448 *
8449 * <p>The MIME type is normalized using
8450 * {@link #normalizeMimeType} before it is set,
8451 * so really this is just a convenience method for
8452 * <pre>
8453 * setType(Intent.normalizeMimeType(type))
8454 * </pre>
8455 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008456 * @param type The MIME type of the data being handled by this intent.
8457 *
8458 * @return Returns the same Intent object, for chaining multiple calls
8459 * into a single statement.
8460 *
Nick Pellyccae4122012-01-09 14:12:58 -08008461 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008462 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008463 * @see #normalizeMimeType
8464 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008465 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008466 return setType(normalizeMimeType(type));
8467 }
8468
8469 /**
8470 * (Usually optional) Set the data for the intent along with an explicit
8471 * MIME data type. This method should very rarely be used -- it allows you
8472 * to override the MIME type that would ordinarily be inferred from the
8473 * data with your own type given here.
8474 *
8475 * <p><em>Note: MIME type and Uri scheme matching in the
8476 * Android framework is case-sensitive, unlike the formal RFC definitions.
8477 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008478 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008479 * {@link #setDataAndTypeAndNormalize}
8480 * to ensure that they are converted to lower case.</em>
8481 *
8482 * @param data The Uri of the data this intent is now targeting.
8483 * @param type The MIME type of the data being handled by this intent.
8484 *
8485 * @return Returns the same Intent object, for chaining multiple calls
8486 * into a single statement.
8487 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008488 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008489 * @see #setData
8490 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008491 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008492 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008493 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008494 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008495 mData = data;
8496 mType = type;
8497 return this;
8498 }
8499
8500 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008501 * (Usually optional) Normalize and set both the data Uri and an explicit
8502 * MIME data type. This method should very rarely be used -- it allows you
8503 * to override the MIME type that would ordinarily be inferred from the
8504 * data with your own type given here.
8505 *
8506 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008507 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008508 * before they are set, so really this is just a convenience method for
8509 * <pre>
8510 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8511 * </pre>
8512 *
8513 * @param data The Uri of the data this intent is now targeting.
8514 * @param type The MIME type of the data being handled by this intent.
8515 *
8516 * @return Returns the same Intent object, for chaining multiple calls
8517 * into a single statement.
8518 *
8519 * @see #setType
8520 * @see #setData
8521 * @see #setDataAndType
8522 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008523 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008524 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008525 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008526 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008527 }
8528
8529 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008530 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008531 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008532 * activities that provide <em>all</em> of the requested categories will be
8533 * used.
8534 *
8535 * @param category The desired category. This can be either one of the
8536 * predefined Intent categories, or a custom category in your own
8537 * namespace.
8538 *
8539 * @return Returns the same Intent object, for chaining multiple calls
8540 * into a single statement.
8541 *
8542 * @see #hasCategory
8543 * @see #removeCategory
8544 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008545 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008546 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008547 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008548 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008549 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008550 return this;
8551 }
8552
8553 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008554 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008555 *
8556 * @param category The category to remove.
8557 *
8558 * @see #addCategory
8559 */
8560 public void removeCategory(String category) {
8561 if (mCategories != null) {
8562 mCategories.remove(category);
8563 if (mCategories.size() == 0) {
8564 mCategories = null;
8565 }
8566 }
8567 }
8568
8569 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008570 * Set a selector for this Intent. This is a modification to the kinds of
8571 * things the Intent will match. If the selector is set, it will be used
8572 * when trying to find entities that can handle the Intent, instead of the
8573 * main contents of the Intent. This allows you build an Intent containing
8574 * a generic protocol while targeting it more specifically.
8575 *
8576 * <p>An example of where this may be used is with things like
8577 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8578 * Intent that will launch the Browser application. However, the correct
8579 * main entry point of an application is actually {@link #ACTION_MAIN}
8580 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8581 * used to specify the actual Activity to launch. If you launch the browser
8582 * with something different, undesired behavior may happen if the user has
8583 * previously or later launches it the normal way, since they do not match.
8584 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8585 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8586 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8587 *
8588 * <p>Setting a selector does not impact the behavior of
8589 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8590 * desired behavior of a selector -- it does not impact the base meaning
8591 * of the Intent, just what kinds of things will be matched against it
8592 * when determining who can handle it.</p>
8593 *
8594 * <p>You can not use both a selector and {@link #setPackage(String)} on
8595 * the same base Intent.</p>
8596 *
8597 * @param selector The desired selector Intent; set to null to not use
8598 * a special selector.
8599 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008600 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008601 if (selector == this) {
8602 throw new IllegalArgumentException(
8603 "Intent being set as a selector of itself");
8604 }
8605 if (selector != null && mPackage != null) {
8606 throw new IllegalArgumentException(
8607 "Can't set selector when package name is already set");
8608 }
8609 mSelector = selector;
8610 }
8611
8612 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008613 * Set a {@link ClipData} associated with this Intent. This replaces any
8614 * previously set ClipData.
8615 *
8616 * <p>The ClipData in an intent is not used for Intent matching or other
8617 * such operations. Semantically it is like extras, used to transmit
8618 * additional data with the Intent. The main feature of using this over
8619 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8620 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8621 * items included in the clip data. This is useful, in particular, if
8622 * you want to transmit an Intent containing multiple <code>content:</code>
8623 * URIs for which the recipient may not have global permission to access the
8624 * content provider.
8625 *
8626 * <p>If the ClipData contains items that are themselves Intents, any
8627 * grant flags in those Intents will be ignored. Only the top-level flags
8628 * of the main Intent are respected, and will be applied to all Uri or
8629 * Intent items in the clip (or sub-items of the clip).
8630 *
8631 * <p>The MIME type, label, and icon in the ClipData object are not
8632 * directly used by Intent. Applications should generally rely on the
8633 * MIME type of the Intent itself, not what it may find in the ClipData.
8634 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008635 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008636 *
8637 * @param clip The new clip to set. May be null to clear the current clip.
8638 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008639 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008640 mClipData = clip;
8641 }
8642
8643 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008644 * This is NOT a secure mechanism to identify the user who sent the intent.
8645 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8646 * who sent the intent.
8647 * @hide
8648 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008649 public void prepareToLeaveUser(int userId) {
8650 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8651 // We want mContentUserHint to refer to the original user, so don't do anything.
8652 if (mContentUserHint == UserHandle.USER_CURRENT) {
8653 mContentUserHint = userId;
8654 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008655 }
8656
8657 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008658 * Add extended data to the intent. The name must include a package
8659 * prefix, for example the app com.android.contacts would use names
8660 * like "com.android.contacts.ShowAll".
8661 *
8662 * @param name The name of the extra data, with package prefix.
8663 * @param value The boolean data value.
8664 *
8665 * @return Returns the same Intent object, for chaining multiple calls
8666 * into a single statement.
8667 *
8668 * @see #putExtras
8669 * @see #removeExtra
8670 * @see #getBooleanExtra(String, boolean)
8671 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008672 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008673 if (mExtras == null) {
8674 mExtras = new Bundle();
8675 }
8676 mExtras.putBoolean(name, value);
8677 return this;
8678 }
8679
8680 /**
8681 * Add extended data to the intent. The name must include a package
8682 * prefix, for example the app com.android.contacts would use names
8683 * like "com.android.contacts.ShowAll".
8684 *
8685 * @param name The name of the extra data, with package prefix.
8686 * @param value The byte data value.
8687 *
8688 * @return Returns the same Intent object, for chaining multiple calls
8689 * into a single statement.
8690 *
8691 * @see #putExtras
8692 * @see #removeExtra
8693 * @see #getByteExtra(String, byte)
8694 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008695 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008696 if (mExtras == null) {
8697 mExtras = new Bundle();
8698 }
8699 mExtras.putByte(name, value);
8700 return this;
8701 }
8702
8703 /**
8704 * Add extended data to the intent. The name must include a package
8705 * prefix, for example the app com.android.contacts would use names
8706 * like "com.android.contacts.ShowAll".
8707 *
8708 * @param name The name of the extra data, with package prefix.
8709 * @param value The char data value.
8710 *
8711 * @return Returns the same Intent object, for chaining multiple calls
8712 * into a single statement.
8713 *
8714 * @see #putExtras
8715 * @see #removeExtra
8716 * @see #getCharExtra(String, char)
8717 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008718 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008719 if (mExtras == null) {
8720 mExtras = new Bundle();
8721 }
8722 mExtras.putChar(name, value);
8723 return this;
8724 }
8725
8726 /**
8727 * Add extended data to the intent. The name must include a package
8728 * prefix, for example the app com.android.contacts would use names
8729 * like "com.android.contacts.ShowAll".
8730 *
8731 * @param name The name of the extra data, with package prefix.
8732 * @param value The short data value.
8733 *
8734 * @return Returns the same Intent object, for chaining multiple calls
8735 * into a single statement.
8736 *
8737 * @see #putExtras
8738 * @see #removeExtra
8739 * @see #getShortExtra(String, short)
8740 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008741 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008742 if (mExtras == null) {
8743 mExtras = new Bundle();
8744 }
8745 mExtras.putShort(name, value);
8746 return this;
8747 }
8748
8749 /**
8750 * Add extended data to the intent. The name must include a package
8751 * prefix, for example the app com.android.contacts would use names
8752 * like "com.android.contacts.ShowAll".
8753 *
8754 * @param name The name of the extra data, with package prefix.
8755 * @param value The integer data value.
8756 *
8757 * @return Returns the same Intent object, for chaining multiple calls
8758 * into a single statement.
8759 *
8760 * @see #putExtras
8761 * @see #removeExtra
8762 * @see #getIntExtra(String, int)
8763 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008764 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008765 if (mExtras == null) {
8766 mExtras = new Bundle();
8767 }
8768 mExtras.putInt(name, value);
8769 return this;
8770 }
8771
8772 /**
8773 * Add extended data to the intent. The name must include a package
8774 * prefix, for example the app com.android.contacts would use names
8775 * like "com.android.contacts.ShowAll".
8776 *
8777 * @param name The name of the extra data, with package prefix.
8778 * @param value The long data value.
8779 *
8780 * @return Returns the same Intent object, for chaining multiple calls
8781 * into a single statement.
8782 *
8783 * @see #putExtras
8784 * @see #removeExtra
8785 * @see #getLongExtra(String, long)
8786 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008787 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008788 if (mExtras == null) {
8789 mExtras = new Bundle();
8790 }
8791 mExtras.putLong(name, value);
8792 return this;
8793 }
8794
8795 /**
8796 * Add extended data to the intent. The name must include a package
8797 * prefix, for example the app com.android.contacts would use names
8798 * like "com.android.contacts.ShowAll".
8799 *
8800 * @param name The name of the extra data, with package prefix.
8801 * @param value The float data value.
8802 *
8803 * @return Returns the same Intent object, for chaining multiple calls
8804 * into a single statement.
8805 *
8806 * @see #putExtras
8807 * @see #removeExtra
8808 * @see #getFloatExtra(String, float)
8809 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008810 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008811 if (mExtras == null) {
8812 mExtras = new Bundle();
8813 }
8814 mExtras.putFloat(name, value);
8815 return this;
8816 }
8817
8818 /**
8819 * Add extended data to the intent. The name must include a package
8820 * prefix, for example the app com.android.contacts would use names
8821 * like "com.android.contacts.ShowAll".
8822 *
8823 * @param name The name of the extra data, with package prefix.
8824 * @param value The double data value.
8825 *
8826 * @return Returns the same Intent object, for chaining multiple calls
8827 * into a single statement.
8828 *
8829 * @see #putExtras
8830 * @see #removeExtra
8831 * @see #getDoubleExtra(String, double)
8832 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008833 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008834 if (mExtras == null) {
8835 mExtras = new Bundle();
8836 }
8837 mExtras.putDouble(name, value);
8838 return this;
8839 }
8840
8841 /**
8842 * Add extended data to the intent. The name must include a package
8843 * prefix, for example the app com.android.contacts would use names
8844 * like "com.android.contacts.ShowAll".
8845 *
8846 * @param name The name of the extra data, with package prefix.
8847 * @param value The String data value.
8848 *
8849 * @return Returns the same Intent object, for chaining multiple calls
8850 * into a single statement.
8851 *
8852 * @see #putExtras
8853 * @see #removeExtra
8854 * @see #getStringExtra(String)
8855 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008856 public @NonNull Intent putExtra(String name, @Nullable String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008857 if (mExtras == null) {
8858 mExtras = new Bundle();
8859 }
8860 mExtras.putString(name, value);
8861 return this;
8862 }
8863
8864 /**
8865 * Add extended data to the intent. The name must include a package
8866 * prefix, for example the app com.android.contacts would use names
8867 * like "com.android.contacts.ShowAll".
8868 *
8869 * @param name The name of the extra data, with package prefix.
8870 * @param value The CharSequence data value.
8871 *
8872 * @return Returns the same Intent object, for chaining multiple calls
8873 * into a single statement.
8874 *
8875 * @see #putExtras
8876 * @see #removeExtra
8877 * @see #getCharSequenceExtra(String)
8878 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008879 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008880 if (mExtras == null) {
8881 mExtras = new Bundle();
8882 }
8883 mExtras.putCharSequence(name, value);
8884 return this;
8885 }
8886
8887 /**
8888 * Add extended data to the intent. The name must include a package
8889 * prefix, for example the app com.android.contacts would use names
8890 * like "com.android.contacts.ShowAll".
8891 *
8892 * @param name The name of the extra data, with package prefix.
8893 * @param value The Parcelable data value.
8894 *
8895 * @return Returns the same Intent object, for chaining multiple calls
8896 * into a single statement.
8897 *
8898 * @see #putExtras
8899 * @see #removeExtra
8900 * @see #getParcelableExtra(String)
8901 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008902 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008903 if (mExtras == null) {
8904 mExtras = new Bundle();
8905 }
8906 mExtras.putParcelable(name, value);
8907 return this;
8908 }
8909
8910 /**
8911 * Add extended data to the intent. The name must include a package
8912 * prefix, for example the app com.android.contacts would use names
8913 * like "com.android.contacts.ShowAll".
8914 *
8915 * @param name The name of the extra data, with package prefix.
8916 * @param value The Parcelable[] data value.
8917 *
8918 * @return Returns the same Intent object, for chaining multiple calls
8919 * into a single statement.
8920 *
8921 * @see #putExtras
8922 * @see #removeExtra
8923 * @see #getParcelableArrayExtra(String)
8924 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008925 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008926 if (mExtras == null) {
8927 mExtras = new Bundle();
8928 }
8929 mExtras.putParcelableArray(name, value);
8930 return this;
8931 }
8932
8933 /**
8934 * Add extended data to the intent. The name must include a package
8935 * prefix, for example the app com.android.contacts would use names
8936 * like "com.android.contacts.ShowAll".
8937 *
8938 * @param name The name of the extra data, with package prefix.
8939 * @param value The ArrayList<Parcelable> data value.
8940 *
8941 * @return Returns the same Intent object, for chaining multiple calls
8942 * into a single statement.
8943 *
8944 * @see #putExtras
8945 * @see #removeExtra
8946 * @see #getParcelableArrayListExtra(String)
8947 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008948 public @NonNull Intent putParcelableArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008949 @Nullable ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008950 if (mExtras == null) {
8951 mExtras = new Bundle();
8952 }
8953 mExtras.putParcelableArrayList(name, value);
8954 return this;
8955 }
8956
8957 /**
8958 * Add extended data to the intent. The name must include a package
8959 * prefix, for example the app com.android.contacts would use names
8960 * like "com.android.contacts.ShowAll".
8961 *
8962 * @param name The name of the extra data, with package prefix.
8963 * @param value The ArrayList<Integer> data value.
8964 *
8965 * @return Returns the same Intent object, for chaining multiple calls
8966 * into a single statement.
8967 *
8968 * @see #putExtras
8969 * @see #removeExtra
8970 * @see #getIntegerArrayListExtra(String)
8971 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008972 public @NonNull Intent putIntegerArrayListExtra(String name,
8973 @Nullable ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008974 if (mExtras == null) {
8975 mExtras = new Bundle();
8976 }
8977 mExtras.putIntegerArrayList(name, value);
8978 return this;
8979 }
8980
8981 /**
8982 * Add extended data to the intent. The name must include a package
8983 * prefix, for example the app com.android.contacts would use names
8984 * like "com.android.contacts.ShowAll".
8985 *
8986 * @param name The name of the extra data, with package prefix.
8987 * @param value The ArrayList<String> data value.
8988 *
8989 * @return Returns the same Intent object, for chaining multiple calls
8990 * into a single statement.
8991 *
8992 * @see #putExtras
8993 * @see #removeExtra
8994 * @see #getStringArrayListExtra(String)
8995 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008996 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008997 if (mExtras == null) {
8998 mExtras = new Bundle();
8999 }
9000 mExtras.putStringArrayList(name, value);
9001 return this;
9002 }
9003
9004 /**
9005 * Add extended data to the intent. The name must include a package
9006 * prefix, for example the app com.android.contacts would use names
9007 * like "com.android.contacts.ShowAll".
9008 *
9009 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009010 * @param value The ArrayList<CharSequence> data value.
9011 *
9012 * @return Returns the same Intent object, for chaining multiple calls
9013 * into a single statement.
9014 *
9015 * @see #putExtras
9016 * @see #removeExtra
9017 * @see #getCharSequenceArrayListExtra(String)
9018 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009019 public @NonNull Intent putCharSequenceArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009020 @Nullable ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009021 if (mExtras == null) {
9022 mExtras = new Bundle();
9023 }
9024 mExtras.putCharSequenceArrayList(name, value);
9025 return this;
9026 }
9027
9028 /**
9029 * Add extended data to the intent. The name must include a package
9030 * prefix, for example the app com.android.contacts would use names
9031 * like "com.android.contacts.ShowAll".
9032 *
9033 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009034 * @param value The Serializable data value.
9035 *
9036 * @return Returns the same Intent object, for chaining multiple calls
9037 * into a single statement.
9038 *
9039 * @see #putExtras
9040 * @see #removeExtra
9041 * @see #getSerializableExtra(String)
9042 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009043 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009044 if (mExtras == null) {
9045 mExtras = new Bundle();
9046 }
9047 mExtras.putSerializable(name, value);
9048 return this;
9049 }
9050
9051 /**
9052 * Add extended data to the intent. The name must include a package
9053 * prefix, for example the app com.android.contacts would use names
9054 * like "com.android.contacts.ShowAll".
9055 *
9056 * @param name The name of the extra data, with package prefix.
9057 * @param value The boolean array data value.
9058 *
9059 * @return Returns the same Intent object, for chaining multiple calls
9060 * into a single statement.
9061 *
9062 * @see #putExtras
9063 * @see #removeExtra
9064 * @see #getBooleanArrayExtra(String)
9065 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009066 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009067 if (mExtras == null) {
9068 mExtras = new Bundle();
9069 }
9070 mExtras.putBooleanArray(name, value);
9071 return this;
9072 }
9073
9074 /**
9075 * Add extended data to the intent. The name must include a package
9076 * prefix, for example the app com.android.contacts would use names
9077 * like "com.android.contacts.ShowAll".
9078 *
9079 * @param name The name of the extra data, with package prefix.
9080 * @param value The byte array data value.
9081 *
9082 * @return Returns the same Intent object, for chaining multiple calls
9083 * into a single statement.
9084 *
9085 * @see #putExtras
9086 * @see #removeExtra
9087 * @see #getByteArrayExtra(String)
9088 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009089 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009090 if (mExtras == null) {
9091 mExtras = new Bundle();
9092 }
9093 mExtras.putByteArray(name, value);
9094 return this;
9095 }
9096
9097 /**
9098 * Add extended data to the intent. The name must include a package
9099 * prefix, for example the app com.android.contacts would use names
9100 * like "com.android.contacts.ShowAll".
9101 *
9102 * @param name The name of the extra data, with package prefix.
9103 * @param value The short array data value.
9104 *
9105 * @return Returns the same Intent object, for chaining multiple calls
9106 * into a single statement.
9107 *
9108 * @see #putExtras
9109 * @see #removeExtra
9110 * @see #getShortArrayExtra(String)
9111 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009112 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009113 if (mExtras == null) {
9114 mExtras = new Bundle();
9115 }
9116 mExtras.putShortArray(name, value);
9117 return this;
9118 }
9119
9120 /**
9121 * Add extended data to the intent. The name must include a package
9122 * prefix, for example the app com.android.contacts would use names
9123 * like "com.android.contacts.ShowAll".
9124 *
9125 * @param name The name of the extra data, with package prefix.
9126 * @param value The char array data value.
9127 *
9128 * @return Returns the same Intent object, for chaining multiple calls
9129 * into a single statement.
9130 *
9131 * @see #putExtras
9132 * @see #removeExtra
9133 * @see #getCharArrayExtra(String)
9134 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009135 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009136 if (mExtras == null) {
9137 mExtras = new Bundle();
9138 }
9139 mExtras.putCharArray(name, value);
9140 return this;
9141 }
9142
9143 /**
9144 * Add extended data to the intent. The name must include a package
9145 * prefix, for example the app com.android.contacts would use names
9146 * like "com.android.contacts.ShowAll".
9147 *
9148 * @param name The name of the extra data, with package prefix.
9149 * @param value The int array data value.
9150 *
9151 * @return Returns the same Intent object, for chaining multiple calls
9152 * into a single statement.
9153 *
9154 * @see #putExtras
9155 * @see #removeExtra
9156 * @see #getIntArrayExtra(String)
9157 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009158 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009159 if (mExtras == null) {
9160 mExtras = new Bundle();
9161 }
9162 mExtras.putIntArray(name, value);
9163 return this;
9164 }
9165
9166 /**
9167 * Add extended data to the intent. The name must include a package
9168 * prefix, for example the app com.android.contacts would use names
9169 * like "com.android.contacts.ShowAll".
9170 *
9171 * @param name The name of the extra data, with package prefix.
9172 * @param value The byte array data value.
9173 *
9174 * @return Returns the same Intent object, for chaining multiple calls
9175 * into a single statement.
9176 *
9177 * @see #putExtras
9178 * @see #removeExtra
9179 * @see #getLongArrayExtra(String)
9180 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009181 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009182 if (mExtras == null) {
9183 mExtras = new Bundle();
9184 }
9185 mExtras.putLongArray(name, value);
9186 return this;
9187 }
9188
9189 /**
9190 * Add extended data to the intent. The name must include a package
9191 * prefix, for example the app com.android.contacts would use names
9192 * like "com.android.contacts.ShowAll".
9193 *
9194 * @param name The name of the extra data, with package prefix.
9195 * @param value The float array data value.
9196 *
9197 * @return Returns the same Intent object, for chaining multiple calls
9198 * into a single statement.
9199 *
9200 * @see #putExtras
9201 * @see #removeExtra
9202 * @see #getFloatArrayExtra(String)
9203 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009204 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009205 if (mExtras == null) {
9206 mExtras = new Bundle();
9207 }
9208 mExtras.putFloatArray(name, value);
9209 return this;
9210 }
9211
9212 /**
9213 * Add extended data to the intent. The name must include a package
9214 * prefix, for example the app com.android.contacts would use names
9215 * like "com.android.contacts.ShowAll".
9216 *
9217 * @param name The name of the extra data, with package prefix.
9218 * @param value The double array data value.
9219 *
9220 * @return Returns the same Intent object, for chaining multiple calls
9221 * into a single statement.
9222 *
9223 * @see #putExtras
9224 * @see #removeExtra
9225 * @see #getDoubleArrayExtra(String)
9226 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009227 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009228 if (mExtras == null) {
9229 mExtras = new Bundle();
9230 }
9231 mExtras.putDoubleArray(name, value);
9232 return this;
9233 }
9234
9235 /**
9236 * Add extended data to the intent. The name must include a package
9237 * prefix, for example the app com.android.contacts would use names
9238 * like "com.android.contacts.ShowAll".
9239 *
9240 * @param name The name of the extra data, with package prefix.
9241 * @param value The String array data value.
9242 *
9243 * @return Returns the same Intent object, for chaining multiple calls
9244 * into a single statement.
9245 *
9246 * @see #putExtras
9247 * @see #removeExtra
9248 * @see #getStringArrayExtra(String)
9249 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009250 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009251 if (mExtras == null) {
9252 mExtras = new Bundle();
9253 }
9254 mExtras.putStringArray(name, value);
9255 return this;
9256 }
9257
9258 /**
9259 * Add extended data to the intent. The name must include a package
9260 * prefix, for example the app com.android.contacts would use names
9261 * like "com.android.contacts.ShowAll".
9262 *
9263 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009264 * @param value The CharSequence array data value.
9265 *
9266 * @return Returns the same Intent object, for chaining multiple calls
9267 * into a single statement.
9268 *
9269 * @see #putExtras
9270 * @see #removeExtra
9271 * @see #getCharSequenceArrayExtra(String)
9272 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009273 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009274 if (mExtras == null) {
9275 mExtras = new Bundle();
9276 }
9277 mExtras.putCharSequenceArray(name, value);
9278 return this;
9279 }
9280
9281 /**
9282 * Add extended data to the intent. The name must include a package
9283 * prefix, for example the app com.android.contacts would use names
9284 * like "com.android.contacts.ShowAll".
9285 *
9286 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009287 * @param value The Bundle data value.
9288 *
9289 * @return Returns the same Intent object, for chaining multiple calls
9290 * into a single statement.
9291 *
9292 * @see #putExtras
9293 * @see #removeExtra
9294 * @see #getBundleExtra(String)
9295 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009296 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009297 if (mExtras == null) {
9298 mExtras = new Bundle();
9299 }
9300 mExtras.putBundle(name, value);
9301 return this;
9302 }
9303
9304 /**
9305 * Add extended data to the intent. The name must include a package
9306 * prefix, for example the app com.android.contacts would use names
9307 * like "com.android.contacts.ShowAll".
9308 *
9309 * @param name The name of the extra data, with package prefix.
9310 * @param value The IBinder data value.
9311 *
9312 * @return Returns the same Intent object, for chaining multiple calls
9313 * into a single statement.
9314 *
9315 * @see #putExtras
9316 * @see #removeExtra
9317 * @see #getIBinderExtra(String)
9318 *
9319 * @deprecated
9320 * @hide
9321 */
9322 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009323 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009324 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009325 if (mExtras == null) {
9326 mExtras = new Bundle();
9327 }
9328 mExtras.putIBinder(name, value);
9329 return this;
9330 }
9331
9332 /**
9333 * Copy all extras in 'src' in to this intent.
9334 *
9335 * @param src Contains the extras to copy.
9336 *
9337 * @see #putExtra
9338 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009339 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009340 if (src.mExtras != null) {
9341 if (mExtras == null) {
9342 mExtras = new Bundle(src.mExtras);
9343 } else {
9344 mExtras.putAll(src.mExtras);
9345 }
9346 }
9347 return this;
9348 }
9349
9350 /**
9351 * Add a set of extended data to the intent. The keys must include a package
9352 * prefix, for example the app com.android.contacts would use names
9353 * like "com.android.contacts.ShowAll".
9354 *
9355 * @param extras The Bundle of extras to add to this intent.
9356 *
9357 * @see #putExtra
9358 * @see #removeExtra
9359 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009360 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009361 if (mExtras == null) {
9362 mExtras = new Bundle();
9363 }
9364 mExtras.putAll(extras);
9365 return this;
9366 }
9367
9368 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009369 * Completely replace the extras in the Intent with the extras in the
9370 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009371 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009372 * @param src The exact extras contained in this Intent are copied
9373 * into the target intent, replacing any that were previously there.
9374 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009375 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009376 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9377 return this;
9378 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009379
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009380 /**
9381 * Completely replace the extras in the Intent with the given Bundle of
9382 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009383 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009384 * @param extras The new set of extras in the Intent, or null to erase
9385 * all extras.
9386 */
Tobias Thierer13991172018-12-23 14:25:58 +00009387 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009388 mExtras = extras != null ? new Bundle(extras) : null;
9389 return this;
9390 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009391
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009392 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009393 * Remove extended data from the intent.
9394 *
9395 * @see #putExtra
9396 */
9397 public void removeExtra(String name) {
9398 if (mExtras != null) {
9399 mExtras.remove(name);
9400 if (mExtras.size() == 0) {
9401 mExtras = null;
9402 }
9403 }
9404 }
9405
9406 /**
9407 * Set special flags controlling how this intent is handled. Most values
9408 * here depend on the type of component being executed by the Intent,
9409 * specifically the FLAG_ACTIVITY_* flags are all for use with
9410 * {@link Context#startActivity Context.startActivity()} and the
9411 * FLAG_RECEIVER_* flags are all for use with
9412 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9413 *
Scott Main7aee61f2011-02-08 11:25:01 -08009414 * <p>See the
9415 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9416 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009417 * the behavior of your application.
9418 *
9419 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009420 * @return Returns the same Intent object, for chaining multiple calls
9421 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009422 * @see #getFlags
9423 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009424 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009425 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009426 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009427 mFlags = flags;
9428 return this;
9429 }
9430
9431 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009432 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009433 *
9434 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009435 * @return Returns the same Intent object, for chaining multiple calls into
9436 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009437 * @see #setFlags
9438 * @see #getFlags
9439 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009440 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009441 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009442 mFlags |= flags;
9443 return this;
9444 }
9445
9446 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009447 * Remove these flags from the intent.
9448 *
9449 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009450 * @see #setFlags
9451 * @see #getFlags
9452 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009453 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009454 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009455 mFlags &= ~flags;
9456 }
9457
9458 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009459 * (Usually optional) Set an explicit application package name that limits
9460 * the components this Intent will resolve to. If left to the default
9461 * value of null, all components in all applications will considered.
9462 * If non-null, the Intent can only match the components in the given
9463 * application package.
9464 *
9465 * @param packageName The name of the application package to handle the
9466 * intent, or null to allow any application package.
9467 *
9468 * @return Returns the same Intent object, for chaining multiple calls
9469 * into a single statement.
9470 *
9471 * @see #getPackage
9472 * @see #resolveActivity
9473 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009474 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009475 if (packageName != null && mSelector != null) {
9476 throw new IllegalArgumentException(
9477 "Can't set package name when selector is already set");
9478 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009479 mPackage = packageName;
9480 return this;
9481 }
9482
9483 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009484 * (Usually optional) Explicitly set the component to handle the intent.
9485 * If left with the default value of null, the system will determine the
9486 * appropriate class to use based on the other fields (action, data,
9487 * type, categories) in the Intent. If this class is defined, the
9488 * specified class will always be used regardless of the other fields. You
9489 * should only set this value when you know you absolutely want a specific
9490 * class to be used; otherwise it is better to let the system find the
9491 * appropriate class so that you will respect the installed applications
9492 * and user preferences.
9493 *
9494 * @param component The name of the application component to handle the
9495 * intent, or null to let the system find one for you.
9496 *
9497 * @return Returns the same Intent object, for chaining multiple calls
9498 * into a single statement.
9499 *
9500 * @see #setClass
9501 * @see #setClassName(Context, String)
9502 * @see #setClassName(String, String)
9503 * @see #getComponent
9504 * @see #resolveActivity
9505 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009506 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009507 mComponent = component;
9508 return this;
9509 }
9510
9511 /**
9512 * Convenience for calling {@link #setComponent} with an
9513 * explicit class name.
9514 *
9515 * @param packageContext A Context of the application package implementing
9516 * this class.
9517 * @param className The name of a class inside of the application package
9518 * that will be used as the component for this Intent.
9519 *
9520 * @return Returns the same Intent object, for chaining multiple calls
9521 * into a single statement.
9522 *
9523 * @see #setComponent
9524 * @see #setClass
9525 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009526 public @NonNull Intent setClassName(@NonNull Context packageContext,
9527 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009528 mComponent = new ComponentName(packageContext, className);
9529 return this;
9530 }
9531
9532 /**
9533 * Convenience for calling {@link #setComponent} with an
9534 * explicit application package name and class name.
9535 *
9536 * @param packageName The name of the package implementing the desired
9537 * component.
9538 * @param className The name of a class inside of the application package
9539 * that will be used as the component for this Intent.
9540 *
9541 * @return Returns the same Intent object, for chaining multiple calls
9542 * into a single statement.
9543 *
9544 * @see #setComponent
9545 * @see #setClass
9546 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009547 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009548 mComponent = new ComponentName(packageName, className);
9549 return this;
9550 }
9551
9552 /**
9553 * Convenience for calling {@link #setComponent(ComponentName)} with the
9554 * name returned by a {@link Class} object.
9555 *
9556 * @param packageContext A Context of the application package implementing
9557 * this class.
9558 * @param cls The class name to set, equivalent to
9559 * <code>setClassName(context, cls.getName())</code>.
9560 *
9561 * @return Returns the same Intent object, for chaining multiple calls
9562 * into a single statement.
9563 *
9564 * @see #setComponent
9565 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009566 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009567 mComponent = new ComponentName(packageContext, cls);
9568 return this;
9569 }
9570
9571 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009572 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9573 * used as a hint to the receiver for animations and the like. Null means that there
9574 * is no source bounds.
9575 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009576 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009577 if (r != null) {
9578 mSourceBounds = new Rect(r);
9579 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009580 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009581 }
9582 }
9583
Tor Norbyed9273d62013-05-30 15:59:53 -07009584 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009585 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9586 FILL_IN_ACTION,
9587 FILL_IN_DATA,
9588 FILL_IN_CATEGORIES,
9589 FILL_IN_COMPONENT,
9590 FILL_IN_PACKAGE,
9591 FILL_IN_SOURCE_BOUNDS,
9592 FILL_IN_SELECTOR,
9593 FILL_IN_CLIP_DATA
9594 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009595 @Retention(RetentionPolicy.SOURCE)
9596 public @interface FillInFlags {}
9597
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009598 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009599 * Use with {@link #fillIn} to allow the current action value to be
9600 * overwritten, even if it is already set.
9601 */
9602 public static final int FILL_IN_ACTION = 1<<0;
9603
9604 /**
9605 * Use with {@link #fillIn} to allow the current data or type value
9606 * overwritten, even if it is already set.
9607 */
9608 public static final int FILL_IN_DATA = 1<<1;
9609
9610 /**
9611 * Use with {@link #fillIn} to allow the current categories to be
9612 * overwritten, even if they are already set.
9613 */
9614 public static final int FILL_IN_CATEGORIES = 1<<2;
9615
9616 /**
9617 * Use with {@link #fillIn} to allow the current component value to be
9618 * overwritten, even if it is already set.
9619 */
9620 public static final int FILL_IN_COMPONENT = 1<<3;
9621
9622 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009623 * Use with {@link #fillIn} to allow the current package value to be
9624 * overwritten, even if it is already set.
9625 */
9626 public static final int FILL_IN_PACKAGE = 1<<4;
9627
9628 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009629 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009630 * overwritten, even if it is already set.
9631 */
9632 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9633
9634 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009635 * Use with {@link #fillIn} to allow the current selector to be
9636 * overwritten, even if it is already set.
9637 */
9638 public static final int FILL_IN_SELECTOR = 1<<6;
9639
9640 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009641 * Use with {@link #fillIn} to allow the current ClipData to be
9642 * overwritten, even if it is already set.
9643 */
9644 public static final int FILL_IN_CLIP_DATA = 1<<7;
9645
9646 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009647 * Copy the contents of <var>other</var> in to this object, but only
9648 * where fields are not defined by this object. For purposes of a field
9649 * being defined, the following pieces of data in the Intent are
9650 * considered to be separate fields:
9651 *
9652 * <ul>
9653 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009654 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009655 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9656 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009657 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009658 * <li> component, as set by {@link #setComponent(ComponentName)} or
9659 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009660 * <li> source bounds, as set by {@link #setSourceBounds}.
9661 * <li> selector, as set by {@link #setSelector(Intent)}.
9662 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009663 * <li> each top-level name in the associated extras.
9664 * </ul>
9665 *
9666 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009667 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009668 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9669 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9670 * the restriction where the corresponding field will not be replaced if
9671 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009672 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009673 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9674 * is explicitly specified. The selector will only be copied if
9675 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009676 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009677 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9678 * and Intent B with {action="gotit", data-type="some/thing",
9679 * categories="one","two"}.
9680 *
9681 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9682 * containing: {action="gotit", data-type="some/thing",
9683 * categories="bar"}.
9684 *
9685 * @param other Another Intent whose values are to be used to fill in
9686 * the current one.
9687 * @param flags Options to control which fields can be filled in.
9688 *
9689 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009690 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009691 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009692 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009693 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009694 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009695 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009696 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009697 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009698 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009699 if (other.mAction != null
9700 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009701 mAction = other.mAction;
9702 changes |= FILL_IN_ACTION;
9703 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009704 if ((other.mData != null || other.mType != null)
9705 && ((mData == null && mType == null)
9706 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009707 mData = other.mData;
9708 mType = other.mType;
9709 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009710 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009711 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009712 if (other.mCategories != null
9713 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009714 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009715 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009716 }
9717 changes |= FILL_IN_CATEGORIES;
9718 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009719 if (other.mPackage != null
9720 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009721 // Only do this if mSelector is not set.
9722 if (mSelector == null) {
9723 mPackage = other.mPackage;
9724 changes |= FILL_IN_PACKAGE;
9725 }
9726 }
9727 // Selector is special: it can only be set if explicitly allowed,
9728 // for the same reason as the component name.
9729 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9730 if (mPackage == null) {
9731 mSelector = new Intent(other.mSelector);
9732 mPackage = null;
9733 changes |= FILL_IN_SELECTOR;
9734 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009735 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009736 if (other.mClipData != null
9737 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9738 mClipData = other.mClipData;
9739 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009740 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009741 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009742 // Component is special: it can -only- be set if explicitly allowed,
9743 // since otherwise the sender could force the intent somewhere the
9744 // originator didn't intend.
9745 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009746 mComponent = other.mComponent;
9747 changes |= FILL_IN_COMPONENT;
9748 }
9749 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009750 if (other.mSourceBounds != null
9751 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9752 mSourceBounds = new Rect(other.mSourceBounds);
9753 changes |= FILL_IN_SOURCE_BOUNDS;
9754 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009755 if (mExtras == null) {
9756 if (other.mExtras != null) {
9757 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009758 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009759 }
9760 } else if (other.mExtras != null) {
9761 try {
9762 Bundle newb = new Bundle(other.mExtras);
9763 newb.putAll(mExtras);
9764 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009765 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009766 } catch (RuntimeException e) {
9767 // Modifying the extras can cause us to unparcel the contents
9768 // of the bundle, and if we do this in the system process that
9769 // may fail. We really should handle this (i.e., the Bundle
9770 // impl shouldn't be on top of a plain map), but for now just
9771 // ignore it and keep the original contents. :(
9772 Log.w("Intent", "Failure filling in extras", e);
9773 }
9774 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009775 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9776 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9777 mContentUserHint = other.mContentUserHint;
9778 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009779 return changes;
9780 }
9781
9782 /**
9783 * Wrapper class holding an Intent and implementing comparisons on it for
9784 * the purpose of filtering. The class implements its
9785 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9786 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9787 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9788 * on the wrapped Intent.
9789 */
9790 public static final class FilterComparison {
9791 private final Intent mIntent;
9792 private final int mHashCode;
9793
9794 public FilterComparison(Intent intent) {
9795 mIntent = intent;
9796 mHashCode = intent.filterHashCode();
9797 }
9798
9799 /**
9800 * Return the Intent that this FilterComparison represents.
9801 * @return Returns the Intent held by the FilterComparison. Do
9802 * not modify!
9803 */
9804 public Intent getIntent() {
9805 return mIntent;
9806 }
9807
9808 @Override
9809 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009810 if (obj instanceof FilterComparison) {
9811 Intent other = ((FilterComparison)obj).mIntent;
9812 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009813 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009814 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009815 }
9816
9817 @Override
9818 public int hashCode() {
9819 return mHashCode;
9820 }
9821 }
9822
9823 /**
9824 * Determine if two intents are the same for the purposes of intent
9825 * resolution (filtering). That is, if their action, data, type,
9826 * class, and categories are the same. This does <em>not</em> compare
9827 * any extra data included in the intents.
9828 *
9829 * @param other The other Intent to compare against.
9830 *
9831 * @return Returns true if action, data, type, class, and categories
9832 * are the same.
9833 */
9834 public boolean filterEquals(Intent other) {
9835 if (other == null) {
9836 return false;
9837 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009838 if (!Objects.equals(this.mAction, other.mAction)) return false;
9839 if (!Objects.equals(this.mData, other.mData)) return false;
9840 if (!Objects.equals(this.mType, other.mType)) return false;
9841 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9842 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9843 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009844
9845 return true;
9846 }
9847
9848 /**
9849 * Generate hash code that matches semantics of filterEquals().
9850 *
9851 * @return Returns the hash value of the action, data, type, class, and
9852 * categories.
9853 *
9854 * @see #filterEquals
9855 */
9856 public int filterHashCode() {
9857 int code = 0;
9858 if (mAction != null) {
9859 code += mAction.hashCode();
9860 }
9861 if (mData != null) {
9862 code += mData.hashCode();
9863 }
9864 if (mType != null) {
9865 code += mType.hashCode();
9866 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009867 if (mPackage != null) {
9868 code += mPackage.hashCode();
9869 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009870 if (mComponent != null) {
9871 code += mComponent.hashCode();
9872 }
9873 if (mCategories != null) {
9874 code += mCategories.hashCode();
9875 }
9876 return code;
9877 }
9878
9879 @Override
9880 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009881 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009882
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009883 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009884 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009885 b.append(" }");
9886
9887 return b.toString();
9888 }
9889
9890 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009891 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009892 public String toInsecureString() {
9893 StringBuilder b = new StringBuilder(128);
9894
9895 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009896 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009897 b.append(" }");
9898
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009899 return b.toString();
9900 }
Romain Guy4969af72009-06-17 10:53:19 -07009901
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009902 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009903 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009904 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009905
9906 b.append("Intent { ");
9907 toShortString(b, false, true, true, true);
9908 b.append(" }");
9909
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009910 return b.toString();
9911 }
9912
9913 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009914 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9915 StringBuilder b = new StringBuilder(128);
9916 toShortString(b, secure, comp, extras, clip);
9917 return b.toString();
9918 }
9919
9920 /** @hide */
9921 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9922 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009923 boolean first = true;
9924 if (mAction != null) {
9925 b.append("act=").append(mAction);
9926 first = false;
9927 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009928 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009929 if (!first) {
9930 b.append(' ');
9931 }
9932 first = false;
9933 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009934 for (int i=0; i<mCategories.size(); i++) {
9935 if (i > 0) b.append(',');
9936 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009937 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009938 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009939 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009940 if (mData != null) {
9941 if (!first) {
9942 b.append(' ');
9943 }
9944 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009945 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009946 if (secure) {
9947 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009948 } else {
9949 b.append(mData);
9950 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009951 }
9952 if (mType != null) {
9953 if (!first) {
9954 b.append(' ');
9955 }
9956 first = false;
9957 b.append("typ=").append(mType);
9958 }
9959 if (mFlags != 0) {
9960 if (!first) {
9961 b.append(' ');
9962 }
9963 first = false;
9964 b.append("flg=0x").append(Integer.toHexString(mFlags));
9965 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009966 if (mPackage != null) {
9967 if (!first) {
9968 b.append(' ');
9969 }
9970 first = false;
9971 b.append("pkg=").append(mPackage);
9972 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009973 if (comp && mComponent != null) {
9974 if (!first) {
9975 b.append(' ');
9976 }
9977 first = false;
9978 b.append("cmp=").append(mComponent.flattenToShortString());
9979 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009980 if (mSourceBounds != null) {
9981 if (!first) {
9982 b.append(' ');
9983 }
9984 first = false;
9985 b.append("bnds=").append(mSourceBounds.toShortString());
9986 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009987 if (mClipData != null) {
9988 if (!first) {
9989 b.append(' ');
9990 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009991 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009992 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009993 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009994 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009995 if (mClipData.getDescription() != null) {
9996 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9997 } else {
9998 first = true;
9999 }
10000 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010001 }
Dianne Hackbornae498722015-08-14 13:29:47 -070010002 first = false;
10003 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010004 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010005 if (extras && mExtras != null) {
10006 if (!first) {
10007 b.append(' ');
10008 }
10009 first = false;
10010 b.append("(has extras)");
10011 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010012 if (mContentUserHint != UserHandle.USER_CURRENT) {
10013 if (!first) {
10014 b.append(' ');
10015 }
10016 first = false;
10017 b.append("u=").append(mContentUserHint);
10018 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010019 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010020 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010021 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010022 b.append("}");
10023 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010024 }
10025
Yi Jin129fc6c2017-09-28 15:48:38 -070010026 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -080010027 public void writeToProto(ProtoOutputStream proto, long fieldId) {
10028 // Same input parameters that toString() gives to toShortString().
10029 writeToProto(proto, fieldId, true, true, true, false);
10030 }
10031
10032 /** @hide */
Igor Murashkine9e439a2019-01-22 13:12:06 -080010033 public void writeToProto(ProtoOutputStream proto) {
10034 // Same input parameters that toString() gives to toShortString().
10035 writeToProtoWithoutFieldId(proto, true, true, true, false);
10036 }
10037
10038 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -070010039 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10040 boolean extras, boolean clip) {
10041 long token = proto.start(fieldId);
Igor Murashkine9e439a2019-01-22 13:12:06 -080010042 writeToProtoWithoutFieldId(proto, secure, comp, extras, clip);
10043 proto.end(token);
10044 }
10045
10046 private void writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10047 boolean extras, boolean clip) {
Yi Jin129fc6c2017-09-28 15:48:38 -070010048 if (mAction != null) {
10049 proto.write(IntentProto.ACTION, mAction);
10050 }
10051 if (mCategories != null) {
10052 for (String category : mCategories) {
10053 proto.write(IntentProto.CATEGORIES, category);
10054 }
10055 }
10056 if (mData != null) {
10057 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10058 }
10059 if (mType != null) {
10060 proto.write(IntentProto.TYPE, mType);
10061 }
10062 if (mFlags != 0) {
10063 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10064 }
10065 if (mPackage != null) {
10066 proto.write(IntentProto.PACKAGE, mPackage);
10067 }
10068 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -080010069 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -070010070 }
10071 if (mSourceBounds != null) {
10072 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10073 }
10074 if (mClipData != null) {
10075 StringBuilder b = new StringBuilder();
10076 if (clip) {
10077 mClipData.toShortString(b);
10078 } else {
10079 mClipData.toShortStringShortItems(b, false);
10080 }
10081 proto.write(IntentProto.CLIP_DATA, b.toString());
10082 }
10083 if (extras && mExtras != null) {
10084 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10085 }
10086 if (mContentUserHint != 0) {
10087 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10088 }
10089 if (mSelector != null) {
10090 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10091 }
Yi Jin129fc6c2017-09-28 15:48:38 -070010092 }
10093
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010094 /**
10095 * Call {@link #toUri} with 0 flags.
10096 * @deprecated Use {@link #toUri} instead.
10097 */
10098 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010099 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010100 return toUri(0);
10101 }
10102
10103 /**
10104 * Convert this Intent into a String holding a URI representation of it.
10105 * The returned URI string has been properly URI encoded, so it can be
10106 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
10107 * Intent's data as the base URI, with an additional fragment describing
10108 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -080010109 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010110 * <p>You can convert the returned string back to an Intent with
10111 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -080010112 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010113 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -080010114 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010115 * @return Returns a URI encoding URI string describing the entire contents
10116 * of the Intent.
10117 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010118 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010119 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010120 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10121 if (mPackage == null) {
10122 throw new IllegalArgumentException(
10123 "Intent must include an explicit package name to build an android-app: "
10124 + this);
10125 }
10126 uri.append("android-app://");
10127 uri.append(mPackage);
10128 String scheme = null;
10129 if (mData != null) {
10130 scheme = mData.getScheme();
10131 if (scheme != null) {
10132 uri.append('/');
10133 uri.append(scheme);
10134 String authority = mData.getEncodedAuthority();
10135 if (authority != null) {
10136 uri.append('/');
10137 uri.append(authority);
10138 String path = mData.getEncodedPath();
10139 if (path != null) {
10140 uri.append(path);
10141 }
10142 String queryParams = mData.getEncodedQuery();
10143 if (queryParams != null) {
10144 uri.append('?');
10145 uri.append(queryParams);
10146 }
10147 String fragment = mData.getEncodedFragment();
10148 if (fragment != null) {
10149 uri.append('#');
10150 uri.append(fragment);
10151 }
10152 }
10153 }
10154 }
10155 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10156 mPackage, flags);
10157 return uri.toString();
10158 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010159 String scheme = null;
10160 if (mData != null) {
10161 String data = mData.toString();
10162 if ((flags&URI_INTENT_SCHEME) != 0) {
10163 final int N = data.length();
10164 for (int i=0; i<N; i++) {
10165 char c = data.charAt(i);
10166 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -070010167 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010168 continue;
10169 }
10170 if (c == ':' && i > 0) {
10171 // Valid scheme.
10172 scheme = data.substring(0, i);
10173 uri.append("intent:");
10174 data = data.substring(i+1);
10175 break;
10176 }
Tom Taylord4a47292009-12-21 13:59:18 -080010177
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010178 // No scheme.
10179 break;
10180 }
10181 }
10182 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -080010183
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010184 } else if ((flags&URI_INTENT_SCHEME) != 0) {
10185 uri.append("intent:");
10186 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010187
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010188 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010189
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010190 return uri.toString();
10191 }
10192
10193 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10194 String defPackage, int flags) {
10195 StringBuilder frag = new StringBuilder(128);
10196
10197 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010198 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -080010199 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010200 // Note that for now we are not going to try to handle the
10201 // data part; not clear how to represent this as a URI, and
10202 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010203 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10204 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010205 }
10206
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010207 if (frag.length() > 0) {
10208 uri.append("#Intent;");
10209 uri.append(frag);
10210 uri.append("end");
10211 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010212 }
10213
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010214 private void toUriInner(StringBuilder uri, String scheme, String defAction,
10215 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010216 if (scheme != null) {
10217 uri.append("scheme=").append(scheme).append(';');
10218 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010219 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010220 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010221 }
10222 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010223 for (int i=0; i<mCategories.size(); i++) {
10224 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010225 }
10226 }
10227 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010228 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010229 }
10230 if (mFlags != 0) {
10231 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10232 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010233 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010234 uri.append("package=").append(Uri.encode(mPackage)).append(';');
10235 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010236 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010237 uri.append("component=").append(Uri.encode(
10238 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010239 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010240 if (mSourceBounds != null) {
10241 uri.append("sourceBounds=")
10242 .append(Uri.encode(mSourceBounds.flattenToString()))
10243 .append(';');
10244 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010245 if (mExtras != null) {
10246 for (String key : mExtras.keySet()) {
10247 final Object value = mExtras.get(key);
10248 char entryType =
10249 value instanceof String ? 'S' :
10250 value instanceof Boolean ? 'B' :
10251 value instanceof Byte ? 'b' :
10252 value instanceof Character ? 'c' :
10253 value instanceof Double ? 'd' :
10254 value instanceof Float ? 'f' :
10255 value instanceof Integer ? 'i' :
10256 value instanceof Long ? 'l' :
10257 value instanceof Short ? 's' :
10258 '\0';
10259
10260 if (entryType != '\0') {
10261 uri.append(entryType);
10262 uri.append('.');
10263 uri.append(Uri.encode(key));
10264 uri.append('=');
10265 uri.append(Uri.encode(value.toString()));
10266 uri.append(';');
10267 }
10268 }
10269 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010270 }
The Android Open Source Project10592532009-03-18 17:39:46 -070010271
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010272 public int describeContents() {
10273 return (mExtras != null) ? mExtras.describeContents() : 0;
10274 }
10275
10276 public void writeToParcel(Parcel out, int flags) {
10277 out.writeString(mAction);
10278 Uri.writeToParcel(out, mData);
10279 out.writeString(mType);
10280 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010281 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010282 ComponentName.writeToParcel(mComponent, out);
10283
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010284 if (mSourceBounds != null) {
10285 out.writeInt(1);
10286 mSourceBounds.writeToParcel(out, flags);
10287 } else {
10288 out.writeInt(0);
10289 }
10290
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010291 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010292 final int N = mCategories.size();
10293 out.writeInt(N);
10294 for (int i=0; i<N; i++) {
10295 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010296 }
10297 } else {
10298 out.writeInt(0);
10299 }
10300
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010301 if (mSelector != null) {
10302 out.writeInt(1);
10303 mSelector.writeToParcel(out, flags);
10304 } else {
10305 out.writeInt(0);
10306 }
10307
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010308 if (mClipData != null) {
10309 out.writeInt(1);
10310 mClipData.writeToParcel(out, flags);
10311 } else {
10312 out.writeInt(0);
10313 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010314 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010315 out.writeBundle(mExtras);
10316 }
10317
10318 public static final Parcelable.Creator<Intent> CREATOR
10319 = new Parcelable.Creator<Intent>() {
10320 public Intent createFromParcel(Parcel in) {
10321 return new Intent(in);
10322 }
10323 public Intent[] newArray(int size) {
10324 return new Intent[size];
10325 }
10326 };
10327
Dianne Hackborneb034652009-09-07 00:49:58 -070010328 /** @hide */
10329 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010330 readFromParcel(in);
10331 }
10332
10333 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010334 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010335 mData = Uri.CREATOR.createFromParcel(in);
10336 mType = in.readString();
10337 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010338 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010339 mComponent = ComponentName.readFromParcel(in);
10340
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010341 if (in.readInt() != 0) {
10342 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10343 }
10344
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010345 int N = in.readInt();
10346 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010347 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010348 int i;
10349 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010350 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010351 }
10352 } else {
10353 mCategories = null;
10354 }
10355
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010356 if (in.readInt() != 0) {
10357 mSelector = new Intent(in);
10358 }
10359
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010360 if (in.readInt() != 0) {
10361 mClipData = new ClipData(in);
10362 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010363 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010364 mExtras = in.readBundle();
10365 }
10366
10367 /**
10368 * Parses the "intent" element (and its children) from XML and instantiates
10369 * an Intent object. The given XML parser should be located at the tag
10370 * where parsing should start (often named "intent"), from which the
10371 * basic action, data, type, and package and class name will be
10372 * retrieved. The function will then parse in to any child elements,
10373 * looking for <category android:name="xxx"> tags to add categories and
10374 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10375 * to the intent.
10376 *
10377 * @param resources The Resources to use when inflating resources.
10378 * @param parser The XML parser pointing at an "intent" tag.
10379 * @param attrs The AttributeSet interface for retrieving extended
10380 * attribute data at the current <var>parser</var> location.
10381 * @return An Intent object matching the XML data.
10382 * @throws XmlPullParserException If there was an XML parsing error.
10383 * @throws IOException If there was an I/O error.
10384 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010385 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10386 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010387 throws XmlPullParserException, IOException {
10388 Intent intent = new Intent();
10389
10390 TypedArray sa = resources.obtainAttributes(attrs,
10391 com.android.internal.R.styleable.Intent);
10392
10393 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10394
10395 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10396 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10397 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10398
10399 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10400 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10401 if (packageName != null && className != null) {
10402 intent.setComponent(new ComponentName(packageName, className));
10403 }
10404
10405 sa.recycle();
10406
10407 int outerDepth = parser.getDepth();
10408 int type;
10409 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10410 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10411 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10412 continue;
10413 }
10414
10415 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010416 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010417 sa = resources.obtainAttributes(attrs,
10418 com.android.internal.R.styleable.IntentCategory);
10419 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10420 sa.recycle();
10421
10422 if (cat != null) {
10423 intent.addCategory(cat);
10424 }
10425 XmlUtils.skipCurrentTag(parser);
10426
Craig Mautner21d24a22014-04-23 11:45:37 -070010427 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010428 if (intent.mExtras == null) {
10429 intent.mExtras = new Bundle();
10430 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010431 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010432 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010433
10434 } else {
10435 XmlUtils.skipCurrentTag(parser);
10436 }
10437 }
10438
10439 return intent;
10440 }
Nick Pellyccae4122012-01-09 14:12:58 -080010441
Craig Mautner21d24a22014-04-23 11:45:37 -070010442 /** @hide */
10443 public void saveToXml(XmlSerializer out) throws IOException {
10444 if (mAction != null) {
10445 out.attribute(null, ATTR_ACTION, mAction);
10446 }
10447 if (mData != null) {
10448 out.attribute(null, ATTR_DATA, mData.toString());
10449 }
10450 if (mType != null) {
10451 out.attribute(null, ATTR_TYPE, mType);
10452 }
10453 if (mComponent != null) {
10454 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10455 }
10456 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10457
10458 if (mCategories != null) {
10459 out.startTag(null, TAG_CATEGORIES);
10460 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10461 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10462 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010463 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010464 }
10465 }
10466
10467 /** @hide */
10468 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10469 XmlPullParserException {
10470 Intent intent = new Intent();
10471 final int outerDepth = in.getDepth();
10472
10473 int attrCount = in.getAttributeCount();
10474 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10475 final String attrName = in.getAttributeName(attrNdx);
10476 final String attrValue = in.getAttributeValue(attrNdx);
10477 if (ATTR_ACTION.equals(attrName)) {
10478 intent.setAction(attrValue);
10479 } else if (ATTR_DATA.equals(attrName)) {
10480 intent.setData(Uri.parse(attrValue));
10481 } else if (ATTR_TYPE.equals(attrName)) {
10482 intent.setType(attrValue);
10483 } else if (ATTR_COMPONENT.equals(attrName)) {
10484 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10485 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010486 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010487 } else {
10488 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10489 }
10490 }
10491
10492 int event;
10493 String name;
10494 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10495 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10496 if (event == XmlPullParser.START_TAG) {
10497 name = in.getName();
10498 if (TAG_CATEGORIES.equals(name)) {
10499 attrCount = in.getAttributeCount();
10500 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10501 intent.addCategory(in.getAttributeValue(attrNdx));
10502 }
10503 } else {
10504 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10505 XmlUtils.skipCurrentTag(in);
10506 }
10507 }
10508 }
10509
10510 return intent;
10511 }
10512
Nick Pellyccae4122012-01-09 14:12:58 -080010513 /**
10514 * Normalize a MIME data type.
10515 *
10516 * <p>A normalized MIME type has white-space trimmed,
10517 * content-type parameters removed, and is lower-case.
10518 * This aligns the type with Android best practices for
10519 * intent filtering.
10520 *
10521 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10522 * "text/x-vCard" becomes "text/x-vcard".
10523 *
10524 * <p>All MIME types received from outside Android (such as user input,
10525 * or external sources like Bluetooth, NFC, or the Internet) should
10526 * be normalized before they are used to create an Intent.
10527 *
10528 * @param type MIME data type to normalize
10529 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010530 * @see #setType
10531 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010532 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010533 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010534 if (type == null) {
10535 return null;
10536 }
10537
Elliott Hughescb64d432013-08-02 10:00:44 -070010538 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010539
10540 final int semicolonIndex = type.indexOf(';');
10541 if (semicolonIndex != -1) {
10542 type = type.substring(0, semicolonIndex);
10543 }
10544 return type;
10545 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010546
10547 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010548 * Prepare this {@link Intent} to leave an app process.
10549 *
10550 * @hide
10551 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010552 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010553 public void prepareToLeaveProcess(Context context) {
10554 final boolean leavingPackage = (mComponent == null)
10555 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10556 prepareToLeaveProcess(leavingPackage);
10557 }
10558
10559 /**
10560 * Prepare this {@link Intent} to leave an app process.
10561 *
10562 * @hide
10563 */
10564 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010565 setAllowFds(false);
10566
10567 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010568 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010569 }
10570 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010571 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010572 }
10573
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010574 if (mExtras != null && !mExtras.isParcelled()) {
10575 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10576 if (intent instanceof Intent) {
10577 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10578 }
10579 }
10580
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010581 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10582 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010583 switch (mAction) {
10584 case ACTION_MEDIA_REMOVED:
10585 case ACTION_MEDIA_UNMOUNTED:
10586 case ACTION_MEDIA_CHECKING:
10587 case ACTION_MEDIA_NOFS:
10588 case ACTION_MEDIA_MOUNTED:
10589 case ACTION_MEDIA_SHARED:
10590 case ACTION_MEDIA_UNSHARED:
10591 case ACTION_MEDIA_BAD_REMOVAL:
10592 case ACTION_MEDIA_UNMOUNTABLE:
10593 case ACTION_MEDIA_EJECT:
10594 case ACTION_MEDIA_SCANNER_STARTED:
10595 case ACTION_MEDIA_SCANNER_FINISHED:
10596 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010597 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10598 case ACTION_PACKAGE_VERIFIED:
Richard Uhlerb29f1452018-09-12 16:38:15 +010010599 case ACTION_PACKAGE_ENABLE_ROLLBACK:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010600 // Ignore legacy actions
10601 break;
10602 default:
10603 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010604 }
10605 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010606
10607 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10608 && leavingPackage) {
10609 switch (mAction) {
10610 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010611 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010612 // Ignore actions that don't need to grant
10613 break;
10614 default:
10615 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10616 }
10617 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010618 }
10619
10620 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010621 * @hide
10622 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010623 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010624 // We just entered destination process, so we should be able to read all
10625 // parcelables inside.
10626 setDefusable(true);
10627
10628 if (mSelector != null) {
10629 mSelector.prepareToEnterProcess();
10630 }
10631 if (mClipData != null) {
10632 mClipData.prepareToEnterProcess();
10633 }
10634
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010635 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010636 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10637 fixUris(mContentUserHint);
10638 mContentUserHint = UserHandle.USER_CURRENT;
10639 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010640 }
10641 }
10642
Patrick Baumann577d4022018-01-31 16:55:10 +000010643 /** @hide */
10644 public boolean hasWebURI() {
10645 if (getData() == null) {
10646 return false;
10647 }
10648 final String scheme = getScheme();
10649 if (TextUtils.isEmpty(scheme)) {
10650 return false;
10651 }
10652 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10653 }
10654
10655 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010656 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010657 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010658 && hasWebURI();
10659 }
10660
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010661 /**
10662 * @hide
10663 */
10664 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010665 Uri data = getData();
10666 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010667 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010668 }
10669 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010670 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010671 }
10672 String action = getAction();
10673 if (ACTION_SEND.equals(action)) {
10674 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10675 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010676 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010677 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010678 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010679 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10680 if (streams != null) {
10681 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10682 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010683 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010684 }
10685 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10686 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010687 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10688 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10689 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10690 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10691 if (output != null) {
10692 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10693 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010694 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010695 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010696
10697 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010698 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010699 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10700 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010701 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010702 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010703 * @hide
10704 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010705 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010706 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010707 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010708
10709 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010710 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010711
10712 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010713 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010714 // Inspect contained intents to see if we need to migrate extras. We
10715 // don't promote ClipData to the parent, since ChooserActivity will
10716 // already start the picked item as the caller, and we can't combine
10717 // the flags in a safe way.
10718
10719 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010720 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010721 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10722 if (intent != null) {
10723 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010724 }
10725 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010726 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010727 try {
10728 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10729 if (intents != null) {
10730 for (int i = 0; i < intents.length; i++) {
10731 final Intent intent = (Intent) intents[i];
10732 if (intent != null) {
10733 migrated |= intent.migrateExtraStreamToClipData();
10734 }
10735 }
10736 }
10737 } catch (ClassCastException e) {
10738 }
10739 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010740
10741 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010742 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010743 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10744 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10745 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10746 if (stream != null || text != null || htmlText != null) {
10747 final ClipData clipData = new ClipData(
10748 null, new String[] { getType() },
10749 new ClipData.Item(text, htmlText, null, stream));
10750 setClipData(clipData);
10751 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010752 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010753 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010754 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010755 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010756
10757 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010758 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010759 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10760 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10761 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10762 int num = -1;
10763 if (streams != null) {
10764 num = streams.size();
10765 }
10766 if (texts != null) {
10767 if (num >= 0 && num != texts.size()) {
10768 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010769 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010770 }
10771 num = texts.size();
10772 }
10773 if (htmlTexts != null) {
10774 if (num >= 0 && num != htmlTexts.size()) {
10775 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010776 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010777 }
10778 num = htmlTexts.size();
10779 }
10780 if (num > 0) {
10781 final ClipData clipData = new ClipData(
10782 null, new String[] { getType() },
10783 makeClipItem(streams, texts, htmlTexts, 0));
10784
10785 for (int i = 1; i < num; i++) {
10786 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10787 }
10788
10789 setClipData(clipData);
10790 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010791 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010792 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010793 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010794 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010795 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10796 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10797 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10798 final Uri output;
10799 try {
10800 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10801 } catch (ClassCastException e) {
10802 return false;
10803 }
10804 if (output != null) {
10805 setClipData(ClipData.newRawUri("", output));
10806 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10807 return true;
10808 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010809 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010810
10811 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010812 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010813
Michael Wright19859762017-09-18 20:57:58 +010010814 /**
10815 * Convert the dock state to a human readable format.
10816 * @hide
10817 */
10818 public static String dockStateToString(int dock) {
10819 switch (dock) {
10820 case EXTRA_DOCK_STATE_HE_DESK:
10821 return "EXTRA_DOCK_STATE_HE_DESK";
10822 case EXTRA_DOCK_STATE_LE_DESK:
10823 return "EXTRA_DOCK_STATE_LE_DESK";
10824 case EXTRA_DOCK_STATE_CAR:
10825 return "EXTRA_DOCK_STATE_CAR";
10826 case EXTRA_DOCK_STATE_DESK:
10827 return "EXTRA_DOCK_STATE_DESK";
10828 case EXTRA_DOCK_STATE_UNDOCKED:
10829 return "EXTRA_DOCK_STATE_UNDOCKED";
10830 default:
10831 return Integer.toString(dock);
10832 }
10833 }
10834
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010835 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10836 ArrayList<String> htmlTexts, int which) {
10837 Uri uri = streams != null ? streams.get(which) : null;
10838 CharSequence text = texts != null ? texts.get(which) : null;
10839 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10840 return new ClipData.Item(text, htmlText, null, uri);
10841 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010842
10843 /** @hide */
10844 public boolean isDocument() {
10845 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10846 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010847}