blob: b67349f2004fbaa576e40465cd94c741ad3be270 [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;
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -070040import android.media.MediaScannerConnection;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060042import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070043import android.os.Bundle;
44import android.os.IBinder;
45import android.os.Parcel;
46import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070047import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000048import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050049import android.os.ResultReceiver;
50import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070051import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010052import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070053import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070054import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070055import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050056import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070057import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000058import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050059import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070060import android.util.AttributeSet;
61import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070062import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070063
Dianne Hackborn2269d1572010-02-24 19:54:22 -080064import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070065
Jason Monk2f68e8a2016-02-23 17:57:28 -050066import org.xmlpull.v1.XmlPullParser;
67import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070068import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070069
70import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080071import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070072import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070073import java.lang.annotation.Retention;
74import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070075import java.net.URISyntaxException;
76import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080077import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070078import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080079import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070080import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070081import java.util.Set;
82
83/**
84 * An intent is an abstract description of an operation to be performed. It
85 * can be used with {@link Context#startActivity(Intent) startActivity} to
86 * launch an {@link android.app.Activity},
87 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
88 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
89 * and {@link android.content.Context#startService} or
90 * {@link android.content.Context#bindService} to communicate with a
91 * background {@link android.app.Service}.
92 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070093 * <p>An Intent provides a facility for performing late runtime binding between the code in
94 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070095 * can be thought of as the glue between activities. It is basically a passive data structure
96 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070097 *
98 * <div class="special reference">
99 * <h3>Developer Guides</h3>
100 * <p>For information about how to create and resolve intents, read the
101 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
102 * developer guide.</p>
103 * </div>
104 *
105 * <a name="IntentStructure"></a>
106 * <h3>Intent Structure</h3>
107 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700108 *
109 * <ul>
110 * <li> <p><b>action</b> -- The general action to be performed, such as
111 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
112 * etc.</p>
113 * </li>
114 * <li> <p><b>data</b> -- The data to operate on, such as a person record
115 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
116 * </li>
117 * </ul>
118 *
119 *
120 * <p>Some examples of action/data pairs are:</p>
121 *
122 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700123 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700124 * information about the person whose identifier is "1".</p>
125 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700126 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700127 * the phone dialer with the person filled in.</p>
128 * </li>
129 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
130 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700131 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700132 * a particular URI.</p>
133 * </li>
134 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
135 * the phone dialer with the given number filled in.</p>
136 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700137 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700138 * information about the person whose identifier is "1".</p>
139 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700140 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700141 * a list of people, which the user can browse through. This example is a
142 * typical top-level entry into the Contacts application, showing you the
143 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700144 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700145 * being used to start an activity to display that person.</p>
146 * </li>
147 * </ul>
148 *
149 * <p>In addition to these primary attributes, there are a number of secondary
150 * attributes that you can also include with an intent:</p>
151 *
152 * <ul>
153 * <li> <p><b>category</b> -- Gives additional information about the action
154 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
155 * appear in the Launcher as a top-level application, while
156 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
157 * of alternative actions the user can perform on a piece of data.</p>
158 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
159 * intent data. Normally the type is inferred from the data itself.
160 * By setting this attribute, you disable that evaluation and force
161 * an explicit type.</p>
162 * <li> <p><b>component</b> -- Specifies an explicit name of a component
163 * class to use for the intent. Normally this is determined by looking
164 * at the other information in the intent (the action, data/type, and
165 * categories) and matching that with a component that can handle it.
166 * If this attribute is set then none of the evaluation is performed,
167 * and this component is used exactly as is. By specifying this attribute,
168 * all of the other Intent attributes become optional.</p>
169 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
170 * This can be used to provide extended information to the component.
171 * For example, if we have a action to send an e-mail message, we could
172 * also include extra pieces of data here to supply a subject, body,
173 * etc.</p>
174 * </ul>
175 *
176 * <p>Here are some examples of other operations you can specify as intents
177 * using these additional parameters:</p>
178 *
179 * <ul>
180 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
181 * Launch the home screen.</p>
182 * </li>
183 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
184 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
185 * vnd.android.cursor.item/phone}</i></b>
186 * -- Display the list of people's phone numbers, allowing the user to
187 * browse through them and pick one and return it to the parent activity.</p>
188 * </li>
189 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
190 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
191 * -- Display all pickers for data that can be opened with
192 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
193 * allowing the user to pick one of them and then some data inside of it
194 * and returning the resulting URI to the caller. This can be used,
195 * for example, in an e-mail application to allow the user to pick some
196 * data to include as an attachment.</p>
197 * </li>
198 * </ul>
199 *
200 * <p>There are a variety of standard Intent action and category constants
201 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700202 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700203 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700204 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700205 *
206 * <p>Put together, the set of actions, data types, categories, and extra data
207 * defines a language for the system allowing for the expression of phrases
208 * such as "call john smith's cell". As applications are added to the system,
209 * they can extend this language by adding new actions, types, and categories, or
210 * they can modify the behavior of existing phrases by supplying their own
211 * activities that handle them.</p>
212 *
213 * <a name="IntentResolution"></a>
214 * <h3>Intent Resolution</h3>
215 *
216 * <p>There are two primary forms of intents you will use.
217 *
218 * <ul>
219 * <li> <p><b>Explicit Intents</b> have specified a component (via
220 * {@link #setComponent} or {@link #setClass}), which provides the exact
221 * class to be run. Often these will not include any other information,
222 * simply being a way for an application to launch various internal
223 * activities it has as the user interacts with the application.
224 *
225 * <li> <p><b>Implicit Intents</b> have not specified a component;
226 * instead, they must include enough information for the system to
227 * determine which of the available components is best to run for that
228 * intent.
229 * </ul>
230 *
231 * <p>When using implicit intents, given such an arbitrary intent we need to
232 * know what to do with it. This is handled by the process of <em>Intent
233 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
234 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
235 * more activities/receivers) that can handle it.</p>
236 *
237 * <p>The intent resolution mechanism basically revolves around matching an
238 * Intent against all of the &lt;intent-filter&gt; descriptions in the
239 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
240 * objects explicitly registered with {@link Context#registerReceiver}.) More
241 * details on this can be found in the documentation on the {@link
242 * IntentFilter} class.</p>
243 *
244 * <p>There are three pieces of information in the Intent that are used for
245 * resolution: the action, type, and category. Using this information, a query
246 * is done on the {@link PackageManager} for a component that can handle the
247 * intent. The appropriate component is determined based on the intent
248 * information supplied in the <code>AndroidManifest.xml</code> file as
249 * follows:</p>
250 *
251 * <ul>
252 * <li> <p>The <b>action</b>, if given, must be listed by the component as
253 * one it handles.</p>
254 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
255 * already supplied in the Intent. Like the action, if a type is
256 * included in the intent (either explicitly or implicitly in its
257 * data), then this must be listed by the component as one it handles.</p>
258 * <li> For data that is not a <code>content:</code> URI and where no explicit
259 * type is included in the Intent, instead the <b>scheme</b> of the
260 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
261 * considered. Again like the action, if we are matching a scheme it
262 * must be listed by the component as one it can handle.
263 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
264 * by the activity as categories it handles. That is, if you include
265 * the categories {@link #CATEGORY_LAUNCHER} and
266 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
267 * with an intent that lists <em>both</em> of those categories.
268 * Activities will very often need to support the
269 * {@link #CATEGORY_DEFAULT} so that they can be found by
270 * {@link Context#startActivity Context.startActivity()}.</p>
271 * </ul>
272 *
273 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700274 * allows a user to browse through a list of notes data and view details about
275 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700276 * name with one specific to your own package.</p>
277 *
278 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
279 * package="<i>com.android.notepad</i>"&gt;
280 * &lt;application android:icon="@drawable/app_notes"
281 * android:label="@string/app_name"&gt;
282 *
283 * &lt;provider class=".NotePadProvider"
284 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
285 *
286 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
287 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700288 * &lt;action android:name="android.intent.action.MAIN" /&gt;
289 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700290 * &lt;/intent-filter&gt;
291 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700292 * &lt;action android:name="android.intent.action.VIEW" /&gt;
293 * &lt;action android:name="android.intent.action.EDIT" /&gt;
294 * &lt;action android:name="android.intent.action.PICK" /&gt;
295 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
296 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700297 * &lt;/intent-filter&gt;
298 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700299 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
300 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
301 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700302 * &lt;/intent-filter&gt;
303 * &lt;/activity&gt;
304 *
305 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
306 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700307 * &lt;action android:name="android.intent.action.VIEW" /&gt;
308 * &lt;action android:name="android.intent.action.EDIT" /&gt;
309 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
310 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700311 * &lt;/intent-filter&gt;
312 *
313 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700314 * &lt;action android:name="android.intent.action.INSERT" /&gt;
315 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700317 * &lt;/intent-filter&gt;
318 *
319 * &lt;/activity&gt;
320 *
321 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
322 * android:theme="@android:style/Theme.Dialog"&gt;
323 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700324 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
325 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
326 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
327 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
328 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700329 * &lt;/intent-filter&gt;
330 * &lt;/activity&gt;
331 *
332 * &lt;/application&gt;
333 * &lt;/manifest&gt;</pre>
334 *
335 * <p>The first activity,
336 * <code>com.android.notepad.NotesList</code>, serves as our main
337 * entry into the app. It can do three things as described by its three intent
338 * templates:
339 * <ol>
340 * <li><pre>
341 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700342 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
343 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700344 * &lt;/intent-filter&gt;</pre>
345 * <p>This provides a top-level entry into the NotePad application: the standard
346 * MAIN action is a main entry point (not requiring any other information in
347 * the Intent), and the LAUNCHER category says that this entry point should be
348 * listed in the application launcher.</p>
349 * <li><pre>
350 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700351 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
352 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
353 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
354 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700355 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700356 * &lt;/intent-filter&gt;</pre>
357 * <p>This declares the things that the activity can do on a directory of
358 * notes. The type being supported is given with the &lt;type&gt; tag, where
359 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
360 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
361 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
362 * The activity allows the user to view or edit the directory of data (via
363 * the VIEW and EDIT actions), or to pick a particular note and return it
364 * to the caller (via the PICK action). Note also the DEFAULT category
365 * supplied here: this is <em>required</em> for the
366 * {@link Context#startActivity Context.startActivity} method to resolve your
367 * activity when its component name is not explicitly specified.</p>
368 * <li><pre>
369 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700370 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
371 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
372 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700373 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700374 * <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 -0700375 * the user without needing to know where it came from. The data type
376 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
377 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
378 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
379 * The GET_CONTENT action is similar to the PICK action, where the activity
380 * will return to its caller a piece of data selected by the user. Here,
381 * however, the caller specifies the type of data they desire instead of
382 * the type of data the user will be picking from.</p>
383 * </ol>
384 *
385 * <p>Given these capabilities, the following intents will resolve to the
386 * NotesList activity:</p>
387 *
388 * <ul>
389 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
390 * activities that can be used as top-level entry points into an
391 * application.</p>
392 * <li> <p><b>{ action=android.app.action.MAIN,
393 * category=android.app.category.LAUNCHER }</b> is the actual intent
394 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700395 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700396 * data=content://com.google.provider.NotePad/notes }</b>
397 * displays a list of all the notes under
398 * "content://com.google.provider.NotePad/notes", which
399 * the user can browse through and see the details on.</p>
400 * <li> <p><b>{ action=android.app.action.PICK
401 * data=content://com.google.provider.NotePad/notes }</b>
402 * provides a list of the notes under
403 * "content://com.google.provider.NotePad/notes", from which
404 * the user can pick a note whose data URL is returned back to the caller.</p>
405 * <li> <p><b>{ action=android.app.action.GET_CONTENT
406 * type=vnd.android.cursor.item/vnd.google.note }</b>
407 * is similar to the pick action, but allows the caller to specify the
408 * kind of data they want back so that the system can find the appropriate
409 * activity to pick something of that data type.</p>
410 * </ul>
411 *
412 * <p>The second activity,
413 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
414 * note entry and allows them to edit it. It can do two things as described
415 * by its two intent templates:
416 * <ol>
417 * <li><pre>
418 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700419 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
420 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
421 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
422 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700423 * &lt;/intent-filter&gt;</pre>
424 * <p>The first, primary, purpose of this activity is to let the user interact
425 * with a single note, as decribed by the MIME type
426 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
427 * either VIEW a note or allow the user to EDIT it. Again we support the
428 * DEFAULT category to allow the activity to be launched without explicitly
429 * specifying its component.</p>
430 * <li><pre>
431 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700432 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
433 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
434 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700435 * &lt;/intent-filter&gt;</pre>
436 * <p>The secondary use of this activity is to insert a new note entry into
437 * an existing directory of notes. This is used when the user creates a new
438 * note: the INSERT action is executed on the directory of notes, causing
439 * this activity to run and have the user create the new note data which
440 * it then adds to the content provider.</p>
441 * </ol>
442 *
443 * <p>Given these capabilities, the following intents will resolve to the
444 * NoteEditor activity:</p>
445 *
446 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700447 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700448 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
449 * shows the user the content of note <var>{ID}</var>.</p>
450 * <li> <p><b>{ action=android.app.action.EDIT
451 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
452 * allows the user to edit the content of note <var>{ID}</var>.</p>
453 * <li> <p><b>{ action=android.app.action.INSERT
454 * data=content://com.google.provider.NotePad/notes }</b>
455 * creates a new, empty note in the notes list at
456 * "content://com.google.provider.NotePad/notes"
457 * and allows the user to edit it. If they keep their changes, the URI
458 * of the newly created note is returned to the caller.</p>
459 * </ul>
460 *
461 * <p>The last activity,
462 * <code>com.android.notepad.TitleEditor</code>, allows the user to
463 * edit the title of a note. This could be implemented as a class that the
464 * application directly invokes (by explicitly setting its component in
465 * the Intent), but here we show a way you can publish alternative
466 * operations on existing data:</p>
467 *
468 * <pre>
469 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700470 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
471 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
472 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
473 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
474 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700475 * &lt;/intent-filter&gt;</pre>
476 *
477 * <p>In the single intent template here, we
478 * have created our own private action called
479 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
480 * edit the title of a note. It must be invoked on a specific note
481 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
482 * view and edit actions, but here displays and edits the title contained
483 * in the note data.
484 *
485 * <p>In addition to supporting the default category as usual, our title editor
486 * also supports two other standard categories: ALTERNATIVE and
487 * SELECTED_ALTERNATIVE. Implementing
488 * these categories allows others to find the special action it provides
489 * without directly knowing about it, through the
490 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
491 * more often to build dynamic menu items with
492 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
493 * template here was also supply an explicit name for the template
494 * (via <code>android:label="@string/resolve_title"</code>) to better control
495 * what the user sees when presented with this activity as an alternative
496 * action to the data they are viewing.
497 *
498 * <p>Given these capabilities, the following intent will resolve to the
499 * TitleEditor activity:</p>
500 *
501 * <ul>
502 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
503 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
504 * displays and allows the user to edit the title associated
505 * with note <var>{ID}</var>.</p>
506 * </ul>
507 *
508 * <h3>Standard Activity Actions</h3>
509 *
510 * <p>These are the current standard actions that Intent defines for launching
511 * activities (usually through {@link Context#startActivity}. The most
512 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
513 * {@link #ACTION_EDIT}.
514 *
515 * <ul>
516 * <li> {@link #ACTION_MAIN}
517 * <li> {@link #ACTION_VIEW}
518 * <li> {@link #ACTION_ATTACH_DATA}
519 * <li> {@link #ACTION_EDIT}
520 * <li> {@link #ACTION_PICK}
521 * <li> {@link #ACTION_CHOOSER}
522 * <li> {@link #ACTION_GET_CONTENT}
523 * <li> {@link #ACTION_DIAL}
524 * <li> {@link #ACTION_CALL}
525 * <li> {@link #ACTION_SEND}
526 * <li> {@link #ACTION_SENDTO}
527 * <li> {@link #ACTION_ANSWER}
528 * <li> {@link #ACTION_INSERT}
529 * <li> {@link #ACTION_DELETE}
530 * <li> {@link #ACTION_RUN}
531 * <li> {@link #ACTION_SYNC}
532 * <li> {@link #ACTION_PICK_ACTIVITY}
533 * <li> {@link #ACTION_SEARCH}
534 * <li> {@link #ACTION_WEB_SEARCH}
535 * <li> {@link #ACTION_FACTORY_TEST}
536 * </ul>
537 *
538 * <h3>Standard Broadcast Actions</h3>
539 *
540 * <p>These are the current standard actions that Intent defines for receiving
541 * broadcasts (usually through {@link Context#registerReceiver} or a
542 * &lt;receiver&gt; tag in a manifest).
543 *
544 * <ul>
545 * <li> {@link #ACTION_TIME_TICK}
546 * <li> {@link #ACTION_TIME_CHANGED}
547 * <li> {@link #ACTION_TIMEZONE_CHANGED}
548 * <li> {@link #ACTION_BOOT_COMPLETED}
549 * <li> {@link #ACTION_PACKAGE_ADDED}
550 * <li> {@link #ACTION_PACKAGE_CHANGED}
551 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800552 * <li> {@link #ACTION_PACKAGE_RESTARTED}
553 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000554 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
555 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700556 * <li> {@link #ACTION_UID_REMOVED}
557 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700558 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700559 * <li> {@link #ACTION_POWER_DISCONNECTED}
560 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700561 * </ul>
562 *
563 * <h3>Standard Categories</h3>
564 *
565 * <p>These are the current standard categories that can be used to further
566 * clarify an Intent via {@link #addCategory}.
567 *
568 * <ul>
569 * <li> {@link #CATEGORY_DEFAULT}
570 * <li> {@link #CATEGORY_BROWSABLE}
571 * <li> {@link #CATEGORY_TAB}
572 * <li> {@link #CATEGORY_ALTERNATIVE}
573 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
574 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800575 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * <li> {@link #CATEGORY_HOME}
577 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700578 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400579 * <li> {@link #CATEGORY_CAR_DOCK}
580 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500581 * <li> {@link #CATEGORY_LE_DESK_DOCK}
582 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200583 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700584 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800585 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700586 * </ul>
587 *
588 * <h3>Standard Extra Data</h3>
589 *
590 * <p>These are the current standard fields that can be used as extra data via
591 * {@link #putExtra}.
592 *
593 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800594 * <li> {@link #EXTRA_ALARM_COUNT}
595 * <li> {@link #EXTRA_BCC}
596 * <li> {@link #EXTRA_CC}
597 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
598 * <li> {@link #EXTRA_DATA_REMOVED}
599 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500600 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
601 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800602 * <li> {@link #EXTRA_DOCK_STATE_CAR}
603 * <li> {@link #EXTRA_DOCK_STATE_DESK}
604 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
605 * <li> {@link #EXTRA_DONT_KILL_APP}
606 * <li> {@link #EXTRA_EMAIL}
607 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700608 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700610 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800611 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700612 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800613 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
614 * <li> {@link #EXTRA_REPLACING}
615 * <li> {@link #EXTRA_SHORTCUT_ICON}
616 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
617 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700618 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800619 * <li> {@link #EXTRA_SHORTCUT_NAME}
620 * <li> {@link #EXTRA_SUBJECT}
621 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700622 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800623 * <li> {@link #EXTRA_TITLE}
624 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700625 * </ul>
626 *
627 * <h3>Flags</h3>
628 *
629 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800630 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
631 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700632 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800633public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700634 private static final String ATTR_ACTION = "action";
635 private static final String TAG_CATEGORIES = "categories";
636 private static final String ATTR_CATEGORY = "category";
637 private static final String TAG_EXTRA = "extra";
638 private static final String ATTR_TYPE = "type";
639 private static final String ATTR_COMPONENT = "component";
640 private static final String ATTR_DATA = "data";
641 private static final String ATTR_FLAGS = "flags";
642
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700643 // ---------------------------------------------------------------------
644 // ---------------------------------------------------------------------
645 // Standard intent activity actions (see action variable).
646
647 /**
648 * Activity Action: Start as a main entry point, does not expect to
649 * receive data.
650 * <p>Input: nothing
651 * <p>Output: nothing
652 */
653 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
654 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800655
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700656 /**
657 * Activity Action: Display the data to the user. This is the most common
658 * action performed on data -- it is the generic action you can use on
659 * a piece of data to get the most reasonable thing to occur. For example,
660 * when used on a contacts entry it will view the entry; when used on a
661 * mailto: URI it will bring up a compose window filled with the information
662 * supplied by the URI; when used with a tel: URI it will invoke the
663 * dialer.
664 * <p>Input: {@link #getData} is URI from which to retrieve data.
665 * <p>Output: nothing.
666 */
667 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
668 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800669
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700670 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700671 * Extra that can be included on activity intents coming from the storage UI
672 * when it launches sub-activities to manage various types of storage. For example,
673 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
674 * the images on the device, and in that case also include this extra to tell the
675 * app it is coming from the storage UI so should help the user manage storage of
676 * this type.
677 */
678 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
679
680 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700681 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
682 * performed on a piece of data.
683 */
684 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800685
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700686 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900687 * Activity Action: Quick view the data. Launches a quick viewer for
688 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900689 * <p>Activities handling this intent action should handle the vast majority of
690 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700691 * <p>Quick viewers must render the quick view image locally, and must not send
692 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900693 * <p>Input: {@link #getData} is a mandatory content URI of the item to
694 * preview. {@link #getClipData} contains an optional list of content URIs
695 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
696 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700697 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
698 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700699 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900700 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700701 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700702 */
703 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
704 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
705
706 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700707 * Used to indicate that some piece of data should be attached to some other
708 * place. For example, image data could be attached to a contact. It is up
709 * to the recipient to decide where the data should be attached; the intent
710 * does not specify the ultimate destination.
711 * <p>Input: {@link #getData} is URI of data to be attached.
712 * <p>Output: nothing.
713 */
714 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
715 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800716
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700717 /**
718 * Activity Action: Provide explicit editable access to the given data.
719 * <p>Input: {@link #getData} is URI of data to be edited.
720 * <p>Output: nothing.
721 */
722 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
723 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800724
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700725 /**
726 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
727 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
728 * The extras can contain type specific data to pass through to the editing/creating
729 * activity.
730 * <p>Output: The URI of the item that was picked. This must be a content:
731 * URI so that any receiver can access it.
732 */
733 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
734 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800735
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700736 /**
737 * Activity Action: Pick an item from the data, returning what was selected.
738 * <p>Input: {@link #getData} is URI containing a directory of data
739 * (vnd.android.cursor.dir/*) from which to pick an item.
740 * <p>Output: The URI of the item that was picked.
741 */
742 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
743 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800744
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700745 /**
746 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800747 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800748 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
749 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700750 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
751 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800752 * (value: ShortcutIconResource).</p>
753 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800754 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700755 * @see #EXTRA_SHORTCUT_INTENT
756 * @see #EXTRA_SHORTCUT_NAME
757 * @see #EXTRA_SHORTCUT_ICON
758 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
759 * @see android.content.Intent.ShortcutIconResource
760 */
761 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
762 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
763
764 /**
765 * The name of the extra used to define the Intent of a shortcut.
766 *
767 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800768 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800770 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700771 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
772 /**
773 * The name of the extra used to define the name of a shortcut.
774 *
775 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800776 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700777 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800778 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700779 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
780 /**
781 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
782 *
783 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800786 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700787 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
788 /**
789 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
790 *
791 * @see #ACTION_CREATE_SHORTCUT
792 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800793 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800795 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700796 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
797 "android.intent.extra.shortcut.ICON_RESOURCE";
798
799 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500800 * An activity that provides a user interface for adjusting application preferences.
801 * Optional but recommended settings for all applications which have settings.
802 */
803 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
804 public static final String ACTION_APPLICATION_PREFERENCES
805 = "android.intent.action.APPLICATION_PREFERENCES";
806
807 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700808 * Activity Action: Launch an activity showing the app information.
809 * For applications which install other applications (such as app stores), it is recommended
810 * to handle this action for providing the app information to the user.
811 *
812 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
813 * to be displayed.
814 * <p>Output: Nothing.
815 */
816 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
817 public static final String ACTION_SHOW_APP_INFO
818 = "android.intent.action.SHOW_APP_INFO";
819
820 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800821 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700822 *
823 * @see Intent#ACTION_CREATE_SHORTCUT
824 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800825 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
826 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700827 */
828 public static class ShortcutIconResource implements Parcelable {
829 /**
830 * The package name of the application containing the icon.
831 */
832 public String packageName;
833
834 /**
835 * The resource name of the icon, including package, name and type.
836 */
837 public String resourceName;
838
839 /**
840 * Creates a new ShortcutIconResource for the specified context and resource
841 * identifier.
842 *
843 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700844 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700846 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700847 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700848 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700849 ShortcutIconResource icon = new ShortcutIconResource();
850 icon.packageName = context.getPackageName();
851 icon.resourceName = context.getResources().getResourceName(resourceId);
852 return icon;
853 }
854
855 /**
856 * Used to read a ShortcutIconResource from a Parcel.
857 */
858 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
859 new Parcelable.Creator<ShortcutIconResource>() {
860
861 public ShortcutIconResource createFromParcel(Parcel source) {
862 ShortcutIconResource icon = new ShortcutIconResource();
863 icon.packageName = source.readString();
864 icon.resourceName = source.readString();
865 return icon;
866 }
867
868 public ShortcutIconResource[] newArray(int size) {
869 return new ShortcutIconResource[size];
870 }
871 };
872
873 /**
874 * No special parcel contents.
875 */
876 public int describeContents() {
877 return 0;
878 }
879
880 public void writeToParcel(Parcel dest, int flags) {
881 dest.writeString(packageName);
882 dest.writeString(resourceName);
883 }
884
885 @Override
886 public String toString() {
887 return resourceName;
888 }
889 }
890
891 /**
892 * Activity Action: Display an activity chooser, allowing the user to pick
893 * what they want to before proceeding. This can be used as an alternative
894 * to the standard activity picker that is displayed by the system when
895 * you try to start an activity with multiple possible matches, with these
896 * differences in behavior:
897 * <ul>
898 * <li>You can specify the title that will appear in the activity chooser.
899 * <li>The user does not have the option to make one of the matching
900 * activities a preferred activity, and all possible activities will
901 * always be shown even if one of them is currently marked as the
902 * preferred activity.
903 * </ul>
904 * <p>
905 * This action should be used when the user will naturally expect to
906 * select an activity in order to proceed. An example if when not to use
907 * it is when the user clicks on a "mailto:" link. They would naturally
908 * expect to go directly to their mail app, so startActivity() should be
909 * called directly: it will
910 * either launch the current preferred app, or put up a dialog allowing the
911 * user to pick an app to use and optionally marking that as preferred.
912 * <p>
913 * In contrast, if the user is selecting a menu item to send a picture
914 * they are viewing to someone else, there are many different things they
915 * may want to do at this point: send it through e-mail, upload it to a
916 * web service, etc. In this case the CHOOSER action should be used, to
917 * always present to the user a list of the things they can do, with a
918 * nice title given by the caller such as "Send this photo with:".
919 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700920 * If you need to grant URI permissions through a chooser, you must specify
921 * the permissions to be granted on the ACTION_CHOOSER Intent
922 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
923 * {@link #setClipData} to specify the URIs to be granted as well as
924 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
925 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
926 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700927 * As a convenience, an Intent of this form can be created with the
928 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700929 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700930 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700931 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
932 * and can optionally have a {@link #EXTRA_TITLE} field containing the
933 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700934 * <p>
935 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700936 */
937 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
938 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
939
940 /**
941 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
942 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700943 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
944 * target intent, also optionally supplying a title. If the target
945 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
946 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
947 * set in the returned chooser intent, with its ClipData set appropriately:
948 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500949 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700950 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700951 * @param target The Intent that the user will be selecting an activity
952 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500953 * @param title Optional title that will be displayed in the chooser,
954 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700955 * @return Return a new Intent object that you can hand to
956 * {@link Context#startActivity(Intent) Context.startActivity()} and
957 * related methods.
958 */
959 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700960 return createChooser(target, title, null);
961 }
962
963 /**
964 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
965 *
966 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
967 * target intent, also optionally supplying a title. If the target
968 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
969 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
970 * set in the returned chooser intent, with its ClipData set appropriately:
971 * either a direct reflection of {@link #getClipData()} if that is non-null,
972 * or a new ClipData built from {@link #getData()}.</p>
973 *
974 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
975 * when the user makes a choice. This can be useful if the calling application wants
976 * to remember the last chosen target and surface it as a more prominent or one-touch
977 * affordance elsewhere in the UI for next time.</p>
978 *
979 * @param target The Intent that the user will be selecting an activity
980 * to perform.
Matt Pietal26038402019-01-08 07:29:34 -0500981 * @param title Optional title that will be displayed in the chooser,
982 * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
Adam Powell0b3c1122014-10-09 12:50:14 -0700983 * @param sender Optional IntentSender to be called when a choice is made.
984 * @return Return a new Intent object that you can hand to
985 * {@link Context#startActivity(Intent) Context.startActivity()} and
986 * related methods.
987 */
988 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700989 Intent intent = new Intent(ACTION_CHOOSER);
990 intent.putExtra(EXTRA_INTENT, target);
991 if (title != null) {
992 intent.putExtra(EXTRA_TITLE, title);
993 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700994
Adam Powell0b3c1122014-10-09 12:50:14 -0700995 if (sender != null) {
996 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
997 }
998
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700999 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -07001000 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1001 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1002 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -07001003 if (permFlags != 0) {
1004 ClipData targetClipData = target.getClipData();
1005 if (targetClipData == null && target.getData() != null) {
1006 ClipData.Item item = new ClipData.Item(target.getData());
1007 String[] mimeTypes;
1008 if (target.getType() != null) {
1009 mimeTypes = new String[] { target.getType() };
1010 } else {
1011 mimeTypes = new String[] { };
1012 }
1013 targetClipData = new ClipData(null, mimeTypes, item);
1014 }
1015 if (targetClipData != null) {
1016 intent.setClipData(targetClipData);
1017 intent.addFlags(permFlags);
1018 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001019 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001020
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001021 return intent;
1022 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001023
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001024 /**
1025 * Activity Action: Allow the user to select a particular kind of data and
1026 * return it. This is different than {@link #ACTION_PICK} in that here we
1027 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001028 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001029 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001030 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001031 * etc.
1032 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001033 * 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 -07001034 * of data, such as a person contact, you set the MIME type to the kind of
1035 * data you want and launch it with {@link Context#startActivity(Intent)}.
1036 * The system will then launch the best application to select that kind
1037 * of data for you.
1038 * <p>
1039 * You may also be interested in any of a set of types of content the user
1040 * can pick. For example, an e-mail application that wants to allow the
1041 * user to add an attachment to an e-mail message can use this action to
1042 * bring up a list of all of the types of content the user can attach.
1043 * <p>
1044 * In this case, you should wrap the GET_CONTENT intent with a chooser
1045 * (through {@link #createChooser}), which will give the proper interface
1046 * for the user to pick how to send your data and allow you to specify
1047 * a prompt indicating what they are doing. You will usually specify a
1048 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1049 * broad range of content types the user can select from.
1050 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001051 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001052 * only pick from data that can be represented as a stream. This is
1053 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1054 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001055 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001056 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001057 * is locally available on the device. For example, if this extra is set
1058 * to true then an image picker should not show any pictures that are available
1059 * from a remote server but not already on the local device (thus requiring
1060 * they be downloaded when opened).
1061 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001062 * If the caller can handle multiple returned items (the user performing
1063 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1064 * to indicate this.
1065 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001066 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1067 * that no URI is supplied in the intent, as there are no constraints on
1068 * where the returned data originally comes from. You may also include the
1069 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001070 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001071 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1072 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001073 * <p>
1074 * Output: The URI of the item that was picked. This must be a content:
1075 * URI so that any receiver can access it.
1076 */
1077 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1078 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1079 /**
1080 * Activity Action: Dial a number as specified by the data. This shows a
1081 * UI with the number being dialed, allowing the user to explicitly
1082 * initiate the call.
1083 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1084 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1085 * number.
1086 * <p>Output: nothing.
1087 */
1088 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1089 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1090 /**
1091 * Activity Action: Perform a call to someone specified by the data.
1092 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1093 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1094 * number.
1095 * <p>Output: nothing.
1096 *
1097 * <p>Note: there will be restrictions on which applications can initiate a
1098 * call; most applications should use the {@link #ACTION_DIAL}.
1099 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1100 * numbers. Applications can <strong>dial</strong> emergency numbers using
1101 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001102 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001103 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001104 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001105 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001106 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001107 */
1108 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1109 public static final String ACTION_CALL = "android.intent.action.CALL";
1110 /**
1111 * Activity Action: Perform a call to an emergency number specified by the
1112 * data.
1113 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1114 * tel: URI of an explicit phone number.
1115 * <p>Output: nothing.
1116 * @hide
1117 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001118 @SystemApi
1119 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001120 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1121 /**
1122 * Activity action: Perform a call to any number (emergency or not)
1123 * specified by the data.
1124 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1125 * tel: URI of an explicit phone number.
1126 * <p>Output: nothing.
1127 * @hide
1128 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001129 @SystemApi
1130 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001131 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001132
Santos Cordon15a13782015-03-31 18:32:31 -07001133 /**
fionaxuadfe7002017-02-17 17:20:46 -08001134 * Activity Action: Main entry point for carrier setup apps.
1135 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1136 * carrier service and typically require
1137 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1138 * fulfill their duties.
1139 */
1140 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1141 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1142 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001143 * Activity Action: Send a message to someone specified by the data.
1144 * <p>Input: {@link #getData} is URI describing the target.
1145 * <p>Output: nothing.
1146 */
1147 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1148 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1149 /**
1150 * Activity Action: Deliver some data to someone else. Who the data is
1151 * being delivered to is not specified; it is up to the receiver of this
1152 * action to ask the user where the data should be sent.
1153 * <p>
1154 * When launching a SEND intent, you should usually wrap it in a chooser
1155 * (through {@link #createChooser}), which will give the proper interface
1156 * for the user to pick how to send your data and allow you to specify
1157 * a prompt indicating what they are doing.
1158 * <p>
1159 * Input: {@link #getType} is the MIME type of the data being sent.
1160 * get*Extra can have either a {@link #EXTRA_TEXT}
1161 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1162 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1163 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1164 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001165 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1166 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1167 * your text with HTML formatting.
1168 * <p>
1169 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1170 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1171 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1172 * content: URIs and other advanced features of {@link ClipData}. If
1173 * using this approach, you still must supply the same data through the
1174 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1175 * for compatibility with old applications. If you don't set a ClipData,
1176 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001177 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001178 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1179 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1180 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1181 * be openable only as asset typed files using
1182 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1183 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001184 * Optional standard extras, which may be interpreted by some recipients as
1185 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1186 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1187 * <p>
1188 * Output: nothing.
1189 */
1190 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1191 public static final String ACTION_SEND = "android.intent.action.SEND";
1192 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001193 * Activity Action: Deliver multiple data to someone else.
1194 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001195 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001196 * <p>
1197 * Input: {@link #getType} is the MIME type of the data being sent.
1198 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001199 * #EXTRA_STREAM} field, containing the data to be sent. If using
1200 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1201 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001202 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001203 * Multiple types are supported, and receivers should handle mixed types
1204 * whenever possible. The right way for the receiver to check them is to
1205 * use the content resolver on each URI. The intent sender should try to
1206 * put the most concrete mime type in the intent type, but it can fall
1207 * back to {@literal <type>/*} or {@literal *}/* as needed.
1208 * <p>
1209 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1210 * be image/jpg, but if you are sending image/jpg and image/png, then the
1211 * intent's type should be image/*.
1212 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001213 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1214 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1215 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1216 * content: URIs and other advanced features of {@link ClipData}. If
1217 * using this approach, you still must supply the same data through the
1218 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1219 * for compatibility with old applications. If you don't set a ClipData,
1220 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1221 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001222 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1223 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1224 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1225 * be openable only as asset typed files using
1226 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1227 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001228 * Optional standard extras, which may be interpreted by some recipients as
1229 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1230 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1231 * <p>
1232 * Output: nothing.
1233 */
1234 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1235 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1236 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001237 * Activity Action: Handle an incoming phone call.
1238 * <p>Input: nothing.
1239 * <p>Output: nothing.
1240 */
1241 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1242 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1243 /**
1244 * Activity Action: Insert an empty item into the given container.
1245 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1246 * in which to place the data.
1247 * <p>Output: URI of the new data that was created.
1248 */
1249 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1251 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001252 * Activity Action: Create a new item in the given container, initializing it
1253 * from the current contents of the clipboard.
1254 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1255 * in which to place the data.
1256 * <p>Output: URI of the new data that was created.
1257 */
1258 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1259 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1260 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001261 * Activity Action: Delete the given data from its container.
1262 * <p>Input: {@link #getData} is URI of data to be deleted.
1263 * <p>Output: nothing.
1264 */
1265 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1266 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1267 /**
1268 * Activity Action: Run the data, whatever that means.
1269 * <p>Input: ? (Note: this is currently specific to the test harness.)
1270 * <p>Output: nothing.
1271 */
1272 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1273 public static final String ACTION_RUN = "android.intent.action.RUN";
1274 /**
1275 * Activity Action: Perform a data synchronization.
1276 * <p>Input: ?
1277 * <p>Output: ?
1278 */
1279 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1280 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1281 /**
1282 * Activity Action: Pick an activity given an intent, returning the class
1283 * selected.
1284 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1285 * used with {@link PackageManager#queryIntentActivities} to determine the
1286 * set of activities from which to pick.
1287 * <p>Output: Class name of the activity that was selected.
1288 */
1289 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1290 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1291 /**
1292 * Activity Action: Perform a search.
1293 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1294 * is the text to search for. If empty, simply
1295 * enter your search results Activity with the search UI activated.
1296 * <p>Output: nothing.
1297 */
1298 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1299 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1300 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001301 * Activity Action: Start the platform-defined tutorial
1302 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1303 * is the text to search for. If empty, simply
1304 * enter your search results Activity with the search UI activated.
1305 * <p>Output: nothing.
1306 */
1307 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1308 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1309 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001310 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001311 * <p>
1312 * Input: {@link android.app.SearchManager#QUERY
1313 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1314 * a url starts with http or https, the site will be opened. If it is plain
1315 * text, Google search will be applied.
1316 * <p>
1317 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001318 */
1319 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1320 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001321
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001322 /**
Jim Miller07994402012-05-02 14:22:27 -07001323 * Activity Action: Perform assist action.
1324 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001325 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1326 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001327 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1328 * information.
Jim Miller07994402012-05-02 14:22:27 -07001329 * Output: nothing.
1330 */
1331 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1332 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001333
1334 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001335 * Activity Action: Perform voice assist action.
1336 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001337 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1338 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001339 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001340 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001341 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001342 */
Amith Yamasani16452032017-03-03 10:15:57 -08001343 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001344 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1346
1347 /**
Adam Skory7140a252013-09-11 12:04:58 +01001348 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1349 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001350 */
1351 public static final String EXTRA_ASSIST_PACKAGE
1352 = "android.intent.extra.ASSIST_PACKAGE";
1353
1354 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001355 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1356 * application package at the time the assist was invoked.
1357 */
1358 public static final String EXTRA_ASSIST_UID
1359 = "android.intent.extra.ASSIST_UID";
1360
1361 /**
Adam Skory7140a252013-09-11 12:04:58 +01001362 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1363 * information supplied by the current foreground app at the time of the assist request.
1364 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001365 */
1366 public static final String EXTRA_ASSIST_CONTEXT
1367 = "android.intent.extra.ASSIST_CONTEXT";
1368
Jim Miller07994402012-05-02 14:22:27 -07001369 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001370 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1371 * keyboard as the primary input device for assistance.
1372 */
1373 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1374 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1375
1376 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001377 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1378 * that was used to invoke the assist.
1379 */
1380 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1381 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1382
1383 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001384 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001385 * <p>Input: Nothing.
1386 * <p>Output: nothing.
1387 */
1388 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1389 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1390 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001391 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001392 * <p>Input: Nothing.
1393 * <p>Output: Nothing.
1394 */
1395 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1396 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1397
1398 /**
1399 * Activity Action: Show activity for reporting a bug.
1400 * <p>Input: Nothing.
1401 * <p>Output: Nothing.
1402 */
1403 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1405
1406 /**
1407 * Activity Action: Main entry point for factory tests. Only used when
1408 * the device is booting in factory test node. The implementing package
1409 * must be installed in the system image.
1410 * <p>Input: nothing
1411 * <p>Output: nothing
1412 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001413 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001414 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1415
1416 /**
1417 * Activity Action: The user pressed the "call" button to go to the dialer
1418 * or other appropriate UI for placing a call.
1419 * <p>Input: Nothing.
1420 * <p>Output: Nothing.
1421 */
1422 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1423 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1424
1425 /**
1426 * Activity Action: Start Voice Command.
1427 * <p>Input: Nothing.
1428 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001429 * <p class="note">
1430 * In some cases, a matching Activity may not exist, so ensure you
1431 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001432 */
1433 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1434 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001435
1436 /**
1437 * Activity Action: Start action associated with long pressing on the
1438 * search key.
1439 * <p>Input: Nothing.
1440 * <p>Output: Nothing.
1441 */
1442 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1443 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001444
Jacek Surazski86b6c532009-05-13 14:38:28 +02001445 /**
1446 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1447 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001448 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001449 * <p>Input: No data is specified. The bug report is passed in using
1450 * an {@link #EXTRA_BUG_REPORT} field.
1451 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001452 *
1453 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001454 */
1455 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1456 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001457
1458 /**
Joe Onoratoe21ab7e2018-12-18 15:00:25 -08001459 * An incident or bug report has been taken, and a system app has requested it to be shared,
1460 * so trigger the confirmation screen.
1461 *
1462 * This will be sent directly to the registered receiver with the
1463 * android.permission.APPROVE_INCIDENT_REPORTS permission.
1464 * @hide
1465 */
1466 @SystemApi
1467 public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1468 "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1469
1470 /**
Joe Onorato8daca752019-01-28 19:41:58 -08001471 * An incident report has been taken, and the user has approved it for sharing.
1472 * <p>
1473 * This will be sent directly to the registered receiver, which must have
1474 * both the DUMP and USAGE_STATS permissions.
1475 * <p>
1476 * After receiving this, the application should wait until a suitable time
1477 * (e.g. network available), get the list of available reports with
1478 * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1479 * and then when the reports have been successfully uploaded, call
1480 * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1481 *
1482 * @hide
1483 */
1484 @SystemApi
1485 public static final String ACTION_INCIDENT_REPORT_READY =
1486 "android.intent.action.INCIDENT_REPORT_READY";
1487
1488 /**
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001489 * Activity Action: Show power usage information to the user.
1490 * <p>Input: Nothing.
1491 * <p>Output: Nothing.
1492 */
1493 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1494 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001495
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001496 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001497 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1498 * to run.
1499 * <p>Input: Nothing.
1500 * <p>Output: Nothing.
1501 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1502 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1503 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001504 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001505 */
1506 @Deprecated
1507 @SystemApi
1508 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1509 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1510
1511 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001512 * Activity Action: Setup wizard to launch after a platform update. This
1513 * activity should have a string meta-data field associated with it,
1514 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1515 * the platform for setup. The activity will be launched only if
1516 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1517 * same value.
1518 * <p>Input: Nothing.
1519 * <p>Output: Nothing.
1520 * @hide
1521 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001522 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001523 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1524 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001525
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001526 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001527 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1528 * <p>Input: Nothing.
1529 * <p>Output: Nothing.
1530 * @hide
1531 */
1532 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1533 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001534 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001535
1536 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001537 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1538 * <p>Input: Nothing.
1539 * <p>Output: Nothing.
1540 * @hide
1541 */
1542 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1543 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001544 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001545
1546 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001547 * Activity Action: Show settings for managing network data usage of a
1548 * specific application. Applications should define an activity that offers
1549 * options to control data usage.
1550 */
1551 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1552 public static final String ACTION_MANAGE_NETWORK_USAGE =
1553 "android.intent.action.MANAGE_NETWORK_USAGE";
1554
1555 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001556 * Activity Action: Launch application installer.
1557 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001558 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001559 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1560 * you can also use "package:<package-name>" to install an application for the
1561 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001562 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1563 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1564 * <p>
1565 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1566 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001567 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001568 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001569 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1570 * in order to launch the application installer.
1571 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001572 *
1573 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1574 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1575 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001576 *
1577 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001578 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001579 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001580 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1581 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1582
1583 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001584 * Activity Action: Activity to handle split installation failures.
1585 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1586 * but the split that contains the application isn't installed. When a split is
1587 * installed in this manner, the containing package usually doesn't know this is
1588 * happening. However, if an error occurs during installation, the containing
1589 * package can define a single activity handling this action to deal with such
1590 * failures.
1591 * <p>The activity handling this action must be in the base package.
1592 * <p>
1593 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1594 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1595 */
1596 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1597 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1598
1599 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001600 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001601 * <p class="note">
1602 * This is a protected intent that can only be sent by the system.
1603 * </p>
1604 *
1605 * @hide
1606 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001607 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001608 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001609 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1610 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001611
1612 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001613 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001614 * <p>
1615 * The system will have a persistent connection to this service.
1616 * This is a protected intent that can only be sent by the system.
1617 * </p>
1618 *
1619 * @hide
1620 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001621 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001622 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001623 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1624 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001625
1626 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001627 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001628 *
1629 * <p class="note">
1630 * This is a protected intent that can only be sent by the system.
1631 * </p>
1632 *
1633 * @hide
1634 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001635 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001636 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001637 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1638 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001639
1640 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001641 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1642 * package. Specifies the installer package name; this package will receive the
1643 * {@link #ACTION_APP_ERROR} intent.
1644 */
1645 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1646 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1647
1648 /**
1649 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1650 * package. Specifies that the application being installed should not be
1651 * treated as coming from an unknown source, but as coming from the app
1652 * invoking the Intent. For this to work you must start the installer with
1653 * startActivityForResult().
1654 */
1655 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1656 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1657
1658 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001659 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1660 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001661 * data field originated from.
1662 */
rich cannings706e8ba2012-08-20 13:20:14 -07001663 public static final String EXTRA_ORIGINATING_URI
1664 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001665
1666 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001667 * This extra can be used with any Intent used to launch an activity, supplying information
1668 * about who is launching that activity. This field contains a {@link android.net.Uri}
1669 * object, typically an http: or https: URI of the web site that the referral came from;
1670 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1671 * a native application that it came from.
1672 *
1673 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1674 * instead of directly retrieving the extra. It is also valid for applications to
1675 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1676 * a string, not a Uri; the field here, if supplied, will always take precedence,
1677 * however.</p>
1678 *
1679 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001680 */
1681 public static final String EXTRA_REFERRER
1682 = "android.intent.extra.REFERRER";
1683
1684 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001685 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1686 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1687 * not be created, in particular when Intent extras are supplied through the
1688 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1689 * schemes.
1690 *
1691 * @see #EXTRA_REFERRER
1692 */
1693 public static final String EXTRA_REFERRER_NAME
1694 = "android.intent.extra.REFERRER_NAME";
1695
1696 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001697 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001698 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001699 * Currently only a system app that hosts the provider authority "downloads" or holds the
1700 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001701 * @hide
1702 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001703 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001704 public static final String EXTRA_ORIGINATING_UID
1705 = "android.intent.extra.ORIGINATING_UID";
1706
1707 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001708 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1709 * package. Tells the installer UI to skip the confirmation with the user
1710 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001711 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1712 * will no longer show an interstitial message about updating existing
1713 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001714 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001715 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001716 public static final String EXTRA_ALLOW_REPLACE
1717 = "android.intent.extra.ALLOW_REPLACE";
1718
1719 /**
1720 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1721 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1722 * return to the application the result code of the install/uninstall. The returned result
1723 * code will be {@link android.app.Activity#RESULT_OK} on success or
1724 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1725 */
1726 public static final String EXTRA_RETURN_RESULT
1727 = "android.intent.extra.RETURN_RESULT";
1728
1729 /**
1730 * Package manager install result code. @hide because result codes are not
1731 * yet ready to be exposed.
1732 */
1733 public static final String EXTRA_INSTALL_RESULT
1734 = "android.intent.extra.INSTALL_RESULT";
1735
1736 /**
1737 * Activity Action: Launch application uninstaller.
1738 * <p>
1739 * Input: The data must be a package: URI whose scheme specific part is
1740 * the package name of the current installed package to be uninstalled.
1741 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1742 * <p>
1743 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1744 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001745 * <p>
1746 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1747 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001748 *
1749 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1750 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001751 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001752 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001753 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1754 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1755
1756 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001757 * Specify whether the package should be uninstalled for all users.
1758 * @hide because these should not be part of normal application flow.
1759 */
1760 public static final String EXTRA_UNINSTALL_ALL_USERS
1761 = "android.intent.extra.UNINSTALL_ALL_USERS";
1762
1763 /**
Varun Shahb9fd6be2018-10-22 19:16:33 -07001764 * A string that associates with a metadata entry, indicating the last run version of the
1765 * platform that was setup.
1766 *
1767 * @see #ACTION_UPGRADE_SETUP
1768 *
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001769 * @hide
1770 */
Varun Shahb9fd6be2018-10-22 19:16:33 -07001771 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001772 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1773
Svet Ganov3695b8a2015-03-24 16:30:25 -07001774 /**
1775 * Activity action: Launch UI to manage the permissions of an app.
1776 * <p>
1777 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1778 * will be managed by the launched UI.
1779 * </p>
1780 * <p>
1781 * Output: Nothing.
1782 * </p>
1783 *
1784 * @see #EXTRA_PACKAGE_NAME
1785 *
1786 * @hide
1787 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001788 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001789 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1790 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1791 "android.intent.action.MANAGE_APP_PERMISSIONS";
1792
1793 /**
Joel Galenson035dfd92019-02-08 13:58:51 -08001794 * Activity action: Launch UI to manage a specific permissions of an app.
1795 * <p>
1796 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1797 * will be managed by the launched UI.
1798 * </p>
1799 * <p>
1800 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1801 * that should be managed by the launched UI.
1802 * </p>
1803 * <p>
1804 * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1805 * </p>
1806 * <p>
1807 * Output: Nothing.
1808 * </p>
1809 *
1810 * @see #EXTRA_PACKAGE_NAME
1811 * @see #EXTRA_PERMISSION_NAME
1812 * @see #EXTRA_USER
1813 *
1814 * @hide
1815 */
1816 @SystemApi
1817 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1818 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1819 public static final String ACTION_MANAGE_APP_PERMISSION =
1820 "android.intent.action.MANAGE_APP_PERMISSION";
1821
1822 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001823 * Activity action: Launch UI to manage permissions.
1824 * <p>
1825 * Input: Nothing.
1826 * </p>
1827 * <p>
1828 * Output: Nothing.
1829 * </p>
1830 *
1831 * @hide
1832 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001833 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001834 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1835 public static final String ACTION_MANAGE_PERMISSIONS =
1836 "android.intent.action.MANAGE_PERMISSIONS";
1837
1838 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001839 * Activity action: Launch UI to review permissions for an app.
1840 * The system uses this intent if permission review for apps not
1841 * supporting the new runtime permissions model is enabled. In
1842 * this mode a permission review is required before any of the
1843 * app components can run.
1844 * <p>
1845 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1846 * permissions will be reviewed (mandatory).
1847 * </p>
1848 * <p>
1849 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1850 * be fired after the permission review (optional).
1851 * </p>
1852 * <p>
1853 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1854 * be invoked after the permission review (optional).
1855 * </p>
1856 * <p>
1857 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1858 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1859 * </p>
1860 * <p>
1861 * Output: Nothing.
1862 * </p>
1863 *
1864 * @see #EXTRA_PACKAGE_NAME
1865 * @see #EXTRA_INTENT
1866 * @see #EXTRA_REMOTE_CALLBACK
1867 * @see #EXTRA_RESULT_NEEDED
1868 *
1869 * @hide
1870 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001871 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001872 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1873 public static final String ACTION_REVIEW_PERMISSIONS =
1874 "android.intent.action.REVIEW_PERMISSIONS";
1875
1876 /**
Hai Zhang3a212892019-01-11 15:21:17 -08001877 * Activity action: Launch UI to manage a default app.
1878 * <p>
1879 * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1880 * by the launched UI.
1881 * </p>
1882 * <p>
1883 * Output: Nothing.
1884 * </p>
1885 *
1886 * @hide
1887 */
1888 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1889 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1890 @SystemApi
1891 public static final String ACTION_MANAGE_DEFAULT_APP =
1892 "android.intent.action.MANAGE_DEFAULT_APP";
1893
1894 /**
1895 * Intent extra: A role name.
1896 * <p>
1897 * Type: String
1898 * </p>
1899 *
1900 * @see android.app.role.RoleManager
1901 *
1902 * @hide
1903 */
1904 @SystemApi
1905 public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1906
1907 /**
Hai Zhang1d792322019-01-07 13:51:52 -08001908 * Activity action: Launch UI to manage special app accesses.
1909 * <p>
1910 * Input: Nothing.
1911 * </p>
1912 * <p>
1913 * Output: Nothing.
1914 * </p>
1915 *
1916 * @hide
1917 */
1918 @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1919 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1920 @SystemApi
1921 public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
1922 "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
1923
1924 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001925 * Intent extra: A callback for reporting remote result as a bundle.
1926 * <p>
1927 * Type: IRemoteCallback
1928 * </p>
1929 *
1930 * @hide
1931 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001932 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001933 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1934
1935 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001936 * Intent extra: An app package name.
1937 * <p>
1938 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001939 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001940 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001941 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001942 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1943
1944 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001945 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1946 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1947 *
1948 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1949 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1950 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001951 *
1952 * @see #ACTION_MY_PACKAGE_SUSPENDED
1953 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1954 * @see PackageManager#isPackageSuspended()
1955 * @see PackageManager#getSuspendedPackageAppExtras()
1956 */
1957 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1958
1959 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001960 * Intent extra: An app split name.
1961 * <p>
1962 * Type: String
1963 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001964 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001965 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1966
1967 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001968 * Intent extra: A {@link ComponentName} value.
1969 * <p>
1970 * Type: String
1971 * </p>
1972 */
1973 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1974
1975 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001976 * Intent extra: An extra for specifying whether a result is needed.
1977 * <p>
1978 * Type: boolean
1979 * </p>
1980 *
1981 * @hide
1982 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001983 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001984 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1985
1986 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001987 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1988 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1989 *
1990 * @see PackageManager#isPackageSuspended()
1991 * @see #ACTION_PACKAGES_SUSPENDED
1992 *
1993 * @hide
1994 */
1995 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1996
1997 /**
Mehdi Alizadeh406e8b32018-12-11 18:21:49 -08001998 * Intent extra: ID of the shortcut used to send the share intent.
1999 *
2000 * @see ShortcutInfo#getId()
2001 *
2002 * <p>
2003 * Type: String
2004 * </p>
2005 */
2006 public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2007
2008 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07002009 * Activity action: Launch UI to manage which apps have a given permission.
2010 * <p>
Philip P. Moltmanned988282018-11-07 16:19:42 -08002011 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2012 * which will be managed by the launched UI.
Svet Ganov3695b8a2015-03-24 16:30:25 -07002013 * </p>
2014 * <p>
2015 * Output: Nothing.
2016 * </p>
2017 *
2018 * @see #EXTRA_PERMISSION_NAME
2019 *
2020 * @hide
2021 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08002022 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07002023 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2024 public static final String ACTION_MANAGE_PERMISSION_APPS =
2025 "android.intent.action.MANAGE_PERMISSION_APPS";
2026
2027 /**
2028 * Intent extra: The name of a permission.
2029 * <p>
2030 * Type: String
2031 * </p>
2032 *
2033 * @hide
2034 */
2035 @SystemApi
2036 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2037
Joel Galenson13096ea2018-09-27 11:18:44 -07002038 /**
Joel Galenson029aac72019-01-07 10:31:28 -08002039 * Intent extra: The name of a permission group.
2040 * <p>
2041 * Type: String
2042 * </p>
2043 *
2044 * @hide
2045 */
2046 @SystemApi
2047 public static final String EXTRA_PERMISSION_GROUP_NAME =
2048 "android.intent.extra.PERMISSION_GROUP_NAME";
2049
2050 /**
Joel Galensonc857f022019-01-22 10:01:00 -08002051 * Intent extra: The number of milliseconds.
2052 * <p>
2053 * Type: long
2054 * </p>
2055 */
2056 public static final String EXTRA_DURATION_MILLIS =
2057 "android.intent.extra.DURATION_MILLIS";
2058
2059 /**
Joel Galenson13096ea2018-09-27 11:18:44 -07002060 * Activity action: Launch UI to review app uses of permissions.
2061 * <p>
Joel Galensonb995eda2018-12-04 16:28:04 -08002062 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
Joel Galenson029aac72019-01-07 10:31:28 -08002063 * that will be displayed by the launched UI. Do not pass both this and
2064 * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2065 * </p>
2066 * <p>
2067 * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2068 * that will be displayed by the launched UI. Do not pass both this and
2069 * {@link #EXTRA_PERMISSION_NAME}.
Joel Galenson13096ea2018-09-27 11:18:44 -07002070 * </p>
2071 * <p>
Joel Galensonc857f022019-01-22 10:01:00 -08002072 * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2073 * activity to show (optional). Must be non-negative.
2074 * </p>
2075 * <p>
Joel Galenson13096ea2018-09-27 11:18:44 -07002076 * Output: Nothing.
2077 * </p>
2078 *
Joel Galensonb995eda2018-12-04 16:28:04 -08002079 * @see #EXTRA_PERMISSION_NAME
Joel Galenson029aac72019-01-07 10:31:28 -08002080 * @see #EXTRA_PERMISSION_GROUP_NAME
Joel Galensonc857f022019-01-22 10:01:00 -08002081 * @see #EXTRA_DURATION_MILLIS
Joel Galensonb995eda2018-12-04 16:28:04 -08002082 *
Joel Galenson13096ea2018-09-27 11:18:44 -07002083 * @hide
2084 */
2085 @SystemApi
2086 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2087 public static final String ACTION_REVIEW_PERMISSION_USAGE =
2088 "android.intent.action.REVIEW_PERMISSION_USAGE";
2089
Joel Galenson78ec58d2018-10-24 10:06:25 -07002090 /**
2091 * Activity action: Launch UI to review uses of permissions for a single app.
2092 * <p>
2093 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
2094 * permissions will be reviewed (mandatory).
2095 * </p>
2096 * <p>
2097 * Output: Nothing.
2098 * </p>
2099 * <p class="note">
2100 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2101 * </p>
2102 *
2103 * @see #EXTRA_PACKAGE_NAME
2104 *
2105 * @hide
2106 */
2107 @SystemApi
2108 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2109 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2110 public static final String ACTION_REVIEW_APP_PERMISSION_USAGE =
2111 "android.intent.action.REVIEW_APP_PERMISSION_USAGE";
2112
Joel Galenson95628242019-02-05 14:15:05 -08002113 /**
2114 * Activity action: Launch UI to review running accessibility services.
2115 * <p>
2116 * Input: Nothing.
2117 * </p>
2118 * <p>
2119 * Output: Nothing.
2120 * </p>
2121 *
2122 * @hide
2123 */
2124 @SystemApi
2125 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2126 public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2127 "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2128
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002129 // ---------------------------------------------------------------------
2130 // ---------------------------------------------------------------------
2131 // Standard intent broadcast actions (see action variable).
2132
2133 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002134 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2135 * <p>
2136 * For historical reasons, the name of this broadcast action refers to the power
2137 * state of the screen but it is actually sent in response to changes in the
2138 * overall interactive state of the device.
2139 * </p><p>
2140 * This broadcast is sent when the device becomes non-interactive which may have
2141 * nothing to do with the screen turning off. To determine the
2142 * actual state of the screen, use {@link android.view.Display#getState}.
2143 * </p><p>
2144 * See {@link android.os.PowerManager#isInteractive} for details.
2145 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002146 * You <em>cannot</em> receive this through components declared in
2147 * manifests, only by explicitly registering for it with
2148 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2149 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002150 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002151 * <p class="note">This is a protected intent that can only be sent
2152 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002153 */
2154 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2155 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07002156
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002157 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07002158 * Broadcast Action: Sent when the device wakes up and becomes interactive.
2159 * <p>
2160 * For historical reasons, the name of this broadcast action refers to the power
2161 * state of the screen but it is actually sent in response to changes in the
2162 * overall interactive state of the device.
2163 * </p><p>
2164 * This broadcast is sent when the device becomes interactive which may have
2165 * nothing to do with the screen turning on. To determine the
2166 * actual state of the screen, use {@link android.view.Display#getState}.
2167 * </p><p>
2168 * See {@link android.os.PowerManager#isInteractive} for details.
2169 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07002170 * You <em>cannot</em> receive this through components declared in
2171 * manifests, only by explicitly registering for it with
2172 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2173 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002174 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002175 * <p class="note">This is a protected intent that can only be sent
2176 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002177 */
2178 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2179 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002180
2181 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07002182 * Broadcast Action: Sent after the system stops dreaming.
2183 *
2184 * <p class="note">This is a protected intent that can only be sent by the system.
2185 * It is only sent to registered receivers.</p>
2186 */
2187 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2188 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2189
2190 /**
2191 * Broadcast Action: Sent after the system starts dreaming.
2192 *
2193 * <p class="note">This is a protected intent that can only be sent by the system.
2194 * It is only sent to registered receivers.</p>
2195 */
2196 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2197 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2198
2199 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07002200 * 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 -07002201 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002202 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002203 * <p class="note">This is a protected intent that can only be sent
2204 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002205 */
2206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002207 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002208
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002209 /**
2210 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002211 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002212 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002213 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2214 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002215 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002216 * <p class="note">This is a protected intent that can only be sent
2217 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002218 */
2219 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2220 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2221 /**
2222 * Broadcast Action: The time was set.
2223 */
2224 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2225 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2226 /**
2227 * Broadcast Action: The date has changed.
2228 */
2229 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2230 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2231 /**
2232 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2233 * <ul>
2234 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2235 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002236 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002237 * <p class="note">This is a protected intent that can only be sent
2238 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002239 */
2240 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2241 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2242 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002243 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2244 * DNS entries should be tossed.
2245 * @hide
2246 */
2247 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2248 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2249 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002250 * Alarm Changed Action: This is broadcast when the AlarmClock
2251 * application's alarm is set or unset. It is used by the
2252 * AlarmClock application and the StatusBar service.
2253 * @hide
2254 */
2255 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002256 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002257 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002258
2259 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002260 * Broadcast Action: This is broadcast once, after the user has finished
2261 * booting, but while still in the "locked" state. It can be used to perform
2262 * application-specific initialization, such as installing alarms. You must
2263 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2264 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002265 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002266 * This broadcast is sent immediately at boot by all devices (regardless of
2267 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2268 * higher. Upon receipt of this broadcast, the user is still locked and only
2269 * device-protected storage can be accessed safely. If you want to access
2270 * credential-protected storage, you need to wait for the user to be
2271 * unlocked (typically by entering their lock pattern or PIN for the first
2272 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2273 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2274 * <p>
2275 * To receive this broadcast, your receiver component must be marked as
2276 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002277 * <p class="note">
2278 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002279 *
2280 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002281 */
2282 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2283 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2284
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002285 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002286 * Broadcast Action: This is broadcast once, after the user has finished
2287 * booting. It can be used to perform application-specific initialization,
2288 * such as installing alarms. You must hold the
2289 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2290 * order to receive this broadcast.
2291 * <p>
2292 * This broadcast is sent at boot by all devices (both with and without
2293 * direct boot support). Upon receipt of this broadcast, the user is
2294 * unlocked and both device-protected and credential-protected storage can
2295 * accessed safely.
2296 * <p>
2297 * If you need to run while the user is still locked (before they've entered
2298 * their lock pattern or PIN for the first time), you can listen for the
2299 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2300 * <p class="note">
2301 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002302 */
2303 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002304 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002305 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002306
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002307 /**
2308 * Broadcast Action: This is broadcast when a user action should request a
2309 * temporary system dialog to dismiss. Some examples of temporary system
2310 * dialogs are the notification window-shade and the recent tasks dialog.
2311 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002312 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002313 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2314 /**
2315 * Broadcast Action: Trigger the download and eventual installation
2316 * of a package.
2317 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002318 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002319 * <p class="note">This is a protected intent that can only be sent
2320 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002321 *
2322 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002323 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002324 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002325 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2327 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002328 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002329 * device. The data contains the name of the package. Note that the
2330 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002331 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002332 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002333 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2334 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002335 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2336 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002337 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002338 * <p class="note">This is a protected intent that can only be sent
2339 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002340 */
2341 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2342 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2343 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002344 * Broadcast Action: A new version of an application package has been
2345 * installed, replacing an existing version that was previously installed.
2346 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002347 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002348 * <ul>
2349 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2350 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002351 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002352 * <p class="note">This is a protected intent that can only be sent
2353 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002354 */
2355 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2356 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2357 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002358 * Broadcast Action: A new version of your application has been installed
2359 * over an existing one. This is only sent to the application that was
2360 * replaced. It does not contain any additional data; to receive it, just
2361 * use an intent filter for this action.
2362 *
2363 * <p class="note">This is a protected intent that can only be sent
2364 * by the system.
2365 */
2366 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2367 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2368 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002369 * Broadcast Action: An existing application package has been removed from
2370 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002371 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002372 * <ul>
2373 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2374 * to the package.
2375 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2376 * application -- data and code -- is being removed.
2377 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2378 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2379 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002380 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002381 * <p class="note">This is a protected intent that can only be sent
2382 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002383 */
2384 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2385 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2386 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002387 * Broadcast Action: An existing application package has been completely
2388 * removed from the device. The data contains the name of the package.
2389 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2390 * {@link #EXTRA_DATA_REMOVED} is true and
2391 * {@link #EXTRA_REPLACING} is false of that broadcast.
2392 *
2393 * <ul>
2394 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2395 * to the package.
2396 * </ul>
2397 *
2398 * <p class="note">This is a protected intent that can only be sent
2399 * by the system.
2400 */
2401 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2402 public static final String ACTION_PACKAGE_FULLY_REMOVED
2403 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2404 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002405 * Broadcast Action: An existing application package has been changed (for
2406 * example, a component has been enabled or disabled). The data contains
2407 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002408 * <ul>
2409 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002410 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002411 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002412 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2413 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002414 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002415 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002416 * <p class="note">This is a protected intent that can only be sent
2417 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002418 */
2419 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2420 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2421 /**
Richard Uhlerb29f1452018-09-12 16:38:15 +01002422 * Broadcast Action: Sent to the system rollback manager when a package
2423 * needs to have rollback enabled.
2424 * <p class="note">
2425 * This is a protected intent that can only be sent by the system.
2426 * </p>
2427 *
2428 * @hide This broadcast is used internally by the system.
2429 */
2430 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2431 public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2432 "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2433 /**
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002434 * Broadcast Action: A rollback has been committed.
Richard Uhlerb29f1452018-09-12 16:38:15 +01002435 *
2436 * <p class="note">This is a protected intent that can only be sent
2437 * by the system.
2438 *
Richard Uhlerc739c8c2018-12-12 11:03:34 +00002439 * @hide
Richard Uhlerb29f1452018-09-12 16:38:15 +01002440 */
Richard Uhlerc739c8c2018-12-12 11:03:34 +00002441 @SystemApi
Richard Uhlerb29f1452018-09-12 16:38:15 +01002442 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Richard Uhlerdca7beb2019-01-24 09:56:03 +00002443 public static final String ACTION_ROLLBACK_COMMITTED =
2444 "android.intent.action.ROLLBACK_COMMITTED";
Richard Uhlerb29f1452018-09-12 16:38:15 +01002445 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002446 * @hide
2447 * Broadcast Action: Ask system services if there is any reason to
2448 * restart the given package. The data contains the name of the
2449 * package.
2450 * <ul>
2451 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2452 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2453 * </ul>
2454 *
2455 * <p class="note">This is a protected intent that can only be sent
2456 * by the system.
2457 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002458 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002459 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2460 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2461 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002462 * Broadcast Action: The user has restarted a package, and all of its
2463 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002464 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002465 * be removed. Note that the restarted package does <em>not</em>
2466 * receive this broadcast.
2467 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002468 * <ul>
2469 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2470 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002471 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002472 * <p class="note">This is a protected intent that can only be sent
2473 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002474 */
2475 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2476 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2477 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002478 * Broadcast Action: The user has cleared the data of a package. This should
2479 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002480 * its persistent data is erased and this broadcast sent.
2481 * Note that the cleared package does <em>not</em>
2482 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002483 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002484 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2485 * package whose data was cleared is an uninstalled instant app, then the UID
2486 * will be -1. The platform keeps some meta-data associated with instant apps
2487 * after they are uninstalled.
2488 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2489 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002490 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002491 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002492 * <p class="note">This is a protected intent that can only be sent
2493 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002494 */
2495 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2496 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2497 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002498 * Broadcast Action: Packages have been suspended.
2499 * <p>Includes the following extras:
2500 * <ul>
2501 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002502 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002503 * </ul>
2504 *
2505 * <p class="note">This is a protected intent that can only be sent
2506 * by the system. It is only sent to registered receivers.
2507 */
2508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2509 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2510 /**
2511 * Broadcast Action: Packages have been unsuspended.
2512 * <p>Includes the following extras:
2513 * <ul>
2514 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002515 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002516 * </ul>
2517 *
2518 * <p class="note">This is a protected intent that can only be sent
2519 * by the system. It is only sent to registered receivers.
2520 */
2521 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2522 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002523
2524 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08002525 * Broadcast Action: Distracting packages have been changed.
2526 * <p>Includes the following extras:
2527 * <ul>
2528 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2529 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2530 * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2531 * </ul>
2532 *
2533 * <p class="note">This is a protected intent that can only be sent
2534 * by the system. It is only sent to registered receivers.
2535 *
2536 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2537 * @hide
2538 */
2539 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2540 public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2541 "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2542
2543 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002544 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002545 * whenever a package is put into a suspended state or any of its app extras change while in the
2546 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002547 * <p> Optionally includes the following extras:
2548 * <ul>
2549 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2550 * useful information for the app being suspended.
2551 * </ul>
2552 * <p class="note">This is a protected intent that can only be sent
2553 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2554 * the manifest.</em>
2555 *
2556 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2557 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2558 * @see PackageManager#isPackageSuspended()
2559 * @see PackageManager#getSuspendedPackageAppExtras()
2560 */
2561 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2562 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2563
2564 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002565 * Activity Action: Started to show more details about why an application was suspended.
2566 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002567 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2568 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002569 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002570 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2571 * handling this intent and protect it with
2572 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2573 *
2574 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2575 *
2576 * <p class="note">This is a protected intent that can only be sent
2577 * by the system.
2578 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002579 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2580 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002581 * @see PackageManager#isPackageSuspended()
2582 * @see #ACTION_PACKAGES_SUSPENDED
2583 *
2584 * @hide
2585 */
2586 @SystemApi
2587 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2588 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2589 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2590
2591 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002592 * Broadcast Action: Sent to a package that has been unsuspended.
2593 *
2594 * <p class="note">This is a protected intent that can only be sent
2595 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2596 * the manifest.</em>
2597 *
2598 * @see #ACTION_MY_PACKAGE_SUSPENDED
2599 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2600 * @see PackageManager#isPackageSuspended()
2601 * @see PackageManager#getSuspendedPackageAppExtras()
2602 */
2603 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2604 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2605
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002606 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002607 * Broadcast Action: A user ID has been removed from the system. The user
2608 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002609 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002610 * <p class="note">This is a protected intent that can only be sent
2611 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002612 */
2613 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2614 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002615
2616 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002617 * Broadcast Action: Sent to the installer package of an application when
2618 * that application is first launched (that is the first time it is moved
2619 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002620 *
2621 * <p class="note">This is a protected intent that can only be sent
2622 * by the system.
2623 */
2624 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2625 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2626
2627 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002628 * Broadcast Action: Sent to the system package verifier when a package
2629 * needs to be verified. The data contains the package URI.
2630 * <p class="note">
2631 * This is a protected intent that can only be sent by the system.
2632 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002633 */
2634 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2635 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2636
2637 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002638 * Broadcast Action: Sent to the system package verifier when a package is
2639 * verified. The data contains the package URI.
2640 * <p class="note">
2641 * This is a protected intent that can only be sent by the system.
2642 */
2643 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2644 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2645
2646 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002647 * Broadcast Action: Sent to the system intent filter verifier when an
2648 * intent filter needs to be verified. The data contains the filter data
2649 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002650 * <p class="note">
2651 * This is a protected intent that can only be sent by the system.
2652 * </p>
2653 *
2654 * @hide
2655 */
2656 @SystemApi
2657 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2658 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2659
2660 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002661 * Broadcast Action: Resources for a set of packages (which were
2662 * previously unavailable) are currently
2663 * available since the media on which they exist is available.
2664 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2665 * list of packages whose availability changed.
2666 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2667 * list of uids of packages whose availability changed.
2668 * Note that the
2669 * packages in this list do <em>not</em> receive this broadcast.
2670 * The specified set of packages are now available on the system.
2671 * <p>Includes the following extras:
2672 * <ul>
2673 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2674 * whose resources(were previously unavailable) are currently available.
2675 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2676 * packages whose resources(were previously unavailable)
2677 * are currently available.
2678 * </ul>
2679 *
2680 * <p class="note">This is a protected intent that can only be sent
2681 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002682 */
2683 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002684 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2685 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002686
2687 /**
2688 * Broadcast Action: Resources for a set of packages are currently
2689 * unavailable since the media on which they exist is unavailable.
2690 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2691 * list of packages whose availability changed.
2692 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2693 * list of uids of packages whose availability changed.
2694 * The specified set of packages can no longer be
2695 * launched and are practically unavailable on the system.
2696 * <p>Inclues the following extras:
2697 * <ul>
2698 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2699 * whose resources are no longer available.
2700 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2701 * whose resources are no longer available.
2702 * </ul>
2703 *
2704 * <p class="note">This is a protected intent that can only be sent
2705 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002706 */
2707 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002708 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002709 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002710
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002711 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002712 * Broadcast Action: preferred activities have changed *explicitly*.
2713 *
2714 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2715 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2716 * be sent.
2717 *
2718 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2719 *
2720 * @hide
2721 */
2722 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2723 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2724 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2725
2726
2727 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002728 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002729 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002730 * This should <em>only</em> be used to determine when the wallpaper
2731 * has changed to show the new wallpaper to the user. You should certainly
2732 * never, in response to this, change the wallpaper or other attributes of
2733 * it such as the suggested size. That would be crazy, right? You'd cause
2734 * all kinds of loops, especially if other apps are doing similar things,
2735 * right? Of course. So please don't do this.
2736 *
2737 * @deprecated Modern applications should use
2738 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2739 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2740 * shown behind their UI, rather than watching for this broadcast and
2741 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002742 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002743 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002744 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2745 /**
2746 * Broadcast Action: The current device {@link android.content.res.Configuration}
2747 * (orientation, locale, etc) has changed. When such a change happens, the
2748 * UIs (view hierarchy) will need to be rebuilt based on this new
2749 * information; for the most part, applications don't need to worry about
2750 * this, because the system will take care of stopping and restarting the
2751 * application to make sure it sees the new changes. Some system code that
2752 * can not be restarted will need to watch for this action and handle it
2753 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002754 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002755 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002756 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002757 * in manifests, only by explicitly registering for it with
2758 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2759 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002760 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002761 * <p class="note">This is a protected intent that can only be sent
2762 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002763 *
2764 * @see android.content.res.Configuration
2765 */
2766 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2767 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002768
2769 /**
2770 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2771 * such that the device may be eligible for the installation of additional configuration splits.
2772 * Configuration properties that can trigger this broadcast include locale and display density.
2773 *
2774 * <p class="note">
2775 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2776 * components declared in manifests. However, the receiver <em>must</em> hold the
2777 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2778 *
2779 * <p class="note">
2780 * This is a protected intent that can only be sent by the system.
2781 *
2782 * @hide
2783 */
2784 @SystemApi
2785 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2786 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2787 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002788 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002789 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002790 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002791 * <p class="note">This is a protected intent that can only be sent
2792 * by the system.
2793 */
2794 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2795 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2796 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002797 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2798 * charging state, level, and other information about the battery.
2799 * See {@link android.os.BatteryManager} for documentation on the
2800 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002801 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002802 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002803 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002804 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002805 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002806 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2807 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2808 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2809 * broadcasts that are sent and can be received through manifest
2810 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002811 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002812 * <p class="note">This is a protected intent that can only be sent
2813 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002814 */
2815 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2816 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002817
2818
2819 /**
2820 * Broadcast Action: Sent when the current battery level changes.
2821 *
2822 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2823 * instances representing individual battery level changes with associated
2824 * extras from {@link #ACTION_BATTERY_CHANGED}.
2825 *
2826 * <p class="note">
2827 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2828 *
2829 * @hide
2830 */
2831 @SystemApi
2832 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2833 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002834 /**
2835 * Broadcast Action: Indicates low battery condition on the device.
2836 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002837 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002838 * <p class="note">This is a protected intent that can only be sent
2839 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002840 */
2841 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2842 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2843 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002844 * Broadcast Action: Indicates the battery is now okay after being low.
2845 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2846 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002847 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002848 * <p class="note">This is a protected intent that can only be sent
2849 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002850 */
2851 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2852 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2853 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002854 * Broadcast Action: External power has been connected to the device.
2855 * This is intended for applications that wish to register specifically to this notification.
2856 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2857 * stay active to receive this notification. This action can be used to implement actions
2858 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002859 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002860 * <p class="note">This is a protected intent that can only be sent
2861 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002862 */
2863 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002864 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002865 /**
2866 * Broadcast Action: External power has been removed from the device.
2867 * This is intended for applications that wish to register specifically to this notification.
2868 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2869 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002870 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002871 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002872 * <p class="note">This is a protected intent that can only be sent
2873 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002874 */
2875 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002876 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002877 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002878 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002879 * Broadcast Action: Device is shutting down.
2880 * This is broadcast when the device is being shut down (completely turned
2881 * off, not sleeping). Once the broadcast is complete, the final shutdown
2882 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002883 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002884 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2885 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2886 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002887 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002888 * <p class="note">This is a protected intent that can only be sent
2889 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002890 * <p>May include the following extras:
2891 * <ul>
2892 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2893 * shutdown is only for userspace processes. If not set, assumed to be false.
2894 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002895 */
2896 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002897 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002898 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002899 * Activity Action: Start this activity to request system shutdown.
2900 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002901 * to request confirmation from the user before shutting down. The optional boolean
2902 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2903 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002904 *
2905 * <p class="note">This is a protected intent that can only be sent
2906 * by the system.
2907 *
2908 * {@hide}
2909 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002910 public static final String ACTION_REQUEST_SHUTDOWN
2911 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002912 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002913 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002914 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002915 * <p class="note">
2916 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002917 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002918 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2919 * or above, this broadcast will no longer be delivered to any
2920 * {@link BroadcastReceiver} defined in your manifest. Instead,
2921 * apps are strongly encouraged to use the improved
2922 * {@link Context#getCacheDir()} behavior so the system can
2923 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002924 */
2925 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002926 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002927 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2928 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002929 * Broadcast Action: Indicates low storage space condition on the device no
2930 * longer exists
2931 * <p class="note">
2932 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002933 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002934 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2935 * or above, this broadcast will no longer be delivered to any
2936 * {@link BroadcastReceiver} defined in your manifest. Instead,
2937 * apps are strongly encouraged to use the improved
2938 * {@link Context#getCacheDir()} behavior so the system can
2939 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002940 */
2941 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002942 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002943 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2944 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002945 * Broadcast Action: A sticky broadcast that indicates a storage space full
2946 * condition on the device. This is intended for activities that want to be
2947 * able to fill the data partition completely, leaving only enough free
2948 * space to prevent system-wide SQLite failures.
2949 * <p class="note">
2950 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002951 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002952 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2953 * or above, this broadcast will no longer be delivered to any
2954 * {@link BroadcastReceiver} defined in your manifest. Instead,
2955 * apps are strongly encouraged to use the improved
2956 * {@link Context#getCacheDir()} behavior so the system can
2957 * automatically free up storage when needed.
2958 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002959 */
2960 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002961 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002962 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2963 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002964 * Broadcast Action: Indicates storage space full condition on the device no
2965 * longer exists.
2966 * <p class="note">
2967 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002968 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002969 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2970 * or above, this broadcast will no longer be delivered to any
2971 * {@link BroadcastReceiver} defined in your manifest. Instead,
2972 * apps are strongly encouraged to use the improved
2973 * {@link Context#getCacheDir()} behavior so the system can
2974 * automatically free up storage when needed.
2975 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002976 */
2977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002978 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002979 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2980 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002981 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2982 * and package management should be started.
2983 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2984 * notification.
2985 */
2986 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2987 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2988 /**
2989 * Broadcast Action: The device has entered USB Mass Storage mode.
2990 * This is used mainly for the USB Settings panel.
2991 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2992 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002993 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002994 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002995 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002996 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002997 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2998
2999 /**
3000 * Broadcast Action: The device has exited USB Mass Storage mode.
3001 * This is used mainly for the USB Settings panel.
3002 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3003 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07003004 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003005 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07003006 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06003007 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003008 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3009
3010 /**
3011 * Broadcast Action: External media has been removed.
3012 * The path to the mount point for the removed media is contained in the Intent.mData field.
3013 */
3014 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3015 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3016
3017 /**
3018 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003019 * 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 -07003020 */
3021 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3022 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3023
3024 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08003025 * Broadcast Action: External media is present, and being disk-checked
3026 * 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 -08003027 */
3028 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3029 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3030
3031 /**
3032 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
3033 * 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 -08003034 */
3035 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3036 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3037
3038 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003039 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08003040 * 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 -07003041 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3042 * media was mounted read only.
3043 */
3044 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3045 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3046
3047 /**
3048 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003049 * 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 -07003050 */
3051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3052 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3053
3054 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05003055 * Broadcast Action: External media is no longer being shared via USB mass storage.
3056 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3057 *
3058 * @hide
3059 */
3060 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3061
3062 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003063 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
3064 * The path to the mount point for the removed media is contained in the Intent.mData field.
3065 */
3066 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3067 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3068
3069 /**
3070 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08003071 * 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 -07003072 */
3073 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3074 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3075
3076 /**
3077 * Broadcast Action: User has expressed the desire to remove the external storage media.
3078 * Applications should close all files they have open within the mount point when they receive this intent.
3079 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3080 */
3081 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3082 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3083
3084 /**
3085 * Broadcast Action: The media scanner has started scanning a directory.
3086 * The path to the directory being scanned is contained in the Intent.mData field.
3087 */
3088 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3089 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3090
3091 /**
3092 * Broadcast Action: The media scanner has finished scanning a directory.
3093 * The path to the scanned directory is contained in the Intent.mData field.
3094 */
3095 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3096 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3097
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003098 /**
3099 * Broadcast Action: Request the media scanner to scan a file and add it to
3100 * the media database.
3101 * <p>
3102 * The path to the file is contained in {@link Intent#getData()}.
3103 *
3104 * @deprecated Starting in the {@link android.os.Build.VERSION_CODES#Q}
3105 * release, shared storage paths are sandboxed per application,
3106 * and this broadcast cannot correctly translate those sandboxed
3107 * paths. Callers will need to instead migrate to using
3108 * {@link MediaScannerConnection}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003109 */
3110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003111 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003112 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3113
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003114 /** @hide */
Jeff Sharkey50e74f12019-01-23 22:36:34 -07003115 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkeyb91eaa52019-02-19 11:09:13 -07003116 @Deprecated
Jeff Sharkey50e74f12019-01-23 22:36:34 -07003117 public static final String ACTION_MEDIA_SCANNER_SCAN_VOLUME = "android.intent.action.MEDIA_SCANNER_SCAN_VOLUME";
3118
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003119 /**
3120 * Broadcast Action: The "Media 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_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3126
3127 /**
3128 * Broadcast Action: The "Camera Button" was pressed. Includes a single
3129 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3130 * caused the broadcast.
3131 */
3132 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3133 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3134
3135 // *** NOTE: @todo(*) The following really should go into a more domain-specific
3136 // location; they are not general-purpose actions.
3137
3138 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003139 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003140 */
3141 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3142 public static final String ACTION_GTALK_SERVICE_CONNECTED =
3143 "android.intent.action.GTALK_CONNECTED";
3144
3145 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09003146 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003147 */
3148 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3149 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3150 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07003151
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003152 /**
3153 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08003154 */
3155 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3156 public static final String ACTION_INPUT_METHOD_CHANGED =
3157 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003158
3159 /**
3160 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3161 * more radios have been turned off or on. The intent will have the following extra value:</p>
3162 * <ul>
3163 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3164 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3165 * turned off</li>
3166 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08003167 *
Peng Xua35b5532016-01-20 00:05:45 -08003168 * <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 -07003169 */
3170 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3171 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3172
3173 /**
3174 * Broadcast Action: Some content providers have parts of their namespace
3175 * where they publish new events or items that the user may be especially
3176 * interested in. For these things, they may broadcast this action when the
3177 * set of interesting items change.
3178 *
3179 * For example, GmailProvider sends this notification when the set of unread
3180 * mail in the inbox changes.
3181 *
3182 * <p>The data of the intent identifies which part of which provider
3183 * changed. When queried through the content resolver, the data URI will
3184 * return the data set in question.
3185 *
3186 * <p>The intent will have the following extra values:
3187 * <ul>
3188 * <li><em>count</em> - The number of items in the data set. This is the
3189 * same as the number of items in the cursor returned by querying the
3190 * data URI. </li>
3191 * </ul>
3192 *
3193 * This intent will be sent at boot (if the count is non-zero) and when the
3194 * data set changes. It is possible for the data set to change without the
3195 * count changing (for example, if a new unread message arrives in the same
3196 * sync operation in which a message is archived). The phone should still
3197 * ring/vibrate/etc as normal in this case.
3198 */
3199 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3200 public static final String ACTION_PROVIDER_CHANGED =
3201 "android.intent.action.PROVIDER_CHANGED";
3202
3203 /**
3204 * Broadcast Action: Wired Headset plugged in or unplugged.
3205 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003206 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3207 * and documentation.
3208 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07003209 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003210 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003211 */
3212 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07003213 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07003214
3215 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07003216 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3217 * <ul>
3218 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3219 * </ul>
3220 *
3221 * <p class="note">This is a protected intent that can only be sent
3222 * by the system.
3223 *
3224 * @hide
3225 */
3226 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3227 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3228 = "android.intent.action.ADVANCED_SETTINGS";
3229
3230 /**
Robin Lee66e5d962014-04-09 16:44:21 +01003231 * Broadcast Action: Sent after application restrictions are changed.
3232 *
3233 * <p class="note">This is a protected intent that can only be sent
3234 * by the system.</p>
3235 */
3236 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3237 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3238 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3239
3240 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003241 * Broadcast Action: An outgoing call is about to be placed.
3242 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07003243 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003244 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07003245 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003246 * the phone number originally intended to be dialed.</li>
3247 * </ul>
3248 * <p>Once the broadcast is finished, the resultData is used as the actual
3249 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07003250 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003251 * outgoing call in turn: for example, a parental control application
3252 * might verify that the user is authorized to place the call at that
3253 * time, then a number-rewriting application might add an area code if
3254 * one was not specified.</p>
3255 * <p>For consistency, any receiver whose purpose is to prohibit phone
3256 * calls should have a priority of 0, to ensure it will see the final
3257 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07003258 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003259 * should have a positive priority.
3260 * Negative priorities are reserved for the system for this broadcast;
3261 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003262 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3263 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003264 * <p>Emergency calls cannot be intercepted using this mechanism, and
3265 * other calls cannot be modified to call emergency numbers using this
3266 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003267 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3268 * call to use their own service instead. Those apps should first prevent
3269 * the call from being placed by setting resultData to <code>null</code>
3270 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003271 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003272 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3273 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003274 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003275 * <p class="note">This is a protected intent that can only be sent
3276 * by the system.
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003277 *
3278 * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3279 * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3280 * This means that attempts to re-write the outgoing call by other apps using this intent will
3281 * be ignored.
3282 * </p>
3283 *
3284 * @deprecated Apps that redirect outgoing calls should use the
3285 * {@link android.telecom.CallRedirectionService} API. Apps that perform call screening
3286 * should use the {@link android.telecom.CallScreeningService} API.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003287 */
Tyler Gunnd8f76c852019-01-15 08:57:57 -08003288 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003289 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3290 public static final String ACTION_NEW_OUTGOING_CALL =
3291 "android.intent.action.NEW_OUTGOING_CALL";
3292
3293 /**
3294 * Broadcast Action: Have the device reboot. This is only for use by
3295 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003296 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003297 * <p class="note">This is a protected intent that can only be sent
3298 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003299 */
3300 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3301 public static final String ACTION_REBOOT =
3302 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003303
Wei Huang97ecc9c2009-05-11 17:44:20 -07003304 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003305 * Broadcast Action: A sticky broadcast for changes in the physical
3306 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003307 *
3308 * <p>The intent will have the following extra values:
3309 * <ul>
3310 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003311 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003312 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003313 * <p>This is intended for monitoring the current physical dock state.
3314 * See {@link android.app.UiModeManager} for the normal API dealing with
3315 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003316 */
3317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3318 public static final String ACTION_DOCK_EVENT =
3319 "android.intent.action.DOCK_EVENT";
3320
3321 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003322 * Broadcast Action: A broadcast when idle maintenance can be started.
3323 * This means that the user is not interacting with the device and is
3324 * not expected to do so soon. Typical use of the idle maintenance is
3325 * to perform somehow expensive tasks that can be postponed at a moment
3326 * when they will not degrade user experience.
3327 * <p>
3328 * <p class="note">In order to keep the device responsive in case of an
3329 * unexpected user interaction, implementations of a maintenance task
3330 * should be interruptible. In such a scenario a broadcast with action
3331 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3332 * should not do the maintenance work in
3333 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3334 * maintenance service by {@link Context#startService(Intent)}. Also
3335 * you should hold a wake lock while your maintenance service is running
3336 * to prevent the device going to sleep.
3337 * </p>
3338 * <p>
3339 * <p class="note">This is a protected intent that can only be sent by
3340 * the system.
3341 * </p>
3342 *
3343 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003344 *
3345 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003346 */
3347 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3348 public static final String ACTION_IDLE_MAINTENANCE_START =
3349 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3350
3351 /**
3352 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3353 * This means that the user was not interacting with the device as a result
3354 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3355 * was sent and now the user started interacting with the device. Typical
3356 * use of the idle maintenance is to perform somehow expensive tasks that
3357 * can be postponed at a moment when they will not degrade user experience.
3358 * <p>
3359 * <p class="note">In order to keep the device responsive in case of an
3360 * unexpected user interaction, implementations of a maintenance task
3361 * should be interruptible. Hence, on receiving a broadcast with this
3362 * action, the maintenance task should be interrupted as soon as possible.
3363 * In other words, you should not do the maintenance work in
3364 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3365 * maintenance service that was started on receiving of
3366 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3367 * lock you acquired when your maintenance service started.
3368 * </p>
3369 * <p class="note">This is a protected intent that can only be sent
3370 * by the system.
3371 *
3372 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003373 *
3374 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003375 */
3376 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3377 public static final String ACTION_IDLE_MAINTENANCE_END =
3378 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3379
3380 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003381 * Broadcast Action: a remote intent is to be broadcasted.
3382 *
3383 * A remote intent is used for remote RPC between devices. The remote intent
3384 * is serialized and sent from one device to another device. The receiving
3385 * device parses the remote intent and broadcasts it. Note that anyone can
3386 * broadcast a remote intent. However, if the intent receiver of the remote intent
3387 * does not trust intent broadcasts from arbitrary intent senders, it should require
3388 * the sender to hold certain permissions so only trusted sender's broadcast will be
3389 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003390 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003391 */
3392 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003393 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003394
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003395 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003396 * Broadcast Action: This is broadcast once when the user is booting after a
3397 * system update. It can be used to perform cleanup or upgrades after a
3398 * system update.
3399 * <p>
3400 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3401 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3402 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3403 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003404 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003405 * @hide
3406 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003407 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003408 public static final String ACTION_PRE_BOOT_COMPLETED =
3409 "android.intent.action.PRE_BOOT_COMPLETED";
3410
Amith Yamasani13593602012-03-22 16:16:17 -07003411 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003412 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003413 * on restricted users. The broadcast intent contains an extra
3414 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3415 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3416 * String[] depending on the restriction type.<p/>
3417 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003418 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3419 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3420 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003421 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3422 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003423 * @see RestrictionEntry
3424 */
3425 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3426 "android.intent.action.GET_RESTRICTION_ENTRIES";
3427
3428 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003429 * Sent the first time a user is starting, to allow system apps to
3430 * perform one time initialization. (This will not be seen by third
3431 * party applications because a newly initialized user does not have any
3432 * third party applications installed for it.) This is sent early in
3433 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003434 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3435 * broadcast, since it is part of a visible user interaction; be as quick
3436 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003437 */
3438 public static final String ACTION_USER_INITIALIZE =
3439 "android.intent.action.USER_INITIALIZE";
3440
3441 /**
3442 * Sent when a user switch is happening, causing the process's user to be
3443 * brought to the foreground. This is only sent to receivers registered
3444 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3445 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003446 * foreground. This is sent as a foreground
3447 * broadcast, since it is part of a visible user interaction; be as quick
3448 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003449 */
3450 public static final String ACTION_USER_FOREGROUND =
3451 "android.intent.action.USER_FOREGROUND";
3452
3453 /**
3454 * Sent when a user switch is happening, causing the process's user to be
3455 * sent to the background. This is only sent to receivers registered
3456 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3457 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003458 * background. This is sent as a foreground
3459 * broadcast, since it is part of a visible user interaction; be as quick
3460 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003461 */
3462 public static final String ACTION_USER_BACKGROUND =
3463 "android.intent.action.USER_BACKGROUND";
3464
3465 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003466 * Broadcast sent to the system when a user is added. Carries an extra
3467 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3468 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003469 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003470 * @hide
3471 */
3472 public static final String ACTION_USER_ADDED =
3473 "android.intent.action.USER_ADDED";
3474
3475 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003476 * Broadcast sent by the system when a user is started. Carries an extra
3477 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003478 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003479 * that has been started. This is sent as a foreground
3480 * broadcast, since it is part of a visible user interaction; be as quick
3481 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003482 * @hide
3483 */
3484 public static final String ACTION_USER_STARTED =
3485 "android.intent.action.USER_STARTED";
3486
3487 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003488 * Broadcast sent when a user is in the process of starting. Carries an extra
3489 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3490 * sent to registered receivers, not manifest receivers. It is sent to all
3491 * users (including the one that is being started). You must hold
3492 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3493 * this broadcast. This is sent as a background broadcast, since
3494 * its result is not part of the primary UX flow; to safely keep track of
3495 * started/stopped state of a user you can use this in conjunction with
3496 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3497 * other user state broadcasts since those are foreground broadcasts so can
3498 * execute in a different order.
3499 * @hide
3500 */
3501 public static final String ACTION_USER_STARTING =
3502 "android.intent.action.USER_STARTING";
3503
3504 /**
3505 * Broadcast sent when a user is going to be stopped. Carries an extra
3506 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3507 * sent to registered receivers, not manifest receivers. It is sent to all
3508 * users (including the one that is being stopped). You must hold
3509 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3510 * this broadcast. The user will not stop until all receivers have
3511 * handled the broadcast. This is sent as a background broadcast, since
3512 * its result is not part of the primary UX flow; to safely keep track of
3513 * started/stopped state of a user you can use this in conjunction with
3514 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3515 * other user state broadcasts since those are foreground broadcasts so can
3516 * execute in a different order.
3517 * @hide
3518 */
3519 public static final String ACTION_USER_STOPPING =
3520 "android.intent.action.USER_STOPPING";
3521
3522 /**
3523 * Broadcast sent to the system when a user is stopped. Carries an extra
3524 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3525 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3526 * specific package. This is only sent to registered receivers, not manifest
3527 * receivers. It is sent to all running users <em>except</em> the one that
3528 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003529 * @hide
3530 */
3531 public static final String ACTION_USER_STOPPED =
3532 "android.intent.action.USER_STOPPED";
3533
3534 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003535 * 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 -07003536 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003537 * one that has been removed. The user will not be completely removed until all receivers have
3538 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003539 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003540 * @hide
3541 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003542 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003543 public static final String ACTION_USER_REMOVED =
3544 "android.intent.action.USER_REMOVED";
3545
3546 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003547 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003548 * the userHandle of the user to become the current one. This is only sent to
3549 * registered receivers, not manifest receivers. It is sent to all running users.
3550 * You must hold
3551 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003552 * @hide
3553 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003554 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003555 public static final String ACTION_USER_SWITCHED =
3556 "android.intent.action.USER_SWITCHED";
3557
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003558 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003559 * Broadcast Action: Sent when the credential-encrypted private storage has
3560 * become unlocked for the target user. This is only sent to registered
3561 * receivers, not manifest receivers.
3562 */
3563 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3564 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3565
3566 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003567 * Broadcast sent to the system when a user's information changes. Carries an extra
3568 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003569 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003570 * @hide
3571 */
3572 public static final String ACTION_USER_INFO_CHANGED =
3573 "android.intent.action.USER_INFO_CHANGED";
3574
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003575 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003576 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3577 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003578 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3579 * that need to display merged content across both primary and managed profiles need to
3580 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003581 * not manifest receivers.
3582 */
3583 public static final String ACTION_MANAGED_PROFILE_ADDED =
3584 "android.intent.action.MANAGED_PROFILE_ADDED";
3585
3586 /**
3587 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003588 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3589 * Only applications (for example Launchers) that need to display merged content across both
3590 * primary and managed profiles need to worry about this broadcast. This is only sent to
3591 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003592 */
3593 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3594 "android.intent.action.MANAGED_PROFILE_REMOVED";
3595
3596 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003597 * Broadcast sent to the primary user when the credential-encrypted private storage for
3598 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3599 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3600 * Launchers) that need to display merged content across both primary and managed profiles
3601 * need to worry about this broadcast. This is only sent to registered receivers,
3602 * not manifest receivers.
3603 */
3604 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3605 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3606
3607 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003608 * Broadcast sent to the primary user when an associated managed profile has become available.
3609 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003610 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3611 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3612 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003613 */
Rubin Xue95057a2016-04-01 16:49:25 +01003614 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3615 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3616
3617 /**
3618 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3619 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3620 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3621 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3622 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3623 */
3624 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3625 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003626
3627 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003628 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3629 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3630 * the device was locked or unlocked.
3631 *
3632 * This is only sent to registered receivers.
3633 *
3634 * @hide
3635 */
3636 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3637 "android.intent.action.DEVICE_LOCKED_CHANGED";
3638
3639 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003640 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3641 */
3642 public static final String ACTION_QUICK_CLOCK =
3643 "android.intent.action.QUICK_CLOCK";
3644
Michael Wright0087a142013-02-05 16:29:39 -08003645 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003646 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003647 * @hide
3648 */
3649 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003650 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003651
Justin Kohd378ad72013-04-01 12:18:26 -07003652 /**
3653 * Broadcast Action: A global button was pressed. Includes a single
3654 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3655 * caused the broadcast.
3656 * @hide
3657 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003658 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003659 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3660
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003661 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003662 * Broadcast Action: Sent when media resource is granted.
3663 * <p>
3664 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3665 * granted.
3666 * </p>
3667 * <p class="note">
3668 * This is a protected intent that can only be sent by the system.
3669 * </p>
3670 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003671 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003672 * </p>
3673 *
3674 * @hide
3675 */
3676 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3677 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3678
3679 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003680 * Broadcast Action: An overlay package has changed. The data contains the
3681 * name of the overlay package which has changed. This is broadcast on all
3682 * changes to the OverlayInfo returned by {@link
3683 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3684 * most common change is a state change that will change whether the
3685 * overlay is enabled or not.
3686 * @hide
3687 */
3688 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3689
3690 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003691 * Activity Action: Allow the user to select and return one or more existing
3692 * documents. When invoked, the system will display the various
3693 * {@link DocumentsProvider} instances installed on the device, letting the
3694 * user interactively navigate through them. These documents include local
3695 * media, such as photos and video, and documents provided by installed
3696 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003697 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003698 * Each document is represented as a {@code content://} URI backed by a
3699 * {@link DocumentsProvider}, which can be opened as a stream with
3700 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3701 * {@link android.provider.DocumentsContract.Document} metadata.
3702 * <p>
3703 * All selected documents are returned to the calling application with
3704 * persistable read and write permission grants. If you want to maintain
3705 * access to the documents across device reboots, you need to explicitly
3706 * take the persistable permissions using
3707 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3708 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003709 * Callers must indicate the acceptable document MIME types through
3710 * {@link #setType(String)}. For example, to select photos, use
3711 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3712 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3713 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003714 * <p>
3715 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003716 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3717 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003718 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003719 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3720 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003721 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003722 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003723 * Callers can set a document URI through
3724 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3725 * location of documents navigator. System will do its best to launch the
3726 * navigator in the specified document if it's a folder, or the folder that
3727 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003728 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003729 * Output: The URI of the item that was picked, returned in
3730 * {@link #getData()}. This must be a {@code content://} URI so that any
3731 * receiver can access it. If multiple documents were selected, they are
3732 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003733 *
3734 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003735 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003736 * @see #ACTION_CREATE_DOCUMENT
3737 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003738 */
3739 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3740 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3741
3742 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003743 * Activity Action: Allow the user to create a new document. When invoked,
3744 * the system will display the various {@link DocumentsProvider} instances
3745 * installed on the device, letting the user navigate through them. The
3746 * returned document may be a newly created document with no content, or it
3747 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003748 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003749 * Each document is represented as a {@code content://} URI backed by a
3750 * {@link DocumentsProvider}, which can be opened as a stream with
3751 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3752 * {@link android.provider.DocumentsContract.Document} metadata.
3753 * <p>
3754 * Callers must indicate the concrete MIME type of the document being
3755 * created by setting {@link #setType(String)}. This MIME type cannot be
3756 * changed after the document is created.
3757 * <p>
3758 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3759 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003760 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003761 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3762 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003763 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003764 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003765 * Callers can set a document URI through
3766 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3767 * location of documents navigator. System will do its best to launch the
3768 * navigator in the specified document if it's a folder, or the folder that
3769 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003770 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003771 * Output: The URI of the item that was created. This must be a
3772 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003773 *
3774 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003775 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003776 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003777 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003778 */
3779 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3780 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3781
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003782 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003783 * Activity Action: Allow the user to pick a directory subtree. When
3784 * invoked, the system will display the various {@link DocumentsProvider}
3785 * instances installed on the device, letting the user navigate through
3786 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003787 * <p>
3788 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003789 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3790 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3791 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003792 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003793 * Callers can set a document URI through
3794 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3795 * location of documents navigator. System will do its best to launch the
3796 * navigator in the specified document if it's a folder, or the folder that
3797 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003798 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003799 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003800 *
3801 * @see DocumentsContract
3802 */
3803 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003804 public static final String
3805 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003806
Abodunrinwa Toki4bad09c2018-10-25 18:12:28 +01003807
3808 /**
3809 * Activity Action: Perform text translation.
3810 * <p>
3811 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3812 * <p>
3813 * Output: nothing.
3814 */
3815 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3816 public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3817
Felipe Lemec7b1f892016-01-15 15:02:31 -08003818 /**
Tony Make1f3ac062018-11-27 14:30:21 +00003819 * Activity Action: Define the meaning of the selected word(s).
3820 * <p>
3821 * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3822 * <p>
3823 * Output: nothing.
3824 */
3825 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3826 public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3827
3828 /**
Peng Xua35b5532016-01-20 00:05:45 -08003829 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3830 * exisiting sensor being disconnected.
3831 *
3832 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3833 *
3834 * {@hide}
3835 */
3836 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3837 public static final String
3838 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3839
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003840 /**
Sam Line707f832017-04-13 17:00:55 -07003841 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003842 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003843 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003844 */
3845 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003846 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003847 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3848
Christopher Tate6597e342015-02-17 12:15:25 -08003849 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003850 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3851 * is about to be performed.
3852 * @hide
3853 */
3854 @SystemApi
3855 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3856 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3857 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3858
3859 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003860 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3861 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3862 *
3863 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3864 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003865 * @hide
3866 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003867 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003868 public static final String EXTRA_FORCE_MASTER_CLEAR =
3869 "android.intent.extra.FORCE_MASTER_CLEAR";
3870
3871 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003872 * A broadcast action to trigger a factory reset.
3873 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003874 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3875 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003876 *
3877 * <p>Not for use by third-party applications.
3878 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003879 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003880 *
3881 * {@hide}
3882 */
3883 @SystemApi
3884 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3885 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3886
3887 /**
3888 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3889 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3890 *
3891 * <p>Not for use by third-party applications.
3892 *
3893 * @hide
3894 */
3895 @SystemApi
3896 public static final String EXTRA_FORCE_FACTORY_RESET =
3897 "android.intent.extra.FORCE_FACTORY_RESET";
3898
3899 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003900 * Broadcast action: report that a settings element is being restored from backup. The intent
3901 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3902 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3903 * is the value of that settings entry prior to the restore operation, and
3904 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3905 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3906 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003907 *
3908 * <p>This broadcast is sent only for settings provider entries known to require special handling
3909 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3910 * the provider's backup agent implementation.
3911 *
3912 * @see #EXTRA_SETTING_NAME
3913 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3914 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003915 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003916 * {@hide}
3917 */
3918 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3919
3920 /** {@hide} */
3921 public static final String EXTRA_SETTING_NAME = "setting_name";
3922 /** {@hide} */
3923 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3924 /** {@hide} */
3925 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003926 /** {@hide} */
3927 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003928
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003929 /**
3930 * Activity Action: Process a piece of text.
3931 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3932 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3933 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3934 */
3935 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3936 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003937
3938 /**
3939 * Broadcast Action: The sim card state has changed.
3940 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3941 * because TelephonyIntents is an internal class.
3942 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003943 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3944 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003945 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003946 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003947 @SystemApi
3948 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3949 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3950
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003951 /**
fionaxu90fee272017-03-31 12:45:12 -07003952 * Broadcast Action: indicate that the phone service state has changed.
3953 * The intent will have the following extra values:</p>
3954 * <p>
3955 * @see #EXTRA_VOICE_REG_STATE
3956 * @see #EXTRA_DATA_REG_STATE
3957 * @see #EXTRA_VOICE_ROAMING_TYPE
3958 * @see #EXTRA_DATA_ROAMING_TYPE
3959 * @see #EXTRA_OPERATOR_ALPHA_LONG
3960 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3961 * @see #EXTRA_OPERATOR_NUMERIC
3962 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3963 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3964 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3965 * @see #EXTRA_MANUAL
3966 * @see #EXTRA_VOICE_RADIO_TECH
3967 * @see #EXTRA_DATA_RADIO_TECH
3968 * @see #EXTRA_CSS_INDICATOR
3969 * @see #EXTRA_NETWORK_ID
3970 * @see #EXTRA_SYSTEM_ID
3971 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3972 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3973 * @see #EXTRA_EMERGENCY_ONLY
3974 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3975 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3976 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3977 *
3978 * <p class="note">
3979 * Requires the READ_PHONE_STATE permission.
3980 *
3981 * <p class="note">This is a protected intent that can only be sent by the system.
3982 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003983 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003984 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3985 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3986 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3987 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003988 */
3989 @Deprecated
3990 @SystemApi
3991 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3992 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3993
3994 /**
3995 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3996 * state.
3997 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3998 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3999 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4000 * @see android.telephony.ServiceState#STATE_POWER_OFF
4001 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004002 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004003 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07004004 */
4005 @Deprecated
4006 @SystemApi
4007 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4008
4009 /**
4010 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4011 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4012 * @see android.telephony.ServiceState#STATE_IN_SERVICE
4013 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4014 * @see android.telephony.ServiceState#STATE_POWER_OFF
4015 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004016 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004017 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07004018 */
4019 @Deprecated
4020 @SystemApi
4021 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4022
4023 /**
4024 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4025 * type.
4026 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004027 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004028 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004029 */
4030 @Deprecated
4031 @SystemApi
4032 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4033
4034 /**
4035 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4036 * type.
4037 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004038 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004039 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07004040 */
4041 @Deprecated
4042 @SystemApi
4043 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4044
4045 /**
4046 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4047 * registered voice operator name in long alphanumeric format.
4048 * {@code null} if the operator name is not known or unregistered.
4049 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004050 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004051 * @deprecated Use
4052 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004053 */
4054 @Deprecated
4055 @SystemApi
4056 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4057
4058 /**
4059 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4060 * registered voice operator name in short alphanumeric format.
4061 * {@code null} if the operator name is not known or unregistered.
4062 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004063 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004064 * @deprecated Use
4065 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004066 */
4067 @Deprecated
4068 @SystemApi
4069 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4070
4071 /**
4072 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4073 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4074 * network.
4075 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004076 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004077 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004078 */
4079 @Deprecated
4080 @SystemApi
4081 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4082
4083 /**
4084 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4085 * registered data operator name in long alphanumeric format.
4086 * {@code null} if the operator name is not known or unregistered.
4087 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004088 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004089 * @deprecated Use
4090 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07004091 */
4092 @Deprecated
4093 @SystemApi
4094 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4095
4096 /**
4097 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4098 * registered data operator name in short alphanumeric format.
4099 * {@code null} if the operator name is not known or unregistered.
4100 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004101 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004102 * @deprecated Use
4103 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07004104 */
4105 @Deprecated
4106 @SystemApi
4107 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4108
4109 /**
4110 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4111 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4112 * data operator.
4113 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004114 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004115 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07004116 */
4117 @Deprecated
4118 @SystemApi
4119 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4120
4121 /**
4122 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4123 * network selection mode is manual.
4124 * Will be {@code true} if manual mode, {@code false} if automatic mode.
4125 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004126 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004127 * @deprecated Use
4128 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07004129 */
4130 @Deprecated
4131 @SystemApi
4132 public static final String EXTRA_MANUAL = "manual";
4133
4134 /**
4135 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4136 * radio technology.
4137 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004138 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004139 * @deprecated Use
4140 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004141 */
4142 @Deprecated
4143 @SystemApi
4144 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4145
4146 /**
4147 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4148 * radio technology.
4149 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004150 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004151 * @deprecated Use
4152 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07004153 */
4154 @Deprecated
4155 @SystemApi
4156 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4157
4158 /**
4159 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4160 * support on CDMA network.
4161 * Will be {@code true} if support, {@code false} otherwise.
4162 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004163 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004164 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004165 */
4166 @Deprecated
4167 @SystemApi
4168 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4169
4170 /**
4171 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4172 * id. {@code Integer.MAX_VALUE} if unknown.
4173 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004174 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004175 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004176 */
4177 @Deprecated
4178 @SystemApi
4179 public static final String EXTRA_NETWORK_ID = "networkId";
4180
4181 /**
4182 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4183 * {@code Integer.MAX_VALUE} if unknown.
4184 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004185 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004186 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07004187 */
4188 @Deprecated
4189 @SystemApi
4190 public static final String EXTRA_SYSTEM_ID = "systemId";
4191
4192 /**
4193 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4194 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4195 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004196 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004197 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004198 */
4199 @Deprecated
4200 @SystemApi
4201 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4202
4203 /**
4204 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4205 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4206 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004207 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004208 * @deprecated Use
4209 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07004210 */
4211 @Deprecated
4212 @SystemApi
4213 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4214
4215 /**
4216 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4217 * only mode.
4218 * {@code true} if in emergency only mode, {@code false} otherwise.
4219 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004220 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004221 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07004222 */
4223 @Deprecated
4224 @SystemApi
4225 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4226
4227 /**
4228 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4229 * registration state is roaming.
4230 * {@code true} if registration indicates roaming, {@code false} otherwise
4231 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004232 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004233 * @deprecated Use
4234 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07004235 */
4236 @Deprecated
4237 @SystemApi
4238 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4239 "isDataRoamingFromRegistration";
4240
4241 /**
4242 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4243 * aggregation is in use.
4244 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4245 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004246 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07004247 * @deprecated Use
4248 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07004249 */
4250 @Deprecated
4251 @SystemApi
4252 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4253
4254 /**
4255 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4256 * is reduced from the rsrp threshold while calculating signal strength level.
4257 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06004258 * @removed
fionaxu90fee272017-03-31 12:45:12 -07004259 */
4260 @Deprecated
4261 @SystemApi
4262 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4263
4264 /**
chen xu02811692018-10-03 19:07:09 -07004265 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
4266 * @hide
4267 */
4268 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4269
4270 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004271 * The name of the extra used to define the text to be processed, as a
4272 * CharSequence. Note that this may be a styled CharSequence, so you must use
4273 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004274 */
4275 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4276 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004277 * 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 +00004278 */
4279 public static final String EXTRA_PROCESS_TEXT_READONLY =
4280 "android.intent.extra.PROCESS_TEXT_READONLY";
4281
Bryce Leebc58f592015-09-25 16:43:01 -07004282 /**
4283 * Broadcast action: reports when a new thermal event has been reached. When the device
4284 * is reaching its maximum temperatue, the thermal level reported
4285 * {@hide}
4286 */
4287 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4288 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4289
4290 /** {@hide} */
4291 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4292
4293 /**
4294 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004295 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004296 * {@hide}
4297 */
4298 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4299
4300 /**
4301 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004302 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004303 * {@hide}
4304 */
4305 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4306
4307 /**
4308 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004309 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004310 * {@hide}
4311 */
4312 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4313
lpeter318abc92018-05-04 16:13:14 +08004314 /**
4315 * Broadcast Action: Indicates the dock in idle state while device is docked.
4316 *
4317 * <p class="note">This is a protected intent that can only be sent
4318 * by the system.
4319 *
4320 * @hide
4321 */
4322 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4323
4324 /**
4325 * Broadcast Action: Indicates the dock in active state while device is docked.
4326 *
4327 * <p class="note">This is a protected intent that can only be sent
4328 * by the system.
4329 *
4330 * @hide
4331 */
4332 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4333
MÃ¥rten Kongstadfd20b832018-10-26 15:36:20 +02004334 /**
4335 * Broadcast Action: Indicates that a new device customization has been
4336 * downloaded and applied (packages installed, runtime resource overlays
4337 * enabled, xml files copied, ...), and that it is time for components that
4338 * need to for example clear their caches to do so now.
4339 *
4340 * @hide
4341 */
4342 @SystemApi
4343 public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4344 "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4345
Bryce Leebc58f592015-09-25 16:43:01 -07004346
Felipe Leme044c63b2019-02-12 14:35:20 -08004347 /**
4348 * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4349 *
4350 * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4351 *
4352 * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4353 * app domain. Should be stable across reboots and backup / restore.
4354 * <p>Output: nothing.
4355 */
4356 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4357 public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4358
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004359 // ---------------------------------------------------------------------
4360 // ---------------------------------------------------------------------
4361 // Standard intent categories (see addCategory()).
4362
4363 /**
4364 * Set if the activity should be an option for the default action
4365 * (center press) to perform on a piece of data. Setting this will
4366 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004367 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004368 * Intent when initiating an action -- it is for use in intent filters
4369 * specified in packages.
4370 */
4371 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4372 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4373 /**
4374 * Activities that can be safely invoked from a browser must support this
4375 * category. For example, if the user is viewing a web page or an e-mail
4376 * and clicks on a link in the text, the Intent generated execute that
4377 * link will require the BROWSABLE category, so that only activities
4378 * supporting this category will be considered as possible actions. By
4379 * supporting this category, you are promising that there is nothing
4380 * damaging (without user intervention) that can happen by invoking any
4381 * matching Intent.
4382 */
4383 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4384 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4385 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004386 * Categories for activities that can participate in voice interaction.
4387 * An activity that supports this category must be prepared to run with
4388 * no UI shown at all (though in some case it may have a UI shown), and
4389 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4390 */
4391 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4392 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4393 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004394 * Set if the activity should be considered as an alternative action to
4395 * the data the user is currently viewing. See also
4396 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4397 * applies to the selection in a list of items.
4398 *
4399 * <p>Supporting this category means that you would like your activity to be
4400 * displayed in the set of alternative things the user can do, usually as
4401 * part of the current activity's options menu. You will usually want to
4402 * include a specific label in the &lt;intent-filter&gt; of this action
4403 * describing to the user what it does.
4404 *
4405 * <p>The action of IntentFilter with this category is important in that it
4406 * describes the specific action the target will perform. This generally
4407 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4408 * a specific name such as "com.android.camera.action.CROP. Only one
4409 * alternative of any particular action will be shown to the user, so using
4410 * a specific action like this makes sure that your alternative will be
4411 * displayed while also allowing other applications to provide their own
4412 * overrides of that particular action.
4413 */
4414 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4415 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4416 /**
4417 * Set if the activity should be considered as an alternative selection
4418 * action to the data the user has currently selected. This is like
4419 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4420 * of items from which the user can select, giving them alternatives to the
4421 * default action that will be performed on it.
4422 */
4423 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4424 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4425 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004426 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004427 */
4428 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4429 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4430 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004431 * Should be displayed in the top-level launcher.
4432 */
4433 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4434 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4435 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004436 * Indicates an activity optimized for Leanback mode, and that should
4437 * be displayed in the Leanback launcher.
4438 */
4439 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4440 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4441 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004442 * Indicates the preferred entry-point activity when an application is launched from a Car
4443 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4444 * fallback, or exclude the application entirely.
4445 * @hide
4446 */
4447 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4448 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4449 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004450 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4451 * @hide
4452 */
4453 @SystemApi
4454 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4455 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004456 * Provides information about the package it is in; typically used if
4457 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4458 * a front-door to the user without having to be shown in the all apps list.
4459 */
4460 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4461 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4462 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004463 * This is the home activity, that is the first activity that is displayed
4464 * when the device boots.
4465 */
4466 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4467 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4468 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004469 * This is the home activity that is displayed when the device is finished setting up and ready
4470 * for use.
4471 * @hide
4472 */
4473 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4474 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4475 /**
Chilun2ef71f72018-11-16 17:57:15 +08004476 * The home activity shown on secondary displays that support showing home activities.
4477 */
4478 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4479 public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4480 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004481 * This is the setup wizard activity, that is the first activity that is displayed
4482 * when the user sets up the device for the first time.
4483 * @hide
4484 */
4485 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4486 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4487 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004488 * This is the home activity, that is the activity that serves as the launcher app
4489 * from there the user can start other apps. Often components with lower/higher
4490 * priority intent filters handle the home intent, for example SetupWizard, to
4491 * setup the device and we need to be able to distinguish the home app from these
4492 * setup helpers.
4493 * @hide
4494 */
4495 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4496 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4497 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004498 * This activity is a preference panel.
4499 */
4500 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4501 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4502 /**
4503 * This activity is a development preference panel.
4504 */
4505 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4506 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4507 /**
4508 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004509 */
4510 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4511 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4512 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004513 * This activity allows the user to browse and download new applications.
4514 */
4515 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4516 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4517 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004518 * This activity may be exercised by the monkey or other automated test tools.
4519 */
4520 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4521 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4522 /**
4523 * To be used as a test (not part of the normal user experience).
4524 */
4525 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4526 /**
4527 * To be used as a unit test (run through the Test Harness).
4528 */
4529 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4530 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004531 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004532 * experience).
4533 */
4534 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004535
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004536 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004537 * Used to indicate that an intent only wants URIs that can be opened with
4538 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4539 * must support at least the columns defined in {@link OpenableColumns} when
4540 * queried.
4541 *
4542 * @see #ACTION_GET_CONTENT
4543 * @see #ACTION_OPEN_DOCUMENT
4544 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004545 */
4546 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4547 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4548
4549 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004550 * Used to indicate that an intent filter can accept files which are not necessarily
4551 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4552 * at least streamable via
4553 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4554 * using one of the stream types exposed via
4555 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4556 *
4557 * @see #ACTION_SEND
4558 * @see #ACTION_SEND_MULTIPLE
4559 */
4560 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4561 public static final String CATEGORY_TYPED_OPENABLE =
4562 "android.intent.category.TYPED_OPENABLE";
4563
4564 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004565 * To be used as code under test for framework instrumentation tests.
4566 */
4567 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4568 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004569 /**
4570 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004571 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4572 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004573 */
4574 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4575 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4576 /**
4577 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004578 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4579 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004580 */
4581 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4582 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004583 /**
4584 * An activity to run when device is inserted into a analog (low end) dock.
4585 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4586 * information, see {@link android.app.UiModeManager}.
4587 */
4588 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4589 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4590
4591 /**
4592 * An activity to run when device is inserted into a digital (high end) dock.
4593 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4594 * information, see {@link android.app.UiModeManager}.
4595 */
4596 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4597 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004598
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004599 /**
4600 * Used to indicate that the activity can be used in a car environment.
4601 */
4602 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4603 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4604
Zak Cohendb6ca492017-01-26 14:09:00 -08004605 /**
4606 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4607 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4608 * information, see {@link android.app.UiModeManager}.
4609 */
4610 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4611 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004612 // ---------------------------------------------------------------------
4613 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004614 // Application launch intent categories (see addCategory()).
4615
4616 /**
4617 * Used with {@link #ACTION_MAIN} to launch the browser application.
4618 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004619 * <p>NOTE: This should not be used as the primary key of an Intent,
4620 * since it will not result in the app launching with the correct
4621 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004622 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004623 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004624 */
4625 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4626 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4627
4628 /**
4629 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4630 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004631 * <p>NOTE: This should not be used as the primary key of an Intent,
4632 * since it will not result in the app launching with the correct
4633 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004634 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004635 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004636 */
4637 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4638 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4639
4640 /**
4641 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4642 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004643 * <p>NOTE: This should not be used as the primary key of an Intent,
4644 * since it will not result in the app launching with the correct
4645 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004646 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004647 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004648 */
4649 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4650 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4651
4652 /**
4653 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4654 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004655 * <p>NOTE: This should not be used as the primary key of an Intent,
4656 * since it will not result in the app launching with the correct
4657 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004658 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004659 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004660 */
4661 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4662 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4663
4664 /**
4665 * Used with {@link #ACTION_MAIN} to launch the email application.
4666 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004667 * <p>NOTE: This should not be used as the primary key of an Intent,
4668 * since it will not result in the app launching with the correct
4669 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004670 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004671 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004672 */
4673 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4674 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4675
4676 /**
4677 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4678 * The activity should be able to view and manipulate image and video files
4679 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004680 * <p>NOTE: This should not be used as the primary key of an Intent,
4681 * since it will not result in the app launching with the correct
4682 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004683 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004684 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004685 */
4686 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4687 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4688
4689 /**
4690 * Used with {@link #ACTION_MAIN} to launch the maps application.
4691 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004692 * <p>NOTE: This should not be used as the primary key of an Intent,
4693 * since it will not result in the app launching with the correct
4694 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004695 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004696 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004697 */
4698 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4699 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4700
4701 /**
4702 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4703 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004704 * <p>NOTE: This should not be used as the primary key of an Intent,
4705 * since it will not result in the app launching with the correct
4706 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004707 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004708 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004709 */
4710 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4711 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4712
4713 /**
4714 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004715 * The activity should be able to play, browse, or manipulate music files
4716 * stored on the device.
4717 * <p>NOTE: This should not be used as the primary key of an Intent,
4718 * since it will not result in the app launching with the correct
4719 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004720 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004721 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004722 */
4723 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4724 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4725
4726 // ---------------------------------------------------------------------
4727 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004728 // Standard extra data keys.
4729
4730 /**
4731 * The initial data to place in a newly created record. Use with
4732 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4733 * fields as would be given to the underlying ContentProvider.insert()
4734 * call.
4735 */
4736 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4737
4738 /**
4739 * A constant CharSequence that is associated with the Intent, used with
4740 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4741 * this may be a styled CharSequence, so you must use
4742 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4743 * retrieve it.
4744 */
4745 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4746
4747 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004748 * A constant String that is associated with the Intent, used with
4749 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4750 * as HTML formatted text. Note that you <em>must</em> also supply
4751 * {@link #EXTRA_TEXT}.
4752 */
4753 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4754
4755 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004756 * A content: URI holding a stream of data associated with the Intent,
4757 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004758 */
4759 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4760
4761 /**
4762 * A String[] holding e-mail addresses that should be delivered to.
4763 */
4764 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4765
4766 /**
4767 * A String[] holding e-mail addresses that should be carbon copied.
4768 */
4769 public static final String EXTRA_CC = "android.intent.extra.CC";
4770
4771 /**
4772 * A String[] holding e-mail addresses that should be blind carbon copied.
4773 */
4774 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4775
4776 /**
4777 * A constant string holding the desired subject line of a message.
4778 */
4779 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4780
4781 /**
4782 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004783 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004784 */
4785 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4786
4787 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004788 * An int representing the user id to be used.
4789 *
4790 * @hide
4791 */
4792 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4793
4794 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004795 * An int representing the task id to be retrieved. This is used when a launch from recents is
4796 * intercepted by another action such as credentials confirmation to remember which task should
4797 * be resumed when complete.
4798 *
4799 * @hide
4800 */
4801 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4802
4803 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004804 * An Intent[] describing additional, alternate choices you would like shown with
4805 * {@link #ACTION_CHOOSER}.
4806 *
4807 * <p>An app may be capable of providing several different payload types to complete a
4808 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4809 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4810 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4811 * photo data or a hosted link where the photos can be viewed.</p>
4812 *
4813 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4814 * first/primary/preferred intent in the set. Additional intents specified in
4815 * this extra are ordered; by default intents that appear earlier in the array will be
4816 * preferred over intents that appear later in the array as matches for the same
4817 * target component. To alter this preference, a calling app may also supply
4818 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4819 */
4820 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4821
4822 /**
Adam Powell52c39212016-04-07 15:14:18 -07004823 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4824 * and omitted from a list of components presented to the user.
4825 *
4826 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4827 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4828 * from your own package or other apps from your organization if the idea of sending to those
4829 * targets would be redundant with other app functionality. Filtered components will not
4830 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4831 */
4832 public static final String EXTRA_EXCLUDE_COMPONENTS
4833 = "android.intent.extra.EXCLUDE_COMPONENTS";
4834
4835 /**
4836 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4837 * describing additional high-priority deep-link targets for the chooser to present to the user.
4838 *
4839 * <p>Targets provided in this way will be presented inline with all other targets provided
4840 * by services from other apps. They will be prioritized before other service targets, but
4841 * after those targets provided by sources that the user has manually pinned to the front.</p>
4842 *
4843 * @see #ACTION_CHOOSER
4844 */
4845 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4846
4847 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004848 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4849 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4850 *
4851 * <p>An app preparing an action for another app to complete may wish to allow the user to
4852 * disambiguate between several options for completing the action based on the chosen target
4853 * or otherwise refine the action before it is invoked.
4854 * </p>
4855 *
4856 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4857 * <ul>
4858 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4859 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4860 * chosen target beyond the first</li>
4861 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4862 * should fill in and send once the disambiguation is complete</li>
4863 * </ul>
4864 */
4865 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4866 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4867
4868 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004869 * An {@code ArrayList} of {@code String} annotations describing content for
4870 * {@link #ACTION_CHOOSER}.
4871 *
4872 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4873 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4874 *
4875 * <p>Annotations should describe the major components or topics of the content. It is up to
4876 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4877 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004878 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4879 * character. Performance on customized annotations can suffer, if they are rarely used for
4880 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4881 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004882 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004883 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004884 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004885 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004886 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004887 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004888 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004889 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004890 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004891 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4892 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4893 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4894 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4895 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004896 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004897 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4898 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004899 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004900 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004901 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004902 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004903 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004904 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004905 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004906 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004907 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004908 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004909 * Christmas and Thanksgiving.</li>
4910 * </ul>
4911 */
4912 public static final String EXTRA_CONTENT_ANNOTATIONS
4913 = "android.intent.extra.CONTENT_ANNOTATIONS";
4914
4915 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004916 * A {@link ResultReceiver} used to return data back to the sender.
4917 *
4918 * <p>Used to complete an app-specific
4919 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4920 *
4921 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4922 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4923 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4924 * when the user selects a target component from the chooser. It is up to the recipient
4925 * to send a result to this ResultReceiver to signal that disambiguation is complete
4926 * and that the chooser should invoke the user's choice.</p>
4927 *
4928 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4929 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4930 * to match and fill in the final Intent or ChooserTarget before starting it.
4931 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4932 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4933 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4934 *
4935 * <p>The result code passed to the ResultReceiver should be
4936 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4937 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4938 * the chooser should finish without starting a target.</p>
4939 */
4940 public static final String EXTRA_RESULT_RECEIVER
4941 = "android.intent.extra.RESULT_RECEIVER";
4942
4943 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004944 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004945 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004946 */
4947 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4948
4949 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004950 * A Parcelable[] of {@link Intent} or
4951 * {@link android.content.pm.LabeledIntent} objects as set with
4952 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4953 * a the front of the list of choices, when shown to the user with a
4954 * {@link #ACTION_CHOOSER}.
4955 */
4956 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4957
4958 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004959 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004960 * @hide
4961 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004962 @SystemApi
4963 public static final String EXTRA_INSTANT_APP_SUCCESS =
4964 "android.intent.extra.INSTANT_APP_SUCCESS";
4965
4966 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004967 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004968 * @hide
4969 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004970 @SystemApi
4971 public static final String EXTRA_INSTANT_APP_FAILURE =
4972 "android.intent.extra.INSTANT_APP_FAILURE";
4973
4974 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004975 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004976 * @hide
4977 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004978 @SystemApi
4979 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4980 "android.intent.extra.INSTANT_APP_HOSTNAME";
4981
4982 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004983 * An opaque token to track instant app resolution.
4984 * @hide
4985 */
4986 @SystemApi
4987 public static final String EXTRA_INSTANT_APP_TOKEN =
4988 "android.intent.extra.INSTANT_APP_TOKEN";
4989
4990 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004991 * The action that triggered an instant application resolution.
4992 * @hide
4993 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004994 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004995 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4996
4997 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004998 * An array of {@link Bundle}s containing details about resolved instant apps..
4999 * @hide
5000 */
5001 @SystemApi
5002 public static final String EXTRA_INSTANT_APP_BUNDLES =
5003 "android.intent.extra.INSTANT_APP_BUNDLES";
5004
5005 /**
5006 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08005007 * installed. This data is populated from the response to
5008 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5009 * instant application resolver.
5010 * @hide
5011 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005012 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08005013 public static final String EXTRA_INSTANT_APP_EXTRAS =
5014 "android.intent.extra.INSTANT_APP_EXTRAS";
5015
5016 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00005017 * A boolean value indicating that the instant app resolver was unable to state with certainty
5018 * that it did or did not have an app for the sanitized {@link Intent} defined at
5019 * {@link #EXTRA_INTENT}.
5020 * @hide
5021 */
5022 @SystemApi
5023 public static final String EXTRA_UNKNOWN_INSTANT_APP =
5024 "android.intent.extra.UNKNOWN_INSTANT_APP";
5025
5026 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08005027 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07005028 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08005029 * @hide
5030 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07005031 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08005032 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5033
5034 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07005035 * The version code of the app to install components from.
5036 * @hide
5037 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005038 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07005039 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5040
5041 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08005042 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07005043 * @hide
5044 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005045 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005046 public static final String EXTRA_CALLING_PACKAGE
5047 = "android.intent.extra.CALLING_PACKAGE";
5048
5049 /**
5050 * Optional calling app provided bundle containing additional launch information the
5051 * installer may use.
5052 * @hide
5053 */
Patrick Baumann159cd022018-01-11 13:25:05 -08005054 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07005055 public static final String EXTRA_VERIFICATION_BUNDLE
5056 = "android.intent.extra.VERIFICATION_BUNDLE";
5057
5058 /**
Adam Powelle49d9392014-07-17 18:45:19 -07005059 * A Bundle forming a mapping of potential target package names to different extras Bundles
5060 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5061 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5062 * be currently installed on the device.
5063 *
5064 * <p>An application may choose to provide alternate extras for the case where a user
5065 * selects an activity from a predetermined set of target packages. If the activity
5066 * the user selects from the chooser belongs to a package with its package name as
5067 * a key in this bundle, the corresponding extras for that package will be merged with
5068 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5069 * extra has the same key as an extra already present in the intent it will overwrite
5070 * the extra from the intent.</p>
5071 *
5072 * <p><em>Examples:</em>
5073 * <ul>
5074 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
5075 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5076 * parameters for that target.</li>
5077 * <li>An application may offer additional metadata for known targets of a given intent
5078 * to pass along information only relevant to that target such as account or content
5079 * identifiers already known to that application.</li>
5080 * </ul></p>
5081 */
5082 public static final String EXTRA_REPLACEMENT_EXTRAS =
5083 "android.intent.extra.REPLACEMENT_EXTRAS";
5084
5085 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07005086 * An {@link IntentSender} that will be notified if a user successfully chooses a target
5087 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5088 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5089 * {@link ComponentName} of the chosen component.
5090 *
5091 * <p>In some situations this callback may never come, for example if the user abandons
5092 * the chooser, switches to another task or any number of other reasons. Apps should not
5093 * be written assuming that this callback will always occur.</p>
5094 */
5095 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5096 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5097
5098 /**
5099 * The {@link ComponentName} chosen by the user to complete an action.
5100 *
5101 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5102 */
5103 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5104
5105 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005106 * A {@link android.view.KeyEvent} object containing the event that
5107 * triggered the creation of the Intent it is in.
5108 */
5109 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5110
5111 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07005112 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5113 * before shutting down.
5114 *
5115 * {@hide}
5116 */
5117 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5118
5119 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07005120 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5121 * requested by the user.
5122 *
5123 * {@hide}
5124 */
5125 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5126 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5127
5128 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09005129 * 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 -07005130 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5131 * of restarting the application.
5132 */
5133 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5134
5135 /**
5136 * A String holding the phone number originally entered in
5137 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5138 * number to call in a {@link android.content.Intent#ACTION_CALL}.
5139 */
5140 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02005141
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005142 /**
5143 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5144 * intents to supply the uid the package had been assigned. Also an optional
5145 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5146 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5147 * purpose.
5148 */
5149 public static final String EXTRA_UID = "android.intent.extra.UID";
5150
5151 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005152 * @hide String array of package names.
5153 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08005154 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08005155 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5156
5157 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005158 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5159 * intents to indicate whether this represents a full uninstall (removing
5160 * both the code and its data) or a partial uninstall (leaving its data,
5161 * implying that this is an update).
5162 */
5163 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07005164
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005165 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07005166 * @hide
5167 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5168 * intents to indicate that at this point the package has been removed for
5169 * all users on the device.
5170 */
5171 public static final String EXTRA_REMOVED_FOR_ALL_USERS
5172 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5173
5174 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005175 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5176 * intents to indicate that this is a replacement of the package, so this
5177 * broadcast will immediately be followed by an add broadcast for a
5178 * different version of the same package.
5179 */
5180 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07005181
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005182 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005183 * Used as an int extra field in {@link android.app.AlarmManager} intents
5184 * to tell the application being invoked how many pending alarms are being
5185 * delievered with the intent. For one-shot alarms this will always be 1.
5186 * For recurring alarms, this might be greater than 1 if the device was
5187 * asleep or powered off at the time an earlier alarm would have been
5188 * delivered.
5189 */
5190 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07005191
Jacek Surazski86b6c532009-05-13 14:38:28 +02005192 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005193 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5194 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07005195 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5196 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005197 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5198 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5199 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005200 */
5201 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5202
5203 /**
5204 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5205 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005206 */
5207 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5208
5209 /**
5210 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5211 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005212 */
5213 public static final int EXTRA_DOCK_STATE_DESK = 1;
5214
5215 /**
5216 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5217 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05005218 */
5219 public static final int EXTRA_DOCK_STATE_CAR = 2;
5220
5221 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05005222 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5223 * to represent that the phone is in a analog (low end) dock.
5224 */
5225 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5226
5227 /**
5228 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5229 * to represent that the phone is in a digital (high end) dock.
5230 */
5231 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5232
5233 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005234 * Boolean that can be supplied as meta-data with a dock activity, to
5235 * indicate that the dock should take over the home key when it is active.
5236 */
5237 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08005238
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07005239 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02005240 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5241 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02005242 */
5243 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5244
5245 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07005246 * Used in the extra field in the remote intent. It's astring token passed with the
5247 * remote intent.
5248 */
5249 public static final String EXTRA_REMOTE_INTENT_TOKEN =
5250 "android.intent.extra.remote_intent_token";
5251
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005252 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005253 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005254 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005255 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08005256 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07005257 "android.intent.extra.changed_component_name";
5258
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005259 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005260 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08005261 * and contains a string array of all of the components that have changed. If
5262 * the state of the overall package has changed, then it will contain an entry
5263 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08005264 */
5265 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5266 "android.intent.extra.changed_component_name_list";
5267
5268 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005269 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005270 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00005271 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5272 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5273 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005274 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005275 */
5276 public static final String EXTRA_CHANGED_PACKAGE_LIST =
5277 "android.intent.extra.changed_package_list";
5278
5279 /**
5280 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08005281 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5282 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005283 * and contains an integer array of uids of all of the components
5284 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08005285 */
5286 public static final String EXTRA_CHANGED_UID_LIST =
5287 "android.intent.extra.changed_uid_list";
5288
5289 /**
Suprabh Shukla79000492018-12-24 17:03:02 -08005290 * An integer denoting a bitwise combination of restrictions set on distracting packages via
5291 * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5292 *
5293 * @hide
5294 * @see PackageManager.DistractionRestriction
5295 * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5296 */
5297 public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5298 "android.intent.extra.distraction_restrictions";
5299
5300 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07005301 * @hide
5302 * Magic extra system code can use when binding, to give a label for
5303 * who it is that has bound to a service. This is an integer giving
5304 * a framework string resource that can be displayed to the user.
5305 */
5306 public static final String EXTRA_CLIENT_LABEL =
5307 "android.intent.extra.client_label";
5308
5309 /**
5310 * @hide
5311 * Magic extra system code can use when binding, to give a PendingIntent object
5312 * that can be launched for the user to disable the system's use of this
5313 * service.
5314 */
5315 public static final String EXTRA_CLIENT_INTENT =
5316 "android.intent.extra.client_intent";
5317
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005318 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005319 * Extra used to indicate that an intent should only return data that is on
5320 * the local device. This is a boolean extra; the default is false. If true,
5321 * an implementation should only allow the user to select data that is
5322 * already on the device, not requiring it be downloaded from a remote
5323 * service when opened.
5324 *
5325 * @see #ACTION_GET_CONTENT
5326 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005327 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005328 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005329 */
5330 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005331 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005332
Amith Yamasani13593602012-03-22 16:16:17 -07005333 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005334 * Extra used to indicate that an intent can allow the user to select and
5335 * return multiple items. This is a boolean extra; the default is false. If
5336 * true, an implementation is allowed to present the user with a UI where
5337 * they can pick multiple items that are all returned to the caller. When
5338 * this happens, they should be returned as the {@link #getClipData()} part
5339 * of the result Intent.
5340 *
5341 * @see #ACTION_GET_CONTENT
5342 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005343 */
5344 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005345 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005346
5347 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005348 * The integer userHandle carried with broadcast intents related to addition, removal and
5349 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5350 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5351 *
Amith Yamasani13593602012-03-22 16:16:17 -07005352 * @hide
5353 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005354 public static final String EXTRA_USER_HANDLE =
5355 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005356
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005357 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005358 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005359 */
5360 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005361 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005362
5363 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005364 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005365 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5366 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005367 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005368 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5369
5370 /**
5371 * Extra sent in the intent to the BroadcastReceiver that handles
5372 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5373 * the restrictions as key/value pairs.
5374 */
5375 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5376 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005377
Amith Yamasani86118ba2013-03-28 14:33:16 -07005378 /**
5379 * Extra used in the response from a BroadcastReceiver that handles
5380 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5381 */
5382 public static final String EXTRA_RESTRICTIONS_INTENT =
5383 "android.intent.extra.restrictions_intent";
5384
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005385 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005386 * Extra used to communicate a set of acceptable MIME types. The type of the
5387 * extra is {@code String[]}. Values may be a combination of concrete MIME
5388 * types (such as "image/png") and/or partial MIME types (such as
5389 * "audio/*").
5390 *
5391 * @see #ACTION_GET_CONTENT
5392 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005393 */
5394 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5395
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005396 /**
5397 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5398 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005399 * When this is true, hardware devices can use this information to determine that
5400 * they shouldn't do a complete shutdown of their device since this is not a
5401 * complete shutdown down to the kernel, but only user space restarting.
5402 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005403 */
5404 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5405 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5406
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005407 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005408 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5409 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5410 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5411 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005412 *
5413 * @hide for internal use only.
5414 */
5415 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5416 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005417 /** @hide */
5418 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5419 /** @hide */
5420 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5421 /** @hide */
5422 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005423
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005424 /**
5425 * Intent extra: the reason that the operation associated with this intent is being performed.
5426 *
5427 * <p>Type: String
5428 * @hide
5429 */
5430 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005431 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5432
qingxi240c2bb2017-04-12 17:31:18 -07005433 /**
5434 * {@hide}
5435 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5436 */
Rubin Xue8490f12015-06-25 12:17:48 +01005437 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5438
Santos Cordon15a13782015-03-31 18:32:31 -07005439 /**
qingxi240c2bb2017-04-12 17:31:18 -07005440 * {@hide}
5441 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5442 * reset for the device with eSIM. This extra will be sent together with
5443 * {@link #ACTION_FACTORY_RESET}
5444 */
5445 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5446
5447 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005448 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5449 * activation request.
5450 * TODO: Add information about the structure and response data used with the pending intent.
5451 * @hide
5452 */
5453 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5454 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5455
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005456 /**
5457 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005458 *
5459 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005460 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005461 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005462 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5463
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005464 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005465 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5466 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5467 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005468 *
5469 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005470 * @see #ACTION_QUICK_VIEW
5471 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005472 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005473 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005474 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5475 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005476
5477 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005478 * An optional extra of {@code String[]} indicating which quick view features should be made
5479 * available to the user in the quick view UI while handing a
5480 * {@link Intent#ACTION_QUICK_VIEW} intent.
5481 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5482 * Quick viewer can implement features not listed below.
5483 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005484 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5485 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5486 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005487 * <p>
5488 * Requirements:
5489 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5490 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5491 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5492 * internal policies.
5493 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5494 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5495 * disable or hide features.
5496 *
5497 * @see #ACTION_QUICK_VIEW
5498 */
5499 public static final String EXTRA_QUICK_VIEW_FEATURES =
5500 "android.intent.extra.QUICK_VIEW_FEATURES";
5501
5502 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005503 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005504 * When a profile goes into quiet mode, all apps in the profile are killed and the
5505 * profile user is stopped. Widgets originating from the profile are masked, and app
5506 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005507 */
5508 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005509
5510 /**
Amin Shaikh710d1232018-11-14 16:58:13 -05005511 * Optional CharSequence extra to provide a search query.
Amin Shaikh5fdc89c2018-12-06 15:50:21 -05005512 * The format of this query is dependent on the receiving application.
Amin Shaikh710d1232018-11-14 16:58:13 -05005513 *
5514 * <p>Applicable to {@link Intent} with actions:
5515 * <ul>
5516 * <li>{@link Intent#ACTION_GET_CONTENT}</li>
5517 * <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5518 * </ul>
5519 */
5520 public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5521
5522 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005523 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005524 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005525 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5526 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005527 *
5528 * @hide
5529 */
5530 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5531 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5532
5533 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005534 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5535 * whether to show the chooser or not when there is only one application available
5536 * to choose from.
Ben Lin145b0ca2016-10-14 14:23:40 -07005537 */
5538 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5539 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5540
5541 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005542 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005543 * to represent that a video codec is allowed to use.
5544 *
5545 * @hide
5546 */
5547 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5548
5549 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005550 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005551 * to represent that a audio codec is allowed to use.
5552 *
5553 * @hide
5554 */
5555 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5556
Felipe Leme044c63b2019-02-12 14:35:20 -08005557 /**
5558 * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
5559 *
5560 * <p>
5561 * Type: {@link LocusId}
5562 * </p>
5563 */
5564 public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
5565
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005566 // ---------------------------------------------------------------------
5567 // ---------------------------------------------------------------------
5568 // Intent flags (see mFlags variable).
5569
Tor Norbyed9273d62013-05-30 15:59:53 -07005570 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005571 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005572 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5573 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005574 @Retention(RetentionPolicy.SOURCE)
5575 public @interface GrantUriMode {}
5576
Jeff Sharkey846318a2014-04-04 12:12:41 -07005577 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005578 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005579 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5580 @Retention(RetentionPolicy.SOURCE)
5581 public @interface AccessUriMode {}
5582
5583 /**
5584 * Test if given mode flags specify an access mode, which must be at least
5585 * read and/or write.
5586 *
5587 * @hide
5588 */
5589 public static boolean isAccessUriMode(int modeFlags) {
5590 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5591 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5592 }
5593
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005594 /** @hide */
5595 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5596 FLAG_GRANT_READ_URI_PERMISSION,
5597 FLAG_GRANT_WRITE_URI_PERMISSION,
5598 FLAG_FROM_BACKGROUND,
5599 FLAG_DEBUG_LOG_RESOLUTION,
5600 FLAG_EXCLUDE_STOPPED_PACKAGES,
5601 FLAG_INCLUDE_STOPPED_PACKAGES,
5602 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5603 FLAG_GRANT_PREFIX_URI_PERMISSION,
5604 FLAG_DEBUG_TRIAGED_MISSING,
5605 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005606 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005607 FLAG_ACTIVITY_NO_HISTORY,
5608 FLAG_ACTIVITY_SINGLE_TOP,
5609 FLAG_ACTIVITY_NEW_TASK,
5610 FLAG_ACTIVITY_MULTIPLE_TASK,
5611 FLAG_ACTIVITY_CLEAR_TOP,
5612 FLAG_ACTIVITY_FORWARD_RESULT,
5613 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5614 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5615 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5616 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5617 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5618 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5619 FLAG_ACTIVITY_NEW_DOCUMENT,
5620 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5621 FLAG_ACTIVITY_NO_USER_ACTION,
5622 FLAG_ACTIVITY_REORDER_TO_FRONT,
5623 FLAG_ACTIVITY_NO_ANIMATION,
5624 FLAG_ACTIVITY_CLEAR_TASK,
5625 FLAG_ACTIVITY_TASK_ON_HOME,
5626 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5627 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5628 FLAG_RECEIVER_REGISTERED_ONLY,
5629 FLAG_RECEIVER_REPLACE_PENDING,
5630 FLAG_RECEIVER_FOREGROUND,
5631 FLAG_RECEIVER_NO_ABORT,
5632 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5633 FLAG_RECEIVER_BOOT_UPGRADE,
5634 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5635 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5636 FLAG_RECEIVER_FROM_SHELL,
5637 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005638 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005639 })
5640 @Retention(RetentionPolicy.SOURCE)
5641 public @interface Flags {}
5642
5643 /** @hide */
5644 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5645 FLAG_FROM_BACKGROUND,
5646 FLAG_DEBUG_LOG_RESOLUTION,
5647 FLAG_EXCLUDE_STOPPED_PACKAGES,
5648 FLAG_INCLUDE_STOPPED_PACKAGES,
5649 FLAG_DEBUG_TRIAGED_MISSING,
5650 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005651 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005652 FLAG_ACTIVITY_NO_HISTORY,
5653 FLAG_ACTIVITY_SINGLE_TOP,
5654 FLAG_ACTIVITY_NEW_TASK,
5655 FLAG_ACTIVITY_MULTIPLE_TASK,
5656 FLAG_ACTIVITY_CLEAR_TOP,
5657 FLAG_ACTIVITY_FORWARD_RESULT,
5658 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5659 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5660 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5661 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5662 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5663 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5664 FLAG_ACTIVITY_NEW_DOCUMENT,
5665 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5666 FLAG_ACTIVITY_NO_USER_ACTION,
5667 FLAG_ACTIVITY_REORDER_TO_FRONT,
5668 FLAG_ACTIVITY_NO_ANIMATION,
5669 FLAG_ACTIVITY_CLEAR_TASK,
5670 FLAG_ACTIVITY_TASK_ON_HOME,
5671 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5672 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5673 FLAG_RECEIVER_REGISTERED_ONLY,
5674 FLAG_RECEIVER_REPLACE_PENDING,
5675 FLAG_RECEIVER_FOREGROUND,
5676 FLAG_RECEIVER_NO_ABORT,
5677 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5678 FLAG_RECEIVER_BOOT_UPGRADE,
5679 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5680 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5681 FLAG_RECEIVER_FROM_SHELL,
5682 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
Ng Zhi An150a6ba2018-08-13 09:08:11 -07005683 FLAG_RECEIVER_OFFLOAD,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005684 })
5685 @Retention(RetentionPolicy.SOURCE)
5686 public @interface MutableFlags {}
5687
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005688 /**
5689 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005690 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005691 * specified in its ClipData. When applying to an Intent's ClipData,
5692 * all URIs as well as recursive traversals through data or other ClipData
5693 * in Intent items will be granted; only the grant flags of the top-level
5694 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005695 */
5696 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5697 /**
5698 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005699 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005700 * specified in its ClipData. When applying to an Intent's ClipData,
5701 * all URIs as well as recursive traversals through data or other ClipData
5702 * in Intent items will be granted; only the grant flags of the top-level
5703 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005704 */
5705 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5706 /**
5707 * Can be set by the caller to indicate that this Intent is coming from
5708 * a background operation, not from direct user interaction.
5709 */
5710 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5711 /**
5712 * A flag you can enable for debugging: when set, log messages will be
5713 * printed during the resolution of this intent to show you what has
5714 * been found to create the final resolved list.
5715 */
5716 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005717 /**
5718 * If set, this intent will not match any components in packages that
5719 * are currently stopped. If this is not set, then the default behavior
5720 * is to include such applications in the result.
5721 */
5722 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5723 /**
5724 * If set, this intent will always match any components in packages that
5725 * are currently stopped. This is the default behavior when
5726 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5727 * flags are set, this one wins (it allows overriding of exclude for
5728 * places where the framework may automatically set the exclude flag).
5729 */
5730 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005731
5732 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005733 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005734 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005735 * persisted across device reboots until explicitly revoked with
5736 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5737 * grant for possible persisting; the receiving application must call
5738 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5739 * actually persist.
5740 *
5741 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5742 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5743 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005744 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005745 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005746 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005747
5748 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005749 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5750 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5751 * applies to any URI that is a prefix match against the original granted
5752 * URI. (Without this flag, the URI must match exactly for access to be
5753 * granted.) Another URI is considered a prefix match only when scheme,
5754 * authority, and all path segments defined by the prefix are an exact
5755 * match.
5756 */
5757 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5758
5759 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005760 * Flag used to automatically match intents based on their Direct Boot
5761 * awareness and the current user state.
5762 * <p>
5763 * Since the default behavior is to automatically apply the current user
5764 * state, this is effectively a sentinel value that doesn't change the
5765 * output of any queries based on its presence or absence.
5766 * <p>
5767 * Instead, this value can be useful in conjunction with
5768 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5769 * to detect when a caller is relying on implicit automatic matching,
5770 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005771 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005772 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5773
5774 /** {@hide} */
5775 @Deprecated
5776 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005777
5778 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005779 * Internal flag used to indicate ephemeral applications should not be
5780 * considered when resolving the intent.
5781 *
5782 * @hide
5783 */
5784 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5785
5786 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005787 * If set, the new activity is not kept in the history stack. As soon as
5788 * the user navigates away from it, the activity is finished. This may also
5789 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5790 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005791 *
5792 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5793 * is never invoked when the current activity starts a new activity which
5794 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005795 */
5796 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5797 /**
5798 * If set, the activity will not be launched if it is already running
5799 * at the top of the history stack.
5800 */
5801 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5802 /**
5803 * If set, this activity will become the start of a new task on this
5804 * history stack. A task (from the activity that started it to the
5805 * next task activity) defines an atomic group of activities that the
5806 * user can move to. Tasks can be moved to the foreground and background;
5807 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005808 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005809 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5810 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005811 *
5812 * <p>This flag is generally used by activities that want
5813 * to present a "launcher" style behavior: they give the user a list of
5814 * separate things that can be done, which otherwise run completely
5815 * independently of the activity launching them.
5816 *
5817 * <p>When using this flag, if a task is already running for the activity
5818 * you are now starting, then a new activity will not be started; instead,
5819 * the current task will simply be brought to the front of the screen with
5820 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5821 * to disable this behavior.
5822 *
5823 * <p>This flag can not be used when the caller is requesting a result from
5824 * the activity being launched.
5825 */
5826 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5827 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005828 * This flag is used to create a new task and launch an activity into it.
5829 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5830 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5831 * search through existing tasks for ones matching this Intent. Only if no such
5832 * task is found would a new task be created. When paired with
5833 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5834 * the search for a matching task and unconditionally start a new task.
5835 *
5836 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5837 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005838 * top-level application launcher.</strong> Used in conjunction with
5839 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5840 * behavior of bringing an existing task to the foreground. When set,
5841 * a new task is <em>always</em> started to host the Activity for the
5842 * Intent, regardless of whether there is already an existing task running
5843 * the same thing.
5844 *
5845 * <p><strong>Because the default system does not include graphical task management,
5846 * you should not use this flag unless you provide some way for a user to
5847 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005848 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005849 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5850 * creating new document tasks.
5851 *
5852 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005853 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005854 *
Scott Main7aee61f2011-02-08 11:25:01 -08005855 * <p>See
5856 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5857 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005858 *
5859 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5860 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005861 */
5862 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5863 /**
5864 * If set, and the activity being launched is already running in the
5865 * current task, then instead of launching a new instance of that activity,
5866 * all of the other activities on top of it will be closed and this Intent
5867 * will be delivered to the (now on top) old activity as a new Intent.
5868 *
5869 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5870 * If D calls startActivity() with an Intent that resolves to the component
5871 * of activity B, then C and D will be finished and B receive the given
5872 * Intent, resulting in the stack now being: A, B.
5873 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005874 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005875 * either receive the new intent you are starting here in its
5876 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005877 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005878 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5879 * the same intent, then it will be finished and re-created; for all other
5880 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5881 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005882 *
5883 * <p>This launch mode can also be used to good effect in conjunction with
5884 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5885 * of a task, it will bring any currently running instance of that task
5886 * to the foreground, and then clear it to its root state. This is
5887 * especially useful, for example, when launching an activity from the
5888 * notification manager.
5889 *
Scott Main7aee61f2011-02-08 11:25:01 -08005890 * <p>See
5891 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5892 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005893 */
5894 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5895 /**
5896 * If set and this intent is being used to launch a new activity from an
5897 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005898 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005899 * {@link android.app.Activity#setResult} and have that result sent back to
5900 * the reply target of the original activity.
5901 */
5902 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5903 /**
5904 * If set and this intent is being used to launch a new activity from an
5905 * existing one, the current activity will not be counted as the top
5906 * activity for deciding whether the new intent should be delivered to
5907 * the top instead of starting a new one. The previous activity will
5908 * be used as the top, with the assumption being that the current activity
5909 * will finish itself immediately.
5910 */
5911 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5912 /**
5913 * If set, the new activity is not kept in the list of recently launched
5914 * activities.
5915 */
5916 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5917 /**
5918 * This flag is not normally set by application code, but set for you by
5919 * the system as described in the
5920 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5921 * launchMode} documentation for the singleTask mode.
5922 */
5923 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5924 /**
5925 * If set, and this activity is either being started in a new task or
5926 * bringing to the top an existing task, then it will be launched as
5927 * the front door of the task. This will result in the application of
5928 * any affinities needed to have that task in the proper state (either
5929 * moving activities to or from it), or simply resetting that task to
5930 * its initial state if needed.
5931 */
5932 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5933 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005934 * This flag is not normally set by application code, but set for you by
5935 * the system if this activity is being launched from history
5936 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005937 */
5938 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005939 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005940 * @deprecated As of API 21 this performs identically to
5941 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005942 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005943 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005944 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005945 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005946 * This flag is used to open a document into a new task rooted at the activity launched
5947 * by this Intent. Through the use of this flag, or its equivalent attribute,
5948 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005949 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005950 *
Craig Mautner026596b2014-05-21 15:35:44 -07005951 * <p>The use of the activity attribute form of this,
5952 * {@link android.R.attr#documentLaunchMode}, is
5953 * preferred over the Intent flag described here. The attribute form allows the
5954 * Activity to specify multiple document behavior for all launchers of the Activity
5955 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005956 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005957 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5958 * it is kept after the activity is finished is different than the use of
5959 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5960 * this flag is being used to create a new recents entry, then by default that entry
5961 * will be removed once the activity is finished. You can modify this behavior with
5962 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5963 *
Craig Mautner026596b2014-05-21 15:35:44 -07005964 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5965 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5966 * equivalent of the Activity manifest specifying {@link
5967 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5968 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5969 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005970 *
Craig Mautner026596b2014-05-21 15:35:44 -07005971 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005972 *
Craig Mautner026596b2014-05-21 15:35:44 -07005973 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005974 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5975 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005976 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005977 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005978 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005979 * callback from occurring on the current frontmost activity before it is
5980 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005981 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005982 * <p>Typically, an activity can rely on that callback to indicate that an
5983 * explicit user action has caused their activity to be moved out of the
5984 * foreground. The callback marks an appropriate point in the activity's
5985 * lifecycle for it to dismiss any notifications that it intends to display
5986 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005987 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005988 * <p>If an activity is ever started via any non-user-driven events such as
5989 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5990 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005991 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005992 */
5993 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005994 /**
5995 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5996 * this flag will cause the launched activity to be brought to the front of its
5997 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005998 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005999 * <p>For example, consider a task consisting of four activities: A, B, C, D.
6000 * If D calls startActivity() with an Intent that resolves to the component
6001 * of activity B, then B will be brought to the front of the history stack,
6002 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07006003 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006004 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07006005 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006006 */
6007 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006008 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07006009 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6010 * this flag will prevent the system from applying an activity transition
6011 * animation to go to the next activity state. This doesn't mean an
6012 * animation will never run -- if another activity change happens that doesn't
6013 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006014 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07006015 * when you are going to do a series of activity operations but the
6016 * animation seen by the user shouldn't be driven by the first activity
6017 * change but rather a later one.
6018 */
6019 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6020 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08006021 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6022 * this flag will cause any existing task that would be associated with the
6023 * activity to be cleared before the activity is started. That is, the activity
6024 * becomes the new root of an otherwise empty task, and any old activities
6025 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6026 */
6027 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6028 /**
6029 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6030 * this flag will cause a newly launching task to be placed on top of the current
6031 * home activity task (if there is one). That is, pressing back from the task
6032 * will always return the user to home even if that was not the last activity they
6033 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6034 */
6035 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6036 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07006037 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6038 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006039 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07006040 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07006041 * this flag. When set and the task's activity is finished, the recents
6042 * entry will remain in the interface for the user to re-launch it, like a
6043 * recents entry for a top-level application.
6044 * <p>
6045 * The receiving activity can override this request with
6046 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6047 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07006048 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07006049 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07006050 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07006051
6052 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006053 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
6054 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08006055 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6056 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006057 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08006058 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006059
Patrick Baumann577d4022018-01-31 16:55:10 +00006060
6061 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07006062 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6063 * this flag will attempt to launch an instant app if no full app on the device can already
6064 * handle the intent.
6065 * <p>
6066 * When attempting to resolve instant apps externally, the following {@link Intent} properties
6067 * are supported:
6068 * <ul>
6069 * <li>{@link Intent#setAction(String)}</li>
6070 * <li>{@link Intent#addCategory(String)}</li>
6071 * <li>{@link Intent#setData(Uri)}</li>
6072 * <li>{@link Intent#setType(String)}</li>
6073 * <li>{@link Intent#setPackage(String)}</li>
6074 * <li>{@link Intent#addFlags(int)}</li>
6075 * </ul>
6076 * <p>
6077 * In the case that no instant app can be found, the installer will be launched to notify the
6078 * user that the intent could not be resolved. On devices that do not support instant apps,
6079 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00006080 */
6081 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6082
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08006083 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006084 * If set, when sending a broadcast only registered receivers will be
6085 * called -- no BroadcastReceiver components will be launched.
6086 */
6087 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006088 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006089 * If set, when sending a broadcast the new broadcast will replace
6090 * any existing pending broadcast that matches it. Matching is defined
6091 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6092 * true for the intents of the two broadcasts. When a match is found,
6093 * the new broadcast (and receivers associated with it) will replace the
6094 * existing one in the pending broadcast list, remaining at the same
6095 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08006096 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08006097 * <p>This flag is most typically used with sticky broadcasts, which
6098 * only care about delivering the most recent values of the broadcast
6099 * to their receivers.
6100 */
6101 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6102 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08006103 * If set, when sending a broadcast the recipient is allowed to run at
6104 * foreground priority, with a shorter timeout interval. During normal
6105 * broadcasts the receivers are not automatically hoisted out of the
6106 * background priority class.
6107 */
6108 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6109 /**
Ng Zhi An150a6ba2018-08-13 09:08:11 -07006110 * If set, when sending a broadcast the recipient will be run on the offload queue.
6111 *
6112 * @hide
6113 */
6114 public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6115 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07006116 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6117 * They can still propagate results through to later receivers, but they can not prevent
6118 * later receivers from seeing the broadcast.
6119 */
6120 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6121 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006122 * If set, when sending a broadcast <i>before boot has completed</i> only
6123 * registered receivers will be called -- no BroadcastReceiver components
6124 * will be launched. Sticky intent state will be recorded properly even
6125 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6126 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07006127 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006128 * <p>This flag is only for use by system sevices as a convenience to
6129 * avoid having to implement a more complex mechanism around detection
6130 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07006131 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08006132 * @hide
6133 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006134 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07006135 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07006136 /**
6137 * Set when this broadcast is for a boot upgrade, a special mode that
6138 * allows the broadcast to be sent before the system is ready and launches
6139 * the app process with no providers running in it.
6140 * @hide
6141 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07006142 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006143 /**
6144 * If set, the broadcast will always go to manifest receivers in background (cached
6145 * or not running) apps, regardless of whether that would be done by default. By
6146 * default they will only receive broadcasts if the broadcast has specified an
6147 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08006148 *
6149 * NOTE: dumpstate uses this flag numerically, so when its value is changed
6150 * the broadcast code there must also be changed to match.
6151 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08006152 * @hide
6153 */
6154 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6155 /**
6156 * If set, the broadcast will never go to manifest receivers in background (cached
6157 * or not running) apps, regardless of whether that would be done by default. By
6158 * default they will receive broadcasts if the broadcast has specified an
6159 * explicit component or package name.
6160 * @hide
6161 */
6162 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07006163 /**
6164 * If set, this broadcast is being sent from the shell.
6165 * @hide
6166 */
6167 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006168
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006169 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08006170 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6171 * will not receive broadcasts.
6172 *
6173 * <em>This flag has no effect when used by an Instant App.</em>
6174 */
6175 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6176
6177 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07006178 * @hide Flags that can't be changed with PendingIntent.
6179 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07006180 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6181 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6182 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08006183
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006184 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006185 // ---------------------------------------------------------------------
6186 // toUri() and parseUri() options.
6187
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006188 /** @hide */
6189 @IntDef(flag = true, prefix = { "URI_" }, value = {
6190 URI_ALLOW_UNSAFE,
6191 URI_ANDROID_APP_SCHEME,
6192 URI_INTENT_SCHEME,
6193 })
6194 @Retention(RetentionPolicy.SOURCE)
6195 public @interface UriFlags {}
6196
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006197 /**
6198 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6199 * always has the "intent:" scheme. This syntax can be used when you want
6200 * to later disambiguate between URIs that are intended to describe an
6201 * Intent vs. all others that should be treated as raw URIs. When used
6202 * with {@link #parseUri}, any other scheme will result in a generic
6203 * VIEW action for that raw URI.
6204 */
6205 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08006206
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006207 /**
6208 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6209 * always has the "android-app:" scheme. This is a variation of
6210 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6211 * http/https URI being delivered to a specific package name. The format
6212 * is:
6213 *
6214 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006215 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006216 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08006217 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
6218 * you must also include a scheme; including a path also requires both a host and a scheme.
6219 * The final #Intent; fragment can be used without a scheme, host, or path.
6220 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006221 * used with intents that have a {@link #setSelector}, since the base intent
6222 * will always have an explicit package name.</p>
6223 *
6224 * <p>Some examples of how this scheme maps to Intent objects:</p>
6225 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6226 * <colgroup align="left" />
6227 * <colgroup align="left" />
6228 * <thead>
6229 * <tr><th>URI</th> <th>Intent</th></tr>
6230 * </thead>
6231 *
6232 * <tbody>
6233 * <tr><td><code>android-app://com.example.app</code></td>
6234 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6235 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6236 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6237 * </table></td>
6238 * </tr>
6239 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6240 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6241 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6242 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6243 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6244 * </table></td>
6245 * </tr>
6246 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6247 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6248 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6249 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6250 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6251 * </table></td>
6252 * </tr>
6253 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6254 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6255 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6256 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6257 * </table></td>
6258 * </tr>
6259 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6260 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6261 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6262 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6263 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6264 * </table></td>
6265 * </tr>
6266 * <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>
6267 * <td><table border="" style="margin:0" >
6268 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6269 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6270 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6271 * </table></td>
6272 * </tr>
6273 * </tbody>
6274 * </table>
6275 */
6276 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6277
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006278 /**
6279 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6280 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6281 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6282 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6283 * generated Intent can not cause unexpected data access to happen.
6284 *
6285 * <p>If you do not trust the source of the URI being parsed, you should still do further
6286 * processing to protect yourself from it. In particular, when using it to start an
6287 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6288 * that can handle it.</p>
6289 */
6290 public static final int URI_ALLOW_UNSAFE = 1<<2;
6291
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006292 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006293
6294 private String mAction;
6295 private Uri mData;
6296 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006297 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006298 private ComponentName mComponent;
6299 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07006300 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006301 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006302 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006303 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006304 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006305 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01006306 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07006307 /** Token to track instant app launches. Local only; do not copy cross-process. */
6308 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006309
6310 // ---------------------------------------------------------------------
6311
Makoto Onuki97f82f22017-05-31 16:20:21 -07006312 private static final int COPY_MODE_ALL = 0;
6313 private static final int COPY_MODE_FILTER = 1;
6314 private static final int COPY_MODE_HISTORY = 2;
6315
6316 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07006317 @IntDef(prefix = { "COPY_MODE_" }, value = {
6318 COPY_MODE_ALL,
6319 COPY_MODE_FILTER,
6320 COPY_MODE_HISTORY
6321 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07006322 @Retention(RetentionPolicy.SOURCE)
6323 public @interface CopyMode {}
6324
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006325 /**
6326 * Create an empty intent.
6327 */
6328 public Intent() {
6329 }
6330
6331 /**
6332 * Copy constructor.
6333 */
6334 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006335 this(o, COPY_MODE_ALL);
6336 }
6337
6338 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006339 this.mAction = o.mAction;
6340 this.mData = o.mData;
6341 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006342 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006343 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006344
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006345 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006346 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006347 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006348
6349 if (copyMode != COPY_MODE_FILTER) {
6350 this.mFlags = o.mFlags;
6351 this.mContentUserHint = o.mContentUserHint;
6352 this.mLaunchToken = o.mLaunchToken;
6353 if (o.mSourceBounds != null) {
6354 this.mSourceBounds = new Rect(o.mSourceBounds);
6355 }
6356 if (o.mSelector != null) {
6357 this.mSelector = new Intent(o.mSelector);
6358 }
6359
6360 if (copyMode != COPY_MODE_HISTORY) {
6361 if (o.mExtras != null) {
6362 this.mExtras = new Bundle(o.mExtras);
6363 }
6364 if (o.mClipData != null) {
6365 this.mClipData = new ClipData(o.mClipData);
6366 }
6367 } else {
6368 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6369 this.mExtras = Bundle.STRIPPED;
6370 }
6371
6372 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6373 // history.
6374 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006375 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006376 }
6377
6378 @Override
6379 public Object clone() {
6380 return new Intent(this);
6381 }
6382
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006383 /**
6384 * Make a clone of only the parts of the Intent that are relevant for
6385 * filter matching: the action, data, type, component, and categories.
6386 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006387 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006388 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006389 }
6390
6391 /**
6392 * Create an intent with a given action. All other fields (data, type,
6393 * class) are null. Note that the action <em>must</em> be in a
6394 * namespace because Intents are used globally in the system -- for
6395 * example the system VIEW action is android.intent.action.VIEW; an
6396 * application's custom action would be something like
6397 * com.google.app.myapp.CUSTOM_ACTION.
6398 *
6399 * @param action The Intent action, such as ACTION_VIEW.
6400 */
6401 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006402 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006403 }
6404
6405 /**
6406 * Create an intent with a given action and for a given data url. Note
6407 * that the action <em>must</em> be in a namespace because Intents are
6408 * used globally in the system -- for example the system VIEW action is
6409 * android.intent.action.VIEW; an application's custom action would be
6410 * something like com.google.app.myapp.CUSTOM_ACTION.
6411 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006412 * <p><em>Note: scheme and host name matching in the Android framework is
6413 * case-sensitive, unlike the formal RFC. As a result,
6414 * you should always ensure that you write your Uri with these elements
6415 * using lower case letters, and normalize any Uris you receive from
6416 * outside of Android to ensure the scheme and host is lower case.</em></p>
6417 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006418 * @param action The Intent action, such as ACTION_VIEW.
6419 * @param uri The Intent data URI.
6420 */
6421 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006422 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006423 mData = uri;
6424 }
6425
6426 /**
6427 * Create an intent for a specific component. All other fields (action, data,
6428 * type, class) are null, though they can be modified later with explicit
6429 * calls. This provides a convenient way to create an intent that is
6430 * intended to execute a hard-coded class name, rather than relying on the
6431 * system to find an appropriate class for you; see {@link #setComponent}
6432 * for more information on the repercussions of this.
6433 *
6434 * @param packageContext A Context of the application package implementing
6435 * this class.
6436 * @param cls The component class that is to be used for the intent.
6437 *
6438 * @see #setClass
6439 * @see #setComponent
6440 * @see #Intent(String, android.net.Uri , Context, Class)
6441 */
6442 public Intent(Context packageContext, Class<?> cls) {
6443 mComponent = new ComponentName(packageContext, cls);
6444 }
6445
6446 /**
6447 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006448 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006449 * construct the Intent and then calling {@link #setClass} to set its
6450 * class.
6451 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006452 * <p><em>Note: scheme and host name matching in the Android framework is
6453 * case-sensitive, unlike the formal RFC. As a result,
6454 * you should always ensure that you write your Uri with these elements
6455 * using lower case letters, and normalize any Uris you receive from
6456 * outside of Android to ensure the scheme and host is lower case.</em></p>
6457 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006458 * @param action The Intent action, such as ACTION_VIEW.
6459 * @param uri The Intent data URI.
6460 * @param packageContext A Context of the application package implementing
6461 * this class.
6462 * @param cls The component class that is to be used for the intent.
6463 *
6464 * @see #Intent(String, android.net.Uri)
6465 * @see #Intent(Context, Class)
6466 * @see #setClass
6467 * @see #setComponent
6468 */
6469 public Intent(String action, Uri uri,
6470 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006471 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006472 mData = uri;
6473 mComponent = new ComponentName(packageContext, cls);
6474 }
6475
6476 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006477 * Create an intent to launch the main (root) activity of a task. This
6478 * is the Intent that is started when the application's is launched from
6479 * Home. For anything else that wants to launch an application in the
6480 * same way, it is important that they use an Intent structured the same
6481 * way, and can use this function to ensure this is the case.
6482 *
6483 * <p>The returned Intent has the given Activity component as its explicit
6484 * component, {@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 mainActivity The main activity component that this Intent will
6490 * launch.
6491 * @return Returns a newly created Intent that can be used to launch the
6492 * activity as a main application entry.
6493 *
6494 * @see #setClass
6495 * @see #setComponent
6496 */
6497 public static Intent makeMainActivity(ComponentName mainActivity) {
6498 Intent intent = new Intent(ACTION_MAIN);
6499 intent.setComponent(mainActivity);
6500 intent.addCategory(CATEGORY_LAUNCHER);
6501 return intent;
6502 }
6503
6504 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006505 * Make an Intent for the main activity of an application, without
6506 * specifying a specific activity to run but giving a selector to find
6507 * the activity. This results in a final Intent that is structured
6508 * the same as when the application is launched from
6509 * Home. For anything else that wants to launch an application in the
6510 * same way, it is important that they use an Intent structured the same
6511 * way, and can use this function to ensure this is the case.
6512 *
6513 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6514 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6515 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6516 * to do that through {@link #addFlags(int)} on the returned Intent.
6517 *
6518 * @param selectorAction The action name of the Intent's selector.
6519 * @param selectorCategory The name of a category to add to the Intent's
6520 * selector.
6521 * @return Returns a newly created Intent that can be used to launch the
6522 * activity as a main application entry.
6523 *
6524 * @see #setSelector(Intent)
6525 */
6526 public static Intent makeMainSelectorActivity(String selectorAction,
6527 String selectorCategory) {
6528 Intent intent = new Intent(ACTION_MAIN);
6529 intent.addCategory(CATEGORY_LAUNCHER);
6530 Intent selector = new Intent();
6531 selector.setAction(selectorAction);
6532 selector.addCategory(selectorCategory);
6533 intent.setSelector(selector);
6534 return intent;
6535 }
6536
6537 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006538 * Make an Intent that can be used to re-launch an application's task
6539 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6540 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6541 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6542 *
6543 * @param mainActivity The activity component that is the root of the
6544 * task; this is the activity that has been published in the application's
6545 * manifest as the main launcher icon.
6546 *
6547 * @return Returns a newly created Intent that can be used to relaunch the
6548 * activity's task in its root state.
6549 */
6550 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6551 Intent intent = makeMainActivity(mainActivity);
6552 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6553 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6554 return intent;
6555 }
6556
6557 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006558 * Call {@link #parseUri} with 0 flags.
6559 * @deprecated Use {@link #parseUri} instead.
6560 */
6561 @Deprecated
6562 public static Intent getIntent(String uri) throws URISyntaxException {
6563 return parseUri(uri, 0);
6564 }
Tom Taylord4a47292009-12-21 13:59:18 -08006565
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006566 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006567 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006568 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006569 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006570 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006571 *
6572 * <p>The URI given here must not be relative -- that is, it must include
6573 * the scheme and full path.
6574 *
6575 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006576 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006577 *
6578 * @return Intent The newly created Intent object.
6579 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006580 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6581 * it bad (as parsed by the Uri class) or the Intent data within the
6582 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006583 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006584 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006585 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006586 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006587 int i = 0;
6588 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006589 final boolean androidApp = uri.startsWith("android-app:");
6590
6591 // Validate intent scheme if requested.
6592 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6593 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006594 Intent intent = new Intent(ACTION_VIEW);
6595 try {
6596 intent.setData(Uri.parse(uri));
6597 } catch (IllegalArgumentException e) {
6598 throw new URISyntaxException(uri, e.getMessage());
6599 }
6600 return intent;
6601 }
6602 }
Tom Taylord4a47292009-12-21 13:59:18 -08006603
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006604 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006605 // simple case
6606 if (i == -1) {
6607 if (!androidApp) {
6608 return new Intent(ACTION_VIEW, Uri.parse(uri));
6609 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006610
6611 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006612 } else if (!uri.startsWith("#Intent;", i)) {
6613 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006614 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006615 } else {
6616 i = -1;
6617 }
6618 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006619
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006620 // new format
6621 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006622 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006623 boolean explicitAction = false;
6624 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006625
6626 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006627 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006628 String data;
6629 if (i >= 0) {
6630 data = uri.substring(0, i);
6631 i += 8; // length of "#Intent;"
6632 } else {
6633 data = uri;
6634 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006635
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006636 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006637 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006638 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006639 if (eq < 0) eq = i-1;
6640 int semi = uri.indexOf(';', i);
6641 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006642
6643 // action
6644 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006645 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006646 if (!inSelector) {
6647 explicitAction = true;
6648 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006649 }
6650
6651 // categories
6652 else if (uri.startsWith("category=", i)) {
6653 intent.addCategory(value);
6654 }
6655
6656 // type
6657 else if (uri.startsWith("type=", i)) {
6658 intent.mType = value;
6659 }
6660
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006661 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006662 else if (uri.startsWith("launchFlags=", i)) {
6663 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006664 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6665 intent.mFlags &= ~IMMUTABLE_FLAGS;
6666 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006667 }
6668
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006669 // package
6670 else if (uri.startsWith("package=", i)) {
6671 intent.mPackage = value;
6672 }
6673
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006674 // component
6675 else if (uri.startsWith("component=", i)) {
6676 intent.mComponent = ComponentName.unflattenFromString(value);
6677 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006678
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006679 // scheme
6680 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006681 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006682 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006683 } else {
6684 scheme = value;
6685 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006686 }
6687
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006688 // source bounds
6689 else if (uri.startsWith("sourceBounds=", i)) {
6690 intent.mSourceBounds = Rect.unflattenFromString(value);
6691 }
6692
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006693 // selector
6694 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6695 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006696 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006697 }
6698
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006699 // extra
6700 else {
6701 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006702 // create Bundle if it doesn't already exist
6703 if (intent.mExtras == null) intent.mExtras = new Bundle();
6704 Bundle b = intent.mExtras;
6705 // add EXTRA
6706 if (uri.startsWith("S.", i)) b.putString(key, value);
6707 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6708 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6709 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6710 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6711 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6712 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6713 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6714 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6715 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6716 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006717
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006718 // move to the next item
6719 i = semi + 1;
6720 }
6721
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006722 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006723 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006724 if (baseIntent.mPackage == null) {
6725 baseIntent.setSelector(intent);
6726 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006727 intent = baseIntent;
6728 }
6729
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006730 if (data != null) {
6731 if (data.startsWith("intent:")) {
6732 data = data.substring(7);
6733 if (scheme != null) {
6734 data = scheme + ':' + data;
6735 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006736 } else if (data.startsWith("android-app:")) {
6737 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6738 // Correctly formed android-app, first part is package name.
6739 int end = data.indexOf('/', 14);
6740 if (end < 0) {
6741 // All we have is a package name.
6742 intent.mPackage = data.substring(14);
6743 if (!explicitAction) {
6744 intent.setAction(ACTION_MAIN);
6745 }
6746 data = "";
6747 } else {
6748 // Target the Intent at the given package name always.
6749 String authority = null;
6750 intent.mPackage = data.substring(14, end);
6751 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006752 if ((end+1) < data.length()) {
6753 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6754 // Found a scheme, remember it.
6755 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006756 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006757 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6758 // Found a authority, remember it.
6759 authority = data.substring(end+1, newEnd);
6760 end = newEnd;
6761 }
6762 } else {
6763 // All we have is a scheme.
6764 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006765 }
6766 }
6767 if (scheme == null) {
6768 // If there was no scheme, then this just targets the package.
6769 if (!explicitAction) {
6770 intent.setAction(ACTION_MAIN);
6771 }
6772 data = "";
6773 } else if (authority == null) {
6774 data = scheme + ":";
6775 } else {
6776 data = scheme + "://" + authority + data.substring(end);
6777 }
6778 }
6779 } else {
6780 data = "";
6781 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006782 }
Tom Taylord4a47292009-12-21 13:59:18 -08006783
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006784 if (data.length() > 0) {
6785 try {
6786 intent.mData = Uri.parse(data);
6787 } catch (IllegalArgumentException e) {
6788 throw new URISyntaxException(uri, e.getMessage());
6789 }
6790 }
6791 }
Tom Taylord4a47292009-12-21 13:59:18 -08006792
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006793 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006794
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006795 } catch (IndexOutOfBoundsException e) {
6796 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6797 }
6798 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006799
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006800 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006801 return getIntentOld(uri, 0);
6802 }
6803
6804 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006805 Intent intent;
6806
6807 int i = uri.lastIndexOf('#');
6808 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006809 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006810 final int intentFragmentStart = i;
6811 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006812
6813 i++;
6814
6815 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006816 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006817 i += 7;
6818 int j = uri.indexOf(')', i);
6819 action = uri.substring(i, j);
6820 i = j + 1;
6821 }
6822
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006823 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006824
6825 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006826 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006827 i += 11;
6828 int j = uri.indexOf(')', i);
6829 while (i < j) {
6830 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006831 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006832 if (i < sep) {
6833 intent.addCategory(uri.substring(i, sep));
6834 }
6835 i = sep + 1;
6836 }
6837 i = j + 1;
6838 }
6839
6840 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006841 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006842 i += 5;
6843 int j = uri.indexOf(')', i);
6844 intent.mType = uri.substring(i, j);
6845 i = j + 1;
6846 }
6847
6848 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006849 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006850 i += 12;
6851 int j = uri.indexOf(')', i);
6852 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006853 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6854 intent.mFlags &= ~IMMUTABLE_FLAGS;
6855 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006856 i = j + 1;
6857 }
6858
6859 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006860 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006861 i += 10;
6862 int j = uri.indexOf(')', i);
6863 int sep = uri.indexOf('!', i);
6864 if (sep >= 0 && sep < j) {
6865 String pkg = uri.substring(i, sep);
6866 String cls = uri.substring(sep + 1, j);
6867 intent.mComponent = new ComponentName(pkg, cls);
6868 }
6869 i = j + 1;
6870 }
6871
6872 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006873 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006874 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006875
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006876 final int closeParen = uri.indexOf(')', i);
6877 if (closeParen == -1) throw new URISyntaxException(uri,
6878 "EXTRA missing trailing ')'", i);
6879
6880 while (i < closeParen) {
6881 // fetch the key value
6882 int j = uri.indexOf('=', i);
6883 if (j <= i + 1 || i >= closeParen) {
6884 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6885 }
6886 char type = uri.charAt(i);
6887 i++;
6888 String key = uri.substring(i, j);
6889 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006890
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006891 // get type-value
6892 j = uri.indexOf('!', i);
6893 if (j == -1 || j >= closeParen) j = closeParen;
6894 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6895 String value = uri.substring(i, j);
6896 i = j;
6897
6898 // create Bundle if it doesn't already exist
6899 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006900
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006901 // add item to bundle
6902 try {
6903 switch (type) {
6904 case 'S':
6905 intent.mExtras.putString(key, Uri.decode(value));
6906 break;
6907 case 'B':
6908 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6909 break;
6910 case 'b':
6911 intent.mExtras.putByte(key, Byte.parseByte(value));
6912 break;
6913 case 'c':
6914 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6915 break;
6916 case 'd':
6917 intent.mExtras.putDouble(key, Double.parseDouble(value));
6918 break;
6919 case 'f':
6920 intent.mExtras.putFloat(key, Float.parseFloat(value));
6921 break;
6922 case 'i':
6923 intent.mExtras.putInt(key, Integer.parseInt(value));
6924 break;
6925 case 'l':
6926 intent.mExtras.putLong(key, Long.parseLong(value));
6927 break;
6928 case 's':
6929 intent.mExtras.putShort(key, Short.parseShort(value));
6930 break;
6931 default:
6932 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6933 }
6934 } catch (NumberFormatException e) {
6935 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6936 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006937
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006938 char ch = uri.charAt(i);
6939 if (ch == ')') break;
6940 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6941 i++;
6942 }
6943 }
6944
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006945 if (isIntentFragment) {
6946 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6947 } else {
6948 intent.mData = Uri.parse(uri);
6949 }
Tom Taylord4a47292009-12-21 13:59:18 -08006950
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006951 if (intent.mAction == null) {
6952 // By default, if no action is specified, then use VIEW.
6953 intent.mAction = ACTION_VIEW;
6954 }
6955
6956 } else {
6957 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6958 }
6959
6960 return intent;
6961 }
6962
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006963 /** @hide */
6964 public interface CommandOptionHandler {
6965 boolean handleOption(String opt, ShellCommand cmd);
6966 }
6967
6968 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006969 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006970 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6971 throws URISyntaxException {
6972 Intent intent = new Intent();
6973 Intent baseIntent = intent;
6974 boolean hasIntentInfo = false;
6975
6976 Uri data = null;
6977 String type = null;
6978
6979 String opt;
6980 while ((opt=cmd.getNextOption()) != null) {
6981 switch (opt) {
6982 case "-a":
6983 intent.setAction(cmd.getNextArgRequired());
6984 if (intent == baseIntent) {
6985 hasIntentInfo = true;
6986 }
6987 break;
6988 case "-d":
6989 data = Uri.parse(cmd.getNextArgRequired());
6990 if (intent == baseIntent) {
6991 hasIntentInfo = true;
6992 }
6993 break;
6994 case "-t":
6995 type = cmd.getNextArgRequired();
6996 if (intent == baseIntent) {
6997 hasIntentInfo = true;
6998 }
6999 break;
7000 case "-c":
7001 intent.addCategory(cmd.getNextArgRequired());
7002 if (intent == baseIntent) {
7003 hasIntentInfo = true;
7004 }
7005 break;
7006 case "-e":
7007 case "--es": {
7008 String key = cmd.getNextArgRequired();
7009 String value = cmd.getNextArgRequired();
7010 intent.putExtra(key, value);
7011 }
7012 break;
7013 case "--esn": {
7014 String key = cmd.getNextArgRequired();
7015 intent.putExtra(key, (String) null);
7016 }
7017 break;
7018 case "--ei": {
7019 String key = cmd.getNextArgRequired();
7020 String value = cmd.getNextArgRequired();
7021 intent.putExtra(key, Integer.decode(value));
7022 }
7023 break;
7024 case "--eu": {
7025 String key = cmd.getNextArgRequired();
7026 String value = cmd.getNextArgRequired();
7027 intent.putExtra(key, Uri.parse(value));
7028 }
7029 break;
7030 case "--ecn": {
7031 String key = cmd.getNextArgRequired();
7032 String value = cmd.getNextArgRequired();
7033 ComponentName cn = ComponentName.unflattenFromString(value);
7034 if (cn == null)
7035 throw new IllegalArgumentException("Bad component name: " + value);
7036 intent.putExtra(key, cn);
7037 }
7038 break;
7039 case "--eia": {
7040 String key = cmd.getNextArgRequired();
7041 String value = cmd.getNextArgRequired();
7042 String[] strings = value.split(",");
7043 int[] list = new int[strings.length];
7044 for (int i = 0; i < strings.length; i++) {
7045 list[i] = Integer.decode(strings[i]);
7046 }
7047 intent.putExtra(key, list);
7048 }
7049 break;
7050 case "--eial": {
7051 String key = cmd.getNextArgRequired();
7052 String value = cmd.getNextArgRequired();
7053 String[] strings = value.split(",");
7054 ArrayList<Integer> list = new ArrayList<>(strings.length);
7055 for (int i = 0; i < strings.length; i++) {
7056 list.add(Integer.decode(strings[i]));
7057 }
7058 intent.putExtra(key, list);
7059 }
7060 break;
7061 case "--el": {
7062 String key = cmd.getNextArgRequired();
7063 String value = cmd.getNextArgRequired();
7064 intent.putExtra(key, Long.valueOf(value));
7065 }
7066 break;
7067 case "--ela": {
7068 String key = cmd.getNextArgRequired();
7069 String value = cmd.getNextArgRequired();
7070 String[] strings = value.split(",");
7071 long[] list = new long[strings.length];
7072 for (int i = 0; i < strings.length; i++) {
7073 list[i] = Long.valueOf(strings[i]);
7074 }
7075 intent.putExtra(key, list);
7076 hasIntentInfo = true;
7077 }
7078 break;
7079 case "--elal": {
7080 String key = cmd.getNextArgRequired();
7081 String value = cmd.getNextArgRequired();
7082 String[] strings = value.split(",");
7083 ArrayList<Long> list = new ArrayList<>(strings.length);
7084 for (int i = 0; i < strings.length; i++) {
7085 list.add(Long.valueOf(strings[i]));
7086 }
7087 intent.putExtra(key, list);
7088 hasIntentInfo = true;
7089 }
7090 break;
7091 case "--ef": {
7092 String key = cmd.getNextArgRequired();
7093 String value = cmd.getNextArgRequired();
7094 intent.putExtra(key, Float.valueOf(value));
7095 hasIntentInfo = true;
7096 }
7097 break;
7098 case "--efa": {
7099 String key = cmd.getNextArgRequired();
7100 String value = cmd.getNextArgRequired();
7101 String[] strings = value.split(",");
7102 float[] list = new float[strings.length];
7103 for (int i = 0; i < strings.length; i++) {
7104 list[i] = Float.valueOf(strings[i]);
7105 }
7106 intent.putExtra(key, list);
7107 hasIntentInfo = true;
7108 }
7109 break;
7110 case "--efal": {
7111 String key = cmd.getNextArgRequired();
7112 String value = cmd.getNextArgRequired();
7113 String[] strings = value.split(",");
7114 ArrayList<Float> list = new ArrayList<>(strings.length);
7115 for (int i = 0; i < strings.length; i++) {
7116 list.add(Float.valueOf(strings[i]));
7117 }
7118 intent.putExtra(key, list);
7119 hasIntentInfo = true;
7120 }
7121 break;
7122 case "--esa": {
7123 String key = cmd.getNextArgRequired();
7124 String value = cmd.getNextArgRequired();
7125 // Split on commas unless they are preceeded by an escape.
7126 // The escape character must be escaped for the string and
7127 // again for the regex, thus four escape characters become one.
7128 String[] strings = value.split("(?<!\\\\),");
7129 intent.putExtra(key, strings);
7130 hasIntentInfo = true;
7131 }
7132 break;
7133 case "--esal": {
7134 String key = cmd.getNextArgRequired();
7135 String value = cmd.getNextArgRequired();
7136 // Split on commas unless they are preceeded by an escape.
7137 // The escape character must be escaped for the string and
7138 // again for the regex, thus four escape characters become one.
7139 String[] strings = value.split("(?<!\\\\),");
7140 ArrayList<String> list = new ArrayList<>(strings.length);
7141 for (int i = 0; i < strings.length; i++) {
7142 list.add(strings[i]);
7143 }
7144 intent.putExtra(key, list);
7145 hasIntentInfo = true;
7146 }
7147 break;
7148 case "--ez": {
7149 String key = cmd.getNextArgRequired();
7150 String value = cmd.getNextArgRequired().toLowerCase();
7151 // Boolean.valueOf() results in false for anything that is not "true", which is
7152 // error-prone in shell commands
7153 boolean arg;
7154 if ("true".equals(value) || "t".equals(value)) {
7155 arg = true;
7156 } else if ("false".equals(value) || "f".equals(value)) {
7157 arg = false;
7158 } else {
7159 try {
7160 arg = Integer.decode(value) != 0;
7161 } catch (NumberFormatException ex) {
7162 throw new IllegalArgumentException("Invalid boolean value: " + value);
7163 }
7164 }
7165
7166 intent.putExtra(key, arg);
7167 }
7168 break;
7169 case "-n": {
7170 String str = cmd.getNextArgRequired();
7171 ComponentName cn = ComponentName.unflattenFromString(str);
7172 if (cn == null)
7173 throw new IllegalArgumentException("Bad component name: " + str);
7174 intent.setComponent(cn);
7175 if (intent == baseIntent) {
7176 hasIntentInfo = true;
7177 }
7178 }
7179 break;
7180 case "-p": {
7181 String str = cmd.getNextArgRequired();
7182 intent.setPackage(str);
7183 if (intent == baseIntent) {
7184 hasIntentInfo = true;
7185 }
7186 }
7187 break;
7188 case "-f":
7189 String str = cmd.getNextArgRequired();
7190 intent.setFlags(Integer.decode(str).intValue());
7191 break;
7192 case "--grant-read-uri-permission":
7193 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7194 break;
7195 case "--grant-write-uri-permission":
7196 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7197 break;
7198 case "--grant-persistable-uri-permission":
7199 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7200 break;
7201 case "--grant-prefix-uri-permission":
7202 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7203 break;
7204 case "--exclude-stopped-packages":
7205 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7206 break;
7207 case "--include-stopped-packages":
7208 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7209 break;
7210 case "--debug-log-resolution":
7211 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7212 break;
7213 case "--activity-brought-to-front":
7214 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7215 break;
7216 case "--activity-clear-top":
7217 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7218 break;
7219 case "--activity-clear-when-task-reset":
7220 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7221 break;
7222 case "--activity-exclude-from-recents":
7223 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7224 break;
7225 case "--activity-launched-from-history":
7226 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7227 break;
7228 case "--activity-multiple-task":
7229 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7230 break;
7231 case "--activity-no-animation":
7232 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7233 break;
7234 case "--activity-no-history":
7235 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7236 break;
7237 case "--activity-no-user-action":
7238 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7239 break;
7240 case "--activity-previous-is-top":
7241 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7242 break;
7243 case "--activity-reorder-to-front":
7244 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7245 break;
7246 case "--activity-reset-task-if-needed":
7247 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7248 break;
7249 case "--activity-single-top":
7250 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7251 break;
7252 case "--activity-clear-task":
7253 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7254 break;
7255 case "--activity-task-on-home":
7256 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7257 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07007258 case "--activity-match-external":
7259 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7260 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007261 case "--receiver-registered-only":
7262 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7263 break;
7264 case "--receiver-replace-pending":
7265 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7266 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08007267 case "--receiver-foreground":
7268 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7269 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08007270 case "--receiver-no-abort":
7271 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7272 break;
7273 case "--receiver-include-background":
7274 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7275 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007276 case "--selector":
7277 intent.setDataAndType(data, type);
7278 intent = new Intent();
7279 break;
7280 default:
7281 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7282 // Okay, caller handled this option.
7283 } else {
7284 throw new IllegalArgumentException("Unknown option: " + opt);
7285 }
7286 break;
7287 }
7288 }
7289 intent.setDataAndType(data, type);
7290
7291 final boolean hasSelector = intent != baseIntent;
7292 if (hasSelector) {
7293 // A selector was specified; fix up.
7294 baseIntent.setSelector(intent);
7295 intent = baseIntent;
7296 }
7297
7298 String arg = cmd.getNextArg();
7299 baseIntent = null;
7300 if (arg == null) {
7301 if (hasSelector) {
7302 // If a selector has been specified, and no arguments
7303 // have been supplied for the main Intent, then we can
7304 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7305 // need to have a component name specified yet, the
7306 // selector will take care of that.
7307 baseIntent = new Intent(Intent.ACTION_MAIN);
7308 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7309 }
7310 } else if (arg.indexOf(':') >= 0) {
7311 // The argument is a URI. Fully parse it, and use that result
7312 // to fill in any data not specified so far.
7313 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7314 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7315 } else if (arg.indexOf('/') >= 0) {
7316 // The argument is a component name. Build an Intent to launch
7317 // it.
7318 baseIntent = new Intent(Intent.ACTION_MAIN);
7319 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7320 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7321 } else {
7322 // Assume the argument is a package name.
7323 baseIntent = new Intent(Intent.ACTION_MAIN);
7324 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7325 baseIntent.setPackage(arg);
7326 }
7327 if (baseIntent != null) {
7328 Bundle extras = intent.getExtras();
7329 intent.replaceExtras((Bundle)null);
7330 Bundle uriExtras = baseIntent.getExtras();
7331 baseIntent.replaceExtras((Bundle)null);
7332 if (intent.getAction() != null && baseIntent.getCategories() != null) {
7333 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7334 for (String c : cats) {
7335 baseIntent.removeCategory(c);
7336 }
7337 }
7338 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7339 if (extras == null) {
7340 extras = uriExtras;
7341 } else if (uriExtras != null) {
7342 uriExtras.putAll(extras);
7343 extras = uriExtras;
7344 }
7345 intent.replaceExtras(extras);
7346 hasIntentInfo = true;
7347 }
7348
7349 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7350 return intent;
7351 }
7352
7353 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007354 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007355 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7356 final String[] lines = new String[] {
7357 "<INTENT> specifications include these flags and arguments:",
7358 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7359 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007360 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007361 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7362 " [--esn <EXTRA_KEY> ...]",
7363 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7364 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7365 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7366 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7367 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7368 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7369 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7370 " (mutiple extras passed as Integer[])",
7371 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7372 " (mutiple extras passed as List<Integer>)",
7373 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7374 " (mutiple extras passed as Long[])",
7375 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7376 " (mutiple extras passed as List<Long>)",
7377 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7378 " (mutiple extras passed as Float[])",
7379 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7380 " (mutiple extras passed as List<Float>)",
7381 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7382 " (mutiple extras passed as String[]; to embed a comma into a string,",
7383 " escape it using \"\\,\")",
7384 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7385 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7386 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007387 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007388 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7389 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7390 " [--debug-log-resolution] [--exclude-stopped-packages]",
7391 " [--include-stopped-packages]",
7392 " [--activity-brought-to-front] [--activity-clear-top]",
7393 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7394 " [--activity-launched-from-history] [--activity-multiple-task]",
7395 " [--activity-no-animation] [--activity-no-history]",
7396 " [--activity-no-user-action] [--activity-previous-is-top]",
7397 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7398 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007399 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007400 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007401 " [--receiver-foreground] [--receiver-no-abort]",
7402 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007403 " [--selector]",
7404 " [<URI> | <PACKAGE> | <COMPONENT>]"
7405 };
7406 for (String line : lines) {
7407 pw.print(prefix);
7408 pw.println(line);
7409 }
7410 }
7411
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007412 /**
7413 * Retrieve the general action to be performed, such as
7414 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7415 * the information in the intent should be interpreted -- most importantly,
7416 * what to do with the data returned by {@link #getData}.
7417 *
7418 * @return The action of this intent or null if none is specified.
7419 *
7420 * @see #setAction
7421 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007422 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007423 return mAction;
7424 }
7425
7426 /**
7427 * Retrieve data this intent is operating on. This URI specifies the name
7428 * of the data; often it uses the content: scheme, specifying data in a
7429 * content provider. Other schemes may be handled by specific activities,
7430 * such as http: by the web browser.
7431 *
7432 * @return The URI of the data this intent is targeting or null.
7433 *
7434 * @see #getScheme
7435 * @see #setData
7436 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007437 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007438 return mData;
7439 }
7440
7441 /**
7442 * The same as {@link #getData()}, but returns the URI as an encoded
7443 * String.
7444 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007445 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007446 return mData != null ? mData.toString() : null;
7447 }
7448
7449 /**
7450 * Return the scheme portion of the intent's data. If the data is null or
7451 * does not include a scheme, null is returned. Otherwise, the scheme
7452 * prefix without the final ':' is returned, i.e. "http".
7453 *
7454 * <p>This is the same as calling getData().getScheme() (and checking for
7455 * null data).
7456 *
7457 * @return The scheme of this intent.
7458 *
7459 * @see #getData
7460 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007461 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007462 return mData != null ? mData.getScheme() : null;
7463 }
7464
7465 /**
7466 * Retrieve any explicit MIME type included in the intent. This is usually
7467 * null, as the type is determined by the intent data.
7468 *
7469 * @return If a type was manually set, it is returned; else null is
7470 * returned.
7471 *
7472 * @see #resolveType(ContentResolver)
7473 * @see #setType
7474 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007475 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007476 return mType;
7477 }
7478
7479 /**
7480 * Return the MIME data type of this intent. If the type field is
7481 * explicitly set, that is simply returned. Otherwise, if the data is set,
7482 * the type of that data is returned. If neither fields are set, a null is
7483 * returned.
7484 *
7485 * @return The MIME type of this intent.
7486 *
7487 * @see #getType
7488 * @see #resolveType(ContentResolver)
7489 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007490 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007491 return resolveType(context.getContentResolver());
7492 }
7493
7494 /**
7495 * Return the MIME data type of this intent. If the type field is
7496 * explicitly set, that is simply returned. Otherwise, if the data is set,
7497 * the type of that data is returned. If neither fields are set, a null is
7498 * returned.
7499 *
7500 * @param resolver A ContentResolver that can be used to determine the MIME
7501 * type of the intent's data.
7502 *
7503 * @return The MIME type of this intent.
7504 *
7505 * @see #getType
7506 * @see #resolveType(Context)
7507 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007508 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007509 if (mType != null) {
7510 return mType;
7511 }
7512 if (mData != null) {
7513 if ("content".equals(mData.getScheme())) {
7514 return resolver.getType(mData);
7515 }
7516 }
7517 return null;
7518 }
7519
7520 /**
7521 * Return the MIME data type of this intent, only if it will be needed for
7522 * intent resolution. This is not generally useful for application code;
7523 * it is used by the frameworks for communicating with back-end system
7524 * services.
7525 *
7526 * @param resolver A ContentResolver that can be used to determine the MIME
7527 * type of the intent's data.
7528 *
7529 * @return The MIME type of this intent, or null if it is unknown or not
7530 * needed.
7531 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007532 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007533 if (mComponent != null) {
7534 return mType;
7535 }
7536 return resolveType(resolver);
7537 }
7538
7539 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007540 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007541 *
7542 * @param category The category to check.
7543 *
7544 * @return boolean True if the intent contains the category, else false.
7545 *
7546 * @see #getCategories
7547 * @see #addCategory
7548 */
7549 public boolean hasCategory(String category) {
7550 return mCategories != null && mCategories.contains(category);
7551 }
7552
7553 /**
7554 * Return the set of all categories in the intent. If there are no categories,
7555 * returns NULL.
7556 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007557 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007558 *
7559 * @see #hasCategory
7560 * @see #addCategory
7561 */
7562 public Set<String> getCategories() {
7563 return mCategories;
7564 }
7565
7566 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007567 * Return the specific selector associated with this Intent. If there is
7568 * none, returns null. See {@link #setSelector} for more information.
7569 *
7570 * @see #setSelector
7571 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007572 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007573 return mSelector;
7574 }
7575
7576 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007577 * Return the {@link ClipData} associated with this Intent. If there is
7578 * none, returns null. See {@link #setClipData} for more information.
7579 *
John Spurlock125d1332013-11-25 11:58:37 -05007580 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007581 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007582 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007583 return mClipData;
7584 }
7585
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007586 /** @hide */
7587 public int getContentUserHint() {
7588 return mContentUserHint;
7589 }
7590
Todd Kennedyb3b431302017-03-20 16:05:48 -07007591 /** @hide */
7592 public String getLaunchToken() {
7593 return mLaunchToken;
7594 }
7595
7596 /** @hide */
7597 public void setLaunchToken(String launchToken) {
7598 mLaunchToken = launchToken;
7599 }
7600
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007601 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007602 * Sets the ClassLoader that will be used when unmarshalling
7603 * any Parcelable values from the extras of this Intent.
7604 *
7605 * @param loader a ClassLoader, or null to use the default loader
7606 * at the time of unmarshalling.
7607 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007608 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007609 if (mExtras != null) {
7610 mExtras.setClassLoader(loader);
7611 }
7612 }
7613
7614 /**
7615 * Returns true if an extra value is associated with the given name.
7616 * @param name the extra's name
7617 * @return true if the given extra is present.
7618 */
7619 public boolean hasExtra(String name) {
7620 return mExtras != null && mExtras.containsKey(name);
7621 }
7622
7623 /**
7624 * Returns true if the Intent's extras contain a parcelled file descriptor.
7625 * @return true if the Intent contains a parcelled file descriptor.
7626 */
7627 public boolean hasFileDescriptors() {
7628 return mExtras != null && mExtras.hasFileDescriptors();
7629 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007630
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007631 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007632 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007633 public void setAllowFds(boolean allowFds) {
7634 if (mExtras != null) {
7635 mExtras.setAllowFds(allowFds);
7636 }
7637 }
7638
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007639 /** {@hide} */
7640 public void setDefusable(boolean defusable) {
7641 if (mExtras != null) {
7642 mExtras.setDefusable(defusable);
7643 }
7644 }
7645
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007646 /**
7647 * Retrieve extended data from the intent.
7648 *
7649 * @param name The name of the desired item.
7650 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007651 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007652 * or null if none was found.
7653 *
7654 * @deprecated
7655 * @hide
7656 */
7657 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007658 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007659 public Object getExtra(String name) {
7660 return getExtra(name, null);
7661 }
7662
7663 /**
7664 * Retrieve extended data from the intent.
7665 *
7666 * @param name The name of the desired item.
7667 * @param defaultValue the value to be returned if no value of the desired
7668 * type is stored with the given name.
7669 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007670 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007671 * or the default value if none was found.
7672 *
7673 * @see #putExtra(String, boolean)
7674 */
7675 public boolean getBooleanExtra(String name, boolean defaultValue) {
7676 return mExtras == null ? defaultValue :
7677 mExtras.getBoolean(name, defaultValue);
7678 }
7679
7680 /**
7681 * Retrieve extended data from the intent.
7682 *
7683 * @param name The name of the desired item.
7684 * @param defaultValue the value to be returned if no value of the desired
7685 * type is stored with the given name.
7686 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007687 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007688 * or the default value if none was found.
7689 *
7690 * @see #putExtra(String, byte)
7691 */
7692 public byte getByteExtra(String name, byte defaultValue) {
7693 return mExtras == null ? defaultValue :
7694 mExtras.getByte(name, defaultValue);
7695 }
7696
7697 /**
7698 * Retrieve extended data from the intent.
7699 *
7700 * @param name The name of the desired item.
7701 * @param defaultValue the value to be returned if no value of the desired
7702 * type is stored with the given name.
7703 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007704 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007705 * or the default value if none was found.
7706 *
7707 * @see #putExtra(String, short)
7708 */
7709 public short getShortExtra(String name, short defaultValue) {
7710 return mExtras == null ? defaultValue :
7711 mExtras.getShort(name, defaultValue);
7712 }
7713
7714 /**
7715 * Retrieve extended data from the intent.
7716 *
7717 * @param name The name of the desired item.
7718 * @param defaultValue the value to be returned if no value of the desired
7719 * type is stored with the given name.
7720 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007721 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007722 * or the default value if none was found.
7723 *
7724 * @see #putExtra(String, char)
7725 */
7726 public char getCharExtra(String name, char defaultValue) {
7727 return mExtras == null ? defaultValue :
7728 mExtras.getChar(name, defaultValue);
7729 }
7730
7731 /**
7732 * Retrieve extended data from the intent.
7733 *
7734 * @param name The name of the desired item.
7735 * @param defaultValue the value to be returned if no value of the desired
7736 * type is stored with the given name.
7737 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007738 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007739 * or the default value if none was found.
7740 *
7741 * @see #putExtra(String, int)
7742 */
7743 public int getIntExtra(String name, int defaultValue) {
7744 return mExtras == null ? defaultValue :
7745 mExtras.getInt(name, defaultValue);
7746 }
7747
7748 /**
7749 * Retrieve extended data from the intent.
7750 *
7751 * @param name The name of the desired item.
7752 * @param defaultValue the value to be returned if no value of the desired
7753 * type is stored with the given name.
7754 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007755 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007756 * or the default value if none was found.
7757 *
7758 * @see #putExtra(String, long)
7759 */
7760 public long getLongExtra(String name, long defaultValue) {
7761 return mExtras == null ? defaultValue :
7762 mExtras.getLong(name, defaultValue);
7763 }
7764
7765 /**
7766 * Retrieve extended data from the intent.
7767 *
7768 * @param name The name of the desired item.
7769 * @param defaultValue the value to be returned if no value of the desired
7770 * type is stored with the given name.
7771 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007772 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007773 * or the default value if no such item is present
7774 *
7775 * @see #putExtra(String, float)
7776 */
7777 public float getFloatExtra(String name, float defaultValue) {
7778 return mExtras == null ? defaultValue :
7779 mExtras.getFloat(name, defaultValue);
7780 }
7781
7782 /**
7783 * Retrieve extended data from the intent.
7784 *
7785 * @param name The name of the desired item.
7786 * @param defaultValue the value to be returned if no value of the desired
7787 * type is stored with the given name.
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 the default value if none was found.
7791 *
7792 * @see #putExtra(String, double)
7793 */
7794 public double getDoubleExtra(String name, double defaultValue) {
7795 return mExtras == null ? defaultValue :
7796 mExtras.getDouble(name, defaultValue);
7797 }
7798
7799 /**
7800 * Retrieve extended data from the intent.
7801 *
7802 * @param name The name of the desired item.
7803 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007804 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007805 * or null if no String value was found.
7806 *
7807 * @see #putExtra(String, String)
7808 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007809 public @Nullable String getStringExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007810 return mExtras == null ? null : mExtras.getString(name);
7811 }
7812
7813 /**
7814 * Retrieve extended data from the intent.
7815 *
7816 * @param name The name of the desired item.
7817 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007818 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007819 * or null if no CharSequence value was found.
7820 *
7821 * @see #putExtra(String, CharSequence)
7822 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007823 public @Nullable CharSequence getCharSequenceExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007824 return mExtras == null ? null : mExtras.getCharSequence(name);
7825 }
7826
7827 /**
7828 * Retrieve extended data from the intent.
7829 *
7830 * @param name The name of the desired item.
7831 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007832 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007833 * or null if no Parcelable value was found.
7834 *
7835 * @see #putExtra(String, Parcelable)
7836 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007837 public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007838 return mExtras == null ? null : mExtras.<T>getParcelable(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 Parcelable[] value was found.
7848 *
7849 * @see #putExtra(String, Parcelable[])
7850 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007851 public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007852 return mExtras == null ? null : mExtras.getParcelableArray(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 * putParcelableArrayListExtra(), or null if no
7862 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007863 *
7864 * @see #putParcelableArrayListExtra(String, ArrayList)
7865 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007866 public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007867 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(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 putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007876 * or null if no Serializable value was found.
7877 *
7878 * @see #putExtra(String, Serializable)
7879 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007880 public @Nullable Serializable getSerializableExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007881 return mExtras == null ? null : mExtras.getSerializable(name);
7882 }
7883
7884 /**
7885 * Retrieve extended data from the intent.
7886 *
7887 * @param name The name of the desired item.
7888 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007889 * @return the value of an item previously added with
7890 * putIntegerArrayListExtra(), or null if no
7891 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007892 *
7893 * @see #putIntegerArrayListExtra(String, ArrayList)
7894 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007895 public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007896 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7897 }
7898
7899 /**
7900 * Retrieve extended data from the intent.
7901 *
7902 * @param name The name of the desired item.
7903 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007904 * @return the value of an item previously added with
7905 * putStringArrayListExtra(), or null if no
7906 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007907 *
7908 * @see #putStringArrayListExtra(String, ArrayList)
7909 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007910 public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007911 return mExtras == null ? null : mExtras.getStringArrayList(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
7920 * putCharSequenceArrayListExtra, or null if no
7921 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007922 *
7923 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7924 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007925 public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007926 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7927 }
7928
7929 /**
7930 * Retrieve extended data from the intent.
7931 *
7932 * @param name The name of the desired item.
7933 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007934 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007935 * or null if no boolean array value was found.
7936 *
7937 * @see #putExtra(String, boolean[])
7938 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007939 public @Nullable boolean[] getBooleanArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007940 return mExtras == null ? null : mExtras.getBooleanArray(name);
7941 }
7942
7943 /**
7944 * Retrieve extended data from the intent.
7945 *
7946 * @param name The name of the desired item.
7947 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007948 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007949 * or null if no byte array value was found.
7950 *
7951 * @see #putExtra(String, byte[])
7952 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007953 public @Nullable byte[] getByteArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007954 return mExtras == null ? null : mExtras.getByteArray(name);
7955 }
7956
7957 /**
7958 * Retrieve extended data from the intent.
7959 *
7960 * @param name The name of the desired item.
7961 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007962 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007963 * or null if no short array value was found.
7964 *
7965 * @see #putExtra(String, short[])
7966 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007967 public @Nullable short[] getShortArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007968 return mExtras == null ? null : mExtras.getShortArray(name);
7969 }
7970
7971 /**
7972 * Retrieve extended data from the intent.
7973 *
7974 * @param name The name of the desired item.
7975 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007976 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007977 * or null if no char array value was found.
7978 *
7979 * @see #putExtra(String, char[])
7980 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007981 public @Nullable char[] getCharArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007982 return mExtras == null ? null : mExtras.getCharArray(name);
7983 }
7984
7985 /**
7986 * Retrieve extended data from the intent.
7987 *
7988 * @param name The name of the desired item.
7989 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007990 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007991 * or null if no int array value was found.
7992 *
7993 * @see #putExtra(String, int[])
7994 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00007995 public @Nullable int[] getIntArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007996 return mExtras == null ? null : mExtras.getIntArray(name);
7997 }
7998
7999 /**
8000 * Retrieve extended data from the intent.
8001 *
8002 * @param name The name of the desired item.
8003 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008004 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008005 * or null if no long array value was found.
8006 *
8007 * @see #putExtra(String, long[])
8008 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008009 public @Nullable long[] getLongArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008010 return mExtras == null ? null : mExtras.getLongArray(name);
8011 }
8012
8013 /**
8014 * Retrieve extended data from the intent.
8015 *
8016 * @param name The name of the desired item.
8017 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008018 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008019 * or null if no float array value was found.
8020 *
8021 * @see #putExtra(String, float[])
8022 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008023 public @Nullable float[] getFloatArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008024 return mExtras == null ? null : mExtras.getFloatArray(name);
8025 }
8026
8027 /**
8028 * Retrieve extended data from the intent.
8029 *
8030 * @param name The name of the desired item.
8031 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008032 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008033 * or null if no double array value was found.
8034 *
8035 * @see #putExtra(String, double[])
8036 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008037 public @Nullable double[] getDoubleArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008038 return mExtras == null ? null : mExtras.getDoubleArray(name);
8039 }
8040
8041 /**
8042 * Retrieve extended data from the intent.
8043 *
8044 * @param name The name of the desired item.
8045 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008046 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008047 * or null if no String array value was found.
8048 *
8049 * @see #putExtra(String, String[])
8050 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008051 public @Nullable String[] getStringArrayExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008052 return mExtras == null ? null : mExtras.getStringArray(name);
8053 }
8054
8055 /**
8056 * Retrieve extended data from the intent.
8057 *
8058 * @param name The name of the desired item.
8059 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008060 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008061 * or null if no CharSequence array value was found.
8062 *
8063 * @see #putExtra(String, CharSequence[])
8064 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008065 public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008066 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8067 }
8068
8069 /**
8070 * Retrieve extended data from the intent.
8071 *
8072 * @param name The name of the desired item.
8073 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008074 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008075 * or null if no Bundle value was found.
8076 *
8077 * @see #putExtra(String, Bundle)
8078 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008079 public @Nullable Bundle getBundleExtra(String name) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008080 return mExtras == null ? null : mExtras.getBundle(name);
8081 }
8082
8083 /**
8084 * Retrieve extended data from the intent.
8085 *
8086 * @param name The name of the desired item.
8087 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008088 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008089 * or null if no IBinder value was found.
8090 *
8091 * @see #putExtra(String, IBinder)
8092 *
8093 * @deprecated
8094 * @hide
8095 */
8096 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008097 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008098 public IBinder getIBinderExtra(String name) {
8099 return mExtras == null ? null : mExtras.getIBinder(name);
8100 }
8101
8102 /**
8103 * Retrieve extended data from the intent.
8104 *
8105 * @param name The name of the desired item.
8106 * @param defaultValue The default value to return in case no item is
8107 * associated with the key 'name'
8108 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07008109 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008110 * or defaultValue if none was found.
8111 *
8112 * @see #putExtra
8113 *
8114 * @deprecated
8115 * @hide
8116 */
8117 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008118 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008119 public Object getExtra(String name, Object defaultValue) {
8120 Object result = defaultValue;
8121 if (mExtras != null) {
8122 Object result2 = mExtras.get(name);
8123 if (result2 != null) {
8124 result = result2;
8125 }
8126 }
8127
8128 return result;
8129 }
8130
8131 /**
8132 * Retrieves a map of extended data from the intent.
8133 *
8134 * @return the map of all extras previously added with putExtra(),
8135 * or null if none have been added.
8136 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008137 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008138 return (mExtras != null)
8139 ? new Bundle(mExtras)
8140 : null;
8141 }
8142
8143 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008144 * Filter extras to only basic types.
8145 * @hide
8146 */
8147 public void removeUnsafeExtras() {
8148 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07008149 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07008150 }
8151 }
8152
8153 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07008154 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8155 * return itself as-is.
8156 * @hide
8157 */
8158 public boolean canStripForHistory() {
8159 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8160 }
8161
8162 /**
8163 * Call it when the system needs to keep an intent for logging purposes to remove fields
8164 * that are not needed for logging.
8165 * @hide
8166 */
8167 public Intent maybeStripForHistory() {
8168 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8169
8170 if (!canStripForHistory()) {
8171 return this;
8172 }
8173 return new Intent(this, COPY_MODE_HISTORY);
8174 }
8175
8176 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008177 * Retrieve any special flags associated with this intent. You will
8178 * normally just set them with {@link #setFlags} and let the system
8179 * take the appropriate action with them.
8180 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008181 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008182 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008183 * @see #addFlags
8184 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008185 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008186 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008187 return mFlags;
8188 }
8189
Dianne Hackborne7f97212011-02-24 14:40:20 -08008190 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008191 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08008192 public boolean isExcludingStopped() {
8193 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8194 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8195 }
8196
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008197 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008198 * Retrieve the application package name this Intent is limited to. When
8199 * resolving an Intent, if non-null this limits the resolution to only
8200 * components in the given application package.
8201 *
8202 * @return The name of the application package for the Intent.
8203 *
8204 * @see #resolveActivity
8205 * @see #setPackage
8206 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008207 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008208 return mPackage;
8209 }
8210
8211 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008212 * Retrieve the concrete component associated with the intent. When receiving
8213 * an intent, this is the component that was found to best handle it (that is,
8214 * yourself) and will always be non-null; in all other cases it will be
8215 * null unless explicitly set.
8216 *
8217 * @return The name of the application component to handle the intent.
8218 *
8219 * @see #resolveActivity
8220 * @see #setComponent
8221 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008222 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008223 return mComponent;
8224 }
8225
8226 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008227 * Get the bounds of the sender of this intent, in screen coordinates. This can be
8228 * used as a hint to the receiver for animations and the like. Null means that there
8229 * is no source bounds.
8230 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008231 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08008232 return mSourceBounds;
8233 }
8234
8235 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008236 * Return the Activity component that should be used to handle this intent.
8237 * The appropriate component is determined based on the information in the
8238 * intent, evaluated as follows:
8239 *
8240 * <p>If {@link #getComponent} returns an explicit class, that is returned
8241 * without any further consideration.
8242 *
8243 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8244 * category to be considered.
8245 *
8246 * <p>If {@link #getAction} is non-NULL, the activity must handle this
8247 * action.
8248 *
8249 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8250 * this type.
8251 *
8252 * <p>If {@link #addCategory} has added any categories, the activity must
8253 * handle ALL of the categories specified.
8254 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07008255 * <p>If {@link #getPackage} is non-NULL, only activity components in
8256 * that application package will be considered.
8257 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008258 * <p>If there are no activities that satisfy all of these conditions, a
8259 * null string is returned.
8260 *
8261 * <p>If multiple activities are found to satisfy the intent, the one with
8262 * the highest priority will be used. If there are multiple activities
8263 * with the same priority, the system will either pick the best activity
8264 * based on user preference, or resolve to a system class that will allow
8265 * the user to pick an activity and forward from there.
8266 *
8267 * <p>This method is implemented simply by calling
8268 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8269 * true.</p>
8270 * <p> This API is called for you as part of starting an activity from an
8271 * intent. You do not normally need to call it yourself.</p>
8272 *
8273 * @param pm The package manager with which to resolve the Intent.
8274 *
8275 * @return Name of the component implementing an activity that can
8276 * display the intent.
8277 *
8278 * @see #setComponent
8279 * @see #getComponent
8280 * @see #resolveActivityInfo
8281 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008282 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008283 if (mComponent != null) {
8284 return mComponent;
8285 }
8286
8287 ResolveInfo info = pm.resolveActivity(
8288 this, PackageManager.MATCH_DEFAULT_ONLY);
8289 if (info != null) {
8290 return new ComponentName(
8291 info.activityInfo.applicationInfo.packageName,
8292 info.activityInfo.name);
8293 }
8294
8295 return null;
8296 }
8297
8298 /**
8299 * Resolve the Intent into an {@link ActivityInfo}
8300 * describing the activity that should execute the intent. Resolution
8301 * follows the same rules as described for {@link #resolveActivity}, but
8302 * you get back the completely information about the resolved activity
8303 * instead of just its class name.
8304 *
8305 * @param pm The package manager with which to resolve the Intent.
8306 * @param flags Addition information to retrieve as per
8307 * {@link PackageManager#getActivityInfo(ComponentName, int)
8308 * PackageManager.getActivityInfo()}.
8309 *
8310 * @return PackageManager.ActivityInfo
8311 *
8312 * @see #resolveActivity
8313 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008314 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8315 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008316 ActivityInfo ai = null;
8317 if (mComponent != null) {
8318 try {
8319 ai = pm.getActivityInfo(mComponent, flags);
8320 } catch (PackageManager.NameNotFoundException e) {
8321 // ignore
8322 }
8323 } else {
8324 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07008325 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008326 if (info != null) {
8327 ai = info.activityInfo;
8328 }
8329 }
8330
8331 return ai;
8332 }
8333
8334 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07008335 * Special function for use by the system to resolve service
8336 * intents to system apps. Throws an exception if there are
8337 * multiple potential matches to the Intent. Returns null if
8338 * there are no matches.
8339 * @hide
8340 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008341 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008342 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8343 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008344 if (mComponent != null) {
8345 return mComponent;
8346 }
8347
8348 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8349 if (results == null) {
8350 return null;
8351 }
8352 ComponentName comp = null;
8353 for (int i=0; i<results.size(); i++) {
8354 ResolveInfo ri = results.get(i);
8355 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8356 continue;
8357 }
8358 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8359 ri.serviceInfo.name);
8360 if (comp != null) {
8361 throw new IllegalStateException("Multiple system services handle " + this
8362 + ": " + comp + ", " + foundComp);
8363 }
8364 comp = foundComp;
8365 }
8366 return comp;
8367 }
8368
8369 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008370 * Set the general action to be performed.
8371 *
8372 * @param action An action name, such as ACTION_VIEW. Application-specific
8373 * actions should be prefixed with the vendor's package name.
8374 *
8375 * @return Returns the same Intent object, for chaining multiple calls
8376 * into a single statement.
8377 *
8378 * @see #getAction
8379 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008380 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008381 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008382 return this;
8383 }
8384
8385 /**
8386 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008387 * clears any type that was previously set by {@link #setType} or
8388 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008389 *
Nick Pellyccae4122012-01-09 14:12:58 -08008390 * <p><em>Note: scheme matching in the Android framework is
8391 * case-sensitive, unlike the formal RFC. As a result,
8392 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008393 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008394 * {@link #setDataAndNormalize}
8395 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008396 *
Nick Pellyccae4122012-01-09 14:12:58 -08008397 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008398 *
8399 * @return Returns the same Intent object, for chaining multiple calls
8400 * into a single statement.
8401 *
8402 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008403 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008404 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008405 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008406 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008407 mData = data;
8408 mType = null;
8409 return this;
8410 }
8411
8412 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008413 * Normalize and set the data this intent is operating on.
8414 *
8415 * <p>This method automatically clears any type that was
8416 * previously set (for example, by {@link #setType}).
8417 *
8418 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008419 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008420 * so really this is just a convenience method for
8421 * <pre>
8422 * setData(data.normalize())
8423 * </pre>
8424 *
8425 * @param data The Uri of the data this intent is now targeting.
8426 *
8427 * @return Returns the same Intent object, for chaining multiple calls
8428 * into a single statement.
8429 *
8430 * @see #getData
8431 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008432 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008433 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008434 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008435 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008436 }
8437
8438 /**
8439 * Set an explicit MIME data type.
8440 *
8441 * <p>This is used to create intents that only specify a type and not data,
8442 * for example to indicate the type of data to return.
8443 *
8444 * <p>This method automatically clears any data that was
8445 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008446 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008447 * <p><em>Note: MIME type matching in the Android framework is
8448 * case-sensitive, unlike formal RFC MIME types. As a result,
8449 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008450 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8451 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008452 *
8453 * @param type The MIME type of the data being handled by this intent.
8454 *
8455 * @return Returns the same Intent object, for chaining multiple calls
8456 * into a single statement.
8457 *
8458 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008459 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008460 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008461 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008462 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008463 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008464 mData = null;
8465 mType = type;
8466 return this;
8467 }
8468
8469 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008470 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008471 *
Nick Pellyccae4122012-01-09 14:12:58 -08008472 * <p>This is used to create intents that only specify a type and not data,
8473 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008474 *
Nick Pellyccae4122012-01-09 14:12:58 -08008475 * <p>This method automatically clears any data that was
8476 * previously set (for example by {@link #setData}).
8477 *
8478 * <p>The MIME type is normalized using
8479 * {@link #normalizeMimeType} before it is set,
8480 * so really this is just a convenience method for
8481 * <pre>
8482 * setType(Intent.normalizeMimeType(type))
8483 * </pre>
8484 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008485 * @param type The MIME type of the data being handled by this intent.
8486 *
8487 * @return Returns the same Intent object, for chaining multiple calls
8488 * into a single statement.
8489 *
Nick Pellyccae4122012-01-09 14:12:58 -08008490 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008491 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008492 * @see #normalizeMimeType
8493 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008494 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008495 return setType(normalizeMimeType(type));
8496 }
8497
8498 /**
8499 * (Usually optional) Set the data for the intent along with an explicit
8500 * MIME data type. This method should very rarely be used -- it allows you
8501 * to override the MIME type that would ordinarily be inferred from the
8502 * data with your own type given here.
8503 *
8504 * <p><em>Note: MIME type and Uri scheme matching in the
8505 * Android framework is case-sensitive, unlike the formal RFC definitions.
8506 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008507 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008508 * {@link #setDataAndTypeAndNormalize}
8509 * to ensure that they are converted to lower case.</em>
8510 *
8511 * @param data The Uri of the data this intent is now targeting.
8512 * @param type The MIME type of the data being handled by this intent.
8513 *
8514 * @return Returns the same Intent object, for chaining multiple calls
8515 * into a single statement.
8516 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008517 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008518 * @see #setData
8519 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008520 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008521 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008522 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008523 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008524 mData = data;
8525 mType = type;
8526 return this;
8527 }
8528
8529 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008530 * (Usually optional) Normalize and set both the data Uri and an explicit
8531 * MIME data type. This method should very rarely be used -- it allows you
8532 * to override the MIME type that would ordinarily be inferred from the
8533 * data with your own type given here.
8534 *
8535 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008536 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008537 * before they are set, so really this is just a convenience method for
8538 * <pre>
8539 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8540 * </pre>
8541 *
8542 * @param data The Uri of the data this intent is now targeting.
8543 * @param type The MIME type of the data being handled by this intent.
8544 *
8545 * @return Returns the same Intent object, for chaining multiple calls
8546 * into a single statement.
8547 *
8548 * @see #setType
8549 * @see #setData
8550 * @see #setDataAndType
8551 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008552 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008553 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008554 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008555 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008556 }
8557
8558 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008559 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008560 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008561 * activities that provide <em>all</em> of the requested categories will be
8562 * used.
8563 *
8564 * @param category The desired category. This can be either one of the
8565 * predefined Intent categories, or a custom category in your own
8566 * namespace.
8567 *
8568 * @return Returns the same Intent object, for chaining multiple calls
8569 * into a single statement.
8570 *
8571 * @see #hasCategory
8572 * @see #removeCategory
8573 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008574 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008576 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008577 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008578 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008579 return this;
8580 }
8581
8582 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008583 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008584 *
8585 * @param category The category to remove.
8586 *
8587 * @see #addCategory
8588 */
8589 public void removeCategory(String category) {
8590 if (mCategories != null) {
8591 mCategories.remove(category);
8592 if (mCategories.size() == 0) {
8593 mCategories = null;
8594 }
8595 }
8596 }
8597
8598 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008599 * Set a selector for this Intent. This is a modification to the kinds of
8600 * things the Intent will match. If the selector is set, it will be used
8601 * when trying to find entities that can handle the Intent, instead of the
8602 * main contents of the Intent. This allows you build an Intent containing
8603 * a generic protocol while targeting it more specifically.
8604 *
8605 * <p>An example of where this may be used is with things like
8606 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8607 * Intent that will launch the Browser application. However, the correct
8608 * main entry point of an application is actually {@link #ACTION_MAIN}
8609 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8610 * used to specify the actual Activity to launch. If you launch the browser
8611 * with something different, undesired behavior may happen if the user has
8612 * previously or later launches it the normal way, since they do not match.
8613 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8614 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8615 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8616 *
8617 * <p>Setting a selector does not impact the behavior of
8618 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8619 * desired behavior of a selector -- it does not impact the base meaning
8620 * of the Intent, just what kinds of things will be matched against it
8621 * when determining who can handle it.</p>
8622 *
8623 * <p>You can not use both a selector and {@link #setPackage(String)} on
8624 * the same base Intent.</p>
8625 *
8626 * @param selector The desired selector Intent; set to null to not use
8627 * a special selector.
8628 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008629 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008630 if (selector == this) {
8631 throw new IllegalArgumentException(
8632 "Intent being set as a selector of itself");
8633 }
8634 if (selector != null && mPackage != null) {
8635 throw new IllegalArgumentException(
8636 "Can't set selector when package name is already set");
8637 }
8638 mSelector = selector;
8639 }
8640
8641 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008642 * Set a {@link ClipData} associated with this Intent. This replaces any
8643 * previously set ClipData.
8644 *
8645 * <p>The ClipData in an intent is not used for Intent matching or other
8646 * such operations. Semantically it is like extras, used to transmit
8647 * additional data with the Intent. The main feature of using this over
8648 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8649 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8650 * items included in the clip data. This is useful, in particular, if
8651 * you want to transmit an Intent containing multiple <code>content:</code>
8652 * URIs for which the recipient may not have global permission to access the
8653 * content provider.
8654 *
8655 * <p>If the ClipData contains items that are themselves Intents, any
8656 * grant flags in those Intents will be ignored. Only the top-level flags
8657 * of the main Intent are respected, and will be applied to all Uri or
8658 * Intent items in the clip (or sub-items of the clip).
8659 *
8660 * <p>The MIME type, label, and icon in the ClipData object are not
8661 * directly used by Intent. Applications should generally rely on the
8662 * MIME type of the Intent itself, not what it may find in the ClipData.
8663 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008664 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008665 *
8666 * @param clip The new clip to set. May be null to clear the current clip.
8667 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008668 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008669 mClipData = clip;
8670 }
8671
8672 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008673 * This is NOT a secure mechanism to identify the user who sent the intent.
8674 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8675 * who sent the intent.
8676 * @hide
8677 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008678 public void prepareToLeaveUser(int userId) {
8679 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8680 // We want mContentUserHint to refer to the original user, so don't do anything.
8681 if (mContentUserHint == UserHandle.USER_CURRENT) {
8682 mContentUserHint = userId;
8683 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008684 }
8685
8686 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008687 * Add extended data to the intent. The name must include a package
8688 * prefix, for example the app com.android.contacts would use names
8689 * like "com.android.contacts.ShowAll".
8690 *
8691 * @param name The name of the extra data, with package prefix.
8692 * @param value The boolean data value.
8693 *
8694 * @return Returns the same Intent object, for chaining multiple calls
8695 * into a single statement.
8696 *
8697 * @see #putExtras
8698 * @see #removeExtra
8699 * @see #getBooleanExtra(String, boolean)
8700 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008701 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008702 if (mExtras == null) {
8703 mExtras = new Bundle();
8704 }
8705 mExtras.putBoolean(name, value);
8706 return this;
8707 }
8708
8709 /**
8710 * Add extended data to the intent. The name must include a package
8711 * prefix, for example the app com.android.contacts would use names
8712 * like "com.android.contacts.ShowAll".
8713 *
8714 * @param name The name of the extra data, with package prefix.
8715 * @param value The byte data value.
8716 *
8717 * @return Returns the same Intent object, for chaining multiple calls
8718 * into a single statement.
8719 *
8720 * @see #putExtras
8721 * @see #removeExtra
8722 * @see #getByteExtra(String, byte)
8723 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008724 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008725 if (mExtras == null) {
8726 mExtras = new Bundle();
8727 }
8728 mExtras.putByte(name, value);
8729 return this;
8730 }
8731
8732 /**
8733 * Add extended data to the intent. The name must include a package
8734 * prefix, for example the app com.android.contacts would use names
8735 * like "com.android.contacts.ShowAll".
8736 *
8737 * @param name The name of the extra data, with package prefix.
8738 * @param value The char data value.
8739 *
8740 * @return Returns the same Intent object, for chaining multiple calls
8741 * into a single statement.
8742 *
8743 * @see #putExtras
8744 * @see #removeExtra
8745 * @see #getCharExtra(String, char)
8746 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008747 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008748 if (mExtras == null) {
8749 mExtras = new Bundle();
8750 }
8751 mExtras.putChar(name, value);
8752 return this;
8753 }
8754
8755 /**
8756 * Add extended data to the intent. The name must include a package
8757 * prefix, for example the app com.android.contacts would use names
8758 * like "com.android.contacts.ShowAll".
8759 *
8760 * @param name The name of the extra data, with package prefix.
8761 * @param value The short data value.
8762 *
8763 * @return Returns the same Intent object, for chaining multiple calls
8764 * into a single statement.
8765 *
8766 * @see #putExtras
8767 * @see #removeExtra
8768 * @see #getShortExtra(String, short)
8769 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008770 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008771 if (mExtras == null) {
8772 mExtras = new Bundle();
8773 }
8774 mExtras.putShort(name, value);
8775 return this;
8776 }
8777
8778 /**
8779 * Add extended data to the intent. The name must include a package
8780 * prefix, for example the app com.android.contacts would use names
8781 * like "com.android.contacts.ShowAll".
8782 *
8783 * @param name The name of the extra data, with package prefix.
8784 * @param value The integer data value.
8785 *
8786 * @return Returns the same Intent object, for chaining multiple calls
8787 * into a single statement.
8788 *
8789 * @see #putExtras
8790 * @see #removeExtra
8791 * @see #getIntExtra(String, int)
8792 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008793 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008794 if (mExtras == null) {
8795 mExtras = new Bundle();
8796 }
8797 mExtras.putInt(name, value);
8798 return this;
8799 }
8800
8801 /**
8802 * Add extended data to the intent. The name must include a package
8803 * prefix, for example the app com.android.contacts would use names
8804 * like "com.android.contacts.ShowAll".
8805 *
8806 * @param name The name of the extra data, with package prefix.
8807 * @param value The long data value.
8808 *
8809 * @return Returns the same Intent object, for chaining multiple calls
8810 * into a single statement.
8811 *
8812 * @see #putExtras
8813 * @see #removeExtra
8814 * @see #getLongExtra(String, long)
8815 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008816 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008817 if (mExtras == null) {
8818 mExtras = new Bundle();
8819 }
8820 mExtras.putLong(name, value);
8821 return this;
8822 }
8823
8824 /**
8825 * Add extended data to the intent. The name must include a package
8826 * prefix, for example the app com.android.contacts would use names
8827 * like "com.android.contacts.ShowAll".
8828 *
8829 * @param name The name of the extra data, with package prefix.
8830 * @param value The float data value.
8831 *
8832 * @return Returns the same Intent object, for chaining multiple calls
8833 * into a single statement.
8834 *
8835 * @see #putExtras
8836 * @see #removeExtra
8837 * @see #getFloatExtra(String, float)
8838 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008839 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008840 if (mExtras == null) {
8841 mExtras = new Bundle();
8842 }
8843 mExtras.putFloat(name, value);
8844 return this;
8845 }
8846
8847 /**
8848 * Add extended data to the intent. The name must include a package
8849 * prefix, for example the app com.android.contacts would use names
8850 * like "com.android.contacts.ShowAll".
8851 *
8852 * @param name The name of the extra data, with package prefix.
8853 * @param value The double data value.
8854 *
8855 * @return Returns the same Intent object, for chaining multiple calls
8856 * into a single statement.
8857 *
8858 * @see #putExtras
8859 * @see #removeExtra
8860 * @see #getDoubleExtra(String, double)
8861 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008862 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008863 if (mExtras == null) {
8864 mExtras = new Bundle();
8865 }
8866 mExtras.putDouble(name, value);
8867 return this;
8868 }
8869
8870 /**
8871 * Add extended data to the intent. The name must include a package
8872 * prefix, for example the app com.android.contacts would use names
8873 * like "com.android.contacts.ShowAll".
8874 *
8875 * @param name The name of the extra data, with package prefix.
8876 * @param value The String data value.
8877 *
8878 * @return Returns the same Intent object, for chaining multiple calls
8879 * into a single statement.
8880 *
8881 * @see #putExtras
8882 * @see #removeExtra
8883 * @see #getStringExtra(String)
8884 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008885 public @NonNull Intent putExtra(String name, @Nullable String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008886 if (mExtras == null) {
8887 mExtras = new Bundle();
8888 }
8889 mExtras.putString(name, value);
8890 return this;
8891 }
8892
8893 /**
8894 * Add extended data to the intent. The name must include a package
8895 * prefix, for example the app com.android.contacts would use names
8896 * like "com.android.contacts.ShowAll".
8897 *
8898 * @param name The name of the extra data, with package prefix.
8899 * @param value The CharSequence data value.
8900 *
8901 * @return Returns the same Intent object, for chaining multiple calls
8902 * into a single statement.
8903 *
8904 * @see #putExtras
8905 * @see #removeExtra
8906 * @see #getCharSequenceExtra(String)
8907 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008908 public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008909 if (mExtras == null) {
8910 mExtras = new Bundle();
8911 }
8912 mExtras.putCharSequence(name, value);
8913 return this;
8914 }
8915
8916 /**
8917 * Add extended data to the intent. The name must include a package
8918 * prefix, for example the app com.android.contacts would use names
8919 * like "com.android.contacts.ShowAll".
8920 *
8921 * @param name The name of the extra data, with package prefix.
8922 * @param value The Parcelable data value.
8923 *
8924 * @return Returns the same Intent object, for chaining multiple calls
8925 * into a single statement.
8926 *
8927 * @see #putExtras
8928 * @see #removeExtra
8929 * @see #getParcelableExtra(String)
8930 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008931 public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008932 if (mExtras == null) {
8933 mExtras = new Bundle();
8934 }
8935 mExtras.putParcelable(name, value);
8936 return this;
8937 }
8938
8939 /**
8940 * Add extended data to the intent. The name must include a package
8941 * prefix, for example the app com.android.contacts would use names
8942 * like "com.android.contacts.ShowAll".
8943 *
8944 * @param name The name of the extra data, with package prefix.
8945 * @param value The Parcelable[] data value.
8946 *
8947 * @return Returns the same Intent object, for chaining multiple calls
8948 * into a single statement.
8949 *
8950 * @see #putExtras
8951 * @see #removeExtra
8952 * @see #getParcelableArrayExtra(String)
8953 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008954 public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008955 if (mExtras == null) {
8956 mExtras = new Bundle();
8957 }
8958 mExtras.putParcelableArray(name, value);
8959 return this;
8960 }
8961
8962 /**
8963 * Add extended data to the intent. The name must include a package
8964 * prefix, for example the app com.android.contacts would use names
8965 * like "com.android.contacts.ShowAll".
8966 *
8967 * @param name The name of the extra data, with package prefix.
8968 * @param value The ArrayList<Parcelable> data value.
8969 *
8970 * @return Returns the same Intent object, for chaining multiple calls
8971 * into a single statement.
8972 *
8973 * @see #putExtras
8974 * @see #removeExtra
8975 * @see #getParcelableArrayListExtra(String)
8976 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008977 public @NonNull Intent putParcelableArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00008978 @Nullable ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008979 if (mExtras == null) {
8980 mExtras = new Bundle();
8981 }
8982 mExtras.putParcelableArrayList(name, value);
8983 return this;
8984 }
8985
8986 /**
8987 * Add extended data to the intent. The name must include a package
8988 * prefix, for example the app com.android.contacts would use names
8989 * like "com.android.contacts.ShowAll".
8990 *
8991 * @param name The name of the extra data, with package prefix.
8992 * @param value The ArrayList<Integer> data value.
8993 *
8994 * @return Returns the same Intent object, for chaining multiple calls
8995 * into a single statement.
8996 *
8997 * @see #putExtras
8998 * @see #removeExtra
8999 * @see #getIntegerArrayListExtra(String)
9000 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009001 public @NonNull Intent putIntegerArrayListExtra(String name,
9002 @Nullable ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009003 if (mExtras == null) {
9004 mExtras = new Bundle();
9005 }
9006 mExtras.putIntegerArrayList(name, value);
9007 return this;
9008 }
9009
9010 /**
9011 * Add extended data to the intent. The name must include a package
9012 * prefix, for example the app com.android.contacts would use names
9013 * like "com.android.contacts.ShowAll".
9014 *
9015 * @param name The name of the extra data, with package prefix.
9016 * @param value The ArrayList<String> data value.
9017 *
9018 * @return Returns the same Intent object, for chaining multiple calls
9019 * into a single statement.
9020 *
9021 * @see #putExtras
9022 * @see #removeExtra
9023 * @see #getStringArrayListExtra(String)
9024 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009025 public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009026 if (mExtras == null) {
9027 mExtras = new Bundle();
9028 }
9029 mExtras.putStringArrayList(name, value);
9030 return this;
9031 }
9032
9033 /**
9034 * Add extended data to the intent. The name must include a package
9035 * prefix, for example the app com.android.contacts would use names
9036 * like "com.android.contacts.ShowAll".
9037 *
9038 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009039 * @param value The ArrayList<CharSequence> data value.
9040 *
9041 * @return Returns the same Intent object, for chaining multiple calls
9042 * into a single statement.
9043 *
9044 * @see #putExtras
9045 * @see #removeExtra
9046 * @see #getCharSequenceArrayListExtra(String)
9047 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009048 public @NonNull Intent putCharSequenceArrayListExtra(String name,
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009049 @Nullable ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009050 if (mExtras == null) {
9051 mExtras = new Bundle();
9052 }
9053 mExtras.putCharSequenceArrayList(name, value);
9054 return this;
9055 }
9056
9057 /**
9058 * Add extended data to the intent. The name must include a package
9059 * prefix, for example the app com.android.contacts would use names
9060 * like "com.android.contacts.ShowAll".
9061 *
9062 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009063 * @param value The Serializable data value.
9064 *
9065 * @return Returns the same Intent object, for chaining multiple calls
9066 * into a single statement.
9067 *
9068 * @see #putExtras
9069 * @see #removeExtra
9070 * @see #getSerializableExtra(String)
9071 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009072 public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009073 if (mExtras == null) {
9074 mExtras = new Bundle();
9075 }
9076 mExtras.putSerializable(name, value);
9077 return this;
9078 }
9079
9080 /**
9081 * Add extended data to the intent. The name must include a package
9082 * prefix, for example the app com.android.contacts would use names
9083 * like "com.android.contacts.ShowAll".
9084 *
9085 * @param name The name of the extra data, with package prefix.
9086 * @param value The boolean array data value.
9087 *
9088 * @return Returns the same Intent object, for chaining multiple calls
9089 * into a single statement.
9090 *
9091 * @see #putExtras
9092 * @see #removeExtra
9093 * @see #getBooleanArrayExtra(String)
9094 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009095 public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009096 if (mExtras == null) {
9097 mExtras = new Bundle();
9098 }
9099 mExtras.putBooleanArray(name, value);
9100 return this;
9101 }
9102
9103 /**
9104 * Add extended data to the intent. The name must include a package
9105 * prefix, for example the app com.android.contacts would use names
9106 * like "com.android.contacts.ShowAll".
9107 *
9108 * @param name The name of the extra data, with package prefix.
9109 * @param value The byte array data value.
9110 *
9111 * @return Returns the same Intent object, for chaining multiple calls
9112 * into a single statement.
9113 *
9114 * @see #putExtras
9115 * @see #removeExtra
9116 * @see #getByteArrayExtra(String)
9117 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009118 public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 if (mExtras == null) {
9120 mExtras = new Bundle();
9121 }
9122 mExtras.putByteArray(name, value);
9123 return this;
9124 }
9125
9126 /**
9127 * Add extended data to the intent. The name must include a package
9128 * prefix, for example the app com.android.contacts would use names
9129 * like "com.android.contacts.ShowAll".
9130 *
9131 * @param name The name of the extra data, with package prefix.
9132 * @param value The short array data value.
9133 *
9134 * @return Returns the same Intent object, for chaining multiple calls
9135 * into a single statement.
9136 *
9137 * @see #putExtras
9138 * @see #removeExtra
9139 * @see #getShortArrayExtra(String)
9140 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009141 public @NonNull Intent putExtra(String name, @Nullable short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009142 if (mExtras == null) {
9143 mExtras = new Bundle();
9144 }
9145 mExtras.putShortArray(name, value);
9146 return this;
9147 }
9148
9149 /**
9150 * Add extended data to the intent. The name must include a package
9151 * prefix, for example the app com.android.contacts would use names
9152 * like "com.android.contacts.ShowAll".
9153 *
9154 * @param name The name of the extra data, with package prefix.
9155 * @param value The char array data value.
9156 *
9157 * @return Returns the same Intent object, for chaining multiple calls
9158 * into a single statement.
9159 *
9160 * @see #putExtras
9161 * @see #removeExtra
9162 * @see #getCharArrayExtra(String)
9163 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009164 public @NonNull Intent putExtra(String name, @Nullable char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009165 if (mExtras == null) {
9166 mExtras = new Bundle();
9167 }
9168 mExtras.putCharArray(name, value);
9169 return this;
9170 }
9171
9172 /**
9173 * Add extended data to the intent. The name must include a package
9174 * prefix, for example the app com.android.contacts would use names
9175 * like "com.android.contacts.ShowAll".
9176 *
9177 * @param name The name of the extra data, with package prefix.
9178 * @param value The int array data value.
9179 *
9180 * @return Returns the same Intent object, for chaining multiple calls
9181 * into a single statement.
9182 *
9183 * @see #putExtras
9184 * @see #removeExtra
9185 * @see #getIntArrayExtra(String)
9186 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009187 public @NonNull Intent putExtra(String name, @Nullable int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009188 if (mExtras == null) {
9189 mExtras = new Bundle();
9190 }
9191 mExtras.putIntArray(name, value);
9192 return this;
9193 }
9194
9195 /**
9196 * Add extended data to the intent. The name must include a package
9197 * prefix, for example the app com.android.contacts would use names
9198 * like "com.android.contacts.ShowAll".
9199 *
9200 * @param name The name of the extra data, with package prefix.
9201 * @param value The byte array data value.
9202 *
9203 * @return Returns the same Intent object, for chaining multiple calls
9204 * into a single statement.
9205 *
9206 * @see #putExtras
9207 * @see #removeExtra
9208 * @see #getLongArrayExtra(String)
9209 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009210 public @NonNull Intent putExtra(String name, @Nullable long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009211 if (mExtras == null) {
9212 mExtras = new Bundle();
9213 }
9214 mExtras.putLongArray(name, value);
9215 return this;
9216 }
9217
9218 /**
9219 * Add extended data to the intent. The name must include a package
9220 * prefix, for example the app com.android.contacts would use names
9221 * like "com.android.contacts.ShowAll".
9222 *
9223 * @param name The name of the extra data, with package prefix.
9224 * @param value The float array data value.
9225 *
9226 * @return Returns the same Intent object, for chaining multiple calls
9227 * into a single statement.
9228 *
9229 * @see #putExtras
9230 * @see #removeExtra
9231 * @see #getFloatArrayExtra(String)
9232 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009233 public @NonNull Intent putExtra(String name, @Nullable float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009234 if (mExtras == null) {
9235 mExtras = new Bundle();
9236 }
9237 mExtras.putFloatArray(name, value);
9238 return this;
9239 }
9240
9241 /**
9242 * Add extended data to the intent. The name must include a package
9243 * prefix, for example the app com.android.contacts would use names
9244 * like "com.android.contacts.ShowAll".
9245 *
9246 * @param name The name of the extra data, with package prefix.
9247 * @param value The double array data value.
9248 *
9249 * @return Returns the same Intent object, for chaining multiple calls
9250 * into a single statement.
9251 *
9252 * @see #putExtras
9253 * @see #removeExtra
9254 * @see #getDoubleArrayExtra(String)
9255 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009256 public @NonNull Intent putExtra(String name, @Nullable double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009257 if (mExtras == null) {
9258 mExtras = new Bundle();
9259 }
9260 mExtras.putDoubleArray(name, value);
9261 return this;
9262 }
9263
9264 /**
9265 * Add extended data to the intent. The name must include a package
9266 * prefix, for example the app com.android.contacts would use names
9267 * like "com.android.contacts.ShowAll".
9268 *
9269 * @param name The name of the extra data, with package prefix.
9270 * @param value The String array data value.
9271 *
9272 * @return Returns the same Intent object, for chaining multiple calls
9273 * into a single statement.
9274 *
9275 * @see #putExtras
9276 * @see #removeExtra
9277 * @see #getStringArrayExtra(String)
9278 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009279 public @NonNull Intent putExtra(String name, @Nullable String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009280 if (mExtras == null) {
9281 mExtras = new Bundle();
9282 }
9283 mExtras.putStringArray(name, value);
9284 return this;
9285 }
9286
9287 /**
9288 * Add extended data to the intent. The name must include a package
9289 * prefix, for example the app com.android.contacts would use names
9290 * like "com.android.contacts.ShowAll".
9291 *
9292 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009293 * @param value The CharSequence array data value.
9294 *
9295 * @return Returns the same Intent object, for chaining multiple calls
9296 * into a single statement.
9297 *
9298 * @see #putExtras
9299 * @see #removeExtra
9300 * @see #getCharSequenceArrayExtra(String)
9301 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009302 public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00009303 if (mExtras == null) {
9304 mExtras = new Bundle();
9305 }
9306 mExtras.putCharSequenceArray(name, value);
9307 return this;
9308 }
9309
9310 /**
9311 * Add extended data to the intent. The name must include a package
9312 * prefix, for example the app com.android.contacts would use names
9313 * like "com.android.contacts.ShowAll".
9314 *
9315 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009316 * @param value The Bundle data value.
9317 *
9318 * @return Returns the same Intent object, for chaining multiple calls
9319 * into a single statement.
9320 *
9321 * @see #putExtras
9322 * @see #removeExtra
9323 * @see #getBundleExtra(String)
9324 */
Andrey Kulikov641c15c2018-11-13 16:44:40 +00009325 public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009326 if (mExtras == null) {
9327 mExtras = new Bundle();
9328 }
9329 mExtras.putBundle(name, value);
9330 return this;
9331 }
9332
9333 /**
9334 * Add extended data to the intent. The name must include a package
9335 * prefix, for example the app com.android.contacts would use names
9336 * like "com.android.contacts.ShowAll".
9337 *
9338 * @param name The name of the extra data, with package prefix.
9339 * @param value The IBinder data value.
9340 *
9341 * @return Returns the same Intent object, for chaining multiple calls
9342 * into a single statement.
9343 *
9344 * @see #putExtras
9345 * @see #removeExtra
9346 * @see #getIBinderExtra(String)
9347 *
9348 * @deprecated
9349 * @hide
9350 */
9351 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009352 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009353 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009354 if (mExtras == null) {
9355 mExtras = new Bundle();
9356 }
9357 mExtras.putIBinder(name, value);
9358 return this;
9359 }
9360
9361 /**
9362 * Copy all extras in 'src' in to this intent.
9363 *
9364 * @param src Contains the extras to copy.
9365 *
9366 * @see #putExtra
9367 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009368 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009369 if (src.mExtras != null) {
9370 if (mExtras == null) {
9371 mExtras = new Bundle(src.mExtras);
9372 } else {
9373 mExtras.putAll(src.mExtras);
9374 }
9375 }
9376 return this;
9377 }
9378
9379 /**
9380 * Add a set of extended data to the intent. The keys must include a package
9381 * prefix, for example the app com.android.contacts would use names
9382 * like "com.android.contacts.ShowAll".
9383 *
9384 * @param extras The Bundle of extras to add to this intent.
9385 *
9386 * @see #putExtra
9387 * @see #removeExtra
9388 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009389 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009390 if (mExtras == null) {
9391 mExtras = new Bundle();
9392 }
9393 mExtras.putAll(extras);
9394 return this;
9395 }
9396
9397 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009398 * Completely replace the extras in the Intent with the extras in the
9399 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009400 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009401 * @param src The exact extras contained in this Intent are copied
9402 * into the target intent, replacing any that were previously there.
9403 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009404 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009405 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9406 return this;
9407 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009408
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009409 /**
9410 * Completely replace the extras in the Intent with the given Bundle of
9411 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009412 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009413 * @param extras The new set of extras in the Intent, or null to erase
9414 * all extras.
9415 */
Tobias Thierer13991172018-12-23 14:25:58 +00009416 public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009417 mExtras = extras != null ? new Bundle(extras) : null;
9418 return this;
9419 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009420
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009421 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009422 * Remove extended data from the intent.
9423 *
9424 * @see #putExtra
9425 */
9426 public void removeExtra(String name) {
9427 if (mExtras != null) {
9428 mExtras.remove(name);
9429 if (mExtras.size() == 0) {
9430 mExtras = null;
9431 }
9432 }
9433 }
9434
9435 /**
9436 * Set special flags controlling how this intent is handled. Most values
9437 * here depend on the type of component being executed by the Intent,
9438 * specifically the FLAG_ACTIVITY_* flags are all for use with
9439 * {@link Context#startActivity Context.startActivity()} and the
9440 * FLAG_RECEIVER_* flags are all for use with
9441 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9442 *
Scott Main7aee61f2011-02-08 11:25:01 -08009443 * <p>See the
9444 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9445 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009446 * the behavior of your application.
9447 *
9448 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009449 * @return Returns the same Intent object, for chaining multiple calls
9450 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009451 * @see #getFlags
9452 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009453 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009454 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009455 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009456 mFlags = flags;
9457 return this;
9458 }
9459
9460 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009461 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009462 *
9463 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009464 * @return Returns the same Intent object, for chaining multiple calls into
9465 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009466 * @see #setFlags
9467 * @see #getFlags
9468 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009469 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009470 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009471 mFlags |= flags;
9472 return this;
9473 }
9474
9475 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009476 * Remove these flags from the intent.
9477 *
9478 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009479 * @see #setFlags
9480 * @see #getFlags
9481 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009482 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009483 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009484 mFlags &= ~flags;
9485 }
9486
9487 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009488 * (Usually optional) Set an explicit application package name that limits
9489 * the components this Intent will resolve to. If left to the default
9490 * value of null, all components in all applications will considered.
9491 * If non-null, the Intent can only match the components in the given
9492 * application package.
9493 *
9494 * @param packageName The name of the application package to handle the
9495 * intent, or null to allow any application package.
9496 *
9497 * @return Returns the same Intent object, for chaining multiple calls
9498 * into a single statement.
9499 *
9500 * @see #getPackage
9501 * @see #resolveActivity
9502 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009503 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009504 if (packageName != null && mSelector != null) {
9505 throw new IllegalArgumentException(
9506 "Can't set package name when selector is already set");
9507 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009508 mPackage = packageName;
9509 return this;
9510 }
9511
9512 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009513 * (Usually optional) Explicitly set the component to handle the intent.
9514 * If left with the default value of null, the system will determine the
9515 * appropriate class to use based on the other fields (action, data,
9516 * type, categories) in the Intent. If this class is defined, the
9517 * specified class will always be used regardless of the other fields. You
9518 * should only set this value when you know you absolutely want a specific
9519 * class to be used; otherwise it is better to let the system find the
9520 * appropriate class so that you will respect the installed applications
9521 * and user preferences.
9522 *
9523 * @param component The name of the application component to handle the
9524 * intent, or null to let the system find one for you.
9525 *
9526 * @return Returns the same Intent object, for chaining multiple calls
9527 * into a single statement.
9528 *
9529 * @see #setClass
9530 * @see #setClassName(Context, String)
9531 * @see #setClassName(String, String)
9532 * @see #getComponent
9533 * @see #resolveActivity
9534 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009535 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009536 mComponent = component;
9537 return this;
9538 }
9539
9540 /**
9541 * Convenience for calling {@link #setComponent} with an
9542 * explicit class name.
9543 *
9544 * @param packageContext A Context of the application package implementing
9545 * this class.
9546 * @param className The name of a class inside of the application package
9547 * that will be used as the component for this Intent.
9548 *
9549 * @return Returns the same Intent object, for chaining multiple calls
9550 * into a single statement.
9551 *
9552 * @see #setComponent
9553 * @see #setClass
9554 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009555 public @NonNull Intent setClassName(@NonNull Context packageContext,
9556 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009557 mComponent = new ComponentName(packageContext, className);
9558 return this;
9559 }
9560
9561 /**
9562 * Convenience for calling {@link #setComponent} with an
9563 * explicit application package name and class name.
9564 *
9565 * @param packageName The name of the package implementing the desired
9566 * component.
9567 * @param className The name of a class inside of the application package
9568 * that will be used as the component for this Intent.
9569 *
9570 * @return Returns the same Intent object, for chaining multiple calls
9571 * into a single statement.
9572 *
9573 * @see #setComponent
9574 * @see #setClass
9575 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009576 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009577 mComponent = new ComponentName(packageName, className);
9578 return this;
9579 }
9580
9581 /**
9582 * Convenience for calling {@link #setComponent(ComponentName)} with the
9583 * name returned by a {@link Class} object.
9584 *
9585 * @param packageContext A Context of the application package implementing
9586 * this class.
9587 * @param cls The class name to set, equivalent to
9588 * <code>setClassName(context, cls.getName())</code>.
9589 *
9590 * @return Returns the same Intent object, for chaining multiple calls
9591 * into a single statement.
9592 *
9593 * @see #setComponent
9594 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009595 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009596 mComponent = new ComponentName(packageContext, cls);
9597 return this;
9598 }
9599
9600 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009601 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9602 * used as a hint to the receiver for animations and the like. Null means that there
9603 * is no source bounds.
9604 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009605 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009606 if (r != null) {
9607 mSourceBounds = new Rect(r);
9608 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009609 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009610 }
9611 }
9612
Tor Norbyed9273d62013-05-30 15:59:53 -07009613 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009614 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9615 FILL_IN_ACTION,
9616 FILL_IN_DATA,
9617 FILL_IN_CATEGORIES,
9618 FILL_IN_COMPONENT,
9619 FILL_IN_PACKAGE,
9620 FILL_IN_SOURCE_BOUNDS,
9621 FILL_IN_SELECTOR,
9622 FILL_IN_CLIP_DATA
9623 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009624 @Retention(RetentionPolicy.SOURCE)
9625 public @interface FillInFlags {}
9626
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009627 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009628 * Use with {@link #fillIn} to allow the current action value to be
9629 * overwritten, even if it is already set.
9630 */
9631 public static final int FILL_IN_ACTION = 1<<0;
9632
9633 /**
9634 * Use with {@link #fillIn} to allow the current data or type value
9635 * overwritten, even if it is already set.
9636 */
9637 public static final int FILL_IN_DATA = 1<<1;
9638
9639 /**
9640 * Use with {@link #fillIn} to allow the current categories to be
9641 * overwritten, even if they are already set.
9642 */
9643 public static final int FILL_IN_CATEGORIES = 1<<2;
9644
9645 /**
9646 * Use with {@link #fillIn} to allow the current component value to be
9647 * overwritten, even if it is already set.
9648 */
9649 public static final int FILL_IN_COMPONENT = 1<<3;
9650
9651 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009652 * Use with {@link #fillIn} to allow the current package value to be
9653 * overwritten, even if it is already set.
9654 */
9655 public static final int FILL_IN_PACKAGE = 1<<4;
9656
9657 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009658 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009659 * overwritten, even if it is already set.
9660 */
9661 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9662
9663 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009664 * Use with {@link #fillIn} to allow the current selector to be
9665 * overwritten, even if it is already set.
9666 */
9667 public static final int FILL_IN_SELECTOR = 1<<6;
9668
9669 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009670 * Use with {@link #fillIn} to allow the current ClipData to be
9671 * overwritten, even if it is already set.
9672 */
9673 public static final int FILL_IN_CLIP_DATA = 1<<7;
9674
9675 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009676 * Copy the contents of <var>other</var> in to this object, but only
9677 * where fields are not defined by this object. For purposes of a field
9678 * being defined, the following pieces of data in the Intent are
9679 * considered to be separate fields:
9680 *
9681 * <ul>
9682 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009683 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009684 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9685 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009686 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009687 * <li> component, as set by {@link #setComponent(ComponentName)} or
9688 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009689 * <li> source bounds, as set by {@link #setSourceBounds}.
9690 * <li> selector, as set by {@link #setSelector(Intent)}.
9691 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009692 * <li> each top-level name in the associated extras.
9693 * </ul>
9694 *
9695 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009696 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009697 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9698 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9699 * the restriction where the corresponding field will not be replaced if
9700 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009701 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009702 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9703 * is explicitly specified. The selector will only be copied if
9704 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009705 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009706 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9707 * and Intent B with {action="gotit", data-type="some/thing",
9708 * categories="one","two"}.
9709 *
9710 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9711 * containing: {action="gotit", data-type="some/thing",
9712 * categories="bar"}.
9713 *
9714 * @param other Another Intent whose values are to be used to fill in
9715 * the current one.
9716 * @param flags Options to control which fields can be filled in.
9717 *
9718 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009719 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009720 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009721 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009722 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009723 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009724 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009725 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009726 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009727 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009728 if (other.mAction != null
9729 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009730 mAction = other.mAction;
9731 changes |= FILL_IN_ACTION;
9732 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009733 if ((other.mData != null || other.mType != null)
9734 && ((mData == null && mType == null)
9735 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009736 mData = other.mData;
9737 mType = other.mType;
9738 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009739 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009740 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009741 if (other.mCategories != null
9742 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009743 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009744 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009745 }
9746 changes |= FILL_IN_CATEGORIES;
9747 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009748 if (other.mPackage != null
9749 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009750 // Only do this if mSelector is not set.
9751 if (mSelector == null) {
9752 mPackage = other.mPackage;
9753 changes |= FILL_IN_PACKAGE;
9754 }
9755 }
9756 // Selector is special: it can only be set if explicitly allowed,
9757 // for the same reason as the component name.
9758 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9759 if (mPackage == null) {
9760 mSelector = new Intent(other.mSelector);
9761 mPackage = null;
9762 changes |= FILL_IN_SELECTOR;
9763 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009764 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009765 if (other.mClipData != null
9766 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9767 mClipData = other.mClipData;
9768 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009769 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009770 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009771 // Component is special: it can -only- be set if explicitly allowed,
9772 // since otherwise the sender could force the intent somewhere the
9773 // originator didn't intend.
9774 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009775 mComponent = other.mComponent;
9776 changes |= FILL_IN_COMPONENT;
9777 }
9778 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009779 if (other.mSourceBounds != null
9780 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9781 mSourceBounds = new Rect(other.mSourceBounds);
9782 changes |= FILL_IN_SOURCE_BOUNDS;
9783 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009784 if (mExtras == null) {
9785 if (other.mExtras != null) {
9786 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009787 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009788 }
9789 } else if (other.mExtras != null) {
9790 try {
9791 Bundle newb = new Bundle(other.mExtras);
9792 newb.putAll(mExtras);
9793 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009794 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009795 } catch (RuntimeException e) {
9796 // Modifying the extras can cause us to unparcel the contents
9797 // of the bundle, and if we do this in the system process that
9798 // may fail. We really should handle this (i.e., the Bundle
9799 // impl shouldn't be on top of a plain map), but for now just
9800 // ignore it and keep the original contents. :(
9801 Log.w("Intent", "Failure filling in extras", e);
9802 }
9803 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009804 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9805 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9806 mContentUserHint = other.mContentUserHint;
9807 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009808 return changes;
9809 }
9810
9811 /**
9812 * Wrapper class holding an Intent and implementing comparisons on it for
9813 * the purpose of filtering. The class implements its
9814 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9815 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9816 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9817 * on the wrapped Intent.
9818 */
9819 public static final class FilterComparison {
9820 private final Intent mIntent;
9821 private final int mHashCode;
9822
9823 public FilterComparison(Intent intent) {
9824 mIntent = intent;
9825 mHashCode = intent.filterHashCode();
9826 }
9827
9828 /**
9829 * Return the Intent that this FilterComparison represents.
9830 * @return Returns the Intent held by the FilterComparison. Do
9831 * not modify!
9832 */
9833 public Intent getIntent() {
9834 return mIntent;
9835 }
9836
9837 @Override
9838 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009839 if (obj instanceof FilterComparison) {
9840 Intent other = ((FilterComparison)obj).mIntent;
9841 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009842 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009843 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009844 }
9845
9846 @Override
9847 public int hashCode() {
9848 return mHashCode;
9849 }
9850 }
9851
9852 /**
9853 * Determine if two intents are the same for the purposes of intent
9854 * resolution (filtering). That is, if their action, data, type,
9855 * class, and categories are the same. This does <em>not</em> compare
9856 * any extra data included in the intents.
9857 *
9858 * @param other The other Intent to compare against.
9859 *
9860 * @return Returns true if action, data, type, class, and categories
9861 * are the same.
9862 */
9863 public boolean filterEquals(Intent other) {
9864 if (other == null) {
9865 return false;
9866 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009867 if (!Objects.equals(this.mAction, other.mAction)) return false;
9868 if (!Objects.equals(this.mData, other.mData)) return false;
9869 if (!Objects.equals(this.mType, other.mType)) return false;
9870 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9871 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9872 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009873
9874 return true;
9875 }
9876
9877 /**
9878 * Generate hash code that matches semantics of filterEquals().
9879 *
9880 * @return Returns the hash value of the action, data, type, class, and
9881 * categories.
9882 *
9883 * @see #filterEquals
9884 */
9885 public int filterHashCode() {
9886 int code = 0;
9887 if (mAction != null) {
9888 code += mAction.hashCode();
9889 }
9890 if (mData != null) {
9891 code += mData.hashCode();
9892 }
9893 if (mType != null) {
9894 code += mType.hashCode();
9895 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009896 if (mPackage != null) {
9897 code += mPackage.hashCode();
9898 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009899 if (mComponent != null) {
9900 code += mComponent.hashCode();
9901 }
9902 if (mCategories != null) {
9903 code += mCategories.hashCode();
9904 }
9905 return code;
9906 }
9907
9908 @Override
9909 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009910 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009911
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009912 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009913 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009914 b.append(" }");
9915
9916 return b.toString();
9917 }
9918
9919 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009920 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009921 public String toInsecureString() {
9922 StringBuilder b = new StringBuilder(128);
9923
9924 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009925 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009926 b.append(" }");
9927
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009928 return b.toString();
9929 }
Romain Guy4969af72009-06-17 10:53:19 -07009930
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009931 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009932 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009933 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009934
9935 b.append("Intent { ");
9936 toShortString(b, false, true, true, true);
9937 b.append(" }");
9938
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009939 return b.toString();
9940 }
9941
9942 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009943 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9944 StringBuilder b = new StringBuilder(128);
9945 toShortString(b, secure, comp, extras, clip);
9946 return b.toString();
9947 }
9948
9949 /** @hide */
9950 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9951 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009952 boolean first = true;
9953 if (mAction != null) {
9954 b.append("act=").append(mAction);
9955 first = false;
9956 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009957 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009958 if (!first) {
9959 b.append(' ');
9960 }
9961 first = false;
9962 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009963 for (int i=0; i<mCategories.size(); i++) {
9964 if (i > 0) b.append(',');
9965 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009966 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009967 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009968 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009969 if (mData != null) {
9970 if (!first) {
9971 b.append(' ');
9972 }
9973 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009974 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009975 if (secure) {
9976 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009977 } else {
9978 b.append(mData);
9979 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009980 }
9981 if (mType != null) {
9982 if (!first) {
9983 b.append(' ');
9984 }
9985 first = false;
9986 b.append("typ=").append(mType);
9987 }
9988 if (mFlags != 0) {
9989 if (!first) {
9990 b.append(' ');
9991 }
9992 first = false;
9993 b.append("flg=0x").append(Integer.toHexString(mFlags));
9994 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009995 if (mPackage != null) {
9996 if (!first) {
9997 b.append(' ');
9998 }
9999 first = false;
10000 b.append("pkg=").append(mPackage);
10001 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010002 if (comp && mComponent != null) {
10003 if (!first) {
10004 b.append(' ');
10005 }
10006 first = false;
10007 b.append("cmp=").append(mComponent.flattenToShortString());
10008 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010009 if (mSourceBounds != null) {
10010 if (!first) {
10011 b.append(' ');
10012 }
10013 first = false;
10014 b.append("bnds=").append(mSourceBounds.toShortString());
10015 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010016 if (mClipData != null) {
10017 if (!first) {
10018 b.append(' ');
10019 }
Dianne Hackbornae498722015-08-14 13:29:47 -070010020 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010021 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010022 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010023 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -070010024 if (mClipData.getDescription() != null) {
10025 first = !mClipData.getDescription().toShortStringTypesOnly(b);
10026 } else {
10027 first = true;
10028 }
10029 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010030 }
Dianne Hackbornae498722015-08-14 13:29:47 -070010031 first = false;
10032 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010033 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010034 if (extras && mExtras != null) {
10035 if (!first) {
10036 b.append(' ');
10037 }
10038 first = false;
10039 b.append("(has extras)");
10040 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010041 if (mContentUserHint != UserHandle.USER_CURRENT) {
10042 if (!first) {
10043 b.append(' ');
10044 }
10045 first = false;
10046 b.append("u=").append(mContentUserHint);
10047 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010048 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010049 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010050 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010051 b.append("}");
10052 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010053 }
10054
Yi Jin129fc6c2017-09-28 15:48:38 -070010055 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -080010056 public void writeToProto(ProtoOutputStream proto, long fieldId) {
10057 // Same input parameters that toString() gives to toShortString().
10058 writeToProto(proto, fieldId, true, true, true, false);
10059 }
10060
10061 /** @hide */
Igor Murashkine9e439a2019-01-22 13:12:06 -080010062 public void writeToProto(ProtoOutputStream proto) {
10063 // Same input parameters that toString() gives to toShortString().
10064 writeToProtoWithoutFieldId(proto, true, true, true, false);
10065 }
10066
10067 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -070010068 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10069 boolean extras, boolean clip) {
10070 long token = proto.start(fieldId);
Igor Murashkine9e439a2019-01-22 13:12:06 -080010071 writeToProtoWithoutFieldId(proto, secure, comp, extras, clip);
10072 proto.end(token);
10073 }
10074
10075 private void writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10076 boolean extras, boolean clip) {
Yi Jin129fc6c2017-09-28 15:48:38 -070010077 if (mAction != null) {
10078 proto.write(IntentProto.ACTION, mAction);
10079 }
10080 if (mCategories != null) {
10081 for (String category : mCategories) {
10082 proto.write(IntentProto.CATEGORIES, category);
10083 }
10084 }
10085 if (mData != null) {
10086 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10087 }
10088 if (mType != null) {
10089 proto.write(IntentProto.TYPE, mType);
10090 }
10091 if (mFlags != 0) {
10092 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10093 }
10094 if (mPackage != null) {
10095 proto.write(IntentProto.PACKAGE, mPackage);
10096 }
10097 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -080010098 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -070010099 }
10100 if (mSourceBounds != null) {
10101 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10102 }
10103 if (mClipData != null) {
10104 StringBuilder b = new StringBuilder();
10105 if (clip) {
10106 mClipData.toShortString(b);
10107 } else {
10108 mClipData.toShortStringShortItems(b, false);
10109 }
10110 proto.write(IntentProto.CLIP_DATA, b.toString());
10111 }
10112 if (extras && mExtras != null) {
10113 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10114 }
10115 if (mContentUserHint != 0) {
10116 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10117 }
10118 if (mSelector != null) {
10119 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10120 }
Yi Jin129fc6c2017-09-28 15:48:38 -070010121 }
10122
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010123 /**
10124 * Call {@link #toUri} with 0 flags.
10125 * @deprecated Use {@link #toUri} instead.
10126 */
10127 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010128 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010129 return toUri(0);
10130 }
10131
10132 /**
10133 * Convert this Intent into a String holding a URI representation of it.
10134 * The returned URI string has been properly URI encoded, so it can be
10135 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
10136 * Intent's data as the base URI, with an additional fragment describing
10137 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -080010138 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010139 * <p>You can convert the returned string back to an Intent with
10140 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -080010141 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010142 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -080010143 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010144 * @return Returns a URI encoding URI string describing the entire contents
10145 * of the Intent.
10146 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010147 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070010148 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010149 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10150 if (mPackage == null) {
10151 throw new IllegalArgumentException(
10152 "Intent must include an explicit package name to build an android-app: "
10153 + this);
10154 }
10155 uri.append("android-app://");
10156 uri.append(mPackage);
10157 String scheme = null;
10158 if (mData != null) {
10159 scheme = mData.getScheme();
10160 if (scheme != null) {
10161 uri.append('/');
10162 uri.append(scheme);
10163 String authority = mData.getEncodedAuthority();
10164 if (authority != null) {
10165 uri.append('/');
10166 uri.append(authority);
10167 String path = mData.getEncodedPath();
10168 if (path != null) {
10169 uri.append(path);
10170 }
10171 String queryParams = mData.getEncodedQuery();
10172 if (queryParams != null) {
10173 uri.append('?');
10174 uri.append(queryParams);
10175 }
10176 String fragment = mData.getEncodedFragment();
10177 if (fragment != null) {
10178 uri.append('#');
10179 uri.append(fragment);
10180 }
10181 }
10182 }
10183 }
10184 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10185 mPackage, flags);
10186 return uri.toString();
10187 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010188 String scheme = null;
10189 if (mData != null) {
10190 String data = mData.toString();
10191 if ((flags&URI_INTENT_SCHEME) != 0) {
10192 final int N = data.length();
10193 for (int i=0; i<N; i++) {
10194 char c = data.charAt(i);
10195 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -070010196 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010197 continue;
10198 }
10199 if (c == ':' && i > 0) {
10200 // Valid scheme.
10201 scheme = data.substring(0, i);
10202 uri.append("intent:");
10203 data = data.substring(i+1);
10204 break;
10205 }
Tom Taylord4a47292009-12-21 13:59:18 -080010206
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010207 // No scheme.
10208 break;
10209 }
10210 }
10211 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -080010212
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010213 } else if ((flags&URI_INTENT_SCHEME) != 0) {
10214 uri.append("intent:");
10215 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010216
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010217 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010218
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010219 return uri.toString();
10220 }
10221
10222 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10223 String defPackage, int flags) {
10224 StringBuilder frag = new StringBuilder(128);
10225
10226 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010227 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -080010228 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010229 // Note that for now we are not going to try to handle the
10230 // data part; not clear how to represent this as a URI, and
10231 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010232 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10233 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010234 }
10235
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010236 if (frag.length() > 0) {
10237 uri.append("#Intent;");
10238 uri.append(frag);
10239 uri.append("end");
10240 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010241 }
10242
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010243 private void toUriInner(StringBuilder uri, String scheme, String defAction,
10244 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010245 if (scheme != null) {
10246 uri.append("scheme=").append(scheme).append(';');
10247 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010248 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010249 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010250 }
10251 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010252 for (int i=0; i<mCategories.size(); i++) {
10253 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010254 }
10255 }
10256 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010257 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010258 }
10259 if (mFlags != 0) {
10260 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10261 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -080010262 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010263 uri.append("package=").append(Uri.encode(mPackage)).append(';');
10264 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010265 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010266 uri.append("component=").append(Uri.encode(
10267 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010268 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010269 if (mSourceBounds != null) {
10270 uri.append("sourceBounds=")
10271 .append(Uri.encode(mSourceBounds.flattenToString()))
10272 .append(';');
10273 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010274 if (mExtras != null) {
10275 for (String key : mExtras.keySet()) {
10276 final Object value = mExtras.get(key);
10277 char entryType =
10278 value instanceof String ? 'S' :
10279 value instanceof Boolean ? 'B' :
10280 value instanceof Byte ? 'b' :
10281 value instanceof Character ? 'c' :
10282 value instanceof Double ? 'd' :
10283 value instanceof Float ? 'f' :
10284 value instanceof Integer ? 'i' :
10285 value instanceof Long ? 'l' :
10286 value instanceof Short ? 's' :
10287 '\0';
10288
10289 if (entryType != '\0') {
10290 uri.append(entryType);
10291 uri.append('.');
10292 uri.append(Uri.encode(key));
10293 uri.append('=');
10294 uri.append(Uri.encode(value.toString()));
10295 uri.append(';');
10296 }
10297 }
10298 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010299 }
The Android Open Source Project10592532009-03-18 17:39:46 -070010300
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010301 public int describeContents() {
10302 return (mExtras != null) ? mExtras.describeContents() : 0;
10303 }
10304
10305 public void writeToParcel(Parcel out, int flags) {
10306 out.writeString(mAction);
10307 Uri.writeToParcel(out, mData);
10308 out.writeString(mType);
10309 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010310 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010311 ComponentName.writeToParcel(mComponent, out);
10312
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010313 if (mSourceBounds != null) {
10314 out.writeInt(1);
10315 mSourceBounds.writeToParcel(out, flags);
10316 } else {
10317 out.writeInt(0);
10318 }
10319
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010320 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010321 final int N = mCategories.size();
10322 out.writeInt(N);
10323 for (int i=0; i<N; i++) {
10324 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010325 }
10326 } else {
10327 out.writeInt(0);
10328 }
10329
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010330 if (mSelector != null) {
10331 out.writeInt(1);
10332 mSelector.writeToParcel(out, flags);
10333 } else {
10334 out.writeInt(0);
10335 }
10336
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010337 if (mClipData != null) {
10338 out.writeInt(1);
10339 mClipData.writeToParcel(out, flags);
10340 } else {
10341 out.writeInt(0);
10342 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010343 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010344 out.writeBundle(mExtras);
10345 }
10346
10347 public static final Parcelable.Creator<Intent> CREATOR
10348 = new Parcelable.Creator<Intent>() {
10349 public Intent createFromParcel(Parcel in) {
10350 return new Intent(in);
10351 }
10352 public Intent[] newArray(int size) {
10353 return new Intent[size];
10354 }
10355 };
10356
Dianne Hackborneb034652009-09-07 00:49:58 -070010357 /** @hide */
10358 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010359 readFromParcel(in);
10360 }
10361
10362 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010363 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010364 mData = Uri.CREATOR.createFromParcel(in);
10365 mType = in.readString();
10366 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010367 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010368 mComponent = ComponentName.readFromParcel(in);
10369
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010370 if (in.readInt() != 0) {
10371 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10372 }
10373
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010374 int N = in.readInt();
10375 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010376 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010377 int i;
10378 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010379 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010380 }
10381 } else {
10382 mCategories = null;
10383 }
10384
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010385 if (in.readInt() != 0) {
10386 mSelector = new Intent(in);
10387 }
10388
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010389 if (in.readInt() != 0) {
10390 mClipData = new ClipData(in);
10391 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010392 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010393 mExtras = in.readBundle();
10394 }
10395
10396 /**
10397 * Parses the "intent" element (and its children) from XML and instantiates
10398 * an Intent object. The given XML parser should be located at the tag
10399 * where parsing should start (often named "intent"), from which the
10400 * basic action, data, type, and package and class name will be
10401 * retrieved. The function will then parse in to any child elements,
10402 * looking for <category android:name="xxx"> tags to add categories and
10403 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10404 * to the intent.
10405 *
10406 * @param resources The Resources to use when inflating resources.
10407 * @param parser The XML parser pointing at an "intent" tag.
10408 * @param attrs The AttributeSet interface for retrieving extended
10409 * attribute data at the current <var>parser</var> location.
10410 * @return An Intent object matching the XML data.
10411 * @throws XmlPullParserException If there was an XML parsing error.
10412 * @throws IOException If there was an I/O error.
10413 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010414 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10415 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010416 throws XmlPullParserException, IOException {
10417 Intent intent = new Intent();
10418
10419 TypedArray sa = resources.obtainAttributes(attrs,
10420 com.android.internal.R.styleable.Intent);
10421
10422 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10423
10424 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10425 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10426 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10427
10428 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10429 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10430 if (packageName != null && className != null) {
10431 intent.setComponent(new ComponentName(packageName, className));
10432 }
10433
10434 sa.recycle();
10435
10436 int outerDepth = parser.getDepth();
10437 int type;
10438 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10439 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10440 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10441 continue;
10442 }
10443
10444 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010445 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010446 sa = resources.obtainAttributes(attrs,
10447 com.android.internal.R.styleable.IntentCategory);
10448 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10449 sa.recycle();
10450
10451 if (cat != null) {
10452 intent.addCategory(cat);
10453 }
10454 XmlUtils.skipCurrentTag(parser);
10455
Craig Mautner21d24a22014-04-23 11:45:37 -070010456 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010457 if (intent.mExtras == null) {
10458 intent.mExtras = new Bundle();
10459 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010460 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010461 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010462
10463 } else {
10464 XmlUtils.skipCurrentTag(parser);
10465 }
10466 }
10467
10468 return intent;
10469 }
Nick Pellyccae4122012-01-09 14:12:58 -080010470
Craig Mautner21d24a22014-04-23 11:45:37 -070010471 /** @hide */
10472 public void saveToXml(XmlSerializer out) throws IOException {
10473 if (mAction != null) {
10474 out.attribute(null, ATTR_ACTION, mAction);
10475 }
10476 if (mData != null) {
10477 out.attribute(null, ATTR_DATA, mData.toString());
10478 }
10479 if (mType != null) {
10480 out.attribute(null, ATTR_TYPE, mType);
10481 }
10482 if (mComponent != null) {
10483 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10484 }
10485 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10486
10487 if (mCategories != null) {
10488 out.startTag(null, TAG_CATEGORIES);
10489 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10490 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10491 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010492 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010493 }
10494 }
10495
10496 /** @hide */
10497 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10498 XmlPullParserException {
10499 Intent intent = new Intent();
10500 final int outerDepth = in.getDepth();
10501
10502 int attrCount = in.getAttributeCount();
10503 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10504 final String attrName = in.getAttributeName(attrNdx);
10505 final String attrValue = in.getAttributeValue(attrNdx);
10506 if (ATTR_ACTION.equals(attrName)) {
10507 intent.setAction(attrValue);
10508 } else if (ATTR_DATA.equals(attrName)) {
10509 intent.setData(Uri.parse(attrValue));
10510 } else if (ATTR_TYPE.equals(attrName)) {
10511 intent.setType(attrValue);
10512 } else if (ATTR_COMPONENT.equals(attrName)) {
10513 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10514 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010515 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010516 } else {
10517 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10518 }
10519 }
10520
10521 int event;
10522 String name;
10523 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10524 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10525 if (event == XmlPullParser.START_TAG) {
10526 name = in.getName();
10527 if (TAG_CATEGORIES.equals(name)) {
10528 attrCount = in.getAttributeCount();
10529 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10530 intent.addCategory(in.getAttributeValue(attrNdx));
10531 }
10532 } else {
10533 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10534 XmlUtils.skipCurrentTag(in);
10535 }
10536 }
10537 }
10538
10539 return intent;
10540 }
10541
Nick Pellyccae4122012-01-09 14:12:58 -080010542 /**
10543 * Normalize a MIME data type.
10544 *
10545 * <p>A normalized MIME type has white-space trimmed,
10546 * content-type parameters removed, and is lower-case.
10547 * This aligns the type with Android best practices for
10548 * intent filtering.
10549 *
10550 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10551 * "text/x-vCard" becomes "text/x-vcard".
10552 *
10553 * <p>All MIME types received from outside Android (such as user input,
10554 * or external sources like Bluetooth, NFC, or the Internet) should
10555 * be normalized before they are used to create an Intent.
10556 *
10557 * @param type MIME data type to normalize
10558 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010559 * @see #setType
10560 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010561 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010562 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010563 if (type == null) {
10564 return null;
10565 }
10566
Elliott Hughescb64d432013-08-02 10:00:44 -070010567 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010568
10569 final int semicolonIndex = type.indexOf(';');
10570 if (semicolonIndex != -1) {
10571 type = type.substring(0, semicolonIndex);
10572 }
10573 return type;
10574 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010575
10576 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010577 * Prepare this {@link Intent} to leave an app process.
10578 *
10579 * @hide
10580 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010581 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010582 public void prepareToLeaveProcess(Context context) {
10583 final boolean leavingPackage = (mComponent == null)
10584 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10585 prepareToLeaveProcess(leavingPackage);
10586 }
10587
10588 /**
10589 * Prepare this {@link Intent} to leave an app process.
10590 *
10591 * @hide
10592 */
10593 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010594 setAllowFds(false);
10595
10596 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010597 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010598 }
10599 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010600 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010601 }
10602
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010603 if (mExtras != null && !mExtras.isParcelled()) {
10604 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10605 if (intent instanceof Intent) {
10606 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10607 }
10608 }
10609
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010610 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10611 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010612 switch (mAction) {
10613 case ACTION_MEDIA_REMOVED:
10614 case ACTION_MEDIA_UNMOUNTED:
10615 case ACTION_MEDIA_CHECKING:
10616 case ACTION_MEDIA_NOFS:
10617 case ACTION_MEDIA_MOUNTED:
10618 case ACTION_MEDIA_SHARED:
10619 case ACTION_MEDIA_UNSHARED:
10620 case ACTION_MEDIA_BAD_REMOVAL:
10621 case ACTION_MEDIA_UNMOUNTABLE:
10622 case ACTION_MEDIA_EJECT:
10623 case ACTION_MEDIA_SCANNER_STARTED:
10624 case ACTION_MEDIA_SCANNER_FINISHED:
10625 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010626 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10627 case ACTION_PACKAGE_VERIFIED:
Richard Uhlerb29f1452018-09-12 16:38:15 +010010628 case ACTION_PACKAGE_ENABLE_ROLLBACK:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010629 // Ignore legacy actions
10630 break;
10631 default:
10632 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010633 }
10634 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010635
10636 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10637 && leavingPackage) {
10638 switch (mAction) {
10639 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010640 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010641 // Ignore actions that don't need to grant
10642 break;
10643 default:
10644 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10645 }
10646 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010647 }
10648
10649 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010650 * @hide
10651 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010652 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010653 // We just entered destination process, so we should be able to read all
10654 // parcelables inside.
10655 setDefusable(true);
10656
10657 if (mSelector != null) {
10658 mSelector.prepareToEnterProcess();
10659 }
10660 if (mClipData != null) {
10661 mClipData.prepareToEnterProcess();
10662 }
10663
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010664 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010665 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10666 fixUris(mContentUserHint);
10667 mContentUserHint = UserHandle.USER_CURRENT;
10668 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010669 }
10670 }
10671
Patrick Baumann577d4022018-01-31 16:55:10 +000010672 /** @hide */
10673 public boolean hasWebURI() {
10674 if (getData() == null) {
10675 return false;
10676 }
10677 final String scheme = getScheme();
10678 if (TextUtils.isEmpty(scheme)) {
10679 return false;
10680 }
10681 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10682 }
10683
10684 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010685 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010686 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010687 && hasWebURI();
10688 }
10689
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010690 /**
10691 * @hide
10692 */
10693 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010694 Uri data = getData();
10695 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010696 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010697 }
10698 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010699 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010700 }
10701 String action = getAction();
10702 if (ACTION_SEND.equals(action)) {
10703 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10704 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010705 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010706 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010707 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010708 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10709 if (streams != null) {
10710 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10711 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010712 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010713 }
10714 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10715 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010716 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10717 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10718 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10719 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10720 if (output != null) {
10721 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10722 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010723 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010724 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010725
10726 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010727 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010728 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10729 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010730 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010731 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010732 * @hide
10733 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010734 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010735 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010736 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010737
10738 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010739 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010740
10741 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010742 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010743 // Inspect contained intents to see if we need to migrate extras. We
10744 // don't promote ClipData to the parent, since ChooserActivity will
10745 // already start the picked item as the caller, and we can't combine
10746 // the flags in a safe way.
10747
10748 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010749 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010750 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10751 if (intent != null) {
10752 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010753 }
10754 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010755 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010756 try {
10757 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10758 if (intents != null) {
10759 for (int i = 0; i < intents.length; i++) {
10760 final Intent intent = (Intent) intents[i];
10761 if (intent != null) {
10762 migrated |= intent.migrateExtraStreamToClipData();
10763 }
10764 }
10765 }
10766 } catch (ClassCastException e) {
10767 }
10768 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010769
10770 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010771 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010772 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10773 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10774 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10775 if (stream != null || text != null || htmlText != null) {
10776 final ClipData clipData = new ClipData(
10777 null, new String[] { getType() },
10778 new ClipData.Item(text, htmlText, null, stream));
10779 setClipData(clipData);
10780 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010781 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010782 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010783 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010784 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010785
10786 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010787 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010788 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10789 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10790 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10791 int num = -1;
10792 if (streams != null) {
10793 num = streams.size();
10794 }
10795 if (texts != null) {
10796 if (num >= 0 && num != texts.size()) {
10797 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010798 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010799 }
10800 num = texts.size();
10801 }
10802 if (htmlTexts != null) {
10803 if (num >= 0 && num != htmlTexts.size()) {
10804 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010805 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010806 }
10807 num = htmlTexts.size();
10808 }
10809 if (num > 0) {
10810 final ClipData clipData = new ClipData(
10811 null, new String[] { getType() },
10812 makeClipItem(streams, texts, htmlTexts, 0));
10813
10814 for (int i = 1; i < num; i++) {
10815 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10816 }
10817
10818 setClipData(clipData);
10819 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010820 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010821 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010822 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010823 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010824 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10825 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10826 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10827 final Uri output;
10828 try {
10829 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10830 } catch (ClassCastException e) {
10831 return false;
10832 }
10833 if (output != null) {
10834 setClipData(ClipData.newRawUri("", output));
10835 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10836 return true;
10837 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010838 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010839
10840 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010841 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010842
Michael Wright19859762017-09-18 20:57:58 +010010843 /**
10844 * Convert the dock state to a human readable format.
10845 * @hide
10846 */
10847 public static String dockStateToString(int dock) {
10848 switch (dock) {
10849 case EXTRA_DOCK_STATE_HE_DESK:
10850 return "EXTRA_DOCK_STATE_HE_DESK";
10851 case EXTRA_DOCK_STATE_LE_DESK:
10852 return "EXTRA_DOCK_STATE_LE_DESK";
10853 case EXTRA_DOCK_STATE_CAR:
10854 return "EXTRA_DOCK_STATE_CAR";
10855 case EXTRA_DOCK_STATE_DESK:
10856 return "EXTRA_DOCK_STATE_DESK";
10857 case EXTRA_DOCK_STATE_UNDOCKED:
10858 return "EXTRA_DOCK_STATE_UNDOCKED";
10859 default:
10860 return Integer.toString(dock);
10861 }
10862 }
10863
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010864 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10865 ArrayList<String> htmlTexts, int which) {
10866 Uri uri = streams != null ? streams.get(which) : null;
10867 CharSequence text = texts != null ? texts.get(which) : null;
10868 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10869 return new ClipData.Item(text, htmlText, null, uri);
10870 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010871
10872 /** @hide */
10873 public boolean isDocument() {
10874 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10875 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010876}