blob: a7a6768ad6c957b3fc715b78230f7620ef207577 [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;
36import android.content.res.Resources;
37import android.content.res.TypedArray;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080038import android.graphics.Rect;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070039import android.net.Uri;
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -060040import android.os.Build;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070041import android.os.Bundle;
42import android.os.IBinder;
43import android.os.Parcel;
44import android.os.Parcelable;
Suprabh Shukla96212bc2018-04-10 15:04:51 -070045import android.os.PersistableBundle;
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000046import android.os.Process;
Jason Monk2f68e8a2016-02-23 17:57:28 -050047import android.os.ResultReceiver;
48import android.os.ShellCommand;
Jeff Sharkeya14acd22013-04-02 18:27:45 -070049import android.os.StrictMode;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010050import android.os.UserHandle;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070051import android.provider.ContactsContract.QuickContact;
Jeff Sharkeybd3b9022013-08-20 15:20:04 -070052import android.provider.DocumentsContract;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070053import android.provider.DocumentsProvider;
Jason Monk2f68e8a2016-02-23 17:57:28 -050054import android.provider.MediaStore;
Jeff Sharkeyadef88a2013-10-15 13:54:44 -070055import android.provider.OpenableColumns;
Patrick Baumann577d4022018-01-31 16:55:10 +000056import android.text.TextUtils;
Jason Monk2f68e8a2016-02-23 17:57:28 -050057import android.util.ArraySet;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070058import android.util.AttributeSet;
59import android.util.Log;
Yi Jin129fc6c2017-09-28 15:48:38 -070060import android.util.proto.ProtoOutputStream;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070061
Dianne Hackborn2269d1572010-02-24 19:54:22 -080062import com.android.internal.util.XmlUtils;
Makoto Onuki7d1911f2017-06-09 12:30:09 -070063
Jason Monk2f68e8a2016-02-23 17:57:28 -050064import org.xmlpull.v1.XmlPullParser;
65import org.xmlpull.v1.XmlPullParserException;
Craig Mautner21d24a22014-04-23 11:45:37 -070066import org.xmlpull.v1.XmlSerializer;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070067
68import java.io.IOException;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080069import java.io.PrintWriter;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070070import java.io.Serializable;
Tor Norbyed9273d62013-05-30 15:59:53 -070071import java.lang.annotation.Retention;
72import java.lang.annotation.RetentionPolicy;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070073import java.net.URISyntaxException;
74import java.util.ArrayList;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -080075import java.util.HashSet;
Dianne Hackborn221ea892013-08-04 16:50:16 -070076import java.util.List;
Nick Pellyccae4122012-01-09 14:12:58 -080077import java.util.Locale;
Christopher Tate63d9ae12014-06-19 19:07:26 -070078import java.util.Objects;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070079import java.util.Set;
80
81/**
82 * An intent is an abstract description of an operation to be performed. It
83 * can be used with {@link Context#startActivity(Intent) startActivity} to
84 * launch an {@link android.app.Activity},
85 * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
86 * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
87 * and {@link android.content.Context#startService} or
88 * {@link android.content.Context#bindService} to communicate with a
89 * background {@link android.app.Service}.
90 *
Joe Fernandezb54e7a32011-10-03 15:09:50 -070091 * <p>An Intent provides a facility for performing late runtime binding between the code in
92 * different applications. Its most significant use is in the launching of activities, where it
Daniel Lehmanna5b58df2011-10-12 16:24:22 -070093 * can be thought of as the glue between activities. It is basically a passive data structure
94 * holding an abstract description of an action to be performed.</p>
Joe Fernandezb54e7a32011-10-03 15:09:50 -070095 *
96 * <div class="special reference">
97 * <h3>Developer Guides</h3>
98 * <p>For information about how to create and resolve intents, read the
99 * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
100 * developer guide.</p>
101 * </div>
102 *
103 * <a name="IntentStructure"></a>
104 * <h3>Intent Structure</h3>
105 * <p>The primary pieces of information in an intent are:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700106 *
107 * <ul>
108 * <li> <p><b>action</b> -- The general action to be performed, such as
109 * {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
110 * etc.</p>
111 * </li>
112 * <li> <p><b>data</b> -- The data to operate on, such as a person record
113 * in the contacts database, expressed as a {@link android.net.Uri}.</p>
114 * </li>
115 * </ul>
116 *
117 *
118 * <p>Some examples of action/data pairs are:</p>
119 *
120 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700121 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700122 * information about the person whose identifier is "1".</p>
123 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700124 * <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700125 * the phone dialer with the person filled in.</p>
126 * </li>
127 * <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
128 * the phone dialer with the given number filled in. Note how the
Trevor Johns682c24e2016-04-12 10:13:47 -0700129 * VIEW action does what is considered the most reasonable thing for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700130 * a particular URI.</p>
131 * </li>
132 * <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
133 * the phone dialer with the given number filled in.</p>
134 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700135 * <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700136 * information about the person whose identifier is "1".</p>
137 * </li>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700138 * <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700139 * a list of people, which the user can browse through. This example is a
140 * typical top-level entry into the Contacts application, showing you the
141 * list of people. Selecting a particular person to view would result in a
Kevin Hufnagleaedfd752016-09-08 21:56:25 -0700142 * new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700143 * being used to start an activity to display that person.</p>
144 * </li>
145 * </ul>
146 *
147 * <p>In addition to these primary attributes, there are a number of secondary
148 * attributes that you can also include with an intent:</p>
149 *
150 * <ul>
151 * <li> <p><b>category</b> -- Gives additional information about the action
152 * to execute. For example, {@link #CATEGORY_LAUNCHER} means it should
153 * appear in the Launcher as a top-level application, while
154 * {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
155 * of alternative actions the user can perform on a piece of data.</p>
156 * <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
157 * intent data. Normally the type is inferred from the data itself.
158 * By setting this attribute, you disable that evaluation and force
159 * an explicit type.</p>
160 * <li> <p><b>component</b> -- Specifies an explicit name of a component
161 * class to use for the intent. Normally this is determined by looking
162 * at the other information in the intent (the action, data/type, and
163 * categories) and matching that with a component that can handle it.
164 * If this attribute is set then none of the evaluation is performed,
165 * and this component is used exactly as is. By specifying this attribute,
166 * all of the other Intent attributes become optional.</p>
167 * <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
168 * This can be used to provide extended information to the component.
169 * For example, if we have a action to send an e-mail message, we could
170 * also include extra pieces of data here to supply a subject, body,
171 * etc.</p>
172 * </ul>
173 *
174 * <p>Here are some examples of other operations you can specify as intents
175 * using these additional parameters:</p>
176 *
177 * <ul>
178 * <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
179 * Launch the home screen.</p>
180 * </li>
181 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
182 * <i>{@link android.provider.Contacts.Phones#CONTENT_URI
183 * vnd.android.cursor.item/phone}</i></b>
184 * -- Display the list of people's phone numbers, allowing the user to
185 * browse through them and pick one and return it to the parent activity.</p>
186 * </li>
187 * <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
188 * <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
189 * -- Display all pickers for data that can be opened with
190 * {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
191 * allowing the user to pick one of them and then some data inside of it
192 * and returning the resulting URI to the caller. This can be used,
193 * for example, in an e-mail application to allow the user to pick some
194 * data to include as an attachment.</p>
195 * </li>
196 * </ul>
197 *
198 * <p>There are a variety of standard Intent action and category constants
199 * defined in the Intent class, but applications can also define their own.
Trevor Johns682c24e2016-04-12 10:13:47 -0700200 * These strings use Java-style scoping, to ensure they are unique -- for
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700201 * example, the standard {@link #ACTION_VIEW} is called
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700202 * "android.intent.action.VIEW".</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700203 *
204 * <p>Put together, the set of actions, data types, categories, and extra data
205 * defines a language for the system allowing for the expression of phrases
206 * such as "call john smith's cell". As applications are added to the system,
207 * they can extend this language by adding new actions, types, and categories, or
208 * they can modify the behavior of existing phrases by supplying their own
209 * activities that handle them.</p>
210 *
211 * <a name="IntentResolution"></a>
212 * <h3>Intent Resolution</h3>
213 *
214 * <p>There are two primary forms of intents you will use.
215 *
216 * <ul>
217 * <li> <p><b>Explicit Intents</b> have specified a component (via
218 * {@link #setComponent} or {@link #setClass}), which provides the exact
219 * class to be run. Often these will not include any other information,
220 * simply being a way for an application to launch various internal
221 * activities it has as the user interacts with the application.
222 *
223 * <li> <p><b>Implicit Intents</b> have not specified a component;
224 * instead, they must include enough information for the system to
225 * determine which of the available components is best to run for that
226 * intent.
227 * </ul>
228 *
229 * <p>When using implicit intents, given such an arbitrary intent we need to
230 * know what to do with it. This is handled by the process of <em>Intent
231 * resolution</em>, which maps an Intent to an {@link android.app.Activity},
232 * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
233 * more activities/receivers) that can handle it.</p>
234 *
235 * <p>The intent resolution mechanism basically revolves around matching an
236 * Intent against all of the &lt;intent-filter&gt; descriptions in the
237 * installed application packages. (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
238 * objects explicitly registered with {@link Context#registerReceiver}.) More
239 * details on this can be found in the documentation on the {@link
240 * IntentFilter} class.</p>
241 *
242 * <p>There are three pieces of information in the Intent that are used for
243 * resolution: the action, type, and category. Using this information, a query
244 * is done on the {@link PackageManager} for a component that can handle the
245 * intent. The appropriate component is determined based on the intent
246 * information supplied in the <code>AndroidManifest.xml</code> file as
247 * follows:</p>
248 *
249 * <ul>
250 * <li> <p>The <b>action</b>, if given, must be listed by the component as
251 * one it handles.</p>
252 * <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
253 * already supplied in the Intent. Like the action, if a type is
254 * included in the intent (either explicitly or implicitly in its
255 * data), then this must be listed by the component as one it handles.</p>
256 * <li> For data that is not a <code>content:</code> URI and where no explicit
257 * type is included in the Intent, instead the <b>scheme</b> of the
258 * intent data (such as <code>http:</code> or <code>mailto:</code>) is
259 * considered. Again like the action, if we are matching a scheme it
260 * must be listed by the component as one it can handle.
261 * <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
262 * by the activity as categories it handles. That is, if you include
263 * the categories {@link #CATEGORY_LAUNCHER} and
264 * {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
265 * with an intent that lists <em>both</em> of those categories.
266 * Activities will very often need to support the
267 * {@link #CATEGORY_DEFAULT} so that they can be found by
268 * {@link Context#startActivity Context.startActivity()}.</p>
269 * </ul>
270 *
271 * <p>For example, consider the Note Pad sample application that
Joshua Baxter9a841a62018-03-27 14:42:03 -0700272 * allows a user to browse through a list of notes data and view details about
273 * individual items. Text in italics indicates places where you would replace a
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700274 * name with one specific to your own package.</p>
275 *
276 * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
277 * package="<i>com.android.notepad</i>"&gt;
278 * &lt;application android:icon="@drawable/app_notes"
279 * android:label="@string/app_name"&gt;
280 *
281 * &lt;provider class=".NotePadProvider"
282 * android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
283 *
284 * &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
285 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700286 * &lt;action android:name="android.intent.action.MAIN" /&gt;
287 * &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700288 * &lt;/intent-filter&gt;
289 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700290 * &lt;action android:name="android.intent.action.VIEW" /&gt;
291 * &lt;action android:name="android.intent.action.EDIT" /&gt;
292 * &lt;action android:name="android.intent.action.PICK" /&gt;
293 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
294 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700295 * &lt;/intent-filter&gt;
296 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700297 * &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
298 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
299 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700300 * &lt;/intent-filter&gt;
301 * &lt;/activity&gt;
302 *
303 * &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
304 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700305 * &lt;action android:name="android.intent.action.VIEW" /&gt;
306 * &lt;action android:name="android.intent.action.EDIT" /&gt;
307 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
308 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700309 * &lt;/intent-filter&gt;
310 *
311 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700312 * &lt;action android:name="android.intent.action.INSERT" /&gt;
313 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
314 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700315 * &lt;/intent-filter&gt;
316 *
317 * &lt;/activity&gt;
318 *
319 * &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
320 * android:theme="@android:style/Theme.Dialog"&gt;
321 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700322 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
323 * &lt;category android:name="android.intent.category.DEFAULT" /&gt;
324 * &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
325 * &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
326 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700327 * &lt;/intent-filter&gt;
328 * &lt;/activity&gt;
329 *
330 * &lt;/application&gt;
331 * &lt;/manifest&gt;</pre>
332 *
333 * <p>The first activity,
334 * <code>com.android.notepad.NotesList</code>, serves as our main
335 * entry into the app. It can do three things as described by its three intent
336 * templates:
337 * <ol>
338 * <li><pre>
339 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700340 * &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
341 * &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700342 * &lt;/intent-filter&gt;</pre>
343 * <p>This provides a top-level entry into the NotePad application: the standard
344 * MAIN action is a main entry point (not requiring any other information in
345 * the Intent), and the LAUNCHER category says that this entry point should be
346 * listed in the application launcher.</p>
347 * <li><pre>
348 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700349 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
350 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
351 * &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
352 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
Trevor Johns682c24e2016-04-12 10:13:47 -0700353 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700354 * &lt;/intent-filter&gt;</pre>
355 * <p>This declares the things that the activity can do on a directory of
356 * notes. The type being supported is given with the &lt;type&gt; tag, where
357 * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
358 * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
359 * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
360 * The activity allows the user to view or edit the directory of data (via
361 * the VIEW and EDIT actions), or to pick a particular note and return it
362 * to the caller (via the PICK action). Note also the DEFAULT category
363 * supplied here: this is <em>required</em> for the
364 * {@link Context#startActivity Context.startActivity} method to resolve your
365 * activity when its component name is not explicitly specified.</p>
366 * <li><pre>
367 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700368 * &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
369 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
370 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700371 * &lt;/intent-filter&gt;</pre>
Trevor Johns682c24e2016-04-12 10:13:47 -0700372 * <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 -0700373 * the user without needing to know where it came from. The data type
374 * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
375 * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
376 * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
377 * The GET_CONTENT action is similar to the PICK action, where the activity
378 * will return to its caller a piece of data selected by the user. Here,
379 * however, the caller specifies the type of data they desire instead of
380 * the type of data the user will be picking from.</p>
381 * </ol>
382 *
383 * <p>Given these capabilities, the following intents will resolve to the
384 * NotesList activity:</p>
385 *
386 * <ul>
387 * <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
388 * activities that can be used as top-level entry points into an
389 * application.</p>
390 * <li> <p><b>{ action=android.app.action.MAIN,
391 * category=android.app.category.LAUNCHER }</b> is the actual intent
392 * used by the Launcher to populate its top-level list.</p>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700393 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700394 * data=content://com.google.provider.NotePad/notes }</b>
395 * displays a list of all the notes under
396 * "content://com.google.provider.NotePad/notes", which
397 * the user can browse through and see the details on.</p>
398 * <li> <p><b>{ action=android.app.action.PICK
399 * data=content://com.google.provider.NotePad/notes }</b>
400 * provides a list of the notes under
401 * "content://com.google.provider.NotePad/notes", from which
402 * the user can pick a note whose data URL is returned back to the caller.</p>
403 * <li> <p><b>{ action=android.app.action.GET_CONTENT
404 * type=vnd.android.cursor.item/vnd.google.note }</b>
405 * is similar to the pick action, but allows the caller to specify the
406 * kind of data they want back so that the system can find the appropriate
407 * activity to pick something of that data type.</p>
408 * </ul>
409 *
410 * <p>The second activity,
411 * <code>com.android.notepad.NoteEditor</code>, shows the user a single
412 * note entry and allows them to edit it. It can do two things as described
413 * by its two intent templates:
414 * <ol>
415 * <li><pre>
416 * &lt;intent-filter android:label="@string/resolve_edit"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700417 * &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
418 * &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
419 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
420 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700421 * &lt;/intent-filter&gt;</pre>
422 * <p>The first, primary, purpose of this activity is to let the user interact
423 * with a single note, as decribed by the MIME type
424 * <code>vnd.android.cursor.item/vnd.google.note</code>. The activity can
425 * either VIEW a note or allow the user to EDIT it. Again we support the
426 * DEFAULT category to allow the activity to be launched without explicitly
427 * specifying its component.</p>
428 * <li><pre>
429 * &lt;intent-filter&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700430 * &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
431 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
432 * &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700433 * &lt;/intent-filter&gt;</pre>
434 * <p>The secondary use of this activity is to insert a new note entry into
435 * an existing directory of notes. This is used when the user creates a new
436 * note: the INSERT action is executed on the directory of notes, causing
437 * this activity to run and have the user create the new note data which
438 * it then adds to the content provider.</p>
439 * </ol>
440 *
441 * <p>Given these capabilities, the following intents will resolve to the
442 * NoteEditor activity:</p>
443 *
444 * <ul>
Yusuf T. Mobile8ecb36e2009-07-10 14:13:29 -0700445 * <li> <p><b>{ action=android.intent.action.VIEW
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700446 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
447 * shows the user the content of note <var>{ID}</var>.</p>
448 * <li> <p><b>{ action=android.app.action.EDIT
449 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
450 * allows the user to edit the content of note <var>{ID}</var>.</p>
451 * <li> <p><b>{ action=android.app.action.INSERT
452 * data=content://com.google.provider.NotePad/notes }</b>
453 * creates a new, empty note in the notes list at
454 * "content://com.google.provider.NotePad/notes"
455 * and allows the user to edit it. If they keep their changes, the URI
456 * of the newly created note is returned to the caller.</p>
457 * </ul>
458 *
459 * <p>The last activity,
460 * <code>com.android.notepad.TitleEditor</code>, allows the user to
461 * edit the title of a note. This could be implemented as a class that the
462 * application directly invokes (by explicitly setting its component in
463 * the Intent), but here we show a way you can publish alternative
464 * operations on existing data:</p>
465 *
466 * <pre>
467 * &lt;intent-filter android:label="@string/resolve_title"&gt;
Romain Guy4969af72009-06-17 10:53:19 -0700468 * &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
469 * &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
470 * &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
471 * &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
472 * &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700473 * &lt;/intent-filter&gt;</pre>
474 *
475 * <p>In the single intent template here, we
476 * have created our own private action called
477 * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
478 * edit the title of a note. It must be invoked on a specific note
479 * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
480 * view and edit actions, but here displays and edits the title contained
481 * in the note data.
482 *
483 * <p>In addition to supporting the default category as usual, our title editor
484 * also supports two other standard categories: ALTERNATIVE and
485 * SELECTED_ALTERNATIVE. Implementing
486 * these categories allows others to find the special action it provides
487 * without directly knowing about it, through the
488 * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
489 * more often to build dynamic menu items with
490 * {@link android.view.Menu#addIntentOptions}. Note that in the intent
491 * template here was also supply an explicit name for the template
492 * (via <code>android:label="@string/resolve_title"</code>) to better control
493 * what the user sees when presented with this activity as an alternative
494 * action to the data they are viewing.
495 *
496 * <p>Given these capabilities, the following intent will resolve to the
497 * TitleEditor activity:</p>
498 *
499 * <ul>
500 * <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
501 * data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
502 * displays and allows the user to edit the title associated
503 * with note <var>{ID}</var>.</p>
504 * </ul>
505 *
506 * <h3>Standard Activity Actions</h3>
507 *
508 * <p>These are the current standard actions that Intent defines for launching
509 * activities (usually through {@link Context#startActivity}. The most
510 * important, and by far most frequently used, are {@link #ACTION_MAIN} and
511 * {@link #ACTION_EDIT}.
512 *
513 * <ul>
514 * <li> {@link #ACTION_MAIN}
515 * <li> {@link #ACTION_VIEW}
516 * <li> {@link #ACTION_ATTACH_DATA}
517 * <li> {@link #ACTION_EDIT}
518 * <li> {@link #ACTION_PICK}
519 * <li> {@link #ACTION_CHOOSER}
520 * <li> {@link #ACTION_GET_CONTENT}
521 * <li> {@link #ACTION_DIAL}
522 * <li> {@link #ACTION_CALL}
523 * <li> {@link #ACTION_SEND}
524 * <li> {@link #ACTION_SENDTO}
525 * <li> {@link #ACTION_ANSWER}
526 * <li> {@link #ACTION_INSERT}
527 * <li> {@link #ACTION_DELETE}
528 * <li> {@link #ACTION_RUN}
529 * <li> {@link #ACTION_SYNC}
530 * <li> {@link #ACTION_PICK_ACTIVITY}
531 * <li> {@link #ACTION_SEARCH}
532 * <li> {@link #ACTION_WEB_SEARCH}
533 * <li> {@link #ACTION_FACTORY_TEST}
534 * </ul>
535 *
536 * <h3>Standard Broadcast Actions</h3>
537 *
538 * <p>These are the current standard actions that Intent defines for receiving
539 * broadcasts (usually through {@link Context#registerReceiver} or a
540 * &lt;receiver&gt; tag in a manifest).
541 *
542 * <ul>
543 * <li> {@link #ACTION_TIME_TICK}
544 * <li> {@link #ACTION_TIME_CHANGED}
545 * <li> {@link #ACTION_TIMEZONE_CHANGED}
546 * <li> {@link #ACTION_BOOT_COMPLETED}
547 * <li> {@link #ACTION_PACKAGE_ADDED}
548 * <li> {@link #ACTION_PACKAGE_CHANGED}
549 * <li> {@link #ACTION_PACKAGE_REMOVED}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800550 * <li> {@link #ACTION_PACKAGE_RESTARTED}
551 * <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +0000552 * <li> {@link #ACTION_PACKAGES_SUSPENDED}
553 * <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700554 * <li> {@link #ACTION_UID_REMOVED}
555 * <li> {@link #ACTION_BATTERY_CHANGED}
Cliff Spradlinfda6fae2008-10-22 20:29:16 -0700556 * <li> {@link #ACTION_POWER_CONNECTED}
Romain Guy4969af72009-06-17 10:53:19 -0700557 * <li> {@link #ACTION_POWER_DISCONNECTED}
558 * <li> {@link #ACTION_SHUTDOWN}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700559 * </ul>
560 *
561 * <h3>Standard Categories</h3>
562 *
563 * <p>These are the current standard categories that can be used to further
564 * clarify an Intent via {@link #addCategory}.
565 *
566 * <ul>
567 * <li> {@link #CATEGORY_DEFAULT}
568 * <li> {@link #CATEGORY_BROWSABLE}
569 * <li> {@link #CATEGORY_TAB}
570 * <li> {@link #CATEGORY_ALTERNATIVE}
571 * <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
572 * <li> {@link #CATEGORY_LAUNCHER}
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800573 * <li> {@link #CATEGORY_INFO}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700574 * <li> {@link #CATEGORY_HOME}
575 * <li> {@link #CATEGORY_PREFERENCE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700576 * <li> {@link #CATEGORY_TEST}
Mike Lockwood9092ab42009-09-16 13:01:32 -0400577 * <li> {@link #CATEGORY_CAR_DOCK}
578 * <li> {@link #CATEGORY_DESK_DOCK}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500579 * <li> {@link #CATEGORY_LE_DESK_DOCK}
580 * <li> {@link #CATEGORY_HE_DESK_DOCK}
Bernd Holzheyaea4b672010-03-31 09:46:13 +0200581 * <li> {@link #CATEGORY_CAR_MODE}
Patrick Dubroy6dabe242010-08-30 10:43:47 -0700582 * <li> {@link #CATEGORY_APP_MARKET}
Zak Cohendb6ca492017-01-26 14:09:00 -0800583 * <li> {@link #CATEGORY_VR_HOME}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700584 * </ul>
585 *
586 * <h3>Standard Extra Data</h3>
587 *
588 * <p>These are the current standard fields that can be used as extra data via
589 * {@link #putExtra}.
590 *
591 * <ul>
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800592 * <li> {@link #EXTRA_ALARM_COUNT}
593 * <li> {@link #EXTRA_BCC}
594 * <li> {@link #EXTRA_CC}
595 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
596 * <li> {@link #EXTRA_DATA_REMOVED}
597 * <li> {@link #EXTRA_DOCK_STATE}
Praveen Bharathi21e941b2010-10-06 15:23:14 -0500598 * <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
599 * <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800600 * <li> {@link #EXTRA_DOCK_STATE_CAR}
601 * <li> {@link #EXTRA_DOCK_STATE_DESK}
602 * <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
603 * <li> {@link #EXTRA_DONT_KILL_APP}
604 * <li> {@link #EXTRA_EMAIL}
605 * <li> {@link #EXTRA_INITIAL_INTENTS}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700606 * <li> {@link #EXTRA_INTENT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800607 * <li> {@link #EXTRA_KEY_EVENT}
rich cannings706e8ba2012-08-20 13:20:14 -0700608 * <li> {@link #EXTRA_ORIGINATING_URI}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800609 * <li> {@link #EXTRA_PHONE_NUMBER}
rich cannings368ed012012-06-07 15:37:57 -0700610 * <li> {@link #EXTRA_REFERRER}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800611 * <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
612 * <li> {@link #EXTRA_REPLACING}
613 * <li> {@link #EXTRA_SHORTCUT_ICON}
614 * <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
615 * <li> {@link #EXTRA_SHORTCUT_INTENT}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700616 * <li> {@link #EXTRA_STREAM}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800617 * <li> {@link #EXTRA_SHORTCUT_NAME}
618 * <li> {@link #EXTRA_SUBJECT}
619 * <li> {@link #EXTRA_TEMPLATE}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700620 * <li> {@link #EXTRA_TEXT}
Trevor Johnsd59fb6e2009-11-20 12:54:57 -0800621 * <li> {@link #EXTRA_TITLE}
622 * <li> {@link #EXTRA_UID}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700623 * </ul>
624 *
625 * <h3>Flags</h3>
626 *
627 * <p>These are the possible flags that can be used in the Intent via
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800628 * {@link #setFlags} and {@link #addFlags}. See {@link #setFlags} for a list
629 * of all possible flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700630 */
Dianne Hackbornee0511d2009-12-21 18:08:13 -0800631public class Intent implements Parcelable, Cloneable {
Craig Mautner21d24a22014-04-23 11:45:37 -0700632 private static final String ATTR_ACTION = "action";
633 private static final String TAG_CATEGORIES = "categories";
634 private static final String ATTR_CATEGORY = "category";
635 private static final String TAG_EXTRA = "extra";
636 private static final String ATTR_TYPE = "type";
637 private static final String ATTR_COMPONENT = "component";
638 private static final String ATTR_DATA = "data";
639 private static final String ATTR_FLAGS = "flags";
640
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700641 // ---------------------------------------------------------------------
642 // ---------------------------------------------------------------------
643 // Standard intent activity actions (see action variable).
644
645 /**
646 * Activity Action: Start as a main entry point, does not expect to
647 * receive data.
648 * <p>Input: nothing
649 * <p>Output: nothing
650 */
651 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
652 public static final String ACTION_MAIN = "android.intent.action.MAIN";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800653
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700654 /**
655 * Activity Action: Display the data to the user. This is the most common
656 * action performed on data -- it is the generic action you can use on
657 * a piece of data to get the most reasonable thing to occur. For example,
658 * when used on a contacts entry it will view the entry; when used on a
659 * mailto: URI it will bring up a compose window filled with the information
660 * supplied by the URI; when used with a tel: URI it will invoke the
661 * dialer.
662 * <p>Input: {@link #getData} is URI from which to retrieve data.
663 * <p>Output: nothing.
664 */
665 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
666 public static final String ACTION_VIEW = "android.intent.action.VIEW";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800667
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700668 /**
Dianne Hackborna320f012017-04-07 13:57:48 -0700669 * Extra that can be included on activity intents coming from the storage UI
670 * when it launches sub-activities to manage various types of storage. For example,
671 * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
672 * the images on the device, and in that case also include this extra to tell the
673 * app it is coming from the storage UI so should help the user manage storage of
674 * this type.
675 */
676 public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
677
678 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700679 * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
680 * performed on a piece of data.
681 */
682 public static final String ACTION_DEFAULT = ACTION_VIEW;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800683
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700684 /**
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900685 * Activity Action: Quick view the data. Launches a quick viewer for
686 * a URI or a list of URIs.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +0900687 * <p>Activities handling this intent action should handle the vast majority of
688 * MIME types rather than only specific ones.
Garfield Tance1d0e92017-03-23 10:52:48 -0700689 * <p>Quick viewers must render the quick view image locally, and must not send
690 * file content outside current device.
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +0900691 * <p>Input: {@link #getData} is a mandatory content URI of the item to
692 * preview. {@link #getClipData} contains an optional list of content URIs
693 * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
694 * optional index of the URI in the clip data to show first.
Garfield Tance1d0e92017-03-23 10:52:48 -0700695 * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
696 * that can be shown in the quick view UI.
Steve McKayc78bcb82015-07-31 14:35:22 -0700697 * <p>Output: nothing.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +0900698 * @see #EXTRA_INDEX
Garfield Tance1d0e92017-03-23 10:52:48 -0700699 * @see #EXTRA_QUICK_VIEW_FEATURES
Steve McKayc78bcb82015-07-31 14:35:22 -0700700 */
701 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
702 public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
703
704 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700705 * Used to indicate that some piece of data should be attached to some other
706 * place. For example, image data could be attached to a contact. It is up
707 * to the recipient to decide where the data should be attached; the intent
708 * does not specify the ultimate destination.
709 * <p>Input: {@link #getData} is URI of data to be attached.
710 * <p>Output: nothing.
711 */
712 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713 public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800714
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700715 /**
716 * Activity Action: Provide explicit editable access to the given data.
717 * <p>Input: {@link #getData} is URI of data to be edited.
718 * <p>Output: nothing.
719 */
720 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
721 public static final String ACTION_EDIT = "android.intent.action.EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800722
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700723 /**
724 * Activity Action: Pick an existing item, or insert a new item, and then edit it.
725 * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
726 * The extras can contain type specific data to pass through to the editing/creating
727 * activity.
728 * <p>Output: The URI of the item that was picked. This must be a content:
729 * URI so that any receiver can access it.
730 */
731 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732 public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800733
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700734 /**
735 * Activity Action: Pick an item from the data, returning what was selected.
736 * <p>Input: {@link #getData} is URI containing a directory of data
737 * (vnd.android.cursor.dir/*) from which to pick an item.
738 * <p>Output: The URI of the item that was picked.
739 */
740 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
741 public static final String ACTION_PICK = "android.intent.action.PICK";
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800742
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700743 /**
744 * Activity Action: Creates a shortcut.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800745 * <p>Input: Nothing.</p>
Sunny Goyala6be88a2017-01-12 16:27:58 -0800746 * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
747 * <p>For compatibility with older versions of android the intent may also contain three
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700748 * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
749 * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800750 * (value: ShortcutIconResource).</p>
751 *
Sunny Goyala6be88a2017-01-12 16:27:58 -0800752 * @see android.content.pm.ShortcutManager#createShortcutResultIntent
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700753 * @see #EXTRA_SHORTCUT_INTENT
754 * @see #EXTRA_SHORTCUT_NAME
755 * @see #EXTRA_SHORTCUT_ICON
756 * @see #EXTRA_SHORTCUT_ICON_RESOURCE
757 * @see android.content.Intent.ShortcutIconResource
758 */
759 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
760 public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
761
762 /**
763 * The name of the extra used to define the Intent of a shortcut.
764 *
765 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800766 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700767 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800768 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700769 public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
770 /**
771 * The name of the extra used to define the name of a shortcut.
772 *
773 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800774 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700775 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800776 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700777 public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
778 /**
779 * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
780 *
781 * @see #ACTION_CREATE_SHORTCUT
Sunny Goyala6be88a2017-01-12 16:27:58 -0800782 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700783 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800784 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700785 public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
786 /**
787 * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
788 *
789 * @see #ACTION_CREATE_SHORTCUT
790 * @see android.content.Intent.ShortcutIconResource
Sunny Goyala6be88a2017-01-12 16:27:58 -0800791 * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700792 */
Sunny Goyala6be88a2017-01-12 16:27:58 -0800793 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700794 public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
795 "android.intent.extra.shortcut.ICON_RESOURCE";
796
797 /**
Jason Monk2f68e8a2016-02-23 17:57:28 -0500798 * An activity that provides a user interface for adjusting application preferences.
799 * Optional but recommended settings for all applications which have settings.
800 */
801 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
802 public static final String ACTION_APPLICATION_PREFERENCES
803 = "android.intent.action.APPLICATION_PREFERENCES";
804
805 /**
Sudheer Shanka80b66412016-04-06 18:31:10 -0700806 * Activity Action: Launch an activity showing the app information.
807 * For applications which install other applications (such as app stores), it is recommended
808 * to handle this action for providing the app information to the user.
809 *
810 * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
811 * to be displayed.
812 * <p>Output: Nothing.
813 */
814 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
815 public static final String ACTION_SHOW_APP_INFO
816 = "android.intent.action.SHOW_APP_INFO";
817
818 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800819 * Represents a shortcut/live folder icon resource.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700820 *
821 * @see Intent#ACTION_CREATE_SHORTCUT
822 * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -0800823 * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
824 * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700825 */
826 public static class ShortcutIconResource implements Parcelable {
827 /**
828 * The package name of the application containing the icon.
829 */
830 public String packageName;
831
832 /**
833 * The resource name of the icon, including package, name and type.
834 */
835 public String resourceName;
836
837 /**
838 * Creates a new ShortcutIconResource for the specified context and resource
839 * identifier.
840 *
841 * @param context The context of the application.
Tor Norbye7b9c9122013-05-30 16:48:33 -0700842 * @param resourceId The resource identifier for the icon.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700843 * @return A new ShortcutIconResource with the specified's context package name
Tor Norbye7b9c9122013-05-30 16:48:33 -0700844 * and icon resource identifier.``
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700845 */
Tor Norbye7b9c9122013-05-30 16:48:33 -0700846 public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700847 ShortcutIconResource icon = new ShortcutIconResource();
848 icon.packageName = context.getPackageName();
849 icon.resourceName = context.getResources().getResourceName(resourceId);
850 return icon;
851 }
852
853 /**
854 * Used to read a ShortcutIconResource from a Parcel.
855 */
856 public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
857 new Parcelable.Creator<ShortcutIconResource>() {
858
859 public ShortcutIconResource createFromParcel(Parcel source) {
860 ShortcutIconResource icon = new ShortcutIconResource();
861 icon.packageName = source.readString();
862 icon.resourceName = source.readString();
863 return icon;
864 }
865
866 public ShortcutIconResource[] newArray(int size) {
867 return new ShortcutIconResource[size];
868 }
869 };
870
871 /**
872 * No special parcel contents.
873 */
874 public int describeContents() {
875 return 0;
876 }
877
878 public void writeToParcel(Parcel dest, int flags) {
879 dest.writeString(packageName);
880 dest.writeString(resourceName);
881 }
882
883 @Override
884 public String toString() {
885 return resourceName;
886 }
887 }
888
889 /**
890 * Activity Action: Display an activity chooser, allowing the user to pick
891 * what they want to before proceeding. This can be used as an alternative
892 * to the standard activity picker that is displayed by the system when
893 * you try to start an activity with multiple possible matches, with these
894 * differences in behavior:
895 * <ul>
896 * <li>You can specify the title that will appear in the activity chooser.
897 * <li>The user does not have the option to make one of the matching
898 * activities a preferred activity, and all possible activities will
899 * always be shown even if one of them is currently marked as the
900 * preferred activity.
901 * </ul>
902 * <p>
903 * This action should be used when the user will naturally expect to
904 * select an activity in order to proceed. An example if when not to use
905 * it is when the user clicks on a "mailto:" link. They would naturally
906 * expect to go directly to their mail app, so startActivity() should be
907 * called directly: it will
908 * either launch the current preferred app, or put up a dialog allowing the
909 * user to pick an app to use and optionally marking that as preferred.
910 * <p>
911 * In contrast, if the user is selecting a menu item to send a picture
912 * they are viewing to someone else, there are many different things they
913 * may want to do at this point: send it through e-mail, upload it to a
914 * web service, etc. In this case the CHOOSER action should be used, to
915 * always present to the user a list of the things they can do, with a
916 * nice title given by the caller such as "Send this photo with:".
917 * <p>
Dianne Hackborne302a162012-05-15 14:58:32 -0700918 * If you need to grant URI permissions through a chooser, you must specify
919 * the permissions to be granted on the ACTION_CHOOSER Intent
920 * <em>in addition</em> to the EXTRA_INTENT inside. This means using
921 * {@link #setClipData} to specify the URIs to be granted as well as
922 * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
923 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
924 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700925 * As a convenience, an Intent of this form can be created with the
926 * {@link #createChooser} function.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700927 * <p>
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700928 * Input: No data should be specified. get*Extra must have
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700929 * a {@link #EXTRA_INTENT} field containing the Intent being executed,
930 * and can optionally have a {@link #EXTRA_TITLE} field containing the
931 * title text to display in the chooser.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700932 * <p>
933 * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700934 */
935 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
936 public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
937
938 /**
939 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
940 *
Dianne Hackborne302a162012-05-15 14:58:32 -0700941 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
942 * target intent, also optionally supplying a title. If the target
943 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
944 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
945 * set in the returned chooser intent, with its ClipData set appropriately:
946 * either a direct reflection of {@link #getClipData()} if that is non-null,
John Spurlock33900182014-01-02 11:04:18 -0500947 * or a new ClipData built from {@link #getData()}.
Dianne Hackborne302a162012-05-15 14:58:32 -0700948 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700949 * @param target The Intent that the user will be selecting an activity
950 * to perform.
951 * @param title Optional title that will be displayed in the chooser.
952 * @return Return a new Intent object that you can hand to
953 * {@link Context#startActivity(Intent) Context.startActivity()} and
954 * related methods.
955 */
956 public static Intent createChooser(Intent target, CharSequence title) {
Adam Powell0b3c1122014-10-09 12:50:14 -0700957 return createChooser(target, title, null);
958 }
959
960 /**
961 * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
962 *
963 * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
964 * target intent, also optionally supplying a title. If the target
965 * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
966 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
967 * set in the returned chooser intent, with its ClipData set appropriately:
968 * either a direct reflection of {@link #getClipData()} if that is non-null,
969 * or a new ClipData built from {@link #getData()}.</p>
970 *
971 * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
972 * when the user makes a choice. This can be useful if the calling application wants
973 * to remember the last chosen target and surface it as a more prominent or one-touch
974 * affordance elsewhere in the UI for next time.</p>
975 *
976 * @param target The Intent that the user will be selecting an activity
977 * to perform.
978 * @param title Optional title that will be displayed in the chooser.
979 * @param sender Optional IntentSender to be called when a choice is made.
980 * @return Return a new Intent object that you can hand to
981 * {@link Context#startActivity(Intent) Context.startActivity()} and
982 * related methods.
983 */
984 public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -0700985 Intent intent = new Intent(ACTION_CHOOSER);
986 intent.putExtra(EXTRA_INTENT, target);
987 if (title != null) {
988 intent.putExtra(EXTRA_TITLE, title);
989 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700990
Adam Powell0b3c1122014-10-09 12:50:14 -0700991 if (sender != null) {
992 intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
993 }
994
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -0700995 // Migrate any clip data and flags from target.
Jeff Sharkey846318a2014-04-04 12:12:41 -0700996 int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
997 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
998 | FLAG_GRANT_PREFIX_URI_PERMISSION);
Dianne Hackborne302a162012-05-15 14:58:32 -0700999 if (permFlags != 0) {
1000 ClipData targetClipData = target.getClipData();
1001 if (targetClipData == null && target.getData() != null) {
1002 ClipData.Item item = new ClipData.Item(target.getData());
1003 String[] mimeTypes;
1004 if (target.getType() != null) {
1005 mimeTypes = new String[] { target.getType() };
1006 } else {
1007 mimeTypes = new String[] { };
1008 }
1009 targetClipData = new ClipData(null, mimeTypes, item);
1010 }
1011 if (targetClipData != null) {
1012 intent.setClipData(targetClipData);
1013 intent.addFlags(permFlags);
1014 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001015 }
Dianne Hackborne302a162012-05-15 14:58:32 -07001016
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001017 return intent;
1018 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -07001019
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001020 /**
1021 * Activity Action: Allow the user to select a particular kind of data and
1022 * return it. This is different than {@link #ACTION_PICK} in that here we
1023 * just say what kind of data is desired, not a URI of existing data from
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001024 * which the user can pick. An ACTION_GET_CONTENT could allow the user to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001025 * create the data as it runs (for example taking a picture or recording a
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001026 * sound), let them browse over the web and download the desired data,
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001027 * etc.
1028 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001029 * 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 -07001030 * of data, such as a person contact, you set the MIME type to the kind of
1031 * data you want and launch it with {@link Context#startActivity(Intent)}.
1032 * The system will then launch the best application to select that kind
1033 * of data for you.
1034 * <p>
1035 * You may also be interested in any of a set of types of content the user
1036 * can pick. For example, an e-mail application that wants to allow the
1037 * user to add an attachment to an e-mail message can use this action to
1038 * bring up a list of all of the types of content the user can attach.
1039 * <p>
1040 * In this case, you should wrap the GET_CONTENT intent with a chooser
1041 * (through {@link #createChooser}), which will give the proper interface
1042 * for the user to pick how to send your data and allow you to specify
1043 * a prompt indicating what they are doing. You will usually specify a
1044 * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1045 * broad range of content types the user can select from.
1046 * <p>
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001047 * When using such a broad GET_CONTENT action, it is often desirable to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001048 * only pick from data that can be represented as a stream. This is
1049 * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1050 * <p>
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001051 * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
Ken Wakasaf76a50c2012-03-09 19:56:35 +09001052 * the launched content chooser only returns results representing data that
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001053 * is locally available on the device. For example, if this extra is set
1054 * to true then an image picker should not show any pictures that are available
1055 * from a remote server but not already on the local device (thus requiring
1056 * they be downloaded when opened).
1057 * <p>
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001058 * If the caller can handle multiple returned items (the user performing
1059 * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1060 * to indicate this.
1061 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001062 * Input: {@link #getType} is the desired MIME type to retrieve. Note
1063 * that no URI is supplied in the intent, as there are no constraints on
1064 * where the returned data originally comes from. You may also include the
1065 * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08001066 * opened as a stream. You may use {@link #EXTRA_LOCAL_ONLY} to limit content
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08001067 * selection to local data. You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1068 * allow the user to select multiple items.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001069 * <p>
1070 * Output: The URI of the item that was picked. This must be a content:
1071 * URI so that any receiver can access it.
1072 */
1073 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1074 public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1075 /**
1076 * Activity Action: Dial a number as specified by the data. This shows a
1077 * UI with the number being dialed, allowing the user to explicitly
1078 * initiate the call.
1079 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1080 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1081 * number.
1082 * <p>Output: nothing.
1083 */
1084 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1085 public static final String ACTION_DIAL = "android.intent.action.DIAL";
1086 /**
1087 * Activity Action: Perform a call to someone specified by the data.
1088 * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1089 * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1090 * number.
1091 * <p>Output: nothing.
1092 *
1093 * <p>Note: there will be restrictions on which applications can initiate a
1094 * call; most applications should use the {@link #ACTION_DIAL}.
1095 * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1096 * numbers. Applications can <strong>dial</strong> emergency numbers using
1097 * {@link #ACTION_DIAL}, however.
Svetoslav7008b512015-06-24 18:47:07 -07001098 *
Dianne Hackborn0e3de6c2015-07-29 15:20:21 -07001099 * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
Svetoslav7008b512015-06-24 18:47:07 -07001100 * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
Svet Ganov7121e182015-07-13 22:38:12 -07001101 * permission which is not granted, then attempting to use this action will
Svetoslav7008b512015-06-24 18:47:07 -07001102 * result in a {@link java.lang.SecurityException}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001103 */
1104 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1105 public static final String ACTION_CALL = "android.intent.action.CALL";
1106 /**
1107 * Activity Action: Perform a call to an emergency number specified by the
1108 * data.
1109 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1110 * tel: URI of an explicit phone number.
1111 * <p>Output: nothing.
1112 * @hide
1113 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001114 @SystemApi
1115 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001116 public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1117 /**
1118 * Activity action: Perform a call to any number (emergency or not)
1119 * specified by the data.
1120 * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1121 * tel: URI of an explicit phone number.
1122 * <p>Output: nothing.
1123 * @hide
1124 */
Brad Ebinger7a8d3522017-03-31 10:21:09 -07001125 @SystemApi
1126 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001127 public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
fionaxu77a744c2017-03-17 14:35:39 -07001128
Santos Cordon15a13782015-03-31 18:32:31 -07001129 /**
fionaxuadfe7002017-02-17 17:20:46 -08001130 * Activity Action: Main entry point for carrier setup apps.
1131 * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1132 * carrier service and typically require
1133 * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1134 * fulfill their duties.
1135 */
1136 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137 public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1138 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001139 * Activity Action: Send a message to someone specified by the data.
1140 * <p>Input: {@link #getData} is URI describing the target.
1141 * <p>Output: nothing.
1142 */
1143 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1144 public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1145 /**
1146 * Activity Action: Deliver some data to someone else. Who the data is
1147 * being delivered to is not specified; it is up to the receiver of this
1148 * action to ask the user where the data should be sent.
1149 * <p>
1150 * When launching a SEND intent, you should usually wrap it in a chooser
1151 * (through {@link #createChooser}), which will give the proper interface
1152 * for the user to pick how to send your data and allow you to specify
1153 * a prompt indicating what they are doing.
1154 * <p>
1155 * Input: {@link #getType} is the MIME type of the data being sent.
1156 * get*Extra can have either a {@link #EXTRA_TEXT}
1157 * or {@link #EXTRA_STREAM} field, containing the data to be sent. If
1158 * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1159 * should be the MIME type of the data in EXTRA_STREAM. Use {@literal *}/*
1160 * if the MIME type is unknown (this will only allow senders that can
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001161 * handle generic data streams). If using {@link #EXTRA_TEXT}, you can
1162 * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1163 * your text with HTML formatting.
1164 * <p>
1165 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1166 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1167 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1168 * content: URIs and other advanced features of {@link ClipData}. If
1169 * using this approach, you still must supply the same data through the
1170 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1171 * for compatibility with old applications. If you don't set a ClipData,
1172 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001173 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001174 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1175 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1176 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1177 * be openable only as asset typed files using
1178 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1179 * <p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001180 * Optional standard extras, which may be interpreted by some recipients as
1181 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1182 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1183 * <p>
1184 * Output: nothing.
1185 */
1186 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187 public static final String ACTION_SEND = "android.intent.action.SEND";
1188 /**
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001189 * Activity Action: Deliver multiple data to someone else.
1190 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001191 * Like {@link #ACTION_SEND}, except the data is multiple.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001192 * <p>
1193 * Input: {@link #getType} is the MIME type of the data being sent.
1194 * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001195 * #EXTRA_STREAM} field, containing the data to be sent. If using
1196 * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1197 * for clients to retrieve your text with HTML formatting.
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001198 * <p>
Chih-Chung Chang5962d272009-09-04 14:36:01 +08001199 * Multiple types are supported, and receivers should handle mixed types
1200 * whenever possible. The right way for the receiver to check them is to
1201 * use the content resolver on each URI. The intent sender should try to
1202 * put the most concrete mime type in the intent type, but it can fall
1203 * back to {@literal <type>/*} or {@literal *}/* as needed.
1204 * <p>
1205 * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1206 * be image/jpg, but if you are sending image/jpg and image/png, then the
1207 * intent's type should be image/*.
1208 * <p>
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07001209 * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1210 * being sent can be supplied through {@link #setClipData(ClipData)}. This
1211 * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1212 * content: URIs and other advanced features of {@link ClipData}. If
1213 * using this approach, you still must supply the same data through the
1214 * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1215 * for compatibility with old applications. If you don't set a ClipData,
1216 * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1217 * <p>
Tomasz Mikolajewskid8a2e192016-12-15 16:10:46 +09001218 * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1219 * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1220 * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1221 * be openable only as asset typed files using
1222 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1223 * <p>
Wu-cheng Li649f99e2009-06-17 14:29:57 +08001224 * Optional standard extras, which may be interpreted by some recipients as
1225 * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1226 * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1227 * <p>
1228 * Output: nothing.
1229 */
1230 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1231 public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001233 * Activity Action: Handle an incoming phone call.
1234 * <p>Input: nothing.
1235 * <p>Output: nothing.
1236 */
1237 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1238 public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1239 /**
1240 * Activity Action: Insert an empty item into the given container.
1241 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1242 * in which to place the data.
1243 * <p>Output: URI of the new data that was created.
1244 */
1245 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1246 public static final String ACTION_INSERT = "android.intent.action.INSERT";
1247 /**
Dianne Hackborn23fdaf62010-08-06 12:16:55 -07001248 * Activity Action: Create a new item in the given container, initializing it
1249 * from the current contents of the clipboard.
1250 * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1251 * in which to place the data.
1252 * <p>Output: URI of the new data that was created.
1253 */
1254 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1255 public static final String ACTION_PASTE = "android.intent.action.PASTE";
1256 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001257 * Activity Action: Delete the given data from its container.
1258 * <p>Input: {@link #getData} is URI of data to be deleted.
1259 * <p>Output: nothing.
1260 */
1261 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1262 public static final String ACTION_DELETE = "android.intent.action.DELETE";
1263 /**
1264 * Activity Action: Run the data, whatever that means.
1265 * <p>Input: ? (Note: this is currently specific to the test harness.)
1266 * <p>Output: nothing.
1267 */
1268 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1269 public static final String ACTION_RUN = "android.intent.action.RUN";
1270 /**
1271 * Activity Action: Perform a data synchronization.
1272 * <p>Input: ?
1273 * <p>Output: ?
1274 */
1275 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1276 public static final String ACTION_SYNC = "android.intent.action.SYNC";
1277 /**
1278 * Activity Action: Pick an activity given an intent, returning the class
1279 * selected.
1280 * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1281 * used with {@link PackageManager#queryIntentActivities} to determine the
1282 * set of activities from which to pick.
1283 * <p>Output: Class name of the activity that was selected.
1284 */
1285 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1286 public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1287 /**
1288 * Activity Action: Perform a search.
1289 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1290 * is the text to search for. If empty, simply
1291 * enter your search results Activity with the search UI activated.
1292 * <p>Output: nothing.
1293 */
1294 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295 public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1296 /**
Jim Miller7e4ad352009-03-25 18:16:41 -07001297 * Activity Action: Start the platform-defined tutorial
1298 * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1299 * is the text to search for. If empty, simply
1300 * enter your search results Activity with the search UI activated.
1301 * <p>Output: nothing.
1302 */
1303 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1304 public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1305 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001306 * Activity Action: Perform a web search.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08001307 * <p>
1308 * Input: {@link android.app.SearchManager#QUERY
1309 * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1310 * a url starts with http or https, the site will be opened. If it is plain
1311 * text, Google search will be applied.
1312 * <p>
1313 * Output: nothing.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001314 */
1315 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1316 public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001317
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001318 /**
Jim Miller07994402012-05-02 14:22:27 -07001319 * Activity Action: Perform assist action.
1320 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001321 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1322 * additional optional contextual information about where the user was when they
Dianne Hackborna3acdb32015-06-08 17:07:40 -07001323 * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1324 * information.
Jim Miller07994402012-05-02 14:22:27 -07001325 * Output: nothing.
1326 */
1327 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1328 public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001329
1330 /**
Bjorn Bringertbc086862013-03-01 12:59:24 +00001331 * Activity Action: Perform voice assist action.
1332 * <p>
Adam Skory7140a252013-09-11 12:04:58 +01001333 * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1334 * additional optional contextual information about where the user was when they
Adam Skorydfc7fd72013-08-05 19:23:41 -07001335 * requested the voice assist.
Bjorn Bringertbc086862013-03-01 12:59:24 +00001336 * Output: nothing.
Adam Skory7140a252013-09-11 12:04:58 +01001337 * @hide
Bjorn Bringertbc086862013-03-01 12:59:24 +00001338 */
Amith Yamasani16452032017-03-03 10:15:57 -08001339 @SystemApi
Bjorn Bringertbc086862013-03-01 12:59:24 +00001340 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1341 public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1342
1343 /**
Adam Skory7140a252013-09-11 12:04:58 +01001344 * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1345 * application package at the time the assist was invoked.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001346 */
1347 public static final String EXTRA_ASSIST_PACKAGE
1348 = "android.intent.extra.ASSIST_PACKAGE";
1349
1350 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07001351 * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1352 * application package at the time the assist was invoked.
1353 */
1354 public static final String EXTRA_ASSIST_UID
1355 = "android.intent.extra.ASSIST_UID";
1356
1357 /**
Adam Skory7140a252013-09-11 12:04:58 +01001358 * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1359 * information supplied by the current foreground app at the time of the assist request.
1360 * This is a {@link Bundle} of additional data.
Dianne Hackbornf9c5e0f2013-01-23 14:39:13 -08001361 */
1362 public static final String EXTRA_ASSIST_CONTEXT
1363 = "android.intent.extra.ASSIST_CONTEXT";
1364
Jim Miller07994402012-05-02 14:22:27 -07001365 /**
Michael Wright8ab940a2014-09-01 11:01:27 -07001366 * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1367 * keyboard as the primary input device for assistance.
1368 */
1369 public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1370 "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1371
1372 /**
Tim Kilbourn0e5f1102015-06-05 16:18:09 -07001373 * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1374 * that was used to invoke the assist.
1375 */
1376 public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1377 "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1378
1379 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001380 * Activity Action: List all available applications.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001381 * <p>Input: Nothing.
1382 * <p>Output: nothing.
1383 */
1384 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1385 public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1386 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07001387 * Activity Action: Show settings for choosing wallpaper.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001388 * <p>Input: Nothing.
1389 * <p>Output: Nothing.
1390 */
1391 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1392 public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1393
1394 /**
1395 * Activity Action: Show activity for reporting a bug.
1396 * <p>Input: Nothing.
1397 * <p>Output: Nothing.
1398 */
1399 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1400 public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1401
1402 /**
1403 * Activity Action: Main entry point for factory tests. Only used when
1404 * the device is booting in factory test node. The implementing package
1405 * must be installed in the system image.
1406 * <p>Input: nothing
1407 * <p>Output: nothing
1408 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06001409 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001410 public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1411
1412 /**
1413 * Activity Action: The user pressed the "call" button to go to the dialer
1414 * or other appropriate UI for placing a call.
1415 * <p>Input: Nothing.
1416 * <p>Output: Nothing.
1417 */
1418 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1419 public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1420
1421 /**
1422 * Activity Action: Start Voice Command.
1423 * <p>Input: Nothing.
1424 * <p>Output: Nothing.
Christopher Tate72da1e62018-05-10 13:09:48 -07001425 * <p class="note">
1426 * In some cases, a matching Activity may not exist, so ensure you
1427 * safeguard against this.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001428 */
1429 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1430 public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001431
1432 /**
1433 * Activity Action: Start action associated with long pressing on the
1434 * search key.
1435 * <p>Input: Nothing.
1436 * <p>Output: Nothing.
1437 */
1438 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1439 public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
The Android Open Source Project10592532009-03-18 17:39:46 -07001440
Jacek Surazski86b6c532009-05-13 14:38:28 +02001441 /**
1442 * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1443 * This intent is delivered to the package which installed the application, usually
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -08001444 * Google Play.
Jacek Surazski86b6c532009-05-13 14:38:28 +02001445 * <p>Input: No data is specified. The bug report is passed in using
1446 * an {@link #EXTRA_BUG_REPORT} field.
1447 * <p>Output: Nothing.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001448 *
1449 * @see #EXTRA_BUG_REPORT
Jacek Surazski86b6c532009-05-13 14:38:28 +02001450 */
1451 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1452 public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
Dianne Hackborn3d74bb42009-06-19 10:35:21 -07001453
1454 /**
1455 * Activity Action: Show power usage information to the user.
1456 * <p>Input: Nothing.
1457 * <p>Output: Nothing.
1458 */
1459 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1460 public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
Tom Taylord4a47292009-12-21 13:59:18 -08001461
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001462 /**
Russell Brenner4cd32e52017-02-24 11:11:47 -08001463 * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1464 * to run.
1465 * <p>Input: Nothing.
1466 * <p>Output: Nothing.
1467 * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1468 * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1469 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06001470 * @removed
Russell Brenner4cd32e52017-02-24 11:11:47 -08001471 */
1472 @Deprecated
1473 @SystemApi
1474 public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1475 "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1476
1477 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001478 * Activity Action: Setup wizard to launch after a platform update. This
1479 * activity should have a string meta-data field associated with it,
1480 * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1481 * the platform for setup. The activity will be launched only if
1482 * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1483 * same value.
1484 * <p>Input: Nothing.
1485 * <p>Output: Nothing.
1486 * @hide
1487 */
Russell Brenner4cd32e52017-02-24 11:11:47 -08001488 @SystemApi
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001489 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1490 public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
Tom Taylord4a47292009-12-21 13:59:18 -08001491
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001492 /**
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001493 * Activity Action: Start the Keyboard Shortcuts Helper screen.
1494 * <p>Input: Nothing.
1495 * <p>Output: Nothing.
1496 * @hide
1497 */
1498 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1499 public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001500 "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
Clara Bayarrieb3c2d32016-04-01 14:37:32 +01001501
1502 /**
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001503 * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1504 * <p>Input: Nothing.
1505 * <p>Output: Nothing.
1506 * @hide
1507 */
1508 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1509 public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
Clara Bayarri847d8682017-03-06 16:48:44 +00001510 "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
Andrei Stingaceanu0bf096f2016-04-14 18:11:57 +01001511
1512 /**
Jeff Sharkey7f868272011-06-05 16:05:02 -07001513 * Activity Action: Show settings for managing network data usage of a
1514 * specific application. Applications should define an activity that offers
1515 * options to control data usage.
1516 */
1517 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1518 public static final String ACTION_MANAGE_NETWORK_USAGE =
1519 "android.intent.action.MANAGE_NETWORK_USAGE";
1520
1521 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001522 * Activity Action: Launch application installer.
1523 * <p>
Todd Kennedy9cc589a2016-08-18 16:23:17 -07001524 * Input: The data must be a content: URI at which the application
Dianne Hackborneba784ff2012-09-19 12:42:37 -07001525 * can be retrieved. As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1526 * you can also use "package:<package-name>" to install an application for the
1527 * current user that is already installed for another user. You can optionally supply
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001528 * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1529 * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1530 * <p>
1531 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1532 * succeeded.
Svet Ganov86877e42015-05-28 08:19:48 -07001533 * <p>
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001534 * <strong>Note:</strong>If your app is targeting API level higher than 25 you
Svet Ganov86877e42015-05-28 08:19:48 -07001535 * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1536 * in order to launch the application installer.
1537 * </p>
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001538 *
1539 * @see #EXTRA_INSTALLER_PACKAGE_NAME
1540 * @see #EXTRA_NOT_UNKNOWN_SOURCE
1541 * @see #EXTRA_RETURN_RESULT
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001542 *
1543 * @deprecated use {@link android.content.pm.PackageInstaller} instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001544 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001545 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001546 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1547 public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1548
1549 /**
Todd Kennedyd0084f72017-07-28 13:56:14 -07001550 * Activity Action: Activity to handle split installation failures.
1551 * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1552 * but the split that contains the application isn't installed. When a split is
1553 * installed in this manner, the containing package usually doesn't know this is
1554 * happening. However, if an error occurs during installation, the containing
1555 * package can define a single activity handling this action to deal with such
1556 * failures.
1557 * <p>The activity handling this action must be in the base package.
1558 * <p>
1559 * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1560 * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1561 */
1562 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1563 public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1564
1565 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001566 * Activity Action: Launch instant application installer.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001567 * <p class="note">
1568 * This is a protected intent that can only be sent by the system.
1569 * </p>
1570 *
1571 * @hide
1572 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001573 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001574 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001575 public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1576 = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001577
1578 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001579 * Service Action: Resolve instant application.
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001580 * <p>
1581 * The system will have a persistent connection to this service.
1582 * This is a protected intent that can only be sent by the system.
1583 * </p>
1584 *
1585 * @hide
1586 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001587 @SystemApi
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001588 @SdkConstant(SdkConstantType.SERVICE_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001589 public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1590 = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
Todd Kennedyb8a279e2015-11-18 09:59:47 -08001591
1592 /**
Todd Kennedyd46a1602017-04-03 15:22:38 -07001593 * Activity Action: Launch instant app settings.
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001594 *
1595 * <p class="note">
1596 * This is a protected intent that can only be sent by the system.
1597 * </p>
1598 *
1599 * @hide
1600 */
Todd Kennedyd46a1602017-04-03 15:22:38 -07001601 @SystemApi
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001602 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Todd Kennedyd46a1602017-04-03 15:22:38 -07001603 public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1604 = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
Chad Brubaker336ae5b2017-03-24 15:53:09 -07001605
1606 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001607 * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1608 * package. Specifies the installer package name; this package will receive the
1609 * {@link #ACTION_APP_ERROR} intent.
1610 */
1611 public static final String EXTRA_INSTALLER_PACKAGE_NAME
1612 = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1613
1614 /**
1615 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1616 * package. Specifies that the application being installed should not be
1617 * treated as coming from an unknown source, but as coming from the app
1618 * invoking the Intent. For this to work you must start the installer with
1619 * startActivityForResult().
1620 */
1621 public static final String EXTRA_NOT_UNKNOWN_SOURCE
1622 = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1623
1624 /**
rich cannings706e8ba2012-08-20 13:20:14 -07001625 * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1626 * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
rich cannings368ed012012-06-07 15:37:57 -07001627 * data field originated from.
1628 */
rich cannings706e8ba2012-08-20 13:20:14 -07001629 public static final String EXTRA_ORIGINATING_URI
1630 = "android.intent.extra.ORIGINATING_URI";
rich cannings368ed012012-06-07 15:37:57 -07001631
1632 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001633 * This extra can be used with any Intent used to launch an activity, supplying information
1634 * about who is launching that activity. This field contains a {@link android.net.Uri}
1635 * object, typically an http: or https: URI of the web site that the referral came from;
1636 * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1637 * a native application that it came from.
1638 *
1639 * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1640 * instead of directly retrieving the extra. It is also valid for applications to
1641 * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1642 * a string, not a Uri; the field here, if supplied, will always take precedence,
1643 * however.</p>
1644 *
1645 * @see #EXTRA_REFERRER_NAME
rich cannings368ed012012-06-07 15:37:57 -07001646 */
1647 public static final String EXTRA_REFERRER
1648 = "android.intent.extra.REFERRER";
1649
1650 /**
Dianne Hackborn85d558c2014-11-04 10:31:54 -08001651 * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1652 * than a {@link android.net.Uri} object. Only for use in cases where Uri objects can
1653 * not be created, in particular when Intent extras are supplied through the
1654 * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1655 * schemes.
1656 *
1657 * @see #EXTRA_REFERRER
1658 */
1659 public static final String EXTRA_REFERRER_NAME
1660 = "android.intent.extra.REFERRER_NAME";
1661
1662 /**
Ben Gruver37d83a32012-09-27 13:02:06 -07001663 * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
Gina Dimino98ad8882016-05-31 17:25:48 -07001664 * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
Suprabh Shukla54a10e62017-04-14 18:17:23 -07001665 * Currently only a system app that hosts the provider authority "downloads" or holds the
1666 * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
Ben Gruver37d83a32012-09-27 13:02:06 -07001667 * @hide
1668 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001669 @SystemApi
Ben Gruver37d83a32012-09-27 13:02:06 -07001670 public static final String EXTRA_ORIGINATING_UID
1671 = "android.intent.extra.ORIGINATING_UID";
1672
1673 /**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001674 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1675 * package. Tells the installer UI to skip the confirmation with the user
1676 * if the .apk is replacing an existing one.
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001677 * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1678 * will no longer show an interstitial message about updating existing
1679 * applications so this is no longer needed.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001680 */
Dianne Hackborn0e128bb2012-05-01 14:40:15 -07001681 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001682 public static final String EXTRA_ALLOW_REPLACE
1683 = "android.intent.extra.ALLOW_REPLACE";
1684
1685 /**
1686 * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1687 * {@link #ACTION_UNINSTALL_PACKAGE}. Specifies that the installer UI should
1688 * return to the application the result code of the install/uninstall. The returned result
1689 * code will be {@link android.app.Activity#RESULT_OK} on success or
1690 * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1691 */
1692 public static final String EXTRA_RETURN_RESULT
1693 = "android.intent.extra.RETURN_RESULT";
1694
1695 /**
1696 * Package manager install result code. @hide because result codes are not
1697 * yet ready to be exposed.
1698 */
1699 public static final String EXTRA_INSTALL_RESULT
1700 = "android.intent.extra.INSTALL_RESULT";
1701
1702 /**
1703 * Activity Action: Launch application uninstaller.
1704 * <p>
1705 * Input: The data must be a package: URI whose scheme specific part is
1706 * the package name of the current installed package to be uninstalled.
1707 * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1708 * <p>
1709 * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1710 * succeeded.
Philip P. Moltmannd9bb39a2017-09-05 12:41:15 -07001711 * <p>
1712 * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1713 * since {@link Build.VERSION_CODES#P}.
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001714 *
1715 * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1716 * instead
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001717 */
Philip P. Moltmannfe460102018-09-25 10:22:32 -07001718 @Deprecated
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07001719 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1720 public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1721
1722 /**
Dianne Hackborn6d235d82012-09-16 18:25:40 -07001723 * Specify whether the package should be uninstalled for all users.
1724 * @hide because these should not be part of normal application flow.
1725 */
1726 public static final String EXTRA_UNINSTALL_ALL_USERS
1727 = "android.intent.extra.UNINSTALL_ALL_USERS";
1728
1729 /**
Dianne Hackbornd7cd29d2009-07-01 11:22:45 -07001730 * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
1731 * describing the last run version of the platform that was setup.
1732 * @hide
1733 */
1734 public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1735
Svet Ganov3695b8a2015-03-24 16:30:25 -07001736 /**
1737 * Activity action: Launch UI to manage the permissions of an app.
1738 * <p>
1739 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1740 * will be managed by the launched UI.
1741 * </p>
1742 * <p>
1743 * Output: Nothing.
1744 * </p>
1745 *
1746 * @see #EXTRA_PACKAGE_NAME
1747 *
1748 * @hide
1749 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001750 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001751 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1752 public static final String ACTION_MANAGE_APP_PERMISSIONS =
1753 "android.intent.action.MANAGE_APP_PERMISSIONS";
1754
1755 /**
Svet Ganov321f0152015-05-16 22:51:50 -07001756 * Activity action: Launch UI to manage permissions.
1757 * <p>
1758 * Input: Nothing.
1759 * </p>
1760 * <p>
1761 * Output: Nothing.
1762 * </p>
1763 *
1764 * @hide
1765 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001766 @SystemApi
Svet Ganov321f0152015-05-16 22:51:50 -07001767 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1768 public static final String ACTION_MANAGE_PERMISSIONS =
1769 "android.intent.action.MANAGE_PERMISSIONS";
1770
1771 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001772 * Activity action: Launch UI to review permissions for an app.
1773 * The system uses this intent if permission review for apps not
1774 * supporting the new runtime permissions model is enabled. In
1775 * this mode a permission review is required before any of the
1776 * app components can run.
1777 * <p>
1778 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1779 * permissions will be reviewed (mandatory).
1780 * </p>
1781 * <p>
1782 * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1783 * be fired after the permission review (optional).
1784 * </p>
1785 * <p>
1786 * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1787 * be invoked after the permission review (optional).
1788 * </p>
1789 * <p>
1790 * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1791 * passed via {@link #EXTRA_INTENT} needs a result (optional).
1792 * </p>
1793 * <p>
1794 * Output: Nothing.
1795 * </p>
1796 *
1797 * @see #EXTRA_PACKAGE_NAME
1798 * @see #EXTRA_INTENT
1799 * @see #EXTRA_REMOTE_CALLBACK
1800 * @see #EXTRA_RESULT_NEEDED
1801 *
1802 * @hide
1803 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001804 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001805 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1806 public static final String ACTION_REVIEW_PERMISSIONS =
1807 "android.intent.action.REVIEW_PERMISSIONS";
1808
1809 /**
1810 * Intent extra: A callback for reporting remote result as a bundle.
1811 * <p>
1812 * Type: IRemoteCallback
1813 * </p>
1814 *
1815 * @hide
1816 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001817 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001818 public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1819
1820 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001821 * Intent extra: An app package name.
1822 * <p>
1823 * Type: String
Svet Ganov0b316702015-05-23 13:25:11 -07001824 * </p>
Svet Ganov3695b8a2015-03-24 16:30:25 -07001825 *
Svet Ganov3695b8a2015-03-24 16:30:25 -07001826 */
Svet Ganov3695b8a2015-03-24 16:30:25 -07001827 public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1828
1829 /**
Suprabh Shukla96212bc2018-04-10 15:04:51 -07001830 * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1831 * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1832 *
1833 * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1834 * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1835 * This is meant to enable the suspended app to better handle the state of being suspended.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07001836 *
1837 * @see #ACTION_MY_PACKAGE_SUSPENDED
1838 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1839 * @see PackageManager#isPackageSuspended()
1840 * @see PackageManager#getSuspendedPackageAppExtras()
1841 */
1842 public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1843
1844 /**
Todd Kennedye5195dd2016-10-19 15:29:19 -07001845 * Intent extra: An app split name.
1846 * <p>
1847 * Type: String
1848 * </p>
Todd Kennedye5195dd2016-10-19 15:29:19 -07001849 */
Todd Kennedye5195dd2016-10-19 15:29:19 -07001850 public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
1851
1852 /**
Jeff Sharkey1a749422017-04-28 14:19:50 -06001853 * Intent extra: A {@link ComponentName} value.
1854 * <p>
1855 * Type: String
1856 * </p>
1857 */
1858 public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
1859
1860 /**
Svet Ganov9c165d72015-12-01 19:52:26 -08001861 * Intent extra: An extra for specifying whether a result is needed.
1862 * <p>
1863 * Type: boolean
1864 * </p>
1865 *
1866 * @hide
1867 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001868 @SystemApi
Svet Ganov9c165d72015-12-01 19:52:26 -08001869 public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
1870
1871 /**
Suprabh Shukla19b41f32018-03-26 22:35:13 -07001872 * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
1873 * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
1874 *
1875 * @see PackageManager#isPackageSuspended()
1876 * @see #ACTION_PACKAGES_SUSPENDED
1877 *
1878 * @hide
1879 */
1880 public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
1881
1882 /**
Svet Ganov3695b8a2015-03-24 16:30:25 -07001883 * Activity action: Launch UI to manage which apps have a given permission.
1884 * <p>
1885 * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
1886 * to which will be managed by the launched UI.
1887 * </p>
1888 * <p>
1889 * Output: Nothing.
1890 * </p>
1891 *
1892 * @see #EXTRA_PERMISSION_NAME
1893 *
1894 * @hide
1895 */
Svet Ganovae0e03a2016-02-25 18:22:10 -08001896 @SystemApi
Svet Ganov3695b8a2015-03-24 16:30:25 -07001897 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1898 public static final String ACTION_MANAGE_PERMISSION_APPS =
1899 "android.intent.action.MANAGE_PERMISSION_APPS";
1900
1901 /**
1902 * Intent extra: The name of a permission.
1903 * <p>
1904 * Type: String
1905 * </p>
1906 *
1907 * @hide
1908 */
1909 @SystemApi
1910 public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
1911
Joel Galenson13096ea2018-09-27 11:18:44 -07001912 /**
1913 * Activity action: Launch UI to review app uses of permissions.
1914 * <p>
1915 * Input: Nothing
1916 * </p>
1917 * <p>
1918 * Output: Nothing.
1919 * </p>
1920 *
1921 * @hide
1922 */
1923 @SystemApi
1924 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1925 public static final String ACTION_REVIEW_PERMISSION_USAGE =
1926 "android.intent.action.REVIEW_PERMISSION_USAGE";
1927
Joel Galenson78ec58d2018-10-24 10:06:25 -07001928 /**
1929 * Activity action: Launch UI to review uses of permissions for a single app.
1930 * <p>
1931 * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1932 * permissions will be reviewed (mandatory).
1933 * </p>
1934 * <p>
1935 * Output: Nothing.
1936 * </p>
1937 * <p class="note">
1938 * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
1939 * </p>
1940 *
1941 * @see #EXTRA_PACKAGE_NAME
1942 *
1943 * @hide
1944 */
1945 @SystemApi
1946 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1947 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1948 public static final String ACTION_REVIEW_APP_PERMISSION_USAGE =
1949 "android.intent.action.REVIEW_APP_PERMISSION_USAGE";
1950
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001951 // ---------------------------------------------------------------------
1952 // ---------------------------------------------------------------------
1953 // Standard intent broadcast actions (see action variable).
1954
1955 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001956 * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
1957 * <p>
1958 * For historical reasons, the name of this broadcast action refers to the power
1959 * state of the screen but it is actually sent in response to changes in the
1960 * overall interactive state of the device.
1961 * </p><p>
1962 * This broadcast is sent when the device becomes non-interactive which may have
1963 * nothing to do with the screen turning off. To determine the
1964 * actual state of the screen, use {@link android.view.Display#getState}.
1965 * </p><p>
1966 * See {@link android.os.PowerManager#isInteractive} for details.
1967 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001968 * You <em>cannot</em> receive this through components declared in
1969 * manifests, only by explicitly registering for it with
1970 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1971 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001972 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001973 * <p class="note">This is a protected intent that can only be sent
1974 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001975 */
1976 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1977 public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
Jeff Brown037c33e2014-04-09 00:31:55 -07001978
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001979 /**
Jeff Brown037c33e2014-04-09 00:31:55 -07001980 * Broadcast Action: Sent when the device wakes up and becomes interactive.
1981 * <p>
1982 * For historical reasons, the name of this broadcast action refers to the power
1983 * state of the screen but it is actually sent in response to changes in the
1984 * overall interactive state of the device.
1985 * </p><p>
1986 * This broadcast is sent when the device becomes interactive which may have
1987 * nothing to do with the screen turning on. To determine the
1988 * actual state of the screen, use {@link android.view.Display#getState}.
1989 * </p><p>
1990 * See {@link android.os.PowerManager#isInteractive} for details.
1991 * </p>
Casey Hodbf6785c2015-03-17 15:59:39 -07001992 * You <em>cannot</em> receive this through components declared in
1993 * manifests, only by explicitly registering for it with
1994 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
1995 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08001996 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07001997 * <p class="note">This is a protected intent that can only be sent
1998 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07001999 */
2000 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2001 public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002002
2003 /**
Dianne Hackbornbe87e2f2012-09-28 16:31:34 -07002004 * Broadcast Action: Sent after the system stops dreaming.
2005 *
2006 * <p class="note">This is a protected intent that can only be sent by the system.
2007 * It is only sent to registered receivers.</p>
2008 */
2009 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2010 public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2011
2012 /**
2013 * Broadcast Action: Sent after the system starts dreaming.
2014 *
2015 * <p class="note">This is a protected intent that can only be sent by the system.
2016 * It is only sent to registered receivers.</p>
2017 */
2018 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2019 public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2020
2021 /**
The Android Open Source Project10592532009-03-18 17:39:46 -07002022 * 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 -07002023 * keyguard is gone).
Tom Taylord4a47292009-12-21 13:59:18 -08002024 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002025 * <p class="note">This is a protected intent that can only be sent
2026 * by the system.
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002027 */
2028 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08002029 public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
The Android Open Source Projectb2a3dd82009-03-09 11:52:12 -07002030
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002031 /**
2032 * Broadcast Action: The current time has changed. Sent every
Casey Hodbf6785c2015-03-17 15:59:39 -07002033 * minute. You <em>cannot</em> receive this through components declared
John Spurlock6098c5d2013-06-17 10:32:46 -04002034 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002035 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2036 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002037 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002038 * <p class="note">This is a protected intent that can only be sent
2039 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002040 */
2041 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2042 public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2043 /**
2044 * Broadcast Action: The time was set.
2045 */
2046 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2047 public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2048 /**
2049 * Broadcast Action: The date has changed.
2050 */
2051 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2052 public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2053 /**
2054 * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2055 * <ul>
2056 * <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2057 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002058 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002059 * <p class="note">This is a protected intent that can only be sent
2060 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002061 */
2062 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2063 public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2064 /**
Robert Greenwalt03595d02010-11-02 14:08:23 -07002065 * Clear DNS Cache Action: This is broadcast when networks have changed and old
2066 * DNS entries should be tossed.
2067 * @hide
2068 */
2069 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2070 public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2071 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002072 * Alarm Changed Action: This is broadcast when the AlarmClock
2073 * application's alarm is set or unset. It is used by the
2074 * AlarmClock application and the StatusBar service.
2075 * @hide
2076 */
2077 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Mathew Inwood5c0d3542018-08-14 13:54:31 +01002078 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002079 public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002080
2081 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002082 * Broadcast Action: This is broadcast once, after the user has finished
2083 * booting, but while still in the "locked" state. It can be used to perform
2084 * application-specific initialization, such as installing alarms. You must
2085 * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2086 * permission in order to receive this broadcast.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002087 * <p>
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002088 * This broadcast is sent immediately at boot by all devices (regardless of
2089 * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2090 * higher. Upon receipt of this broadcast, the user is still locked and only
2091 * device-protected storage can be accessed safely. If you want to access
2092 * credential-protected storage, you need to wait for the user to be
2093 * unlocked (typically by entering their lock pattern or PIN for the first
2094 * time), after which the {@link #ACTION_USER_UNLOCKED} and
2095 * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2096 * <p>
2097 * To receive this broadcast, your receiver component must be marked as
2098 * being {@link ComponentInfo#directBootAware}.
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002099 * <p class="note">
2100 * This is a protected intent that can only be sent by the system.
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002101 *
2102 * @see Context#createDeviceProtectedStorageContext()
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002103 */
2104 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2105 public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2106
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002107 /**
Jeff Sharkeycf3f0a12016-03-17 19:57:58 -06002108 * Broadcast Action: This is broadcast once, after the user has finished
2109 * booting. It can be used to perform application-specific initialization,
2110 * such as installing alarms. You must hold the
2111 * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2112 * order to receive this broadcast.
2113 * <p>
2114 * This broadcast is sent at boot by all devices (both with and without
2115 * direct boot support). Upon receipt of this broadcast, the user is
2116 * unlocked and both device-protected and credential-protected storage can
2117 * accessed safely.
2118 * <p>
2119 * If you need to run while the user is still locked (before they've entered
2120 * their lock pattern or PIN for the first time), you can listen for the
2121 * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2122 * <p class="note">
2123 * This is a protected intent that can only be sent by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002124 */
2125 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey32ee8ee2017-03-08 20:17:51 -07002126 @BroadcastBehavior(includeBackground = true)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002127 public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
Jeff Sharkeybedbaa92015-12-02 16:42:25 -07002128
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002129 /**
2130 * Broadcast Action: This is broadcast when a user action should request a
2131 * temporary system dialog to dismiss. Some examples of temporary system
2132 * dialogs are the notification window-shade and the recent tasks dialog.
2133 */
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002134 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002135 public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2136 /**
2137 * Broadcast Action: Trigger the download and eventual installation
2138 * of a package.
2139 * <p>Input: {@link #getData} is the URI of the package file to download.
Tom Taylord4a47292009-12-21 13:59:18 -08002140 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002141 * <p class="note">This is a protected intent that can only be sent
2142 * by the system.
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002143 *
2144 * @deprecated This constant has never been used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002145 */
Dianne Hackborn271c2fe2011-08-09 19:35:13 -07002146 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002147 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2148 public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2149 /**
Christopher Tate94b91db2017-04-19 15:49:17 -07002150 * Broadcast Action: A new application package has been installed on the
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002151 * device. The data contains the name of the package. Note that the
2152 * newly installed package does <em>not</em> receive this broadcast.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002153 * <p>May include the following extras:
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002154 * <ul>
Christopher Tate94b91db2017-04-19 15:49:17 -07002155 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2156 * <li> {@link #EXTRA_REPLACING} is set to true if this is following
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002157 * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2158 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002159 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002160 * <p class="note">This is a protected intent that can only be sent
2161 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002162 */
2163 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2164 public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2165 /**
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002166 * Broadcast Action: A new version of an application package has been
2167 * installed, replacing an existing version that was previously installed.
2168 * The data contains the name of the package.
Jeff Sharkeyd0c6ccb2012-09-14 16:26:37 -07002169 * <p>May include the following extras:
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002170 * <ul>
2171 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2172 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002173 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002174 * <p class="note">This is a protected intent that can only be sent
2175 * by the system.
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002176 */
2177 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2178 public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2179 /**
Dianne Hackborne7f97212011-02-24 14:40:20 -08002180 * Broadcast Action: A new version of your application has been installed
2181 * over an existing one. This is only sent to the application that was
2182 * replaced. It does not contain any additional data; to receive it, just
2183 * use an intent filter for this action.
2184 *
2185 * <p class="note">This is a protected intent that can only be sent
2186 * by the system.
2187 */
2188 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2189 public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2190 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002191 * Broadcast Action: An existing application package has been removed from
2192 * the device. The data contains the name of the package. The package
Trevor Johns682c24e2016-04-12 10:13:47 -07002193 * that is being removed does <em>not</em> receive this Intent.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002194 * <ul>
2195 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2196 * to the package.
2197 * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2198 * application -- data and code -- is being removed.
2199 * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2200 * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2201 * </ul>
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 Project54b6cfa2008-10-21 07:00:00 -07002205 */
2206 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2207 public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2208 /**
Dianne Hackbornf9abb402011-08-10 15:00:59 -07002209 * Broadcast Action: An existing application package has been completely
2210 * removed from the device. The data contains the name of the package.
2211 * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2212 * {@link #EXTRA_DATA_REMOVED} is true and
2213 * {@link #EXTRA_REPLACING} is false of that broadcast.
2214 *
2215 * <ul>
2216 * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2217 * to the package.
2218 * </ul>
2219 *
2220 * <p class="note">This is a protected intent that can only be sent
2221 * by the system.
2222 */
2223 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2224 public static final String ACTION_PACKAGE_FULLY_REMOVED
2225 = "android.intent.action.PACKAGE_FULLY_REMOVED";
2226 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002227 * Broadcast Action: An existing application package has been changed (for
2228 * example, a component has been enabled or disabled). The data contains
2229 * the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002230 * <ul>
2231 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002232 * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08002233 * of the changed components (or the package name itself).
Dianne Hackborn86a72da2009-11-11 20:12:41 -08002234 * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2235 * default action of restarting the application.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002236 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002237 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002238 * <p class="note">This is a protected intent that can only be sent
2239 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002240 */
2241 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2242 public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2243 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002244 * @hide
2245 * Broadcast Action: Ask system services if there is any reason to
2246 * restart the given package. The data contains the name of the
2247 * package.
2248 * <ul>
2249 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2250 * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2251 * </ul>
2252 *
2253 * <p class="note">This is a protected intent that can only be sent
2254 * by the system.
2255 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08002256 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08002257 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2258 public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2259 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002260 * Broadcast Action: The user has restarted a package, and all of its
2261 * processes have been killed. All runtime state
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002262 * associated with it (processes, alarms, notifications, etc) should
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002263 * be removed. Note that the restarted package does <em>not</em>
2264 * receive this broadcast.
2265 * The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002266 * <ul>
2267 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2268 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002269 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002270 * <p class="note">This is a protected intent that can only be sent
2271 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002272 */
2273 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2274 public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2275 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002276 * Broadcast Action: The user has cleared the data of a package. This should
2277 * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
The Android Open Source Projectc2ad2412009-03-19 23:08:54 -07002278 * its persistent data is erased and this broadcast sent.
2279 * Note that the cleared package does <em>not</em>
2280 * receive this broadcast. The data contains the name of the package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002281 * <ul>
Svet Ganovf935a702017-08-22 12:15:58 -07002282 * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2283 * package whose data was cleared is an uninstalled instant app, then the UID
2284 * will be -1. The platform keeps some meta-data associated with instant apps
2285 * after they are uninstalled.
2286 * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2287 * data was for an instant app.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002288 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002289 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002290 * <p class="note">This is a protected intent that can only be sent
2291 * by the system.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002292 */
2293 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2294 public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2295 /**
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002296 * Broadcast Action: Packages have been suspended.
2297 * <p>Includes the following extras:
2298 * <ul>
2299 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002300 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002301 * </ul>
2302 *
2303 * <p class="note">This is a protected intent that can only be sent
2304 * by the system. It is only sent to registered receivers.
2305 */
2306 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307 public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2308 /**
2309 * Broadcast Action: Packages have been unsuspended.
2310 * <p>Includes the following extras:
2311 * <ul>
2312 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
Julia Reynolds4bc42b92018-08-14 11:27:35 -04002313 * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002314 * </ul>
2315 *
2316 * <p class="note">This is a protected intent that can only be sent
2317 * by the system. It is only sent to registered receivers.
2318 */
2319 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2320 public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002321
2322 /**
2323 * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
Suprabh Shukla19b41f32018-03-26 22:35:13 -07002324 * whenever a package is put into a suspended state or any of its app extras change while in the
2325 * suspended state.
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002326 * <p> Optionally includes the following extras:
2327 * <ul>
2328 * <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2329 * useful information for the app being suspended.
2330 * </ul>
2331 * <p class="note">This is a protected intent that can only be sent
2332 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2333 * the manifest.</em>
2334 *
2335 * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2336 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2337 * @see PackageManager#isPackageSuspended()
2338 * @see PackageManager#getSuspendedPackageAppExtras()
2339 */
2340 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2341 public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2342
2343 /**
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002344 * Activity Action: Started to show more details about why an application was suspended.
2345 *
Suprabh Shukla3e03ab92018-04-11 16:03:49 -07002346 * <p>Whenever the system detects an activity launch for a suspended app, this action can
2347 * be used to show more details about the reason for suspension.
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002348 *
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002349 * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2350 * handling this intent and protect it with
2351 * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2352 *
2353 * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2354 *
2355 * <p class="note">This is a protected intent that can only be sent
2356 * by the system.
2357 *
Suprabh Shukla96212bc2018-04-10 15:04:51 -07002358 * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2359 * PersistableBundle, String)
Suprabh Shukla3c3af142018-03-30 00:28:37 -07002360 * @see PackageManager#isPackageSuspended()
2361 * @see #ACTION_PACKAGES_SUSPENDED
2362 *
2363 * @hide
2364 */
2365 @SystemApi
2366 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2367 public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2368 "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2369
2370 /**
Suprabh Shukla2fd43ba2018-03-22 16:57:49 -07002371 * Broadcast Action: Sent to a package that has been unsuspended.
2372 *
2373 * <p class="note">This is a protected intent that can only be sent
2374 * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2375 * the manifest.</em>
2376 *
2377 * @see #ACTION_MY_PACKAGE_SUSPENDED
2378 * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2379 * @see PackageManager#isPackageSuspended()
2380 * @see PackageManager#getSuspendedPackageAppExtras()
2381 */
2382 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2383 public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2384
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00002385 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002386 * Broadcast Action: A user ID has been removed from the system. The user
2387 * ID number is stored in the extra data under {@link #EXTRA_UID}.
Tom Taylord4a47292009-12-21 13:59:18 -08002388 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002389 * <p class="note">This is a protected intent that can only be sent
2390 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002391 */
2392 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2393 public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002394
2395 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002396 * Broadcast Action: Sent to the installer package of an application when
2397 * that application is first launched (that is the first time it is moved
2398 * out of the stopped state). The data contains the name of the package.
Dianne Hackborne7f97212011-02-24 14:40:20 -08002399 *
2400 * <p class="note">This is a protected intent that can only be sent
2401 * by the system.
2402 */
2403 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2404 public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2405
2406 /**
Kenny Root5ab21572011-07-27 11:11:19 -07002407 * Broadcast Action: Sent to the system package verifier when a package
2408 * needs to be verified. The data contains the package URI.
2409 * <p class="note">
2410 * This is a protected intent that can only be sent by the system.
2411 * </p>
Kenny Root5ab21572011-07-27 11:11:19 -07002412 */
2413 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414 public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2415
2416 /**
rich canningsd1b5cfc2012-08-29 14:49:51 -07002417 * Broadcast Action: Sent to the system package verifier when a package is
2418 * verified. The data contains the package URI.
2419 * <p class="note">
2420 * This is a protected intent that can only be sent by the system.
2421 */
2422 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2423 public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2424
2425 /**
Trevor Johns682c24e2016-04-12 10:13:47 -07002426 * Broadcast Action: Sent to the system intent filter verifier when an
2427 * intent filter needs to be verified. The data contains the filter data
2428 * hosts to be verified against.
Fabrice Di Meglio1c1b4712014-11-19 17:12:32 -08002429 * <p class="note">
2430 * This is a protected intent that can only be sent by the system.
2431 * </p>
2432 *
2433 * @hide
2434 */
2435 @SystemApi
2436 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2437 public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2438
2439 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002440 * Broadcast Action: Resources for a set of packages (which were
2441 * previously unavailable) are currently
2442 * available since the media on which they exist is available.
2443 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2444 * list of packages whose availability changed.
2445 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2446 * list of uids of packages whose availability changed.
2447 * Note that the
2448 * packages in this list do <em>not</em> receive this broadcast.
2449 * The specified set of packages are now available on the system.
2450 * <p>Includes the following extras:
2451 * <ul>
2452 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2453 * whose resources(were previously unavailable) are currently available.
2454 * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2455 * packages whose resources(were previously unavailable)
2456 * are currently available.
2457 * </ul>
2458 *
2459 * <p class="note">This is a protected intent that can only be sent
2460 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002461 */
2462 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002463 public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2464 "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002465
2466 /**
2467 * Broadcast Action: Resources for a set of packages are currently
2468 * unavailable since the media on which they exist is unavailable.
2469 * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2470 * list of packages whose availability changed.
2471 * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2472 * list of uids of packages whose availability changed.
2473 * The specified set of packages can no longer be
2474 * launched and are practically unavailable on the system.
2475 * <p>Inclues the following extras:
2476 * <ul>
2477 * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2478 * whose resources are no longer available.
2479 * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2480 * whose resources are no longer available.
2481 * </ul>
2482 *
2483 * <p class="note">This is a protected intent that can only be sent
2484 * by the system.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002485 */
2486 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08002487 public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
Joe Onorato8a051a42010-03-04 15:54:50 -05002488 "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08002489
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002490 /**
Makoto Onuki10305202016-07-14 18:14:08 -07002491 * Broadcast Action: preferred activities have changed *explicitly*.
2492 *
2493 * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2494 * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2495 * be sent.
2496 *
2497 * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2498 *
2499 * @hide
2500 */
2501 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2502 public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2503 "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2504
2505
2506 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002507 * Broadcast Action: The current system wallpaper has changed. See
Scott Main8b2e0002009-09-29 18:17:31 -07002508 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002509 * This should <em>only</em> be used to determine when the wallpaper
2510 * has changed to show the new wallpaper to the user. You should certainly
2511 * never, in response to this, change the wallpaper or other attributes of
2512 * it such as the suggested size. That would be crazy, right? You'd cause
2513 * all kinds of loops, especially if other apps are doing similar things,
2514 * right? Of course. So please don't do this.
2515 *
2516 * @deprecated Modern applications should use
2517 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2518 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2519 * shown behind their UI, rather than watching for this broadcast and
2520 * rendering the wallpaper on their own.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002521 */
Dianne Hackbornc5bf7582012-04-25 19:12:07 -07002522 @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002523 public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2524 /**
2525 * Broadcast Action: The current device {@link android.content.res.Configuration}
2526 * (orientation, locale, etc) has changed. When such a change happens, the
2527 * UIs (view hierarchy) will need to be rebuilt based on this new
2528 * information; for the most part, applications don't need to worry about
2529 * this, because the system will take care of stopping and restarting the
2530 * application to make sure it sees the new changes. Some system code that
2531 * can not be restarted will need to watch for this action and handle it
2532 * appropriately.
Tom Taylord4a47292009-12-21 13:59:18 -08002533 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002534 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002535 * You <em>cannot</em> receive this through components declared
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002536 * in manifests, only by explicitly registering for it with
2537 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2538 * Context.registerReceiver()}.
Tom Taylord4a47292009-12-21 13:59:18 -08002539 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002540 * <p class="note">This is a protected intent that can only be sent
2541 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002542 *
2543 * @see android.content.res.Configuration
2544 */
2545 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2546 public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
Adam Lesinski57fccd62018-01-25 13:03:57 -08002547
2548 /**
2549 * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2550 * such that the device may be eligible for the installation of additional configuration splits.
2551 * Configuration properties that can trigger this broadcast include locale and display density.
2552 *
2553 * <p class="note">
2554 * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2555 * components declared in manifests. However, the receiver <em>must</em> hold the
2556 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2557 *
2558 * <p class="note">
2559 * This is a protected intent that can only be sent by the system.
2560 *
2561 * @hide
2562 */
2563 @SystemApi
2564 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565 public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2566 "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002567 /**
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002568 * Broadcast Action: The current device's locale has changed.
Tom Taylord4a47292009-12-21 13:59:18 -08002569 *
Dianne Hackborn362d5b92009-11-11 18:04:39 -08002570 * <p class="note">This is a protected intent that can only be sent
2571 * by the system.
2572 */
2573 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2574 public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2575 /**
Dianne Hackbornedd93162009-09-19 14:03:05 -07002576 * Broadcast Action: This is a <em>sticky broadcast</em> containing the
2577 * charging state, level, and other information about the battery.
2578 * See {@link android.os.BatteryManager} for documentation on the
2579 * contents of the Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07002580 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002581 * <p class="note">
Casey Hodbf6785c2015-03-17 15:59:39 -07002582 * You <em>cannot</em> receive this through components declared
Dianne Hackborn854060af2009-07-09 18:14:31 -07002583 * in manifests, only by explicitly registering for it with
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002584 * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
Dianne Hackbornedd93162009-09-19 14:03:05 -07002585 * Context.registerReceiver()}. See {@link #ACTION_BATTERY_LOW},
2586 * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2587 * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2588 * broadcasts that are sent and can be received through manifest
2589 * receivers.
Tom Taylord4a47292009-12-21 13:59:18 -08002590 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002591 * <p class="note">This is a protected intent that can only be sent
2592 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002593 */
2594 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2595 public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
Fyodor Kupolov70e75432018-03-01 18:29:06 -08002596
2597
2598 /**
2599 * Broadcast Action: Sent when the current battery level changes.
2600 *
2601 * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2602 * instances representing individual battery level changes with associated
2603 * extras from {@link #ACTION_BATTERY_CHANGED}.
2604 *
2605 * <p class="note">
2606 * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2607 *
2608 * @hide
2609 */
2610 @SystemApi
2611 public static final String ACTION_BATTERY_LEVEL_CHANGED =
2612 "android.intent.action.BATTERY_LEVEL_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002613 /**
2614 * Broadcast Action: Indicates low battery condition on the device.
2615 * This broadcast corresponds to the "Low battery warning" system dialog.
Tom Taylord4a47292009-12-21 13:59:18 -08002616 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002617 * <p class="note">This is a protected intent that can only be sent
2618 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002619 */
2620 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621 public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2622 /**
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002623 * Broadcast Action: Indicates the battery is now okay after being low.
2624 * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2625 * gone back up to an okay state.
Tom Taylord4a47292009-12-21 13:59:18 -08002626 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002627 * <p class="note">This is a protected intent that can only be sent
2628 * by the system.
Dianne Hackborn1dac2772009-06-26 18:16:48 -07002629 */
2630 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2631 public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2632 /**
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002633 * Broadcast Action: External power has been connected to the device.
2634 * This is intended for applications that wish to register specifically to this notification.
2635 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2636 * stay active to receive this notification. This action can be used to implement actions
2637 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002638 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002639 * <p class="note">This is a protected intent that can only be sent
2640 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002641 */
2642 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002643 public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002644 /**
2645 * Broadcast Action: External power has been removed from the device.
2646 * This is intended for applications that wish to register specifically to this notification.
2647 * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2648 * stay active to receive this notification. This action can be used to implement actions
Romain Guy4969af72009-06-17 10:53:19 -07002649 * that wait until power is available to trigger.
Tom Taylord4a47292009-12-21 13:59:18 -08002650 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002651 * <p class="note">This is a protected intent that can only be sent
2652 * by the system.
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002653 */
2654 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Baptiste Queru1ef45642008-10-24 11:49:25 -07002655 public static final String ACTION_POWER_DISCONNECTED =
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002656 "android.intent.action.ACTION_POWER_DISCONNECTED";
Cliff Spradlinfda6fae2008-10-22 20:29:16 -07002657 /**
Dianne Hackborn55280a92009-05-07 15:53:46 -07002658 * Broadcast Action: Device is shutting down.
2659 * This is broadcast when the device is being shut down (completely turned
2660 * off, not sleeping). Once the broadcast is complete, the final shutdown
2661 * will proceed and all unsaved data lost. Apps will not normally need
Dianne Hackbornfe240ec2009-08-27 12:51:11 -07002662 * to handle this, since the foreground activity will be paused as well.
Fyodor Kupolov1fc62602018-02-01 15:48:53 -08002663 * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2664 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2665 * Context.registerReceiver}.
Tom Taylord4a47292009-12-21 13:59:18 -08002666 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07002667 * <p class="note">This is a protected intent that can only be sent
2668 * by the system.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07002669 * <p>May include the following extras:
2670 * <ul>
2671 * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2672 * shutdown is only for userspace processes. If not set, assumed to be false.
2673 * </ul>
Dianne Hackborn55280a92009-05-07 15:53:46 -07002674 */
2675 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Romain Guy4969af72009-06-17 10:53:19 -07002676 public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
Dianne Hackborn55280a92009-05-07 15:53:46 -07002677 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002678 * Activity Action: Start this activity to request system shutdown.
2679 * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
Yusuke Sato705ffd12015-07-21 15:52:11 -07002680 * to request confirmation from the user before shutting down. The optional boolean
2681 * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2682 * indicate that the shutdown is requested by the user.
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002683 *
2684 * <p class="note">This is a protected intent that can only be sent
2685 * by the system.
2686 *
2687 * {@hide}
2688 */
Sudheer Shanka218190a2017-03-30 16:07:54 -07002689 public static final String ACTION_REQUEST_SHUTDOWN
2690 = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
Mike Lockwoodbad80e02009-07-30 01:21:08 -07002691 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002692 * Broadcast Action: A sticky broadcast that indicates low storage space
Dianne Hackbornedd93162009-09-19 14:03:05 -07002693 * condition on the device
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002694 * <p class="note">
2695 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002696 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002697 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2698 * or above, this broadcast will no longer be delivered to any
2699 * {@link BroadcastReceiver} defined in your manifest. Instead,
2700 * apps are strongly encouraged to use the improved
2701 * {@link Context#getCacheDir()} behavior so the system can
2702 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002703 */
2704 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002705 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002706 public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2707 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002708 * Broadcast Action: Indicates low storage space condition on the device no
2709 * longer exists
2710 * <p class="note">
2711 * This is a protected intent that can only be sent by the system.
Tom Taylord4a47292009-12-21 13:59:18 -08002712 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002713 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2714 * or above, this broadcast will no longer be delivered to any
2715 * {@link BroadcastReceiver} defined in your manifest. Instead,
2716 * apps are strongly encouraged to use the improved
2717 * {@link Context#getCacheDir()} behavior so the system can
2718 * automatically free up storage when needed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002719 */
2720 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002721 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002722 public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
2723 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002724 * Broadcast Action: A sticky broadcast that indicates a storage space full
2725 * condition on the device. This is intended for activities that want to be
2726 * able to fill the data partition completely, leaving only enough free
2727 * space to prevent system-wide SQLite failures.
2728 * <p class="note">
2729 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002730 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002731 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2732 * or above, this broadcast will no longer be delivered to any
2733 * {@link BroadcastReceiver} defined in your manifest. Instead,
2734 * apps are strongly encouraged to use the improved
2735 * {@link Context#getCacheDir()} behavior so the system can
2736 * automatically free up storage when needed.
2737 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002738 */
2739 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002740 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002741 public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
2742 /**
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002743 * Broadcast Action: Indicates storage space full condition on the device no
2744 * longer exists.
2745 * <p class="note">
2746 * This is a protected intent that can only be sent by the system.
Jake Hambybb371632010-08-23 18:16:48 -07002747 *
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002748 * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2749 * or above, this broadcast will no longer be delivered to any
2750 * {@link BroadcastReceiver} defined in your manifest. Instead,
2751 * apps are strongly encouraged to use the improved
2752 * {@link Context#getCacheDir()} behavior so the system can
2753 * automatically free up storage when needed.
2754 * @hide
Jake Hambybb371632010-08-23 18:16:48 -07002755 */
2756 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey179d6b32017-03-12 17:27:47 -06002757 @Deprecated
Jake Hambybb371632010-08-23 18:16:48 -07002758 public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
2759 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002760 * Broadcast Action: Indicates low memory condition notification acknowledged by user
2761 * and package management should be started.
2762 * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
2763 * notification.
2764 */
2765 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2766 public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
2767 /**
2768 * Broadcast Action: The device has entered USB Mass Storage mode.
2769 * This is used mainly for the USB Settings panel.
2770 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2771 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002772 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002773 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002774 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002775 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002776 public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
2777
2778 /**
2779 * Broadcast Action: The device has exited USB Mass Storage mode.
2780 * This is used mainly for the USB Settings panel.
2781 * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
2782 * when the SD card file system is mounted or unmounted
Mike Lockwood7e4db372011-06-07 11:23:44 -07002783 * @deprecated replaced by android.os.storage.StorageEventListener
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002784 */
Mike Lockwoodda85e522011-06-07 09:08:34 -07002785 @Deprecated
Jeff Sharkey0f3f60b2017-04-24 18:06:20 -06002786 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002787 public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
2788
2789 /**
2790 * Broadcast Action: External media has been removed.
2791 * The path to the mount point for the removed media is contained in the Intent.mData field.
2792 */
2793 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2794 public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
2795
2796 /**
2797 * Broadcast Action: External media is present, but not mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002798 * 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 -07002799 */
2800 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2801 public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
2802
2803 /**
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08002804 * Broadcast Action: External media is present, and being disk-checked
2805 * 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 -08002806 */
2807 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2808 public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
2809
2810 /**
2811 * Broadcast Action: External media is present, but is using an incompatible fs (or is blank)
2812 * 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 -08002813 */
2814 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2815 public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
2816
2817 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002818 * Broadcast Action: External media is present and mounted at its mount point.
suyi Yuanbe7af832013-01-04 21:21:59 +08002819 * 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 -07002820 * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
2821 * media was mounted read only.
2822 */
2823 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2824 public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
2825
2826 /**
2827 * Broadcast Action: External media is unmounted because it is being shared via USB mass storage.
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002828 * 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 -07002829 */
2830 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2831 public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
2832
2833 /**
Mike Lockwoodbf2dd442010-03-03 06:16:52 -05002834 * Broadcast Action: External media is no longer being shared via USB mass storage.
2835 * The path to the mount point for the previously shared media is contained in the Intent.mData field.
2836 *
2837 * @hide
2838 */
2839 public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
2840
2841 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002842 * Broadcast Action: External media was removed from SD card slot, but mount point was not unmounted.
2843 * The path to the mount point for the removed media is contained in the Intent.mData field.
2844 */
2845 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2846 public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
2847
2848 /**
2849 * Broadcast Action: External media is present but cannot be mounted.
suyi Yuanbe7af832013-01-04 21:21:59 +08002850 * 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 -07002851 */
2852 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2853 public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
2854
2855 /**
2856 * Broadcast Action: User has expressed the desire to remove the external storage media.
2857 * Applications should close all files they have open within the mount point when they receive this intent.
2858 * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
2859 */
2860 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2861 public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
2862
2863 /**
2864 * Broadcast Action: The media scanner has started scanning a directory.
2865 * The path to the directory being scanned is contained in the Intent.mData field.
2866 */
2867 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2868 public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
2869
2870 /**
2871 * Broadcast Action: The media scanner has finished scanning a directory.
2872 * The path to the scanned directory is contained in the Intent.mData field.
2873 */
2874 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2875 public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
2876
2877 /**
2878 * Broadcast Action: Request the media scanner to scan a file and add it to the media database.
2879 * The path to the file is contained in the Intent.mData field.
2880 */
2881 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2882 public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
2883
2884 /**
2885 * Broadcast Action: The "Media Button" was pressed. Includes a single
2886 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2887 * caused the broadcast.
2888 */
2889 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2890 public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
2891
2892 /**
2893 * Broadcast Action: The "Camera Button" was pressed. Includes a single
2894 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
2895 * caused the broadcast.
2896 */
2897 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2898 public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
2899
2900 // *** NOTE: @todo(*) The following really should go into a more domain-specific
2901 // location; they are not general-purpose actions.
2902
2903 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002904 * Broadcast Action: A GTalk connection has been established.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002905 */
2906 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2907 public static final String ACTION_GTALK_SERVICE_CONNECTED =
2908 "android.intent.action.GTALK_CONNECTED";
2909
2910 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09002911 * Broadcast Action: A GTalk connection has been disconnected.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002912 */
2913 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2914 public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
2915 "android.intent.action.GTALK_DISCONNECTED";
The Android Open Source Project10592532009-03-18 17:39:46 -07002916
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002917 /**
2918 * Broadcast Action: An input method has been changed.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08002919 */
2920 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2921 public static final String ACTION_INPUT_METHOD_CHANGED =
2922 "android.intent.action.INPUT_METHOD_CHANGED";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002923
2924 /**
2925 * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
2926 * more radios have been turned off or on. The intent will have the following extra value:</p>
2927 * <ul>
2928 * <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
2929 * then cell radio and possibly other radios such as bluetooth or WiFi may have also been
2930 * turned off</li>
2931 * </ul>
Tom Taylord4a47292009-12-21 13:59:18 -08002932 *
Peng Xua35b5532016-01-20 00:05:45 -08002933 * <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 -07002934 */
2935 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2936 public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
2937
2938 /**
2939 * Broadcast Action: Some content providers have parts of their namespace
2940 * where they publish new events or items that the user may be especially
2941 * interested in. For these things, they may broadcast this action when the
2942 * set of interesting items change.
2943 *
2944 * For example, GmailProvider sends this notification when the set of unread
2945 * mail in the inbox changes.
2946 *
2947 * <p>The data of the intent identifies which part of which provider
2948 * changed. When queried through the content resolver, the data URI will
2949 * return the data set in question.
2950 *
2951 * <p>The intent will have the following extra values:
2952 * <ul>
2953 * <li><em>count</em> - The number of items in the data set. This is the
2954 * same as the number of items in the cursor returned by querying the
2955 * data URI. </li>
2956 * </ul>
2957 *
2958 * This intent will be sent at boot (if the count is non-zero) and when the
2959 * data set changes. It is possible for the data set to change without the
2960 * count changing (for example, if a new unread message arrives in the same
2961 * sync operation in which a message is archived). The phone should still
2962 * ring/vibrate/etc as normal in this case.
2963 */
2964 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2965 public static final String ACTION_PROVIDER_CHANGED =
2966 "android.intent.action.PROVIDER_CHANGED";
2967
2968 /**
2969 * Broadcast Action: Wired Headset plugged in or unplugged.
2970 *
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002971 * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
2972 * and documentation.
2973 * <p>If the minimum SDK version of your application is
Dianne Hackborn955d8d62014-10-07 20:17:19 -07002974 * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002975 * to the <code>AudioManager</code> constant in your receiver registration code instead.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07002976 */
2977 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jean-Michel Trivic5258432014-08-27 15:46:54 -07002978 public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
Eric Laurent59f48272012-04-05 19:42:21 -07002979
2980 /**
Joe Onorato9cdffa12011-04-06 18:27:27 -07002981 * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
2982 * <ul>
2983 * <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
2984 * </ul>
2985 *
2986 * <p class="note">This is a protected intent that can only be sent
2987 * by the system.
2988 *
2989 * @hide
2990 */
2991 //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2992 public static final String ACTION_ADVANCED_SETTINGS_CHANGED
2993 = "android.intent.action.ADVANCED_SETTINGS";
2994
2995 /**
Robin Lee66e5d962014-04-09 16:44:21 +01002996 * Broadcast Action: Sent after application restrictions are changed.
2997 *
2998 * <p class="note">This is a protected intent that can only be sent
2999 * by the system.</p>
3000 */
3001 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3002 public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3003 "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3004
3005 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003006 * Broadcast Action: An outgoing call is about to be placed.
3007 *
Dirk Dougherty367ce902013-05-28 17:37:12 -07003008 * <p>The Intent will have the following extra value:</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003009 * <ul>
The Android Open Source Project10592532009-03-18 17:39:46 -07003010 * <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003011 * the phone number originally intended to be dialed.</li>
3012 * </ul>
3013 * <p>Once the broadcast is finished, the resultData is used as the actual
3014 * number to call. If <code>null</code>, no call will be placed.</p>
The Android Open Source Project10592532009-03-18 17:39:46 -07003015 * <p>It is perfectly acceptable for multiple receivers to process the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003016 * outgoing call in turn: for example, a parental control application
3017 * might verify that the user is authorized to place the call at that
3018 * time, then a number-rewriting application might add an area code if
3019 * one was not specified.</p>
3020 * <p>For consistency, any receiver whose purpose is to prohibit phone
3021 * calls should have a priority of 0, to ensure it will see the final
3022 * phone number to be dialed.
The Android Open Source Project10592532009-03-18 17:39:46 -07003023 * Any receiver whose purpose is to rewrite phone numbers to be called
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003024 * should have a positive priority.
3025 * Negative priorities are reserved for the system for this broadcast;
3026 * using them may cause problems.</p>
Dirk Dougherty932fbcc2013-05-29 15:19:14 -07003027 * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3028 * abort the broadcast.</p>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003029 * <p>Emergency calls cannot be intercepted using this mechanism, and
3030 * other calls cannot be modified to call emergency numbers using this
3031 * mechanism.
Santos Cordonba701362013-05-17 14:48:54 -07003032 * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3033 * call to use their own service instead. Those apps should first prevent
3034 * the call from being placed by setting resultData to <code>null</code>
3035 * and then start their own app to make the call.
The Android Open Source Project10592532009-03-18 17:39:46 -07003036 * <p>You must hold the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003037 * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3038 * permission to receive this Intent.</p>
Tom Taylord4a47292009-12-21 13:59:18 -08003039 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003040 * <p class="note">This is a protected intent that can only be sent
3041 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003042 */
3043 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3044 public static final String ACTION_NEW_OUTGOING_CALL =
3045 "android.intent.action.NEW_OUTGOING_CALL";
3046
3047 /**
3048 * Broadcast Action: Have the device reboot. This is only for use by
3049 * system code.
Tom Taylord4a47292009-12-21 13:59:18 -08003050 *
Dianne Hackborn854060af2009-07-09 18:14:31 -07003051 * <p class="note">This is a protected intent that can only be sent
3052 * by the system.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07003053 */
3054 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3055 public static final String ACTION_REBOOT =
3056 "android.intent.action.REBOOT";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08003057
Wei Huang97ecc9c2009-05-11 17:44:20 -07003058 /**
Dianne Hackborn7299c412010-03-04 18:41:49 -08003059 * Broadcast Action: A sticky broadcast for changes in the physical
3060 * docking state of the device.
Tobias Haamel154f7a12010-02-17 11:56:39 -08003061 *
3062 * <p>The intent will have the following extra values:
3063 * <ul>
3064 * <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
Dianne Hackborn7299c412010-03-04 18:41:49 -08003065 * state, indicating which dock the device is physically in.</li>
Tobias Haamel154f7a12010-02-17 11:56:39 -08003066 * </ul>
Dianne Hackborn7299c412010-03-04 18:41:49 -08003067 * <p>This is intended for monitoring the current physical dock state.
3068 * See {@link android.app.UiModeManager} for the normal API dealing with
3069 * dock mode changes.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003070 */
3071 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3072 public static final String ACTION_DOCK_EVENT =
3073 "android.intent.action.DOCK_EVENT";
3074
3075 /**
Svetoslavb3038ec2013-02-13 14:39:30 -08003076 * Broadcast Action: A broadcast when idle maintenance can be started.
3077 * This means that the user is not interacting with the device and is
3078 * not expected to do so soon. Typical use of the idle maintenance is
3079 * to perform somehow expensive tasks that can be postponed at a moment
3080 * when they will not degrade user experience.
3081 * <p>
3082 * <p class="note">In order to keep the device responsive in case of an
3083 * unexpected user interaction, implementations of a maintenance task
3084 * should be interruptible. In such a scenario a broadcast with action
3085 * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3086 * should not do the maintenance work in
3087 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3088 * maintenance service by {@link Context#startService(Intent)}. Also
3089 * you should hold a wake lock while your maintenance service is running
3090 * to prevent the device going to sleep.
3091 * </p>
3092 * <p>
3093 * <p class="note">This is a protected intent that can only be sent by
3094 * the system.
3095 * </p>
3096 *
3097 * @see #ACTION_IDLE_MAINTENANCE_END
Svetoslav6a08a122013-05-03 11:24:26 -07003098 *
3099 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003100 */
3101 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3102 public static final String ACTION_IDLE_MAINTENANCE_START =
3103 "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3104
3105 /**
3106 * Broadcast Action: A broadcast when idle maintenance should be stopped.
3107 * This means that the user was not interacting with the device as a result
3108 * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3109 * was sent and now the user started interacting with the device. Typical
3110 * use of the idle maintenance is to perform somehow expensive tasks that
3111 * can be postponed at a moment when they will not degrade user experience.
3112 * <p>
3113 * <p class="note">In order to keep the device responsive in case of an
3114 * unexpected user interaction, implementations of a maintenance task
3115 * should be interruptible. Hence, on receiving a broadcast with this
3116 * action, the maintenance task should be interrupted as soon as possible.
3117 * In other words, you should not do the maintenance work in
3118 * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3119 * maintenance service that was started on receiving of
3120 * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3121 * lock you acquired when your maintenance service started.
3122 * </p>
3123 * <p class="note">This is a protected intent that can only be sent
3124 * by the system.
3125 *
3126 * @see #ACTION_IDLE_MAINTENANCE_START
Svetoslav6a08a122013-05-03 11:24:26 -07003127 *
3128 * @hide
Svetoslavb3038ec2013-02-13 14:39:30 -08003129 */
3130 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3131 public static final String ACTION_IDLE_MAINTENANCE_END =
3132 "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3133
3134 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07003135 * Broadcast Action: a remote intent is to be broadcasted.
3136 *
3137 * A remote intent is used for remote RPC between devices. The remote intent
3138 * is serialized and sent from one device to another device. The receiving
3139 * device parses the remote intent and broadcasts it. Note that anyone can
3140 * broadcast a remote intent. However, if the intent receiver of the remote intent
3141 * does not trust intent broadcasts from arbitrary intent senders, it should require
3142 * the sender to hold certain permissions so only trusted sender's broadcast will be
3143 * let through.
Dianne Hackbornedd93162009-09-19 14:03:05 -07003144 * @hide
Wei Huang97ecc9c2009-05-11 17:44:20 -07003145 */
3146 public static final String ACTION_REMOTE_INTENT =
Costin Manolache8d83f9e2010-05-12 16:04:10 -07003147 "com.google.android.c2dm.intent.RECEIVE";
Wei Huang97ecc9c2009-05-11 17:44:20 -07003148
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003149 /**
Jeff Sharkeybd91e2f2016-03-22 15:32:31 -06003150 * Broadcast Action: This is broadcast once when the user is booting after a
3151 * system update. It can be used to perform cleanup or upgrades after a
3152 * system update.
3153 * <p>
3154 * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3155 * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3156 * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3157 * sent to receivers in the system image.
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003158 *
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003159 * @hide
3160 */
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003161 @SystemApi
Dianne Hackborn9acc0302009-08-25 00:27:12 -07003162 public static final String ACTION_PRE_BOOT_COMPLETED =
3163 "android.intent.action.PRE_BOOT_COMPLETED";
3164
Amith Yamasani13593602012-03-22 16:16:17 -07003165 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003166 * Broadcast to a specific application to query any supported restrictions to impose
Amith Yamasani7e99bc02013-04-16 18:24:51 -07003167 * on restricted users. The broadcast intent contains an extra
3168 * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3169 * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3170 * String[] depending on the restriction type.<p/>
3171 * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
Amith Yamasani86118ba2013-03-28 14:33:16 -07003172 * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3173 * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3174 * The activity specified by that intent will be launched for a result which must contain
Amith Yamasani3b458ad2013-04-18 18:40:07 -07003175 * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3176 * The keys and values of the returned restrictions will be persisted.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08003177 * @see RestrictionEntry
3178 */
3179 public static final String ACTION_GET_RESTRICTION_ENTRIES =
3180 "android.intent.action.GET_RESTRICTION_ENTRIES";
3181
3182 /**
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003183 * Sent the first time a user is starting, to allow system apps to
3184 * perform one time initialization. (This will not be seen by third
3185 * party applications because a newly initialized user does not have any
3186 * third party applications installed for it.) This is sent early in
3187 * starting the user, around the time the home app is started, before
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003188 * {@link #ACTION_BOOT_COMPLETED} is sent. This is sent as a foreground
3189 * broadcast, since it is part of a visible user interaction; be as quick
3190 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003191 */
3192 public static final String ACTION_USER_INITIALIZE =
3193 "android.intent.action.USER_INITIALIZE";
3194
3195 /**
3196 * Sent when a user switch is happening, causing the process's user to be
3197 * brought to the foreground. This is only sent to receivers registered
3198 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3199 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003200 * foreground. This is sent as a foreground
3201 * broadcast, since it is part of a visible user interaction; be as quick
3202 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003203 */
3204 public static final String ACTION_USER_FOREGROUND =
3205 "android.intent.action.USER_FOREGROUND";
3206
3207 /**
3208 * Sent when a user switch is happening, causing the process's user to be
3209 * sent to the background. This is only sent to receivers registered
3210 * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3211 * Context.registerReceiver}. It is sent to the user that is going to the
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003212 * background. This is sent as a foreground
3213 * broadcast, since it is part of a visible user interaction; be as quick
3214 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003215 */
3216 public static final String ACTION_USER_BACKGROUND =
3217 "android.intent.action.USER_BACKGROUND";
3218
3219 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003220 * Broadcast sent to the system when a user is added. Carries an extra
3221 * EXTRA_USER_HANDLE that has the userHandle of the new user. It is sent to
3222 * all running users. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003223 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003224 * @hide
3225 */
3226 public static final String ACTION_USER_ADDED =
3227 "android.intent.action.USER_ADDED";
3228
3229 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003230 * Broadcast sent by the system when a user is started. Carries an extra
3231 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only sent to
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003232 * registered receivers, not manifest receivers. It is sent to the user
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003233 * that has been started. This is sent as a foreground
3234 * broadcast, since it is part of a visible user interaction; be as quick
3235 * as possible when handling it.
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003236 * @hide
3237 */
3238 public static final String ACTION_USER_STARTED =
3239 "android.intent.action.USER_STARTED";
3240
3241 /**
Dianne Hackborn36d337a2012-10-08 14:33:47 -07003242 * Broadcast sent when a user is in the process of starting. Carries an extra
3243 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3244 * sent to registered receivers, not manifest receivers. It is sent to all
3245 * users (including the one that is being started). You must hold
3246 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3247 * this broadcast. This is sent as a background broadcast, since
3248 * its result is not part of the primary UX flow; to safely keep track of
3249 * started/stopped state of a user you can use this in conjunction with
3250 * {@link #ACTION_USER_STOPPING}. It is <b>not</b> generally safe to use with
3251 * other user state broadcasts since those are foreground broadcasts so can
3252 * execute in a different order.
3253 * @hide
3254 */
3255 public static final String ACTION_USER_STARTING =
3256 "android.intent.action.USER_STARTING";
3257
3258 /**
3259 * Broadcast sent when a user is going to be stopped. Carries an extra
3260 * EXTRA_USER_HANDLE that has the userHandle of the user. This is only
3261 * sent to registered receivers, not manifest receivers. It is sent to all
3262 * users (including the one that is being stopped). You must hold
3263 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3264 * this broadcast. The user will not stop until all receivers have
3265 * handled the broadcast. This is sent as a background broadcast, since
3266 * its result is not part of the primary UX flow; to safely keep track of
3267 * started/stopped state of a user you can use this in conjunction with
3268 * {@link #ACTION_USER_STARTING}. It is <b>not</b> generally safe to use with
3269 * other user state broadcasts since those are foreground broadcasts so can
3270 * execute in a different order.
3271 * @hide
3272 */
3273 public static final String ACTION_USER_STOPPING =
3274 "android.intent.action.USER_STOPPING";
3275
3276 /**
3277 * Broadcast sent to the system when a user is stopped. Carries an extra
3278 * EXTRA_USER_HANDLE that has the userHandle of the user. This is similar to
3279 * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3280 * specific package. This is only sent to registered receivers, not manifest
3281 * receivers. It is sent to all running users <em>except</em> the one that
3282 * has just been stopped (which is no longer running).
Dianne Hackborn80a4af22012-08-27 19:18:31 -07003283 * @hide
3284 */
3285 public static final String ACTION_USER_STOPPED =
3286 "android.intent.action.USER_STOPPED";
3287
3288 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003289 * 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 -07003290 * the userHandle of the user. It is sent to all running users except the
Amith Yamasanidb6a14c2012-10-17 21:16:52 -07003291 * one that has been removed. The user will not be completely removed until all receivers have
3292 * handled the broadcast. You must hold
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003293 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003294 * @hide
3295 */
Sudheer Shanka166a81b2017-03-30 15:42:51 -07003296 @SystemApi
Amith Yamasani13593602012-03-22 16:16:17 -07003297 public static final String ACTION_USER_REMOVED =
3298 "android.intent.action.USER_REMOVED";
3299
3300 /**
Amith Yamasani2a003292012-08-14 18:25:45 -07003301 * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
Dianne Hackborn5dc5a002012-09-15 19:33:48 -07003302 * the userHandle of the user to become the current one. This is only sent to
3303 * registered receivers, not manifest receivers. It is sent to all running users.
3304 * You must hold
3305 * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
Amith Yamasani13593602012-03-22 16:16:17 -07003306 * @hide
3307 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01003308 @UnsupportedAppUsage
Amith Yamasani13593602012-03-22 16:16:17 -07003309 public static final String ACTION_USER_SWITCHED =
3310 "android.intent.action.USER_SWITCHED";
3311
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003312 /**
Jeff Sharkey8924e872015-11-30 12:52:10 -07003313 * Broadcast Action: Sent when the credential-encrypted private storage has
3314 * become unlocked for the target user. This is only sent to registered
3315 * receivers, not manifest receivers.
3316 */
3317 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3318 public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3319
3320 /**
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003321 * Broadcast sent to the system when a user's information changes. Carries an extra
3322 * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
Amith Yamasani6fc1d4e2013-05-08 16:43:58 -07003323 * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
Amith Yamasanie928d7d2012-09-17 21:46:51 -07003324 * @hide
3325 */
3326 public static final String ACTION_USER_INFO_CHANGED =
3327 "android.intent.action.USER_INFO_CHANGED";
3328
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003329 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003330 * Broadcast sent to the primary user when an associated managed profile is added (the profile
3331 * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
Adam Connorsd4b584e2014-06-09 13:55:47 +01003332 * the UserHandle of the profile that was added. Only applications (for example Launchers)
3333 * that need to display merged content across both primary and managed profiles need to
3334 * worry about this broadcast. This is only sent to registered receivers,
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003335 * not manifest receivers.
3336 */
3337 public static final String ACTION_MANAGED_PROFILE_ADDED =
3338 "android.intent.action.MANAGED_PROFILE_ADDED";
3339
3340 /**
3341 * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
Adam Connorsd4b584e2014-06-09 13:55:47 +01003342 * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3343 * Only applications (for example Launchers) that need to display merged content across both
3344 * primary and managed profiles need to worry about this broadcast. This is only sent to
3345 * registered receivers, not manifest receivers.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01003346 */
3347 public static final String ACTION_MANAGED_PROFILE_REMOVED =
3348 "android.intent.action.MANAGED_PROFILE_REMOVED";
3349
3350 /**
Kenny Guyb1b30262016-02-09 16:02:35 +00003351 * Broadcast sent to the primary user when the credential-encrypted private storage for
3352 * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3353 * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3354 * Launchers) that need to display merged content across both primary and managed profiles
3355 * need to worry about this broadcast. This is only sent to registered receivers,
3356 * not manifest receivers.
3357 */
3358 public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3359 "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3360
3361 /**
Rubin Xue95057a2016-04-01 16:49:25 +01003362 * Broadcast sent to the primary user when an associated managed profile has become available.
3363 * Currently this includes when the user disables quiet mode for the profile. Carries an extra
Rubin Xuf13c9802016-01-21 18:06:00 +00003364 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3365 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3366 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003367 */
Rubin Xue95057a2016-04-01 16:49:25 +01003368 public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3369 "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3370
3371 /**
3372 * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3373 * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3374 * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3375 * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3376 * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3377 */
3378 public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3379 "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
Rubin Xu0a29ecd2015-11-04 15:11:48 +00003380
3381 /**
Robin Lee92b83c62016-08-31 13:27:51 +01003382 * Broadcast sent to the system user when the 'device locked' state changes for any user.
3383 * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3384 * the device was locked or unlocked.
3385 *
3386 * This is only sent to registered receivers.
3387 *
3388 * @hide
3389 */
3390 public static final String ACTION_DEVICE_LOCKED_CHANGED =
3391 "android.intent.action.DEVICE_LOCKED_CHANGED";
3392
3393 /**
Daniel Sandler2e7d25b2012-10-01 16:43:26 -04003394 * Sent when the user taps on the clock widget in the system's "quick settings" area.
3395 */
3396 public static final String ACTION_QUICK_CLOCK =
3397 "android.intent.action.QUICK_CLOCK";
3398
Michael Wright0087a142013-02-05 16:29:39 -08003399 /**
Alan Viverette5a399492014-07-14 16:19:38 -07003400 * Activity Action: Shows the brightness setting dialog.
Michael Wright0087a142013-02-05 16:29:39 -08003401 * @hide
3402 */
3403 public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
Clara Bayarri847d8682017-03-06 16:48:44 +00003404 "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
Michael Wright0087a142013-02-05 16:29:39 -08003405
Justin Kohd378ad72013-04-01 12:18:26 -07003406 /**
3407 * Broadcast Action: A global button was pressed. Includes a single
3408 * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3409 * caused the broadcast.
3410 * @hide
3411 */
Sujith Ramakrishnan48e19c82017-04-24 15:57:58 -07003412 @SystemApi
Justin Kohd378ad72013-04-01 12:18:26 -07003413 public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3414
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003415 /**
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003416 * Broadcast Action: Sent when media resource is granted.
3417 * <p>
3418 * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3419 * granted.
3420 * </p>
3421 * <p class="note">
3422 * This is a protected intent that can only be sent by the system.
3423 * </p>
3424 * <p class="note">
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08003425 * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09003426 * </p>
3427 *
3428 * @hide
3429 */
3430 public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3431 "android.intent.action.MEDIA_RESOURCE_GRANTED";
3432
3433 /**
MÃ¥rten Kongstadeabc9e92015-12-15 16:40:23 +01003434 * Broadcast Action: An overlay package has changed. The data contains the
3435 * name of the overlay package which has changed. This is broadcast on all
3436 * changes to the OverlayInfo returned by {@link
3437 * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3438 * most common change is a state change that will change whether the
3439 * overlay is enabled or not.
3440 * @hide
3441 */
3442 public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3443
3444 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003445 * Activity Action: Allow the user to select and return one or more existing
3446 * documents. When invoked, the system will display the various
3447 * {@link DocumentsProvider} instances installed on the device, letting the
3448 * user interactively navigate through them. These documents include local
3449 * media, such as photos and video, and documents provided by installed
3450 * cloud storage providers.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003451 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003452 * Each document is represented as a {@code content://} URI backed by a
3453 * {@link DocumentsProvider}, which can be opened as a stream with
3454 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3455 * {@link android.provider.DocumentsContract.Document} metadata.
3456 * <p>
3457 * All selected documents are returned to the calling application with
3458 * persistable read and write permission grants. If you want to maintain
3459 * access to the documents across device reboots, you need to explicitly
3460 * take the persistable permissions using
3461 * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3462 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003463 * Callers must indicate the acceptable document MIME types through
3464 * {@link #setType(String)}. For example, to select photos, use
3465 * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3466 * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3467 * {@literal *}/*.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003468 * <p>
3469 * If the caller can handle multiple returned items (the user performing
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003470 * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3471 * to indicate this.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003472 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003473 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3474 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003475 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003476 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003477 * Callers can set a document URI through
3478 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3479 * location of documents navigator. System will do its best to launch the
3480 * navigator in the specified document if it's a folder, or the folder that
3481 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003482 * <p>
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003483 * Output: The URI of the item that was picked, returned in
3484 * {@link #getData()}. This must be a {@code content://} URI so that any
3485 * receiver can access it. If multiple documents were selected, they are
3486 * returned in {@link #getClipData()}.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003487 *
3488 * @see DocumentsContract
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003489 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003490 * @see #ACTION_CREATE_DOCUMENT
3491 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003492 */
3493 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3494 public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3495
3496 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003497 * Activity Action: Allow the user to create a new document. When invoked,
3498 * the system will display the various {@link DocumentsProvider} instances
3499 * installed on the device, letting the user navigate through them. The
3500 * returned document may be a newly created document with no content, or it
3501 * may be an existing document with the requested MIME type.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003502 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003503 * Each document is represented as a {@code content://} URI backed by a
3504 * {@link DocumentsProvider}, which can be opened as a stream with
3505 * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3506 * {@link android.provider.DocumentsContract.Document} metadata.
3507 * <p>
3508 * Callers must indicate the concrete MIME type of the document being
3509 * created by setting {@link #setType(String)}. This MIME type cannot be
3510 * changed after the document is created.
3511 * <p>
3512 * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3513 * but the user may change this value before creating the file.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003514 * <p>
Tomasz Mikolajewskia8057a92015-11-16 11:41:28 +09003515 * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3516 * URIs that can be opened with
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003517 * {@link ContentResolver#openFileDescriptor(Uri, String)}.
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003518 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003519 * Callers can set a document URI through
3520 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3521 * location of documents navigator. System will do its best to launch the
3522 * navigator in the specified document if it's a folder, or the folder that
3523 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003524 * <p>
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003525 * Output: The URI of the item that was created. This must be a
3526 * {@code content://} URI so that any receiver can access it.
Jeff Sharkeybd3b9022013-08-20 15:20:04 -07003527 *
3528 * @see DocumentsContract
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003529 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003530 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07003531 * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07003532 */
3533 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3534 public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3535
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003536 /**
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003537 * Activity Action: Allow the user to pick a directory subtree. When
3538 * invoked, the system will display the various {@link DocumentsProvider}
3539 * instances installed on the device, letting the user navigate through
3540 * them. Apps can fully manage documents within the returned directory.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003541 * <p>
3542 * To gain access to descendant (child, grandchild, etc) documents, use
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003543 * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3544 * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3545 * with the returned URI.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003546 * <p>
Garfield Tanb44ae612016-11-07 16:46:37 -08003547 * Callers can set a document URI through
3548 * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3549 * location of documents navigator. System will do its best to launch the
3550 * navigator in the specified document if it's a folder, or the folder that
3551 * contains the specified document if not.
Garfield Tan0b3cf662016-10-31 12:59:45 -07003552 * <p>
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003553 * Output: The URI representing the selected directory tree.
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003554 *
3555 * @see DocumentsContract
3556 */
3557 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07003558 public static final String
3559 ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
Jeff Sharkey21de56a2014-04-05 19:05:24 -07003560
Felipe Lemec7b1f892016-01-15 15:02:31 -08003561 /**
Peng Xua35b5532016-01-20 00:05:45 -08003562 * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3563 * exisiting sensor being disconnected.
3564 *
3565 * <p class="note">This is a protected intent that can only be sent by the system.</p>
3566 *
3567 * {@hide}
3568 */
3569 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3570 public static final String
3571 ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3572
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003573 /**
Sam Line707f832017-04-13 17:00:55 -07003574 * Deprecated - use ACTION_FACTORY_RESET instead.
Amith Yamasanie99757e42017-04-14 14:41:45 -07003575 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003576 * @removed
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003577 */
3578 @Deprecated
Amith Yamasanie99757e42017-04-14 14:41:45 -07003579 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07003580 public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3581
Christopher Tate6597e342015-02-17 12:15:25 -08003582 /**
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003583 * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3584 * is about to be performed.
3585 * @hide
3586 */
3587 @SystemApi
3588 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3589 public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3590 = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3591
3592 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003593 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3594 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3595 *
3596 * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3597 *
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003598 * @hide
3599 */
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003600 @Deprecated
Benjamin Franzf9d5e6a2016-05-26 14:24:29 +01003601 public static final String EXTRA_FORCE_MASTER_CLEAR =
3602 "android.intent.extra.FORCE_MASTER_CLEAR";
3603
3604 /**
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003605 * A broadcast action to trigger a factory reset.
3606 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003607 * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3608 * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003609 *
3610 * <p>Not for use by third-party applications.
3611 *
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07003612 * @see #EXTRA_FORCE_FACTORY_RESET
Lenka Trochtova73aeea22016-11-18 17:34:34 +01003613 *
3614 * {@hide}
3615 */
3616 @SystemApi
3617 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3618 public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3619
3620 /**
3621 * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3622 * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3623 *
3624 * <p>Not for use by third-party applications.
3625 *
3626 * @hide
3627 */
3628 @SystemApi
3629 public static final String EXTRA_FORCE_FACTORY_RESET =
3630 "android.intent.extra.FORCE_FACTORY_RESET";
3631
3632 /**
Michal Karpinski6135a262017-08-11 10:45:58 +01003633 * Broadcast action: report that a settings element is being restored from backup. The intent
3634 * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3635 * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3636 * is the value of that settings entry prior to the restore operation, and
3637 * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3638 * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3639 * values are represented as strings, the fourth one as int.
Christopher Tate6597e342015-02-17 12:15:25 -08003640 *
3641 * <p>This broadcast is sent only for settings provider entries known to require special handling
3642 * around restore time. These entries are found in the BROADCAST_ON_RESTORE table within
3643 * the provider's backup agent implementation.
3644 *
3645 * @see #EXTRA_SETTING_NAME
3646 * @see #EXTRA_SETTING_PREVIOUS_VALUE
3647 * @see #EXTRA_SETTING_NEW_VALUE
Michal Karpinski6135a262017-08-11 10:45:58 +01003648 * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
Christopher Tate6597e342015-02-17 12:15:25 -08003649 * {@hide}
3650 */
3651 public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3652
3653 /** {@hide} */
3654 public static final String EXTRA_SETTING_NAME = "setting_name";
3655 /** {@hide} */
3656 public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3657 /** {@hide} */
3658 public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
Michal Karpinski6135a262017-08-11 10:45:58 +01003659 /** {@hide} */
3660 public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
Christopher Tate6597e342015-02-17 12:15:25 -08003661
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003662 /**
3663 * Activity Action: Process a piece of text.
3664 * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3665 * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3666 * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3667 */
3668 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3669 public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003670
3671 /**
3672 * Broadcast Action: The sim card state has changed.
3673 * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3674 * because TelephonyIntents is an internal class.
3675 * @hide
Amit Mahajan052e1e22018-01-12 17:40:29 -08003676 * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3677 * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003678 */
Amit Mahajan052e1e22018-01-12 17:40:29 -08003679 @Deprecated
Amith Yamasanicbabb8d2017-02-17 16:50:05 -08003680 @SystemApi
3681 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3682 public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
3683
Clara Bayarri0a26157a2015-03-26 18:38:55 +00003684 /**
fionaxu90fee272017-03-31 12:45:12 -07003685 * Broadcast Action: indicate that the phone service state has changed.
3686 * The intent will have the following extra values:</p>
3687 * <p>
3688 * @see #EXTRA_VOICE_REG_STATE
3689 * @see #EXTRA_DATA_REG_STATE
3690 * @see #EXTRA_VOICE_ROAMING_TYPE
3691 * @see #EXTRA_DATA_ROAMING_TYPE
3692 * @see #EXTRA_OPERATOR_ALPHA_LONG
3693 * @see #EXTRA_OPERATOR_ALPHA_SHORT
3694 * @see #EXTRA_OPERATOR_NUMERIC
3695 * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
3696 * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
3697 * @see #EXTRA_DATA_OPERATOR_NUMERIC
3698 * @see #EXTRA_MANUAL
3699 * @see #EXTRA_VOICE_RADIO_TECH
3700 * @see #EXTRA_DATA_RADIO_TECH
3701 * @see #EXTRA_CSS_INDICATOR
3702 * @see #EXTRA_NETWORK_ID
3703 * @see #EXTRA_SYSTEM_ID
3704 * @see #EXTRA_CDMA_ROAMING_INDICATOR
3705 * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
3706 * @see #EXTRA_EMERGENCY_ONLY
3707 * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
3708 * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
3709 * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
3710 *
3711 * <p class="note">
3712 * Requires the READ_PHONE_STATE permission.
3713 *
3714 * <p class="note">This is a protected intent that can only be sent by the system.
3715 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003716 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003717 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
3718 * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
3719 * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
3720 * for a given subscription id and field with a ContentObserver or using JobScheduler.
fionaxu90fee272017-03-31 12:45:12 -07003721 */
3722 @Deprecated
3723 @SystemApi
3724 @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
3725 public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
3726
3727 /**
3728 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
3729 * state.
3730 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3731 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3732 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3733 * @see android.telephony.ServiceState#STATE_POWER_OFF
3734 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003735 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003736 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003737 */
3738 @Deprecated
3739 @SystemApi
3740 public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
3741
3742 /**
3743 * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
3744 * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
3745 * @see android.telephony.ServiceState#STATE_IN_SERVICE
3746 * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
3747 * @see android.telephony.ServiceState#STATE_POWER_OFF
3748 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003749 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003750 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
fionaxu90fee272017-03-31 12:45:12 -07003751 */
3752 @Deprecated
3753 @SystemApi
3754 public static final String EXTRA_DATA_REG_STATE = "dataRegState";
3755
3756 /**
3757 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
3758 * type.
3759 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003760 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003761 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003762 */
3763 @Deprecated
3764 @SystemApi
3765 public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
3766
3767 /**
3768 * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
3769 * type.
3770 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003771 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003772 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
fionaxu90fee272017-03-31 12:45:12 -07003773 */
3774 @Deprecated
3775 @SystemApi
3776 public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
3777
3778 /**
3779 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3780 * registered voice operator name in long alphanumeric format.
3781 * {@code null} if the operator name is not known or unregistered.
3782 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003783 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003784 * @deprecated Use
3785 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003786 */
3787 @Deprecated
3788 @SystemApi
3789 public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
3790
3791 /**
3792 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3793 * registered voice operator name in short alphanumeric format.
3794 * {@code null} if the operator name is not known or unregistered.
3795 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003796 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003797 * @deprecated Use
3798 * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003799 */
3800 @Deprecated
3801 @SystemApi
3802 public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
3803
3804 /**
3805 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3806 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
3807 * network.
3808 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003809 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003810 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003811 */
3812 @Deprecated
3813 @SystemApi
3814 public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
3815
3816 /**
3817 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3818 * registered data operator name in long alphanumeric format.
3819 * {@code null} if the operator name is not known or unregistered.
3820 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003821 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003822 * @deprecated Use
3823 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
fionaxu90fee272017-03-31 12:45:12 -07003824 */
3825 @Deprecated
3826 @SystemApi
3827 public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
3828
3829 /**
3830 * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
3831 * registered data operator name in short alphanumeric format.
3832 * {@code null} if the operator name is not known or unregistered.
3833 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003834 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003835 * @deprecated Use
3836 * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
fionaxu90fee272017-03-31 12:45:12 -07003837 */
3838 @Deprecated
3839 @SystemApi
3840 public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
3841
3842 /**
3843 * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
3844 * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
3845 * data operator.
3846 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003847 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003848 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
fionaxu90fee272017-03-31 12:45:12 -07003849 */
3850 @Deprecated
3851 @SystemApi
3852 public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
3853
3854 /**
3855 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
3856 * network selection mode is manual.
3857 * Will be {@code true} if manual mode, {@code false} if automatic mode.
3858 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003859 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003860 * @deprecated Use
3861 * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
fionaxu90fee272017-03-31 12:45:12 -07003862 */
3863 @Deprecated
3864 @SystemApi
3865 public static final String EXTRA_MANUAL = "manual";
3866
3867 /**
3868 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
3869 * radio technology.
3870 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003871 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003872 * @deprecated Use
3873 * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003874 */
3875 @Deprecated
3876 @SystemApi
3877 public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
3878
3879 /**
3880 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
3881 * radio technology.
3882 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003883 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003884 * @deprecated Use
3885 * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
fionaxu90fee272017-03-31 12:45:12 -07003886 */
3887 @Deprecated
3888 @SystemApi
3889 public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
3890
3891 /**
3892 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
3893 * support on CDMA network.
3894 * Will be {@code true} if support, {@code false} otherwise.
3895 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003896 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003897 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003898 */
3899 @Deprecated
3900 @SystemApi
3901 public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
3902
3903 /**
3904 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
3905 * id. {@code Integer.MAX_VALUE} if unknown.
3906 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003907 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003908 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003909 */
3910 @Deprecated
3911 @SystemApi
3912 public static final String EXTRA_NETWORK_ID = "networkId";
3913
3914 /**
3915 * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
3916 * {@code Integer.MAX_VALUE} if unknown.
3917 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003918 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003919 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
fionaxu90fee272017-03-31 12:45:12 -07003920 */
3921 @Deprecated
3922 @SystemApi
3923 public static final String EXTRA_SYSTEM_ID = "systemId";
3924
3925 /**
3926 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
3927 * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
3928 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003929 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003930 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003931 */
3932 @Deprecated
3933 @SystemApi
3934 public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
3935
3936 /**
3937 * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
3938 * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
3939 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003940 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003941 * @deprecated Use
3942 * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
fionaxu90fee272017-03-31 12:45:12 -07003943 */
3944 @Deprecated
3945 @SystemApi
3946 public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
3947
3948 /**
3949 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
3950 * only mode.
3951 * {@code true} if in emergency only mode, {@code false} otherwise.
3952 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003953 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003954 * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
fionaxu90fee272017-03-31 12:45:12 -07003955 */
3956 @Deprecated
3957 @SystemApi
3958 public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
3959
3960 /**
3961 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
3962 * registration state is roaming.
3963 * {@code true} if registration indicates roaming, {@code false} otherwise
3964 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003965 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003966 * @deprecated Use
3967 * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
fionaxu90fee272017-03-31 12:45:12 -07003968 */
3969 @Deprecated
3970 @SystemApi
3971 public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
3972 "isDataRoamingFromRegistration";
3973
3974 /**
3975 * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
3976 * aggregation is in use.
3977 * {@code true} if carrier aggregation is in use, {@code false} otherwise.
3978 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003979 * @removed
Jordan Liu479904522018-04-17 14:43:39 -07003980 * @deprecated Use
3981 * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
fionaxu90fee272017-03-31 12:45:12 -07003982 */
3983 @Deprecated
3984 @SystemApi
3985 public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
3986
3987 /**
3988 * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
3989 * is reduced from the rsrp threshold while calculating signal strength level.
3990 * @hide
Jeff Sharkey84789112017-08-11 14:45:43 -06003991 * @removed
fionaxu90fee272017-03-31 12:45:12 -07003992 */
3993 @Deprecated
3994 @SystemApi
3995 public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
3996
3997 /**
chen xu02811692018-10-03 19:07:09 -07003998 * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
3999 * @hide
4000 */
4001 public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4002
4003 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004004 * The name of the extra used to define the text to be processed, as a
4005 * CharSequence. Note that this may be a styled CharSequence, so you must use
4006 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
Clara Bayarri0a26157a2015-03-26 18:38:55 +00004007 */
4008 public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4009 /**
Clara Bayarri92c8e6f2015-05-21 17:50:08 +01004010 * 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 +00004011 */
4012 public static final String EXTRA_PROCESS_TEXT_READONLY =
4013 "android.intent.extra.PROCESS_TEXT_READONLY";
4014
Bryce Leebc58f592015-09-25 16:43:01 -07004015 /**
4016 * Broadcast action: reports when a new thermal event has been reached. When the device
4017 * is reaching its maximum temperatue, the thermal level reported
4018 * {@hide}
4019 */
4020 @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4021 public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4022
4023 /** {@hide} */
4024 public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4025
4026 /**
4027 * Thermal state when the device is normal. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004028 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004029 * {@hide}
4030 */
4031 public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4032
4033 /**
4034 * Thermal state where the device is approaching its maximum threshold. This state is sent in
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004035 * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004036 * {@hide}
4037 */
4038 public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4039
4040 /**
4041 * Thermal state where the device has reached its maximum threshold. This state is sent in the
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08004042 * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
Bryce Leebc58f592015-09-25 16:43:01 -07004043 * {@hide}
4044 */
4045 public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4046
lpeter318abc92018-05-04 16:13:14 +08004047 /**
4048 * Broadcast Action: Indicates the dock in idle state while device is docked.
4049 *
4050 * <p class="note">This is a protected intent that can only be sent
4051 * by the system.
4052 *
4053 * @hide
4054 */
4055 public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4056
4057 /**
4058 * Broadcast Action: Indicates the dock in active state while device is docked.
4059 *
4060 * <p class="note">This is a protected intent that can only be sent
4061 * by the system.
4062 *
4063 * @hide
4064 */
4065 public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4066
Bryce Leebc58f592015-09-25 16:43:01 -07004067
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004068 // ---------------------------------------------------------------------
4069 // ---------------------------------------------------------------------
4070 // Standard intent categories (see addCategory()).
4071
4072 /**
4073 * Set if the activity should be an option for the default action
4074 * (center press) to perform on a piece of data. Setting this will
4075 * hide from the user any activities without it set when performing an
John Spurlock6098c5d2013-06-17 10:32:46 -04004076 * action on some data. Note that this is normally -not- set in the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004077 * Intent when initiating an action -- it is for use in intent filters
4078 * specified in packages.
4079 */
4080 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4081 public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4082 /**
4083 * Activities that can be safely invoked from a browser must support this
4084 * category. For example, if the user is viewing a web page or an e-mail
4085 * and clicks on a link in the text, the Intent generated execute that
4086 * link will require the BROWSABLE category, so that only activities
4087 * supporting this category will be considered as possible actions. By
4088 * supporting this category, you are promising that there is nothing
4089 * damaging (without user intervention) that can happen by invoking any
4090 * matching Intent.
4091 */
4092 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4093 public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4094 /**
Dianne Hackborn91097de2014-04-04 18:02:06 -07004095 * Categories for activities that can participate in voice interaction.
4096 * An activity that supports this category must be prepared to run with
4097 * no UI shown at all (though in some case it may have a UI shown), and
4098 * rely on {@link android.app.VoiceInteractor} to interact with the user.
4099 */
4100 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4101 public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4102 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004103 * Set if the activity should be considered as an alternative action to
4104 * the data the user is currently viewing. See also
4105 * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4106 * applies to the selection in a list of items.
4107 *
4108 * <p>Supporting this category means that you would like your activity to be
4109 * displayed in the set of alternative things the user can do, usually as
4110 * part of the current activity's options menu. You will usually want to
4111 * include a specific label in the &lt;intent-filter&gt; of this action
4112 * describing to the user what it does.
4113 *
4114 * <p>The action of IntentFilter with this category is important in that it
4115 * describes the specific action the target will perform. This generally
4116 * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4117 * a specific name such as "com.android.camera.action.CROP. Only one
4118 * alternative of any particular action will be shown to the user, so using
4119 * a specific action like this makes sure that your alternative will be
4120 * displayed while also allowing other applications to provide their own
4121 * overrides of that particular action.
4122 */
4123 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4124 public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4125 /**
4126 * Set if the activity should be considered as an alternative selection
4127 * action to the data the user has currently selected. This is like
4128 * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4129 * of items from which the user can select, giving them alternatives to the
4130 * default action that will be performed on it.
4131 */
4132 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4133 public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4134 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004135 * Intended to be used as a tab inside of a containing TabActivity.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004136 */
4137 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4138 public static final String CATEGORY_TAB = "android.intent.category.TAB";
4139 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004140 * Should be displayed in the top-level launcher.
4141 */
4142 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4143 public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4144 /**
Jose Lima38b75b62014-03-11 10:41:39 -07004145 * Indicates an activity optimized for Leanback mode, and that should
4146 * be displayed in the Leanback launcher.
4147 */
4148 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4149 public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4150 /**
Roberto Perez7ee1a7a2017-12-04 17:14:33 -08004151 * Indicates the preferred entry-point activity when an application is launched from a Car
4152 * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4153 * fallback, or exclude the application entirely.
4154 * @hide
4155 */
4156 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4157 public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4158 /**
Jose Lima73915cf2014-07-29 17:16:31 -07004159 * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4160 * @hide
4161 */
4162 @SystemApi
4163 public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4164 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004165 * Provides information about the package it is in; typically used if
4166 * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4167 * a front-door to the user without having to be shown in the all apps list.
4168 */
4169 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4170 public static final String CATEGORY_INFO = "android.intent.category.INFO";
4171 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004172 * This is the home activity, that is the first activity that is displayed
4173 * when the device boots.
4174 */
4175 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4176 public static final String CATEGORY_HOME = "android.intent.category.HOME";
4177 /**
Anthony Hugh979b81a2015-09-29 16:50:35 -07004178 * This is the home activity that is displayed when the device is finished setting up and ready
4179 * for use.
4180 * @hide
4181 */
4182 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4183 public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4184 /**
Svet Ganov50a8bf42015-07-15 11:04:18 -07004185 * This is the setup wizard activity, that is the first activity that is displayed
4186 * when the user sets up the device for the first time.
4187 * @hide
4188 */
4189 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4190 public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4191 /**
Svet Ganov5bb6bc62017-08-28 12:39:35 -07004192 * This is the home activity, that is the activity that serves as the launcher app
4193 * from there the user can start other apps. Often components with lower/higher
4194 * priority intent filters handle the home intent, for example SetupWizard, to
4195 * setup the device and we need to be able to distinguish the home app from these
4196 * setup helpers.
4197 * @hide
4198 */
4199 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4200 public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4201 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004202 * This activity is a preference panel.
4203 */
4204 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4205 public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4206 /**
4207 * This activity is a development preference panel.
4208 */
4209 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4210 public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4211 /**
4212 * Capable of running inside a parent activity container.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004213 */
4214 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4215 public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4216 /**
Patrick Dubroy6dabe242010-08-30 10:43:47 -07004217 * This activity allows the user to browse and download new applications.
4218 */
4219 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4220 public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4221 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004222 * This activity may be exercised by the monkey or other automated test tools.
4223 */
4224 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4225 public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4226 /**
4227 * To be used as a test (not part of the normal user experience).
4228 */
4229 public static final String CATEGORY_TEST = "android.intent.category.TEST";
4230 /**
4231 * To be used as a unit test (run through the Test Harness).
4232 */
4233 public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4234 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004235 * To be used as a sample code example (not part of the normal user
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004236 * experience).
4237 */
4238 public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004240 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07004241 * Used to indicate that an intent only wants URIs that can be opened with
4242 * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4243 * must support at least the columns defined in {@link OpenableColumns} when
4244 * queried.
4245 *
4246 * @see #ACTION_GET_CONTENT
4247 * @see #ACTION_OPEN_DOCUMENT
4248 * @see #ACTION_CREATE_DOCUMENT
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004249 */
4250 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4251 public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4252
4253 /**
Tomasz Mikolajewski28a815c2016-10-28 15:54:11 +09004254 * Used to indicate that an intent filter can accept files which are not necessarily
4255 * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4256 * at least streamable via
4257 * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4258 * using one of the stream types exposed via
4259 * {@link ContentResolver#getStreamTypes(Uri, String)}.
4260 *
4261 * @see #ACTION_SEND
4262 * @see #ACTION_SEND_MULTIPLE
4263 */
4264 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4265 public static final String CATEGORY_TYPED_OPENABLE =
4266 "android.intent.category.TYPED_OPENABLE";
4267
4268 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004269 * To be used as code under test for framework instrumentation tests.
4270 */
4271 public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4272 "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
Mike Lockwood9092ab42009-09-16 13:01:32 -04004273 /**
4274 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004275 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4276 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004277 */
4278 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4279 public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4280 /**
4281 * An activity to run when device is inserted into a car dock.
Dianne Hackborn7299c412010-03-04 18:41:49 -08004282 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4283 * information, see {@link android.app.UiModeManager}.
Mike Lockwood9092ab42009-09-16 13:01:32 -04004284 */
4285 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4286 public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004287 /**
4288 * An activity to run when device is inserted into a analog (low end) dock.
4289 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4290 * information, see {@link android.app.UiModeManager}.
4291 */
4292 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4293 public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4294
4295 /**
4296 * An activity to run when device is inserted into a digital (high end) dock.
4297 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4298 * information, see {@link android.app.UiModeManager}.
4299 */
4300 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4301 public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004302
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004303 /**
4304 * Used to indicate that the activity can be used in a car environment.
4305 */
4306 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4307 public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4308
Zak Cohendb6ca492017-01-26 14:09:00 -08004309 /**
4310 * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4311 * Used with {@link #ACTION_MAIN} to launch an activity. For more
4312 * information, see {@link android.app.UiModeManager}.
4313 */
4314 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4315 public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004316 // ---------------------------------------------------------------------
4317 // ---------------------------------------------------------------------
Jeff Brown6651a632011-11-28 12:59:11 -08004318 // Application launch intent categories (see addCategory()).
4319
4320 /**
4321 * Used with {@link #ACTION_MAIN} to launch the browser application.
4322 * The activity should be able to browse the Internet.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004323 * <p>NOTE: This should not be used as the primary key of an Intent,
4324 * since it will not result in the app launching with the correct
4325 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004326 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004327 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004328 */
4329 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4330 public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4331
4332 /**
4333 * Used with {@link #ACTION_MAIN} to launch the calculator application.
4334 * The activity should be able to perform standard arithmetic operations.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004335 * <p>NOTE: This should not be used as the primary key of an Intent,
4336 * since it will not result in the app launching with the correct
4337 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004338 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004339 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004340 */
4341 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4342 public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4343
4344 /**
4345 * Used with {@link #ACTION_MAIN} to launch the calendar application.
4346 * The activity should be able to view and manipulate calendar entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004347 * <p>NOTE: This should not be used as the primary key of an Intent,
4348 * since it will not result in the app launching with the correct
4349 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004350 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004351 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004352 */
4353 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4354 public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4355
4356 /**
4357 * Used with {@link #ACTION_MAIN} to launch the contacts application.
4358 * The activity should be able to view and manipulate address book entries.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004359 * <p>NOTE: This should not be used as the primary key of an Intent,
4360 * since it will not result in the app launching with the correct
4361 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004362 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004363 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004364 */
4365 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4366 public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4367
4368 /**
4369 * Used with {@link #ACTION_MAIN} to launch the email application.
4370 * The activity should be able to send and receive email.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004371 * <p>NOTE: This should not be used as the primary key of an Intent,
4372 * since it will not result in the app launching with the correct
4373 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004374 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004375 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004376 */
4377 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4378 public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4379
4380 /**
4381 * Used with {@link #ACTION_MAIN} to launch the gallery application.
4382 * The activity should be able to view and manipulate image and video files
4383 * stored on the device.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004384 * <p>NOTE: This should not be used as the primary key of an Intent,
4385 * since it will not result in the app launching with the correct
4386 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004387 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004388 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004389 */
4390 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4391 public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4392
4393 /**
4394 * Used with {@link #ACTION_MAIN} to launch the maps application.
4395 * The activity should be able to show the user's current location and surroundings.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004396 * <p>NOTE: This should not be used as the primary key of an Intent,
4397 * since it will not result in the app launching with the correct
4398 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004399 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004400 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004401 */
4402 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4403 public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4404
4405 /**
4406 * Used with {@link #ACTION_MAIN} to launch the messaging application.
4407 * The activity should be able to send and receive text messages.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004408 * <p>NOTE: This should not be used as the primary key of an Intent,
4409 * since it will not result in the app launching with the correct
4410 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004411 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004412 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004413 */
4414 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4415 public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4416
4417 /**
4418 * Used with {@link #ACTION_MAIN} to launch the music application.
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004419 * The activity should be able to play, browse, or manipulate music files
4420 * stored on the device.
4421 * <p>NOTE: This should not be used as the primary key of an Intent,
4422 * since it will not result in the app launching with the correct
4423 * action and category. Instead, use this with
Dianne Hackborn251fe262011-12-14 17:20:54 -08004424 * {@link #makeMainSelectorActivity(String, String)} to generate a main
Dianne Hackbornf5b86712011-12-05 17:42:41 -08004425 * Intent with this category in the selector.</p>
Jeff Brown6651a632011-11-28 12:59:11 -08004426 */
4427 @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4428 public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4429
4430 // ---------------------------------------------------------------------
4431 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004432 // Standard extra data keys.
4433
4434 /**
4435 * The initial data to place in a newly created record. Use with
4436 * {@link #ACTION_INSERT}. The data here is a Map containing the same
4437 * fields as would be given to the underlying ContentProvider.insert()
4438 * call.
4439 */
4440 public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4441
4442 /**
4443 * A constant CharSequence that is associated with the Intent, used with
4444 * {@link #ACTION_SEND} to supply the literal data to be sent. Note that
4445 * this may be a styled CharSequence, so you must use
4446 * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4447 * retrieve it.
4448 */
4449 public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4450
4451 /**
Dianne Hackbornacb69bb2012-04-13 15:36:06 -07004452 * A constant String that is associated with the Intent, used with
4453 * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4454 * as HTML formatted text. Note that you <em>must</em> also supply
4455 * {@link #EXTRA_TEXT}.
4456 */
4457 public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4458
4459 /**
Jeff Sharkey81aebe72017-04-03 20:14:10 +00004460 * A content: URI holding a stream of data associated with the Intent,
4461 * used with {@link #ACTION_SEND} to supply the data being sent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004462 */
4463 public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4464
4465 /**
4466 * A String[] holding e-mail addresses that should be delivered to.
4467 */
4468 public static final String EXTRA_EMAIL = "android.intent.extra.EMAIL";
4469
4470 /**
4471 * A String[] holding e-mail addresses that should be carbon copied.
4472 */
4473 public static final String EXTRA_CC = "android.intent.extra.CC";
4474
4475 /**
4476 * A String[] holding e-mail addresses that should be blind carbon copied.
4477 */
4478 public static final String EXTRA_BCC = "android.intent.extra.BCC";
4479
4480 /**
4481 * A constant string holding the desired subject line of a message.
4482 */
4483 public static final String EXTRA_SUBJECT = "android.intent.extra.SUBJECT";
4484
4485 /**
4486 * An Intent describing the choices you would like shown with
Adam Powell2ed547e2015-04-29 18:45:04 -07004487 * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004488 */
4489 public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4490
4491 /**
Clara Bayarrif7fea162015-10-22 16:09:52 +01004492 * An int representing the user id to be used.
4493 *
4494 * @hide
4495 */
4496 public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4497
4498 /**
Clara Bayarriea9b10e2015-12-04 15:36:26 +00004499 * An int representing the task id to be retrieved. This is used when a launch from recents is
4500 * intercepted by another action such as credentials confirmation to remember which task should
4501 * be resumed when complete.
4502 *
4503 * @hide
4504 */
4505 public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4506
4507 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004508 * An Intent[] describing additional, alternate choices you would like shown with
4509 * {@link #ACTION_CHOOSER}.
4510 *
4511 * <p>An app may be capable of providing several different payload types to complete a
4512 * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4513 * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4514 * several different supported sending mechanisms for sharing, such as the actual "image/*"
4515 * photo data or a hosted link where the photos can be viewed.</p>
4516 *
4517 * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4518 * first/primary/preferred intent in the set. Additional intents specified in
4519 * this extra are ordered; by default intents that appear earlier in the array will be
4520 * preferred over intents that appear later in the array as matches for the same
4521 * target component. To alter this preference, a calling app may also supply
4522 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4523 */
4524 public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4525
4526 /**
Adam Powell52c39212016-04-07 15:14:18 -07004527 * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4528 * and omitted from a list of components presented to the user.
4529 *
4530 * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4531 * in this array if it otherwise would have shown them. Useful for omitting specific targets
4532 * from your own package or other apps from your organization if the idea of sending to those
4533 * targets would be redundant with other app functionality. Filtered components will not
4534 * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4535 */
4536 public static final String EXTRA_EXCLUDE_COMPONENTS
4537 = "android.intent.extra.EXCLUDE_COMPONENTS";
4538
4539 /**
4540 * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4541 * describing additional high-priority deep-link targets for the chooser to present to the user.
4542 *
4543 * <p>Targets provided in this way will be presented inline with all other targets provided
4544 * by services from other apps. They will be prioritized before other service targets, but
4545 * after those targets provided by sources that the user has manually pinned to the front.</p>
4546 *
4547 * @see #ACTION_CHOOSER
4548 */
4549 public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4550
4551 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004552 * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4553 * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4554 *
4555 * <p>An app preparing an action for another app to complete may wish to allow the user to
4556 * disambiguate between several options for completing the action based on the chosen target
4557 * or otherwise refine the action before it is invoked.
4558 * </p>
4559 *
4560 * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4561 * <ul>
4562 * <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4563 * <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4564 * chosen target beyond the first</li>
4565 * <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4566 * should fill in and send once the disambiguation is complete</li>
4567 * </ul>
4568 */
4569 public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4570 = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4571
4572 /**
Kang Li9fa2a2c2017-01-06 13:33:24 -08004573 * An {@code ArrayList} of {@code String} annotations describing content for
4574 * {@link #ACTION_CHOOSER}.
4575 *
4576 * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4577 * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4578 *
4579 * <p>Annotations should describe the major components or topics of the content. It is up to
4580 * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4581 * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
Kang Li2f85e8a2017-04-26 09:19:54 -07004582 * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4583 * character. Performance on customized annotations can suffer, if they are rarely used for
4584 * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4585 * following annotations when applicable.</p>
Kang Li9fa2a2c2017-01-06 13:33:24 -08004586 * <ul>
Kang Lifadc0162017-04-19 11:56:05 -07004587 * <li>"product" represents that the topic of the content is mainly about products, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004588 * health & beauty, and office supplies.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004589 * <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004590 * happy, and sad.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004591 * <li>"person" represents that the topic of the content is mainly about persons, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004592 * face, finger, standing, and walking.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004593 * <li>"child" represents that the topic of the content is mainly about children, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004594 * child, and baby.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004595 * <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4596 * <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4597 * <li>"party" represents that the topic of the content is mainly about parties.</li>
4598 * <li>"animal" represent that the topic of the content is mainly about animals.</li>
4599 * <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004600 * flowers.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004601 * <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4602 * <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004603 * sunglasses, jewelry, handbags and clothing.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004604 * <li>"material" represents that the topic of the content is mainly about materials, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004605 * paper, and silk.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004606 * <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
Kang Li9fa2a2c2017-01-06 13:33:24 -08004607 * cars, and boats.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004608 * <li>"document" represents that the topic of the content is mainly about documents, e.g.
Kang Li9fa2a2c2017-01-06 13:33:24 -08004609 * posters.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004610 * <li>"design" represents that the topic of the content is mainly about design, e.g. arts
Kang Li9fa2a2c2017-01-06 13:33:24 -08004611 * and designs of houses.</li>
Kang Lifadc0162017-04-19 11:56:05 -07004612 * <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
Kang Li9fa2a2c2017-01-06 13:33:24 -08004613 * Christmas and Thanksgiving.</li>
4614 * </ul>
4615 */
4616 public static final String EXTRA_CONTENT_ANNOTATIONS
4617 = "android.intent.extra.CONTENT_ANNOTATIONS";
4618
4619 /**
Adam Powell2ed547e2015-04-29 18:45:04 -07004620 * A {@link ResultReceiver} used to return data back to the sender.
4621 *
4622 * <p>Used to complete an app-specific
4623 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4624 *
4625 * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4626 * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4627 * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4628 * when the user selects a target component from the chooser. It is up to the recipient
4629 * to send a result to this ResultReceiver to signal that disambiguation is complete
4630 * and that the chooser should invoke the user's choice.</p>
4631 *
4632 * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4633 * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4634 * to match and fill in the final Intent or ChooserTarget before starting it.
4635 * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4636 * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4637 * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4638 *
4639 * <p>The result code passed to the ResultReceiver should be
4640 * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
4641 * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
4642 * the chooser should finish without starting a target.</p>
4643 */
4644 public static final String EXTRA_RESULT_RECEIVER
4645 = "android.intent.extra.RESULT_RECEIVER";
4646
4647 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004648 * A CharSequence dialog title to provide to the user when used with a
Jim Miller4d64746d2014-08-13 21:08:41 +00004649 * {@link #ACTION_CHOOSER}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004650 */
4651 public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
4652
4653 /**
Dianne Hackborneb034652009-09-07 00:49:58 -07004654 * A Parcelable[] of {@link Intent} or
4655 * {@link android.content.pm.LabeledIntent} objects as set with
4656 * {@link #putExtra(String, Parcelable[])} of additional activities to place
4657 * a the front of the list of choices, when shown to the user with a
4658 * {@link #ACTION_CHOOSER}.
4659 */
4660 public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
4661
4662 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004663 * A {@link IntentSender} to start after instant app installation success.
Todd Kennedy7440f172015-12-09 14:31:22 -08004664 * @hide
4665 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004666 @SystemApi
4667 public static final String EXTRA_INSTANT_APP_SUCCESS =
4668 "android.intent.extra.INSTANT_APP_SUCCESS";
4669
4670 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004671 * A {@link IntentSender} to start after instant app installation failure.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004672 * @hide
4673 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004674 @SystemApi
4675 public static final String EXTRA_INSTANT_APP_FAILURE =
4676 "android.intent.extra.INSTANT_APP_FAILURE";
4677
4678 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004679 * The host name that triggered an instant app resolution.
Todd Kennedy01ad0c72016-11-11 15:33:12 -08004680 * @hide
4681 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004682 @SystemApi
4683 public static final String EXTRA_INSTANT_APP_HOSTNAME =
4684 "android.intent.extra.INSTANT_APP_HOSTNAME";
4685
4686 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004687 * An opaque token to track instant app resolution.
4688 * @hide
4689 */
4690 @SystemApi
4691 public static final String EXTRA_INSTANT_APP_TOKEN =
4692 "android.intent.extra.INSTANT_APP_TOKEN";
4693
4694 /**
Patrick Baumannb4165d72017-12-04 11:29:24 -08004695 * The action that triggered an instant application resolution.
4696 * @hide
4697 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004698 @SystemApi
Patrick Baumannb4165d72017-12-04 11:29:24 -08004699 public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
4700
4701 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004702 * An array of {@link Bundle}s containing details about resolved instant apps..
4703 * @hide
4704 */
4705 @SystemApi
4706 public static final String EXTRA_INSTANT_APP_BUNDLES =
4707 "android.intent.extra.INSTANT_APP_BUNDLES";
4708
4709 /**
4710 * A {@link Bundle} of metadata that describes the instant application that needs to be
Patrick Baumann709ee152017-12-04 16:12:52 -08004711 * installed. This data is populated from the response to
4712 * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
4713 * instant application resolver.
4714 * @hide
4715 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004716 @SystemApi
Patrick Baumann709ee152017-12-04 16:12:52 -08004717 public static final String EXTRA_INSTANT_APP_EXTRAS =
4718 "android.intent.extra.INSTANT_APP_EXTRAS";
4719
4720 /**
Patrick Baumann577d4022018-01-31 16:55:10 +00004721 * A boolean value indicating that the instant app resolver was unable to state with certainty
4722 * that it did or did not have an app for the sanitized {@link Intent} defined at
4723 * {@link #EXTRA_INTENT}.
4724 * @hide
4725 */
4726 @SystemApi
4727 public static final String EXTRA_UNKNOWN_INSTANT_APP =
4728 "android.intent.extra.UNKNOWN_INSTANT_APP";
4729
4730 /**
Todd Kennedy316c2f22017-01-23 15:40:07 -08004731 * The version code of the app to install components from.
Dianne Hackborn3accca02013-09-20 09:32:11 -07004732 * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
Todd Kennedy316c2f22017-01-23 15:40:07 -08004733 * @hide
4734 */
Dianne Hackborn3accca02013-09-20 09:32:11 -07004735 @Deprecated
Todd Kennedy316c2f22017-01-23 15:40:07 -08004736 public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
4737
4738 /**
Dianne Hackborn3accca02013-09-20 09:32:11 -07004739 * The version code of the app to install components from.
4740 * @hide
4741 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004742 @SystemApi
Dianne Hackborn3accca02013-09-20 09:32:11 -07004743 public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
4744
4745 /**
Patrick Baumann159cd022018-01-11 13:25:05 -08004746 * The app that triggered the instant app installation.
Chad Brubaker06068612017-04-06 09:43:47 -07004747 * @hide
4748 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004749 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004750 public static final String EXTRA_CALLING_PACKAGE
4751 = "android.intent.extra.CALLING_PACKAGE";
4752
4753 /**
4754 * Optional calling app provided bundle containing additional launch information the
4755 * installer may use.
4756 * @hide
4757 */
Patrick Baumann159cd022018-01-11 13:25:05 -08004758 @SystemApi
Chad Brubaker06068612017-04-06 09:43:47 -07004759 public static final String EXTRA_VERIFICATION_BUNDLE
4760 = "android.intent.extra.VERIFICATION_BUNDLE";
4761
4762 /**
Adam Powelle49d9392014-07-17 18:45:19 -07004763 * A Bundle forming a mapping of potential target package names to different extras Bundles
4764 * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
4765 * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
4766 * be currently installed on the device.
4767 *
4768 * <p>An application may choose to provide alternate extras for the case where a user
4769 * selects an activity from a predetermined set of target packages. If the activity
4770 * the user selects from the chooser belongs to a package with its package name as
4771 * a key in this bundle, the corresponding extras for that package will be merged with
4772 * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
4773 * extra has the same key as an extra already present in the intent it will overwrite
4774 * the extra from the intent.</p>
4775 *
4776 * <p><em>Examples:</em>
4777 * <ul>
4778 * <li>An application may offer different {@link #EXTRA_TEXT} to an application
4779 * when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
4780 * parameters for that target.</li>
4781 * <li>An application may offer additional metadata for known targets of a given intent
4782 * to pass along information only relevant to that target such as account or content
4783 * identifiers already known to that application.</li>
4784 * </ul></p>
4785 */
4786 public static final String EXTRA_REPLACEMENT_EXTRAS =
4787 "android.intent.extra.REPLACEMENT_EXTRAS";
4788
4789 /**
Adam Powell0b3c1122014-10-09 12:50:14 -07004790 * An {@link IntentSender} that will be notified if a user successfully chooses a target
4791 * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
4792 * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
4793 * {@link ComponentName} of the chosen component.
4794 *
4795 * <p>In some situations this callback may never come, for example if the user abandons
4796 * the chooser, switches to another task or any number of other reasons. Apps should not
4797 * be written assuming that this callback will always occur.</p>
4798 */
4799 public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
4800 "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
4801
4802 /**
4803 * The {@link ComponentName} chosen by the user to complete an action.
4804 *
4805 * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
4806 */
4807 public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
4808
4809 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004810 * A {@link android.view.KeyEvent} object containing the event that
4811 * triggered the creation of the Intent it is in.
4812 */
4813 public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
4814
4815 /**
Mike Lockwoodbad80e02009-07-30 01:21:08 -07004816 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
4817 * before shutting down.
4818 *
4819 * {@hide}
4820 */
4821 public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
4822
4823 /**
Yusuke Sato705ffd12015-07-21 15:52:11 -07004824 * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
4825 * requested by the user.
4826 *
4827 * {@hide}
4828 */
4829 public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
4830 "android.intent.extra.USER_REQUESTED_SHUTDOWN";
4831
4832 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09004833 * 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 -07004834 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
4835 * of restarting the application.
4836 */
4837 public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
4838
4839 /**
4840 * A String holding the phone number originally entered in
4841 * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
4842 * number to call in a {@link android.content.Intent#ACTION_CALL}.
4843 */
4844 public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
Bernd Holzheyaea4b672010-03-31 09:46:13 +02004845
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004846 /**
4847 * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
4848 * intents to supply the uid the package had been assigned. Also an optional
4849 * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
4850 * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
4851 * purpose.
4852 */
4853 public static final String EXTRA_UID = "android.intent.extra.UID";
4854
4855 /**
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004856 * @hide String array of package names.
4857 */
Soonil Nagarkar0e8fd092015-02-10 10:37:36 -08004858 @SystemApi
Dianne Hackborn21f1bd12010-02-19 17:02:21 -08004859 public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
4860
4861 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004862 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4863 * intents to indicate whether this represents a full uninstall (removing
4864 * both the code and its data) or a partial uninstall (leaving its data,
4865 * implying that this is an update).
4866 */
4867 public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
The Android Open Source Project10592532009-03-18 17:39:46 -07004868
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004869 /**
Dianne Hackbornc72fc672012-09-20 13:12:03 -07004870 * @hide
4871 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4872 * intents to indicate that at this point the package has been removed for
4873 * all users on the device.
4874 */
4875 public static final String EXTRA_REMOVED_FOR_ALL_USERS
4876 = "android.intent.extra.REMOVED_FOR_ALL_USERS";
4877
4878 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004879 * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
4880 * intents to indicate that this is a replacement of the package, so this
4881 * broadcast will immediately be followed by an add broadcast for a
4882 * different version of the same package.
4883 */
4884 public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
The Android Open Source Project10592532009-03-18 17:39:46 -07004885
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08004886 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07004887 * Used as an int extra field in {@link android.app.AlarmManager} intents
4888 * to tell the application being invoked how many pending alarms are being
4889 * delievered with the intent. For one-shot alarms this will always be 1.
4890 * For recurring alarms, this might be greater than 1 if the device was
4891 * asleep or powered off at the time an earlier alarm would have been
4892 * delivered.
4893 */
4894 public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
Romain Guy4969af72009-06-17 10:53:19 -07004895
Jacek Surazski86b6c532009-05-13 14:38:28 +02004896 /**
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004897 * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
4898 * intents to request the dock state. Possible values are
Mike Lockwood725fcbf2009-08-24 13:09:20 -07004899 * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
4900 * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004901 * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
4902 * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
4903 * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004904 */
4905 public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
4906
4907 /**
4908 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4909 * to represent that the phone is not in any dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004910 */
4911 public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
4912
4913 /**
4914 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4915 * to represent that the phone is in a desk dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004916 */
4917 public static final int EXTRA_DOCK_STATE_DESK = 1;
4918
4919 /**
4920 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4921 * to represent that the phone is in a car dock.
Dan Murphyc9f4eaf2009-08-12 15:15:43 -05004922 */
4923 public static final int EXTRA_DOCK_STATE_CAR = 2;
4924
4925 /**
Praveen Bharathi21e941b2010-10-06 15:23:14 -05004926 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4927 * to represent that the phone is in a analog (low end) dock.
4928 */
4929 public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
4930
4931 /**
4932 * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
4933 * to represent that the phone is in a digital (high end) dock.
4934 */
4935 public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
4936
4937 /**
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004938 * Boolean that can be supplied as meta-data with a dock activity, to
4939 * indicate that the dock should take over the home key when it is active.
4940 */
4941 public static final String METADATA_DOCK_HOME = "android.dock_home";
Tom Taylord4a47292009-12-21 13:59:18 -08004942
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07004943 /**
Jacek Surazski86b6c532009-05-13 14:38:28 +02004944 * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
4945 * the bug report.
Jacek Surazski86b6c532009-05-13 14:38:28 +02004946 */
4947 public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
4948
4949 /**
Wei Huang97ecc9c2009-05-11 17:44:20 -07004950 * Used in the extra field in the remote intent. It's astring token passed with the
4951 * remote intent.
4952 */
4953 public static final String EXTRA_REMOTE_INTENT_TOKEN =
4954 "android.intent.extra.remote_intent_token";
4955
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004956 /**
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004957 * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004958 * will contain only the first name in the list.
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004959 */
Dianne Hackborn1d62ea92009-11-17 12:49:50 -08004960 @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
Suchi Amalapurapu0214e942009-09-02 11:03:18 -07004961 "android.intent.extra.changed_component_name";
4962
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004963 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004964 * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
Dianne Hackbornfd7aded2013-01-22 17:10:23 -08004965 * and contains a string array of all of the components that have changed. If
4966 * the state of the overall package has changed, then it will contain an entry
4967 * with the package name itself.
Dianne Hackborn86a72da2009-11-11 20:12:41 -08004968 */
4969 public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
4970 "android.intent.extra.changed_component_name_list";
4971
4972 /**
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004973 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004974 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
Andrei Stingaceanu69d5ebc2016-01-14 12:59:03 +00004975 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
4976 * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
4977 * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004978 * and contains a string array of all of the components that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004979 */
4980 public static final String EXTRA_CHANGED_PACKAGE_LIST =
4981 "android.intent.extra.changed_package_list";
4982
4983 /**
4984 * This field is part of
Suchi Amalapurapub56ae202010-02-04 22:51:07 -08004985 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
4986 * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004987 * and contains an integer array of uids of all of the components
4988 * that have changed.
Suchi Amalapurapu08675a32010-01-28 09:57:30 -08004989 */
4990 public static final String EXTRA_CHANGED_UID_LIST =
4991 "android.intent.extra.changed_uid_list";
4992
4993 /**
Dianne Hackborndd9b82c2009-09-03 00:18:47 -07004994 * @hide
4995 * Magic extra system code can use when binding, to give a label for
4996 * who it is that has bound to a service. This is an integer giving
4997 * a framework string resource that can be displayed to the user.
4998 */
4999 public static final String EXTRA_CLIENT_LABEL =
5000 "android.intent.extra.client_label";
5001
5002 /**
5003 * @hide
5004 * Magic extra system code can use when binding, to give a PendingIntent object
5005 * that can be launched for the user to disable the system's use of this
5006 * service.
5007 */
5008 public static final String EXTRA_CLIENT_INTENT =
5009 "android.intent.extra.client_intent";
5010
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005011 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005012 * Extra used to indicate that an intent should only return data that is on
5013 * the local device. This is a boolean extra; the default is false. If true,
5014 * an implementation should only allow the user to select data that is
5015 * already on the device, not requiring it be downloaded from a remote
5016 * service when opened.
5017 *
5018 * @see #ACTION_GET_CONTENT
5019 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkeyb9fbb722014-06-04 16:42:47 -07005020 * @see #ACTION_OPEN_DOCUMENT_TREE
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005021 * @see #ACTION_CREATE_DOCUMENT
Dianne Hackbornc4d0e6f2011-01-25 14:55:06 -08005022 */
5023 public static final String EXTRA_LOCAL_ONLY =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005024 "android.intent.extra.LOCAL_ONLY";
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07005025
Amith Yamasani13593602012-03-22 16:16:17 -07005026 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005027 * Extra used to indicate that an intent can allow the user to select and
5028 * return multiple items. This is a boolean extra; the default is false. If
5029 * true, an implementation is allowed to present the user with a UI where
5030 * they can pick multiple items that are all returned to the caller. When
5031 * this happens, they should be returned as the {@link #getClipData()} part
5032 * of the result Intent.
5033 *
5034 * @see #ACTION_GET_CONTENT
5035 * @see #ACTION_OPEN_DOCUMENT
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005036 */
5037 public static final String EXTRA_ALLOW_MULTIPLE =
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005038 "android.intent.extra.ALLOW_MULTIPLE";
Dianne Hackbornfdb3f092013-01-28 15:10:48 -08005039
5040 /**
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005041 * The integer userHandle carried with broadcast intents related to addition, removal and
5042 * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5043 * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5044 *
Amith Yamasani13593602012-03-22 16:16:17 -07005045 * @hide
5046 */
Amith Yamasani2a003292012-08-14 18:25:45 -07005047 public static final String EXTRA_USER_HANDLE =
5048 "android.intent.extra.user_handle";
Jean-Michel Trivi3114ce32012-06-11 15:03:52 -07005049
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005050 /**
Philip P. Moltmannc54c36d2018-10-08 15:51:07 -07005051 * The UserHandle carried with intents.
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005052 */
5053 public static final String EXTRA_USER =
Alexandra Gherghina3315f6b2014-09-05 15:48:06 +01005054 "android.intent.extra.USER";
Alexandra Gherghinac17d7e02014-04-04 16:27:28 +01005055
5056 /**
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005057 * Extra used in the response from a BroadcastReceiver that handles
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005058 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5059 * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005060 */
Amith Yamasani7e99bc02013-04-16 18:24:51 -07005061 public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5062
5063 /**
5064 * Extra sent in the intent to the BroadcastReceiver that handles
5065 * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5066 * the restrictions as key/value pairs.
5067 */
5068 public static final String EXTRA_RESTRICTIONS_BUNDLE =
5069 "android.intent.extra.restrictions_bundle";
Amith Yamasanidf2e92a2013-03-01 17:04:38 -08005070
Amith Yamasani86118ba2013-03-28 14:33:16 -07005071 /**
5072 * Extra used in the response from a BroadcastReceiver that handles
5073 * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5074 */
5075 public static final String EXTRA_RESTRICTIONS_INTENT =
5076 "android.intent.extra.restrictions_intent";
5077
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005078 /**
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005079 * Extra used to communicate a set of acceptable MIME types. The type of the
5080 * extra is {@code String[]}. Values may be a combination of concrete MIME
5081 * types (such as "image/png") and/or partial MIME types (such as
5082 * "audio/*").
5083 *
5084 * @see #ACTION_GET_CONTENT
5085 * @see #ACTION_OPEN_DOCUMENT
Jeff Sharkey9ecfee02013-04-19 14:05:03 -07005086 */
5087 public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5088
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005089 /**
5090 * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5091 * this shutdown is only for the user space of the system, not a complete shutdown.
Dianne Hackbornd318e0b2013-09-03 14:34:12 -07005092 * When this is true, hardware devices can use this information to determine that
5093 * they shouldn't do a complete shutdown of their device since this is not a
5094 * complete shutdown down to the kernel, but only user space restarting.
5095 * The default if not supplied is false.
Dianne Hackborn57a7f592013-07-22 18:21:32 -07005096 */
5097 public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5098 = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5099
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005100 /**
Neil Fullerb7146fe2016-11-15 16:52:15 +00005101 * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5102 * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5103 * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5104 * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005105 *
5106 * @hide for internal use only.
5107 */
5108 public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5109 "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
Neil Fullerb7146fe2016-11-15 16:52:15 +00005110 /** @hide */
5111 public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5112 /** @hide */
5113 public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5114 /** @hide */
5115 public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
Narayan Kamathccb2a0862013-12-19 14:49:36 +00005116
Jeff Davidsona0c7d1f2017-11-01 17:41:41 -07005117 /**
5118 * Intent extra: the reason that the operation associated with this intent is being performed.
5119 *
5120 * <p>Type: String
5121 * @hide
5122 */
5123 @SystemApi
Jeff Sharkey004a4b22014-09-24 11:45:24 -07005124 public static final String EXTRA_REASON = "android.intent.extra.REASON";
5125
qingxi240c2bb2017-04-12 17:31:18 -07005126 /**
5127 * {@hide}
5128 * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5129 */
Rubin Xue8490f12015-06-25 12:17:48 +01005130 public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5131
Santos Cordon15a13782015-03-31 18:32:31 -07005132 /**
qingxi240c2bb2017-04-12 17:31:18 -07005133 * {@hide}
5134 * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5135 * reset for the device with eSIM. This extra will be sent together with
5136 * {@link #ACTION_FACTORY_RESET}
5137 */
5138 public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5139
5140 /**
Santos Cordon15a13782015-03-31 18:32:31 -07005141 * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5142 * activation request.
5143 * TODO: Add information about the structure and response data used with the pending intent.
5144 * @hide
5145 */
5146 public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5147 "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5148
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005149 /**
5150 * Optional index with semantics depending on the intent action.
Tomasz Mikolajewskife023132016-03-10 17:42:35 +09005151 *
5152 * <p>The value must be an integer greater or equal to 0.
Garfield Tance1d0e92017-03-23 10:52:48 -07005153 * @see #ACTION_QUICK_VIEW
Tomasz Mikolajewski319fb492016-01-20 12:24:01 +09005154 */
Steve McKay6eaf38632015-08-04 10:11:01 -07005155 public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5156
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005157 /**
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005158 * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5159 * such as opening in other apps, sharing, opening, editing, printing, deleting,
5160 * casting, etc.
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005161 *
5162 * <p>The value is boolean. By default false.
Garfield Tance1d0e92017-03-23 10:52:48 -07005163 * @see #ACTION_QUICK_VIEW
5164 * @removed
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005165 */
Garfield Tance1d0e92017-03-23 10:52:48 -07005166 @Deprecated
Tomasz Mikolajewski17c50da2017-02-16 14:38:04 +09005167 public static final String EXTRA_QUICK_VIEW_ADVANCED =
5168 "android.intent.extra.QUICK_VIEW_ADVANCED";
Tomasz Mikolajewski867addf2017-02-01 14:16:39 +09005169
5170 /**
Garfield Tance1d0e92017-03-23 10:52:48 -07005171 * An optional extra of {@code String[]} indicating which quick view features should be made
5172 * available to the user in the quick view UI while handing a
5173 * {@link Intent#ACTION_QUICK_VIEW} intent.
5174 * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5175 * Quick viewer can implement features not listed below.
5176 * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
Geoffrey Pitschbc02b772017-12-06 11:24:15 -05005177 * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5178 * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5179 * {@link QuickViewConstants#FEATURE_PRINT}.
Garfield Tance1d0e92017-03-23 10:52:48 -07005180 * <p>
5181 * Requirements:
5182 * <li>Quick viewer shouldn't show a feature if the feature is absent in
5183 * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5184 * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5185 * internal policies.
5186 * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5187 * requirement that the feature be shown. Quick viewer may, according to its own policies,
5188 * disable or hide features.
5189 *
5190 * @see #ACTION_QUICK_VIEW
5191 */
5192 public static final String EXTRA_QUICK_VIEW_FEATURES =
5193 "android.intent.extra.QUICK_VIEW_FEATURES";
5194
5195 /**
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005196 * Optional boolean extra indicating whether quiet mode has been switched on or off.
Rubin Xue95057a2016-04-01 16:49:25 +01005197 * When a profile goes into quiet mode, all apps in the profile are killed and the
5198 * profile user is stopped. Widgets originating from the profile are masked, and app
5199 * launcher icons are grayed out.
Rubin Xu0a29ecd2015-11-04 15:11:48 +00005200 */
5201 public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005202
5203 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005204 * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005205 * intents to specify the resource type granted. Possible values are
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005206 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5207 * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005208 *
5209 * @hide
5210 */
5211 public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5212 "android.intent.extra.MEDIA_RESOURCE_TYPE";
5213
5214 /**
Ben Lin145b0ca2016-10-14 14:23:40 -07005215 * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5216 * whether to show the chooser or not when there is only one application available
5217 * to choose from.
5218 *
5219 * @hide
5220 */
5221 public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5222 "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5223
5224 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005225 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005226 * to represent that a video codec is allowed to use.
5227 *
5228 * @hide
5229 */
5230 public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5231
5232 /**
Dongwon Kang32cb9ab2016-01-13 18:11:10 -08005233 * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
Dongwon Kang2034a4c2015-12-14 21:57:34 +09005234 * to represent that a audio codec is allowed to use.
5235 *
5236 * @hide
5237 */
5238 public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5239
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005240 // ---------------------------------------------------------------------
5241 // ---------------------------------------------------------------------
5242 // Intent flags (see mFlags variable).
5243
Tor Norbyed9273d62013-05-30 15:59:53 -07005244 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005245 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005246 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5247 FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
Tor Norbyed9273d62013-05-30 15:59:53 -07005248 @Retention(RetentionPolicy.SOURCE)
5249 public @interface GrantUriMode {}
5250
Jeff Sharkey846318a2014-04-04 12:12:41 -07005251 /** @hide */
Jeff Sharkey6503bd82017-04-19 23:24:18 -06005252 @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
Jeff Sharkey846318a2014-04-04 12:12:41 -07005253 FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5254 @Retention(RetentionPolicy.SOURCE)
5255 public @interface AccessUriMode {}
5256
5257 /**
5258 * Test if given mode flags specify an access mode, which must be at least
5259 * read and/or write.
5260 *
5261 * @hide
5262 */
5263 public static boolean isAccessUriMode(int modeFlags) {
5264 return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5265 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5266 }
5267
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005268 /** @hide */
5269 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5270 FLAG_GRANT_READ_URI_PERMISSION,
5271 FLAG_GRANT_WRITE_URI_PERMISSION,
5272 FLAG_FROM_BACKGROUND,
5273 FLAG_DEBUG_LOG_RESOLUTION,
5274 FLAG_EXCLUDE_STOPPED_PACKAGES,
5275 FLAG_INCLUDE_STOPPED_PACKAGES,
5276 FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5277 FLAG_GRANT_PREFIX_URI_PERMISSION,
5278 FLAG_DEBUG_TRIAGED_MISSING,
5279 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005280 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005281 FLAG_ACTIVITY_NO_HISTORY,
5282 FLAG_ACTIVITY_SINGLE_TOP,
5283 FLAG_ACTIVITY_NEW_TASK,
5284 FLAG_ACTIVITY_MULTIPLE_TASK,
5285 FLAG_ACTIVITY_CLEAR_TOP,
5286 FLAG_ACTIVITY_FORWARD_RESULT,
5287 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5288 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5289 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5290 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5291 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5292 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5293 FLAG_ACTIVITY_NEW_DOCUMENT,
5294 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5295 FLAG_ACTIVITY_NO_USER_ACTION,
5296 FLAG_ACTIVITY_REORDER_TO_FRONT,
5297 FLAG_ACTIVITY_NO_ANIMATION,
5298 FLAG_ACTIVITY_CLEAR_TASK,
5299 FLAG_ACTIVITY_TASK_ON_HOME,
5300 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5301 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5302 FLAG_RECEIVER_REGISTERED_ONLY,
5303 FLAG_RECEIVER_REPLACE_PENDING,
5304 FLAG_RECEIVER_FOREGROUND,
5305 FLAG_RECEIVER_NO_ABORT,
5306 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5307 FLAG_RECEIVER_BOOT_UPGRADE,
5308 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5309 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5310 FLAG_RECEIVER_FROM_SHELL,
5311 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5312 })
5313 @Retention(RetentionPolicy.SOURCE)
5314 public @interface Flags {}
5315
5316 /** @hide */
5317 @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5318 FLAG_FROM_BACKGROUND,
5319 FLAG_DEBUG_LOG_RESOLUTION,
5320 FLAG_EXCLUDE_STOPPED_PACKAGES,
5321 FLAG_INCLUDE_STOPPED_PACKAGES,
5322 FLAG_DEBUG_TRIAGED_MISSING,
5323 FLAG_IGNORE_EPHEMERAL,
Patrick Baumann577d4022018-01-31 16:55:10 +00005324 FLAG_ACTIVITY_MATCH_EXTERNAL,
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005325 FLAG_ACTIVITY_NO_HISTORY,
5326 FLAG_ACTIVITY_SINGLE_TOP,
5327 FLAG_ACTIVITY_NEW_TASK,
5328 FLAG_ACTIVITY_MULTIPLE_TASK,
5329 FLAG_ACTIVITY_CLEAR_TOP,
5330 FLAG_ACTIVITY_FORWARD_RESULT,
5331 FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5332 FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5333 FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5334 FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5335 FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5336 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5337 FLAG_ACTIVITY_NEW_DOCUMENT,
5338 FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5339 FLAG_ACTIVITY_NO_USER_ACTION,
5340 FLAG_ACTIVITY_REORDER_TO_FRONT,
5341 FLAG_ACTIVITY_NO_ANIMATION,
5342 FLAG_ACTIVITY_CLEAR_TASK,
5343 FLAG_ACTIVITY_TASK_ON_HOME,
5344 FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5345 FLAG_ACTIVITY_LAUNCH_ADJACENT,
5346 FLAG_RECEIVER_REGISTERED_ONLY,
5347 FLAG_RECEIVER_REPLACE_PENDING,
5348 FLAG_RECEIVER_FOREGROUND,
5349 FLAG_RECEIVER_NO_ABORT,
5350 FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5351 FLAG_RECEIVER_BOOT_UPGRADE,
5352 FLAG_RECEIVER_INCLUDE_BACKGROUND,
5353 FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5354 FLAG_RECEIVER_FROM_SHELL,
5355 FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5356 })
5357 @Retention(RetentionPolicy.SOURCE)
5358 public @interface MutableFlags {}
5359
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005360 /**
5361 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005362 * perform read operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005363 * specified in its ClipData. When applying to an Intent's ClipData,
5364 * all URIs as well as recursive traversals through data or other ClipData
5365 * in Intent items will be granted; only the grant flags of the top-level
5366 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005367 */
5368 public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5369 /**
5370 * If set, the recipient of this Intent will be granted permission to
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005371 * perform write operations on the URI in the Intent's data and any URIs
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005372 * specified in its ClipData. When applying to an Intent's ClipData,
5373 * all URIs as well as recursive traversals through data or other ClipData
5374 * in Intent items will be granted; only the grant flags of the top-level
5375 * Intent are used.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005376 */
5377 public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5378 /**
5379 * Can be set by the caller to indicate that this Intent is coming from
5380 * a background operation, not from direct user interaction.
5381 */
5382 public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5383 /**
5384 * A flag you can enable for debugging: when set, log messages will be
5385 * printed during the resolution of this intent to show you what has
5386 * been found to create the final resolved list.
5387 */
5388 public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
Dianne Hackborne7f97212011-02-24 14:40:20 -08005389 /**
5390 * If set, this intent will not match any components in packages that
5391 * are currently stopped. If this is not set, then the default behavior
5392 * is to include such applications in the result.
5393 */
5394 public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5395 /**
5396 * If set, this intent will always match any components in packages that
5397 * are currently stopped. This is the default behavior when
5398 * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set. If both of these
5399 * flags are set, this one wins (it allows overriding of exclude for
5400 * places where the framework may automatically set the exclude flag).
5401 */
5402 public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005403
5404 /**
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005405 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005406 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005407 * persisted across device reboots until explicitly revoked with
5408 * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5409 * grant for possible persisting; the receiving application must call
5410 * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5411 * actually persist.
5412 *
5413 * @see ContentResolver#takePersistableUriPermission(Uri, int)
5414 * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5415 * @see ContentResolver#getPersistedUriPermissions()
Jeff Sharkeyadef88a2013-10-15 13:54:44 -07005416 * @see ContentResolver#getOutgoingPersistedUriPermissions()
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005417 */
Jeff Sharkeye66c1772013-09-20 14:30:59 -07005418 public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
Jeff Sharkey328ebf22013-03-21 18:09:39 -07005419
5420 /**
Jeff Sharkey846318a2014-04-04 12:12:41 -07005421 * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5422 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5423 * applies to any URI that is a prefix match against the original granted
5424 * URI. (Without this flag, the URI must match exactly for access to be
5425 * granted.) Another URI is considered a prefix match only when scheme,
5426 * authority, and all path segments defined by the prefix are an exact
5427 * match.
5428 */
5429 public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5430
5431 /**
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005432 * Flag used to automatically match intents based on their Direct Boot
5433 * awareness and the current user state.
5434 * <p>
5435 * Since the default behavior is to automatically apply the current user
5436 * state, this is effectively a sentinel value that doesn't change the
5437 * output of any queries based on its presence or absence.
5438 * <p>
5439 * Instead, this value can be useful in conjunction with
5440 * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5441 * to detect when a caller is relying on implicit automatic matching,
5442 * instead of confirming the explicit behavior they want.
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005443 */
Jeff Sharkeyc59a5e72018-06-21 19:14:58 -06005444 public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5445
5446 /** {@hide} */
5447 @Deprecated
5448 public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
Jeff Sharkey2a9e3f82015-12-18 10:57:58 -07005449
5450 /**
Todd Kennedy8e2d9d12016-06-28 14:09:55 -07005451 * Internal flag used to indicate ephemeral applications should not be
5452 * considered when resolving the intent.
5453 *
5454 * @hide
5455 */
5456 public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5457
5458 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005459 * If set, the new activity is not kept in the history stack. As soon as
5460 * the user navigates away from it, the activity is finished. This may also
5461 * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5462 * noHistory} attribute.
Ricardo Cervera92f6a742014-04-04 11:17:06 -07005463 *
5464 * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5465 * is never invoked when the current activity starts a new activity which
5466 * sets a result and finishes.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005467 */
5468 public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5469 /**
5470 * If set, the activity will not be launched if it is already running
5471 * at the top of the history stack.
5472 */
5473 public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5474 /**
5475 * If set, this activity will become the start of a new task on this
5476 * history stack. A task (from the activity that started it to the
5477 * next task activity) defines an atomic group of activities that the
5478 * user can move to. Tasks can be moved to the foreground and background;
5479 * all of the activities inside of a particular task always remain in
The Android Open Source Project10592532009-03-18 17:39:46 -07005480 * the same order. See
Scott Main7aee61f2011-02-08 11:25:01 -08005481 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5482 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005483 *
5484 * <p>This flag is generally used by activities that want
5485 * to present a "launcher" style behavior: they give the user a list of
5486 * separate things that can be done, which otherwise run completely
5487 * independently of the activity launching them.
5488 *
5489 * <p>When using this flag, if a task is already running for the activity
5490 * you are now starting, then a new activity will not be started; instead,
5491 * the current task will simply be brought to the front of the screen with
5492 * the state it was last in. See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5493 * to disable this behavior.
5494 *
5495 * <p>This flag can not be used when the caller is requesting a result from
5496 * the activity being launched.
5497 */
5498 public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5499 /**
Craig Mautnerd00f4742014-03-12 14:17:26 -07005500 * This flag is used to create a new task and launch an activity into it.
5501 * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5502 * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5503 * search through existing tasks for ones matching this Intent. Only if no such
5504 * task is found would a new task be created. When paired with
5505 * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5506 * the search for a matching task and unconditionally start a new task.
5507 *
5508 * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5509 * flag unless you are implementing your own
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005510 * top-level application launcher.</strong> Used in conjunction with
5511 * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5512 * behavior of bringing an existing task to the foreground. When set,
5513 * a new task is <em>always</em> started to host the Activity for the
5514 * Intent, regardless of whether there is already an existing task running
5515 * the same thing.
5516 *
5517 * <p><strong>Because the default system does not include graphical task management,
5518 * you should not use this flag unless you provide some way for a user to
5519 * return back to the tasks you have launched.</strong>
The Android Open Source Project10592532009-03-18 17:39:46 -07005520 *
Craig Mautnerd00f4742014-03-12 14:17:26 -07005521 * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5522 * creating new document tasks.
5523 *
5524 * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
Paul Soulos628cb742014-09-19 11:00:52 -07005525 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005526 *
Scott Main7aee61f2011-02-08 11:25:01 -08005527 * <p>See
5528 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5529 * Stack</a> for more information about tasks.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005530 *
5531 * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5532 * @see #FLAG_ACTIVITY_NEW_TASK
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005533 */
5534 public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5535 /**
5536 * If set, and the activity being launched is already running in the
5537 * current task, then instead of launching a new instance of that activity,
5538 * all of the other activities on top of it will be closed and this Intent
5539 * will be delivered to the (now on top) old activity as a new Intent.
5540 *
5541 * <p>For example, consider a task consisting of the activities: A, B, C, D.
5542 * If D calls startActivity() with an Intent that resolves to the component
5543 * of activity B, then C and D will be finished and B receive the given
5544 * Intent, resulting in the stack now being: A, B.
5545 *
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005546 * <p>The currently running instance of activity B in the above example will
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005547 * either receive the new intent you are starting here in its
5548 * onNewIntent() method, or be itself finished and restarted with the
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005549 * new intent. If it has declared its launch mode to be "multiple" (the
Dianne Hackbornaa52f9a2009-08-25 16:01:15 -07005550 * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5551 * the same intent, then it will be finished and re-created; for all other
5552 * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5553 * Intent will be delivered to the current instance's onNewIntent().
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005554 *
5555 * <p>This launch mode can also be used to good effect in conjunction with
5556 * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5557 * of a task, it will bring any currently running instance of that task
5558 * to the foreground, and then clear it to its root state. This is
5559 * especially useful, for example, when launching an activity from the
5560 * notification manager.
5561 *
Scott Main7aee61f2011-02-08 11:25:01 -08005562 * <p>See
5563 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5564 * Stack</a> for more information about tasks.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005565 */
5566 public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5567 /**
5568 * If set and this intent is being used to launch a new activity from an
5569 * existing one, then the reply target of the existing activity will be
kopriva219f7dc2018-10-09 13:42:28 -07005570 * transferred to the new activity. This way, the new activity can call
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005571 * {@link android.app.Activity#setResult} and have that result sent back to
5572 * the reply target of the original activity.
5573 */
5574 public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5575 /**
5576 * If set and this intent is being used to launch a new activity from an
5577 * existing one, the current activity will not be counted as the top
5578 * activity for deciding whether the new intent should be delivered to
5579 * the top instead of starting a new one. The previous activity will
5580 * be used as the top, with the assumption being that the current activity
5581 * will finish itself immediately.
5582 */
5583 public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5584 /**
5585 * If set, the new activity is not kept in the list of recently launched
5586 * activities.
5587 */
5588 public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5589 /**
5590 * This flag is not normally set by application code, but set for you by
5591 * the system as described in the
5592 * {@link android.R.styleable#AndroidManifestActivity_launchMode
5593 * launchMode} documentation for the singleTask mode.
5594 */
5595 public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5596 /**
5597 * If set, and this activity is either being started in a new task or
5598 * bringing to the top an existing task, then it will be launched as
5599 * the front door of the task. This will result in the application of
5600 * any affinities needed to have that task in the proper state (either
5601 * moving activities to or from it), or simply resetting that task to
5602 * its initial state if needed.
5603 */
5604 public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5605 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005606 * This flag is not normally set by application code, but set for you by
5607 * the system if this activity is being launched from history
5608 * (longpress home key).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005609 */
5610 public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005611 /**
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005612 * @deprecated As of API 21 this performs identically to
5613 * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005614 */
Aurimas Liutikas514c5ef2016-05-24 15:22:55 -07005615 @Deprecated
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08005616 public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005617 /**
Craig Mautner026596b2014-05-21 15:35:44 -07005618 * This flag is used to open a document into a new task rooted at the activity launched
5619 * by this Intent. Through the use of this flag, or its equivalent attribute,
5620 * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
Chet Haase0d1c27a2014-11-03 18:35:16 +00005621 * containing different documents will appear in the recent tasks list.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005622 *
Craig Mautner026596b2014-05-21 15:35:44 -07005623 * <p>The use of the activity attribute form of this,
5624 * {@link android.R.attr#documentLaunchMode}, is
5625 * preferred over the Intent flag described here. The attribute form allows the
5626 * Activity to specify multiple document behavior for all launchers of the Activity
5627 * whereas using this flag requires each Intent that launches the Activity to specify it.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005628 *
Dianne Hackborn13420f22014-07-18 15:43:56 -07005629 * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
5630 * it is kept after the activity is finished is different than the use of
5631 * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
5632 * this flag is being used to create a new recents entry, then by default that entry
5633 * will be removed once the activity is finished. You can modify this behavior with
5634 * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
5635 *
Craig Mautner026596b2014-05-21 15:35:44 -07005636 * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
5637 * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
5638 * equivalent of the Activity manifest specifying {@link
5639 * android.R.attr#documentLaunchMode}="intoExisting". When used with
5640 * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
5641 * {@link android.R.attr#documentLaunchMode}="always".
Craig Mautnerd00f4742014-03-12 14:17:26 -07005642 *
Craig Mautner026596b2014-05-21 15:35:44 -07005643 * Refer to {@link android.R.attr#documentLaunchMode} for more information.
Craig Mautnerd00f4742014-03-12 14:17:26 -07005644 *
Craig Mautner026596b2014-05-21 15:35:44 -07005645 * @see android.R.attr#documentLaunchMode
Craig Mautnerd00f4742014-03-12 14:17:26 -07005646 * @see #FLAG_ACTIVITY_MULTIPLE_TASK
5647 */
Craig Mautnerf357c0c2014-06-09 09:23:27 -07005648 public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
Craig Mautnerd00f4742014-03-12 14:17:26 -07005649 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005650 * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005651 * callback from occurring on the current frontmost activity before it is
5652 * paused as the newly-started activity is brought to the front.
The Android Open Source Project10592532009-03-18 17:39:46 -07005653 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005654 * <p>Typically, an activity can rely on that callback to indicate that an
5655 * explicit user action has caused their activity to be moved out of the
5656 * foreground. The callback marks an appropriate point in the activity's
5657 * lifecycle for it to dismiss any notifications that it intends to display
5658 * "until the user has seen them," such as a blinking LED.
The Android Open Source Project10592532009-03-18 17:39:46 -07005659 *
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005660 * <p>If an activity is ever started via any non-user-driven events such as
5661 * phone-call receipt or an alarm handler, this flag should be passed to {@link
5662 * Context#startActivity Context.startActivity}, ensuring that the pausing
The Android Open Source Project10592532009-03-18 17:39:46 -07005663 * activity does not think the user has acknowledged its notification.
The Android Open Source Projectf1e484a2009-01-22 00:13:42 -08005664 */
5665 public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005666 /**
5667 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5668 * this flag will cause the launched activity to be brought to the front of its
5669 * task's history stack if it is already running.
The Android Open Source Project10592532009-03-18 17:39:46 -07005670 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005671 * <p>For example, consider a task consisting of four activities: A, B, C, D.
5672 * If D calls startActivity() with an Intent that resolves to the component
5673 * of activity B, then B will be brought to the front of the history stack,
5674 * with this resulting order: A, C, D, B.
The Android Open Source Project10592532009-03-18 17:39:46 -07005675 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005676 * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
The Android Open Source Project10592532009-03-18 17:39:46 -07005677 * specified.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005678 */
5679 public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005680 /**
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005681 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5682 * this flag will prevent the system from applying an activity transition
5683 * animation to go to the next activity state. This doesn't mean an
5684 * animation will never run -- if another activity change happens that doesn't
5685 * specify this flag before the activity started here is displayed, then
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005686 * that transition will be used. This flag can be put to good use
Dianne Hackbornbfe319e2009-09-21 00:34:05 -07005687 * when you are going to do a series of activity operations but the
5688 * animation seen by the user shouldn't be driven by the first activity
5689 * change but rather a later one.
5690 */
5691 public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
5692 /**
Dianne Hackborn621e17d2010-11-22 15:59:56 -08005693 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5694 * this flag will cause any existing task that would be associated with the
5695 * activity to be cleared before the activity is started. That is, the activity
5696 * becomes the new root of an otherwise empty task, and any old activities
5697 * are finished. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5698 */
5699 public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
5700 /**
5701 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5702 * this flag will cause a newly launching task to be placed on top of the current
5703 * home activity task (if there is one). That is, pressing back from the task
5704 * will always return the user to home even if that was not the last activity they
5705 * saw. This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
5706 */
5707 public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
5708 /**
Dianne Hackborn13420f22014-07-18 15:43:56 -07005709 * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
5710 * have its entry in recent tasks removed when the user closes it (with back
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005711 * or however else it may finish()). If you would like to instead allow the
Dianne Hackborn13420f22014-07-18 15:43:56 -07005712 * document to be kept in recents so that it can be re-launched, you can use
Jeff Sharkey9f991a22014-08-13 11:37:41 -07005713 * this flag. When set and the task's activity is finished, the recents
5714 * entry will remain in the interface for the user to re-launch it, like a
5715 * recents entry for a top-level application.
5716 * <p>
5717 * The receiving activity can override this request with
5718 * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
5719 * {@link android.app.Activity#finishAndRemoveTask()
Dianne Hackborn13420f22014-07-18 15:43:56 -07005720 * Activity.finishAndRemoveTask()}.
Craig Mautner2dac0562014-05-06 09:06:44 -07005721 */
Dianne Hackborn13420f22014-07-18 15:43:56 -07005722 public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
Craig Mautnera228ae92014-07-09 05:44:55 -07005723
5724 /**
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005725 * This flag is only used in split-screen multi-window mode. The new activity will be displayed
5726 * adjacent to the one launching it. This can only be used in conjunction with
Wale Ogunwale6bdf2572016-03-11 15:22:38 -08005727 * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
5728 * required if you want a new instance of an existing activity to be created.
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005729 */
Wale Ogunwale2a25a622016-01-30 11:27:21 -08005730 public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005731
Patrick Baumann577d4022018-01-31 16:55:10 +00005732
5733 /**
Patrick Baumann92ae2c62018-05-10 10:10:26 -07005734 * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
5735 * this flag will attempt to launch an instant app if no full app on the device can already
5736 * handle the intent.
5737 * <p>
5738 * When attempting to resolve instant apps externally, the following {@link Intent} properties
5739 * are supported:
5740 * <ul>
5741 * <li>{@link Intent#setAction(String)}</li>
5742 * <li>{@link Intent#addCategory(String)}</li>
5743 * <li>{@link Intent#setData(Uri)}</li>
5744 * <li>{@link Intent#setType(String)}</li>
5745 * <li>{@link Intent#setPackage(String)}</li>
5746 * <li>{@link Intent#addFlags(int)}</li>
5747 * </ul>
5748 * <p>
5749 * In the case that no instant app can be found, the installer will be launched to notify the
5750 * user that the intent could not be resolved. On devices that do not support instant apps,
5751 * the flag will be ignored.
Patrick Baumann577d4022018-01-31 16:55:10 +00005752 */
5753 public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
5754
Filip Gruszczynski80e29f12015-12-14 14:58:30 -08005755 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005756 * If set, when sending a broadcast only registered receivers will be
5757 * called -- no BroadcastReceiver components will be launched.
5758 */
5759 public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005760 /**
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005761 * If set, when sending a broadcast the new broadcast will replace
5762 * any existing pending broadcast that matches it. Matching is defined
5763 * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
5764 * true for the intents of the two broadcasts. When a match is found,
5765 * the new broadcast (and receivers associated with it) will replace the
5766 * existing one in the pending broadcast list, remaining at the same
5767 * position in the list.
Tom Taylord4a47292009-12-21 13:59:18 -08005768 *
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08005769 * <p>This flag is most typically used with sticky broadcasts, which
5770 * only care about delivering the most recent values of the broadcast
5771 * to their receivers.
5772 */
5773 public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
5774 /**
Christopher Tatef46723b2012-01-26 14:19:24 -08005775 * If set, when sending a broadcast the recipient is allowed to run at
5776 * foreground priority, with a shorter timeout interval. During normal
5777 * broadcasts the receivers are not automatically hoisted out of the
5778 * background priority class.
5779 */
5780 public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
5781 /**
Dianne Hackborn6285a322013-09-18 12:09:47 -07005782 * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
5783 * They can still propagate results through to later receivers, but they can not prevent
5784 * later receivers from seeing the broadcast.
5785 */
5786 public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
5787 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005788 * If set, when sending a broadcast <i>before boot has completed</i> only
5789 * registered receivers will be called -- no BroadcastReceiver components
5790 * will be launched. Sticky intent state will be recorded properly even
5791 * if no receivers wind up being called. If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
5792 * is specified in the broadcast intent, this flag is unnecessary.
The Android Open Source Project10592532009-03-18 17:39:46 -07005793 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005794 * <p>This flag is only for use by system sevices as a convenience to
5795 * avoid having to implement a more complex mechanism around detection
5796 * of boot completion.
The Android Open Source Project10592532009-03-18 17:39:46 -07005797 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08005798 * @hide
5799 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005800 @UnsupportedAppUsage
Dianne Hackborn6285a322013-09-18 12:09:47 -07005801 public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
Dianne Hackborn9acc0302009-08-25 00:27:12 -07005802 /**
5803 * Set when this broadcast is for a boot upgrade, a special mode that
5804 * allows the broadcast to be sent before the system is ready and launches
5805 * the app process with no providers running in it.
5806 * @hide
5807 */
Dianne Hackborn6285a322013-09-18 12:09:47 -07005808 public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005809 /**
5810 * If set, the broadcast will always go to manifest receivers in background (cached
5811 * or not running) apps, regardless of whether that would be done by default. By
5812 * default they will only receive broadcasts if the broadcast has specified an
5813 * explicit component or package name.
Christopher Tatebdc39412017-01-23 12:21:13 -08005814 *
5815 * NOTE: dumpstate uses this flag numerically, so when its value is changed
5816 * the broadcast code there must also be changed to match.
5817 *
Dianne Hackborn6ac42ae2015-12-08 17:22:10 -08005818 * @hide
5819 */
5820 public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
5821 /**
5822 * If set, the broadcast will never go to manifest receivers in background (cached
5823 * or not running) apps, regardless of whether that would be done by default. By
5824 * default they will receive broadcasts if the broadcast has specified an
5825 * explicit component or package name.
5826 * @hide
5827 */
5828 public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
Jeff Sharkey6a34e562016-12-21 09:56:00 -07005829 /**
5830 * If set, this broadcast is being sent from the shell.
5831 * @hide
5832 */
5833 public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005834
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005835 /**
Chad Brubakerb7e34d52017-02-22 12:36:06 -08005836 * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
5837 * will not receive broadcasts.
5838 *
5839 * <em>This flag has no effect when used by an Instant App.</em>
5840 */
5841 public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
5842
5843 /**
Dianne Hackbornfa82f222009-09-17 15:14:12 -07005844 * @hide Flags that can't be changed with PendingIntent.
5845 */
Jeff Sharkey846318a2014-04-04 12:12:41 -07005846 public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
5847 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
5848 | FLAG_GRANT_PREFIX_URI_PERMISSION;
Tom Taylord4a47292009-12-21 13:59:18 -08005849
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005850 // ---------------------------------------------------------------------
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005851 // ---------------------------------------------------------------------
5852 // toUri() and parseUri() options.
5853
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06005854 /** @hide */
5855 @IntDef(flag = true, prefix = { "URI_" }, value = {
5856 URI_ALLOW_UNSAFE,
5857 URI_ANDROID_APP_SCHEME,
5858 URI_INTENT_SCHEME,
5859 })
5860 @Retention(RetentionPolicy.SOURCE)
5861 public @interface UriFlags {}
5862
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005863 /**
5864 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5865 * always has the "intent:" scheme. This syntax can be used when you want
5866 * to later disambiguate between URIs that are intended to describe an
5867 * Intent vs. all others that should be treated as raw URIs. When used
5868 * with {@link #parseUri}, any other scheme will result in a generic
5869 * VIEW action for that raw URI.
5870 */
5871 public static final int URI_INTENT_SCHEME = 1<<0;
Tom Taylord4a47292009-12-21 13:59:18 -08005872
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005873 /**
5874 * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
5875 * always has the "android-app:" scheme. This is a variation of
5876 * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
5877 * http/https URI being delivered to a specific package name. The format
5878 * is:
5879 *
5880 * <pre class="prettyprint">
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005881 * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005882 *
Dianne Hackborn0ee10f62015-01-14 16:16:13 -08005883 * <p>In this scheme, only the <code>package_id</code> is required. If you include a host,
5884 * you must also include a scheme; including a path also requires both a host and a scheme.
5885 * The final #Intent; fragment can be used without a scheme, host, or path.
5886 * Note that this can not be
Dianne Hackborn85d558c2014-11-04 10:31:54 -08005887 * used with intents that have a {@link #setSelector}, since the base intent
5888 * will always have an explicit package name.</p>
5889 *
5890 * <p>Some examples of how this scheme maps to Intent objects:</p>
5891 * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
5892 * <colgroup align="left" />
5893 * <colgroup align="left" />
5894 * <thead>
5895 * <tr><th>URI</th> <th>Intent</th></tr>
5896 * </thead>
5897 *
5898 * <tbody>
5899 * <tr><td><code>android-app://com.example.app</code></td>
5900 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5901 * <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
5902 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5903 * </table></td>
5904 * </tr>
5905 * <tr><td><code>android-app://com.example.app/http/example.com</code></td>
5906 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5907 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5908 * <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
5909 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5910 * </table></td>
5911 * </tr>
5912 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
5913 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5914 * <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
5915 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5916 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5917 * </table></td>
5918 * </tr>
5919 * <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5920 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5921 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5922 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5923 * </table></td>
5924 * </tr>
5925 * <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
5926 * <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
5927 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5928 * <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
5929 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5930 * </table></td>
5931 * </tr>
5932 * <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>
5933 * <td><table border="" style="margin:0" >
5934 * <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
5935 * <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
5936 * <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
5937 * </table></td>
5938 * </tr>
5939 * </tbody>
5940 * </table>
5941 */
5942 public static final int URI_ANDROID_APP_SCHEME = 1<<1;
5943
Dianne Hackborn24b1c232014-11-20 17:17:39 -08005944 /**
5945 * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
5946 * of unsafe information. In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
5947 * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
5948 * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
5949 * generated Intent can not cause unexpected data access to happen.
5950 *
5951 * <p>If you do not trust the source of the URI being parsed, you should still do further
5952 * processing to protect yourself from it. In particular, when using it to start an
5953 * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
5954 * that can handle it.</p>
5955 */
5956 public static final int URI_ALLOW_UNSAFE = 1<<2;
5957
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005958 // ---------------------------------------------------------------------
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005959
5960 private String mAction;
5961 private Uri mData;
5962 private String mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07005963 private String mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005964 private ComponentName mComponent;
5965 private int mFlags;
Dianne Hackbornadd005c2013-07-17 18:43:12 -07005966 private ArraySet<String> mCategories;
Mathew Inwood5c0d3542018-08-14 13:54:31 +01005967 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005968 private Bundle mExtras;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08005969 private Rect mSourceBounds;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08005970 private Intent mSelector;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08005971 private ClipData mClipData;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01005972 private int mContentUserHint = UserHandle.USER_CURRENT;
Todd Kennedyb3b431302017-03-20 16:05:48 -07005973 /** Token to track instant app launches. Local only; do not copy cross-process. */
5974 private String mLaunchToken;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005975
5976 // ---------------------------------------------------------------------
5977
Makoto Onuki97f82f22017-05-31 16:20:21 -07005978 private static final int COPY_MODE_ALL = 0;
5979 private static final int COPY_MODE_FILTER = 1;
5980 private static final int COPY_MODE_HISTORY = 2;
5981
5982 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07005983 @IntDef(prefix = { "COPY_MODE_" }, value = {
5984 COPY_MODE_ALL,
5985 COPY_MODE_FILTER,
5986 COPY_MODE_HISTORY
5987 })
Makoto Onuki97f82f22017-05-31 16:20:21 -07005988 @Retention(RetentionPolicy.SOURCE)
5989 public @interface CopyMode {}
5990
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07005991 /**
5992 * Create an empty intent.
5993 */
5994 public Intent() {
5995 }
5996
5997 /**
5998 * Copy constructor.
5999 */
6000 public Intent(Intent o) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006001 this(o, COPY_MODE_ALL);
6002 }
6003
6004 private Intent(Intent o, @CopyMode int copyMode) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006005 this.mAction = o.mAction;
6006 this.mData = o.mData;
6007 this.mType = o.mType;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006008 this.mPackage = o.mPackage;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006009 this.mComponent = o.mComponent;
Makoto Onuki97f82f22017-05-31 16:20:21 -07006010
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006011 if (o.mCategories != null) {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006012 this.mCategories = new ArraySet<>(o.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006013 }
Makoto Onuki97f82f22017-05-31 16:20:21 -07006014
6015 if (copyMode != COPY_MODE_FILTER) {
6016 this.mFlags = o.mFlags;
6017 this.mContentUserHint = o.mContentUserHint;
6018 this.mLaunchToken = o.mLaunchToken;
6019 if (o.mSourceBounds != null) {
6020 this.mSourceBounds = new Rect(o.mSourceBounds);
6021 }
6022 if (o.mSelector != null) {
6023 this.mSelector = new Intent(o.mSelector);
6024 }
6025
6026 if (copyMode != COPY_MODE_HISTORY) {
6027 if (o.mExtras != null) {
6028 this.mExtras = new Bundle(o.mExtras);
6029 }
6030 if (o.mClipData != null) {
6031 this.mClipData = new ClipData(o.mClipData);
6032 }
6033 } else {
6034 if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6035 this.mExtras = Bundle.STRIPPED;
6036 }
6037
6038 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6039 // history.
6040 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08006041 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006042 }
6043
6044 @Override
6045 public Object clone() {
6046 return new Intent(this);
6047 }
6048
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006049 /**
6050 * Make a clone of only the parts of the Intent that are relevant for
6051 * filter matching: the action, data, type, component, and categories.
6052 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006053 public @NonNull Intent cloneFilter() {
Makoto Onuki97f82f22017-05-31 16:20:21 -07006054 return new Intent(this, COPY_MODE_FILTER);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006055 }
6056
6057 /**
6058 * Create an intent with a given action. All other fields (data, type,
6059 * class) are null. Note that the action <em>must</em> be in a
6060 * namespace because Intents are used globally in the system -- for
6061 * example the system VIEW action is android.intent.action.VIEW; an
6062 * application's custom action would be something like
6063 * com.google.app.myapp.CUSTOM_ACTION.
6064 *
6065 * @param action The Intent action, such as ACTION_VIEW.
6066 */
6067 public Intent(String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006068 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006069 }
6070
6071 /**
6072 * Create an intent with a given action and for a given data url. Note
6073 * that the action <em>must</em> be in a namespace because Intents are
6074 * used globally in the system -- for example the system VIEW action is
6075 * android.intent.action.VIEW; an application's custom action would be
6076 * something like com.google.app.myapp.CUSTOM_ACTION.
6077 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006078 * <p><em>Note: scheme and host name matching in the Android framework is
6079 * case-sensitive, unlike the formal RFC. As a result,
6080 * you should always ensure that you write your Uri with these elements
6081 * using lower case letters, and normalize any Uris you receive from
6082 * outside of Android to ensure the scheme and host is lower case.</em></p>
6083 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006084 * @param action The Intent action, such as ACTION_VIEW.
6085 * @param uri The Intent data URI.
6086 */
6087 public Intent(String action, Uri uri) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006088 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006089 mData = uri;
6090 }
6091
6092 /**
6093 * Create an intent for a specific component. All other fields (action, data,
6094 * type, class) are null, though they can be modified later with explicit
6095 * calls. This provides a convenient way to create an intent that is
6096 * intended to execute a hard-coded class name, rather than relying on the
6097 * system to find an appropriate class for you; see {@link #setComponent}
6098 * for more information on the repercussions of this.
6099 *
6100 * @param packageContext A Context of the application package implementing
6101 * this class.
6102 * @param cls The component class that is to be used for the intent.
6103 *
6104 * @see #setClass
6105 * @see #setComponent
6106 * @see #Intent(String, android.net.Uri , Context, Class)
6107 */
6108 public Intent(Context packageContext, Class<?> cls) {
6109 mComponent = new ComponentName(packageContext, cls);
6110 }
6111
6112 /**
6113 * Create an intent for a specific component with a specified action and data.
Craig Mautner2dac0562014-05-06 09:06:44 -07006114 * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006115 * construct the Intent and then calling {@link #setClass} to set its
6116 * class.
6117 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07006118 * <p><em>Note: scheme and host name matching in the Android framework is
6119 * case-sensitive, unlike the formal RFC. As a result,
6120 * you should always ensure that you write your Uri with these elements
6121 * using lower case letters, and normalize any Uris you receive from
6122 * outside of Android to ensure the scheme and host is lower case.</em></p>
6123 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006124 * @param action The Intent action, such as ACTION_VIEW.
6125 * @param uri The Intent data URI.
6126 * @param packageContext A Context of the application package implementing
6127 * this class.
6128 * @param cls The component class that is to be used for the intent.
6129 *
6130 * @see #Intent(String, android.net.Uri)
6131 * @see #Intent(Context, Class)
6132 * @see #setClass
6133 * @see #setComponent
6134 */
6135 public Intent(String action, Uri uri,
6136 Context packageContext, Class<?> cls) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006137 setAction(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006138 mData = uri;
6139 mComponent = new ComponentName(packageContext, cls);
6140 }
6141
6142 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006143 * Create an intent to launch the main (root) activity of a task. This
6144 * is the Intent that is started when the application's is launched from
6145 * Home. For anything else that wants to launch an application in the
6146 * same way, it is important that they use an Intent structured the same
6147 * way, and can use this function to ensure this is the case.
6148 *
6149 * <p>The returned Intent has the given Activity component as its explicit
6150 * component, {@link #ACTION_MAIN} as its action, and includes the
6151 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6152 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6153 * to do that through {@link #addFlags(int)} on the returned Intent.
6154 *
6155 * @param mainActivity The main activity component that this Intent will
6156 * launch.
6157 * @return Returns a newly created Intent that can be used to launch the
6158 * activity as a main application entry.
6159 *
6160 * @see #setClass
6161 * @see #setComponent
6162 */
6163 public static Intent makeMainActivity(ComponentName mainActivity) {
6164 Intent intent = new Intent(ACTION_MAIN);
6165 intent.setComponent(mainActivity);
6166 intent.addCategory(CATEGORY_LAUNCHER);
6167 return intent;
6168 }
6169
6170 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006171 * Make an Intent for the main activity of an application, without
6172 * specifying a specific activity to run but giving a selector to find
6173 * the activity. This results in a final Intent that is structured
6174 * the same as when the application is launched from
6175 * Home. For anything else that wants to launch an application in the
6176 * same way, it is important that they use an Intent structured the same
6177 * way, and can use this function to ensure this is the case.
6178 *
6179 * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6180 * category {@link #CATEGORY_LAUNCHER}. This does <em>not</em> have
6181 * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6182 * to do that through {@link #addFlags(int)} on the returned Intent.
6183 *
6184 * @param selectorAction The action name of the Intent's selector.
6185 * @param selectorCategory The name of a category to add to the Intent's
6186 * selector.
6187 * @return Returns a newly created Intent that can be used to launch the
6188 * activity as a main application entry.
6189 *
6190 * @see #setSelector(Intent)
6191 */
6192 public static Intent makeMainSelectorActivity(String selectorAction,
6193 String selectorCategory) {
6194 Intent intent = new Intent(ACTION_MAIN);
6195 intent.addCategory(CATEGORY_LAUNCHER);
6196 Intent selector = new Intent();
6197 selector.setAction(selectorAction);
6198 selector.addCategory(selectorCategory);
6199 intent.setSelector(selector);
6200 return intent;
6201 }
6202
6203 /**
Dianne Hackborn30d71892010-12-11 10:37:55 -08006204 * Make an Intent that can be used to re-launch an application's task
6205 * in its base state. This is like {@link #makeMainActivity(ComponentName)},
6206 * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6207 * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6208 *
6209 * @param mainActivity The activity component that is the root of the
6210 * task; this is the activity that has been published in the application's
6211 * manifest as the main launcher icon.
6212 *
6213 * @return Returns a newly created Intent that can be used to relaunch the
6214 * activity's task in its root state.
6215 */
6216 public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6217 Intent intent = makeMainActivity(mainActivity);
6218 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6219 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6220 return intent;
6221 }
6222
6223 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006224 * Call {@link #parseUri} with 0 flags.
6225 * @deprecated Use {@link #parseUri} instead.
6226 */
6227 @Deprecated
6228 public static Intent getIntent(String uri) throws URISyntaxException {
6229 return parseUri(uri, 0);
6230 }
Tom Taylord4a47292009-12-21 13:59:18 -08006231
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006232 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006233 * Create an intent from a URI. This URI may encode the action,
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006234 * category, and other intent fields, if it was returned by
Dianne Hackborn7f205432009-07-28 00:13:47 -07006235 * {@link #toUri}. If the Intent was not generate by toUri(), its data
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006236 * will be the entire URI and its action will be ACTION_VIEW.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006237 *
6238 * <p>The URI given here must not be relative -- that is, it must include
6239 * the scheme and full path.
6240 *
6241 * @param uri The URI to turn into an Intent.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006242 * @param flags Additional processing flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006243 *
6244 * @return Intent The newly created Intent object.
6245 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006246 * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6247 * it bad (as parsed by the Uri class) or the Intent data within the
6248 * URI is invalid.
Tom Taylord4a47292009-12-21 13:59:18 -08006249 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006250 * @see #toUri
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006251 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06006252 public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006253 int i = 0;
6254 try {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006255 final boolean androidApp = uri.startsWith("android-app:");
6256
6257 // Validate intent scheme if requested.
6258 if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6259 if (!uri.startsWith("intent:") && !androidApp) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006260 Intent intent = new Intent(ACTION_VIEW);
6261 try {
6262 intent.setData(Uri.parse(uri));
6263 } catch (IllegalArgumentException e) {
6264 throw new URISyntaxException(uri, e.getMessage());
6265 }
6266 return intent;
6267 }
6268 }
Tom Taylord4a47292009-12-21 13:59:18 -08006269
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006270 i = uri.lastIndexOf("#");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006271 // simple case
6272 if (i == -1) {
6273 if (!androidApp) {
6274 return new Intent(ACTION_VIEW, Uri.parse(uri));
6275 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006276
6277 // old format Intent URI
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006278 } else if (!uri.startsWith("#Intent;", i)) {
6279 if (!androidApp) {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006280 return getIntentOld(uri, flags);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006281 } else {
6282 i = -1;
6283 }
6284 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006285
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006286 // new format
6287 Intent intent = new Intent(ACTION_VIEW);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006288 Intent baseIntent = intent;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006289 boolean explicitAction = false;
6290 boolean inSelector = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006291
6292 // fetch data part, if present
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006293 String scheme = null;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006294 String data;
6295 if (i >= 0) {
6296 data = uri.substring(0, i);
6297 i += 8; // length of "#Intent;"
6298 } else {
6299 data = uri;
6300 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006301
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006302 // loop over contents of Intent, all name=value;
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006303 while (i >= 0 && !uri.startsWith("end", i)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006304 int eq = uri.indexOf('=', i);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006305 if (eq < 0) eq = i-1;
6306 int semi = uri.indexOf(';', i);
6307 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006308
6309 // action
6310 if (uri.startsWith("action=", i)) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08006311 intent.setAction(value);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006312 if (!inSelector) {
6313 explicitAction = true;
6314 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006315 }
6316
6317 // categories
6318 else if (uri.startsWith("category=", i)) {
6319 intent.addCategory(value);
6320 }
6321
6322 // type
6323 else if (uri.startsWith("type=", i)) {
6324 intent.mType = value;
6325 }
6326
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006327 // launch flags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006328 else if (uri.startsWith("launchFlags=", i)) {
6329 intent.mFlags = Integer.decode(value).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006330 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6331 intent.mFlags &= ~IMMUTABLE_FLAGS;
6332 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006333 }
6334
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006335 // package
6336 else if (uri.startsWith("package=", i)) {
6337 intent.mPackage = value;
6338 }
6339
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006340 // component
6341 else if (uri.startsWith("component=", i)) {
6342 intent.mComponent = ComponentName.unflattenFromString(value);
6343 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006344
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006345 // scheme
6346 else if (uri.startsWith("scheme=", i)) {
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006347 if (inSelector) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006348 intent.mData = Uri.parse(value + ":");
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006349 } else {
6350 scheme = value;
6351 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006352 }
6353
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08006354 // source bounds
6355 else if (uri.startsWith("sourceBounds=", i)) {
6356 intent.mSourceBounds = Rect.unflattenFromString(value);
6357 }
6358
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006359 // selector
6360 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6361 intent = new Intent();
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006362 inSelector = true;
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006363 }
6364
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006365 // extra
6366 else {
6367 String key = Uri.decode(uri.substring(i + 2, eq));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006368 // create Bundle if it doesn't already exist
6369 if (intent.mExtras == null) intent.mExtras = new Bundle();
6370 Bundle b = intent.mExtras;
6371 // add EXTRA
6372 if (uri.startsWith("S.", i)) b.putString(key, value);
6373 else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6374 else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6375 else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6376 else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6377 else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6378 else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6379 else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6380 else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6381 else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6382 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006383
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006384 // move to the next item
6385 i = semi + 1;
6386 }
6387
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006388 if (inSelector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006389 // The Intent had a selector; fix it up.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006390 if (baseIntent.mPackage == null) {
6391 baseIntent.setSelector(intent);
6392 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08006393 intent = baseIntent;
6394 }
6395
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006396 if (data != null) {
6397 if (data.startsWith("intent:")) {
6398 data = data.substring(7);
6399 if (scheme != null) {
6400 data = scheme + ':' + data;
6401 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006402 } else if (data.startsWith("android-app:")) {
6403 if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6404 // Correctly formed android-app, first part is package name.
6405 int end = data.indexOf('/', 14);
6406 if (end < 0) {
6407 // All we have is a package name.
6408 intent.mPackage = data.substring(14);
6409 if (!explicitAction) {
6410 intent.setAction(ACTION_MAIN);
6411 }
6412 data = "";
6413 } else {
6414 // Target the Intent at the given package name always.
6415 String authority = null;
6416 intent.mPackage = data.substring(14, end);
6417 int newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006418 if ((end+1) < data.length()) {
6419 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6420 // Found a scheme, remember it.
6421 scheme = data.substring(end+1, newEnd);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006422 end = newEnd;
Dianne Hackborn80b1c562014-12-09 20:22:08 -08006423 if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6424 // Found a authority, remember it.
6425 authority = data.substring(end+1, newEnd);
6426 end = newEnd;
6427 }
6428 } else {
6429 // All we have is a scheme.
6430 scheme = data.substring(end+1);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08006431 }
6432 }
6433 if (scheme == null) {
6434 // If there was no scheme, then this just targets the package.
6435 if (!explicitAction) {
6436 intent.setAction(ACTION_MAIN);
6437 }
6438 data = "";
6439 } else if (authority == null) {
6440 data = scheme + ":";
6441 } else {
6442 data = scheme + "://" + authority + data.substring(end);
6443 }
6444 }
6445 } else {
6446 data = "";
6447 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006448 }
Tom Taylord4a47292009-12-21 13:59:18 -08006449
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07006450 if (data.length() > 0) {
6451 try {
6452 intent.mData = Uri.parse(data);
6453 } catch (IllegalArgumentException e) {
6454 throw new URISyntaxException(uri, e.getMessage());
6455 }
6456 }
6457 }
Tom Taylord4a47292009-12-21 13:59:18 -08006458
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006459 return intent;
The Android Open Source Project10592532009-03-18 17:39:46 -07006460
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006461 } catch (IndexOutOfBoundsException e) {
6462 throw new URISyntaxException(uri, "illegal Intent URI format", i);
6463 }
6464 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006465
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006466 public static Intent getIntentOld(String uri) throws URISyntaxException {
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006467 return getIntentOld(uri, 0);
6468 }
6469
6470 private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006471 Intent intent;
6472
6473 int i = uri.lastIndexOf('#');
6474 if (i >= 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006475 String action = null;
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006476 final int intentFragmentStart = i;
6477 boolean isIntentFragment = false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006478
6479 i++;
6480
6481 if (uri.regionMatches(i, "action(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006482 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006483 i += 7;
6484 int j = uri.indexOf(')', i);
6485 action = uri.substring(i, j);
6486 i = j + 1;
6487 }
6488
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006489 intent = new Intent(action);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006490
6491 if (uri.regionMatches(i, "categories(", 0, 11)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006492 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006493 i += 11;
6494 int j = uri.indexOf(')', i);
6495 while (i < j) {
6496 int sep = uri.indexOf('!', i);
Alan Viverette0adf32b2014-09-18 12:53:16 -07006497 if (sep < 0 || sep > j) sep = j;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006498 if (i < sep) {
6499 intent.addCategory(uri.substring(i, sep));
6500 }
6501 i = sep + 1;
6502 }
6503 i = j + 1;
6504 }
6505
6506 if (uri.regionMatches(i, "type(", 0, 5)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006507 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006508 i += 5;
6509 int j = uri.indexOf(')', i);
6510 intent.mType = uri.substring(i, j);
6511 i = j + 1;
6512 }
6513
6514 if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006515 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006516 i += 12;
6517 int j = uri.indexOf(')', i);
6518 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
Dianne Hackborn24b1c232014-11-20 17:17:39 -08006519 if ((flags& URI_ALLOW_UNSAFE) == 0) {
6520 intent.mFlags &= ~IMMUTABLE_FLAGS;
6521 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006522 i = j + 1;
6523 }
6524
6525 if (uri.regionMatches(i, "component(", 0, 10)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006526 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006527 i += 10;
6528 int j = uri.indexOf(')', i);
6529 int sep = uri.indexOf('!', i);
6530 if (sep >= 0 && sep < j) {
6531 String pkg = uri.substring(i, sep);
6532 String cls = uri.substring(sep + 1, j);
6533 intent.mComponent = new ComponentName(pkg, cls);
6534 }
6535 i = j + 1;
6536 }
6537
6538 if (uri.regionMatches(i, "extras(", 0, 7)) {
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006539 isIntentFragment = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006540 i += 7;
The Android Open Source Project10592532009-03-18 17:39:46 -07006541
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006542 final int closeParen = uri.indexOf(')', i);
6543 if (closeParen == -1) throw new URISyntaxException(uri,
6544 "EXTRA missing trailing ')'", i);
6545
6546 while (i < closeParen) {
6547 // fetch the key value
6548 int j = uri.indexOf('=', i);
6549 if (j <= i + 1 || i >= closeParen) {
6550 throw new URISyntaxException(uri, "EXTRA missing '='", i);
6551 }
6552 char type = uri.charAt(i);
6553 i++;
6554 String key = uri.substring(i, j);
6555 i = j + 1;
The Android Open Source Project10592532009-03-18 17:39:46 -07006556
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006557 // get type-value
6558 j = uri.indexOf('!', i);
6559 if (j == -1 || j >= closeParen) j = closeParen;
6560 if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6561 String value = uri.substring(i, j);
6562 i = j;
6563
6564 // create Bundle if it doesn't already exist
6565 if (intent.mExtras == null) intent.mExtras = new Bundle();
The Android Open Source Project10592532009-03-18 17:39:46 -07006566
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006567 // add item to bundle
6568 try {
6569 switch (type) {
6570 case 'S':
6571 intent.mExtras.putString(key, Uri.decode(value));
6572 break;
6573 case 'B':
6574 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6575 break;
6576 case 'b':
6577 intent.mExtras.putByte(key, Byte.parseByte(value));
6578 break;
6579 case 'c':
6580 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6581 break;
6582 case 'd':
6583 intent.mExtras.putDouble(key, Double.parseDouble(value));
6584 break;
6585 case 'f':
6586 intent.mExtras.putFloat(key, Float.parseFloat(value));
6587 break;
6588 case 'i':
6589 intent.mExtras.putInt(key, Integer.parseInt(value));
6590 break;
6591 case 'l':
6592 intent.mExtras.putLong(key, Long.parseLong(value));
6593 break;
6594 case 's':
6595 intent.mExtras.putShort(key, Short.parseShort(value));
6596 break;
6597 default:
6598 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
6599 }
6600 } catch (NumberFormatException e) {
6601 throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
6602 }
The Android Open Source Project10592532009-03-18 17:39:46 -07006603
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006604 char ch = uri.charAt(i);
6605 if (ch == ')') break;
6606 if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6607 i++;
6608 }
6609 }
6610
Dianne Hackborn6cca1592009-09-20 12:40:03 -07006611 if (isIntentFragment) {
6612 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
6613 } else {
6614 intent.mData = Uri.parse(uri);
6615 }
Tom Taylord4a47292009-12-21 13:59:18 -08006616
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07006617 if (intent.mAction == null) {
6618 // By default, if no action is specified, then use VIEW.
6619 intent.mAction = ACTION_VIEW;
6620 }
6621
6622 } else {
6623 intent = new Intent(ACTION_VIEW, Uri.parse(uri));
6624 }
6625
6626 return intent;
6627 }
6628
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006629 /** @hide */
6630 public interface CommandOptionHandler {
6631 boolean handleOption(String opt, ShellCommand cmd);
6632 }
6633
6634 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01006635 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006636 public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
6637 throws URISyntaxException {
6638 Intent intent = new Intent();
6639 Intent baseIntent = intent;
6640 boolean hasIntentInfo = false;
6641
6642 Uri data = null;
6643 String type = null;
6644
6645 String opt;
6646 while ((opt=cmd.getNextOption()) != null) {
6647 switch (opt) {
6648 case "-a":
6649 intent.setAction(cmd.getNextArgRequired());
6650 if (intent == baseIntent) {
6651 hasIntentInfo = true;
6652 }
6653 break;
6654 case "-d":
6655 data = Uri.parse(cmd.getNextArgRequired());
6656 if (intent == baseIntent) {
6657 hasIntentInfo = true;
6658 }
6659 break;
6660 case "-t":
6661 type = cmd.getNextArgRequired();
6662 if (intent == baseIntent) {
6663 hasIntentInfo = true;
6664 }
6665 break;
6666 case "-c":
6667 intent.addCategory(cmd.getNextArgRequired());
6668 if (intent == baseIntent) {
6669 hasIntentInfo = true;
6670 }
6671 break;
6672 case "-e":
6673 case "--es": {
6674 String key = cmd.getNextArgRequired();
6675 String value = cmd.getNextArgRequired();
6676 intent.putExtra(key, value);
6677 }
6678 break;
6679 case "--esn": {
6680 String key = cmd.getNextArgRequired();
6681 intent.putExtra(key, (String) null);
6682 }
6683 break;
6684 case "--ei": {
6685 String key = cmd.getNextArgRequired();
6686 String value = cmd.getNextArgRequired();
6687 intent.putExtra(key, Integer.decode(value));
6688 }
6689 break;
6690 case "--eu": {
6691 String key = cmd.getNextArgRequired();
6692 String value = cmd.getNextArgRequired();
6693 intent.putExtra(key, Uri.parse(value));
6694 }
6695 break;
6696 case "--ecn": {
6697 String key = cmd.getNextArgRequired();
6698 String value = cmd.getNextArgRequired();
6699 ComponentName cn = ComponentName.unflattenFromString(value);
6700 if (cn == null)
6701 throw new IllegalArgumentException("Bad component name: " + value);
6702 intent.putExtra(key, cn);
6703 }
6704 break;
6705 case "--eia": {
6706 String key = cmd.getNextArgRequired();
6707 String value = cmd.getNextArgRequired();
6708 String[] strings = value.split(",");
6709 int[] list = new int[strings.length];
6710 for (int i = 0; i < strings.length; i++) {
6711 list[i] = Integer.decode(strings[i]);
6712 }
6713 intent.putExtra(key, list);
6714 }
6715 break;
6716 case "--eial": {
6717 String key = cmd.getNextArgRequired();
6718 String value = cmd.getNextArgRequired();
6719 String[] strings = value.split(",");
6720 ArrayList<Integer> list = new ArrayList<>(strings.length);
6721 for (int i = 0; i < strings.length; i++) {
6722 list.add(Integer.decode(strings[i]));
6723 }
6724 intent.putExtra(key, list);
6725 }
6726 break;
6727 case "--el": {
6728 String key = cmd.getNextArgRequired();
6729 String value = cmd.getNextArgRequired();
6730 intent.putExtra(key, Long.valueOf(value));
6731 }
6732 break;
6733 case "--ela": {
6734 String key = cmd.getNextArgRequired();
6735 String value = cmd.getNextArgRequired();
6736 String[] strings = value.split(",");
6737 long[] list = new long[strings.length];
6738 for (int i = 0; i < strings.length; i++) {
6739 list[i] = Long.valueOf(strings[i]);
6740 }
6741 intent.putExtra(key, list);
6742 hasIntentInfo = true;
6743 }
6744 break;
6745 case "--elal": {
6746 String key = cmd.getNextArgRequired();
6747 String value = cmd.getNextArgRequired();
6748 String[] strings = value.split(",");
6749 ArrayList<Long> list = new ArrayList<>(strings.length);
6750 for (int i = 0; i < strings.length; i++) {
6751 list.add(Long.valueOf(strings[i]));
6752 }
6753 intent.putExtra(key, list);
6754 hasIntentInfo = true;
6755 }
6756 break;
6757 case "--ef": {
6758 String key = cmd.getNextArgRequired();
6759 String value = cmd.getNextArgRequired();
6760 intent.putExtra(key, Float.valueOf(value));
6761 hasIntentInfo = true;
6762 }
6763 break;
6764 case "--efa": {
6765 String key = cmd.getNextArgRequired();
6766 String value = cmd.getNextArgRequired();
6767 String[] strings = value.split(",");
6768 float[] list = new float[strings.length];
6769 for (int i = 0; i < strings.length; i++) {
6770 list[i] = Float.valueOf(strings[i]);
6771 }
6772 intent.putExtra(key, list);
6773 hasIntentInfo = true;
6774 }
6775 break;
6776 case "--efal": {
6777 String key = cmd.getNextArgRequired();
6778 String value = cmd.getNextArgRequired();
6779 String[] strings = value.split(",");
6780 ArrayList<Float> list = new ArrayList<>(strings.length);
6781 for (int i = 0; i < strings.length; i++) {
6782 list.add(Float.valueOf(strings[i]));
6783 }
6784 intent.putExtra(key, list);
6785 hasIntentInfo = true;
6786 }
6787 break;
6788 case "--esa": {
6789 String key = cmd.getNextArgRequired();
6790 String value = cmd.getNextArgRequired();
6791 // Split on commas unless they are preceeded by an escape.
6792 // The escape character must be escaped for the string and
6793 // again for the regex, thus four escape characters become one.
6794 String[] strings = value.split("(?<!\\\\),");
6795 intent.putExtra(key, strings);
6796 hasIntentInfo = true;
6797 }
6798 break;
6799 case "--esal": {
6800 String key = cmd.getNextArgRequired();
6801 String value = cmd.getNextArgRequired();
6802 // Split on commas unless they are preceeded by an escape.
6803 // The escape character must be escaped for the string and
6804 // again for the regex, thus four escape characters become one.
6805 String[] strings = value.split("(?<!\\\\),");
6806 ArrayList<String> list = new ArrayList<>(strings.length);
6807 for (int i = 0; i < strings.length; i++) {
6808 list.add(strings[i]);
6809 }
6810 intent.putExtra(key, list);
6811 hasIntentInfo = true;
6812 }
6813 break;
6814 case "--ez": {
6815 String key = cmd.getNextArgRequired();
6816 String value = cmd.getNextArgRequired().toLowerCase();
6817 // Boolean.valueOf() results in false for anything that is not "true", which is
6818 // error-prone in shell commands
6819 boolean arg;
6820 if ("true".equals(value) || "t".equals(value)) {
6821 arg = true;
6822 } else if ("false".equals(value) || "f".equals(value)) {
6823 arg = false;
6824 } else {
6825 try {
6826 arg = Integer.decode(value) != 0;
6827 } catch (NumberFormatException ex) {
6828 throw new IllegalArgumentException("Invalid boolean value: " + value);
6829 }
6830 }
6831
6832 intent.putExtra(key, arg);
6833 }
6834 break;
6835 case "-n": {
6836 String str = cmd.getNextArgRequired();
6837 ComponentName cn = ComponentName.unflattenFromString(str);
6838 if (cn == null)
6839 throw new IllegalArgumentException("Bad component name: " + str);
6840 intent.setComponent(cn);
6841 if (intent == baseIntent) {
6842 hasIntentInfo = true;
6843 }
6844 }
6845 break;
6846 case "-p": {
6847 String str = cmd.getNextArgRequired();
6848 intent.setPackage(str);
6849 if (intent == baseIntent) {
6850 hasIntentInfo = true;
6851 }
6852 }
6853 break;
6854 case "-f":
6855 String str = cmd.getNextArgRequired();
6856 intent.setFlags(Integer.decode(str).intValue());
6857 break;
6858 case "--grant-read-uri-permission":
6859 intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
6860 break;
6861 case "--grant-write-uri-permission":
6862 intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
6863 break;
6864 case "--grant-persistable-uri-permission":
6865 intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
6866 break;
6867 case "--grant-prefix-uri-permission":
6868 intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
6869 break;
6870 case "--exclude-stopped-packages":
6871 intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
6872 break;
6873 case "--include-stopped-packages":
6874 intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
6875 break;
6876 case "--debug-log-resolution":
6877 intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
6878 break;
6879 case "--activity-brought-to-front":
6880 intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
6881 break;
6882 case "--activity-clear-top":
6883 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
6884 break;
6885 case "--activity-clear-when-task-reset":
6886 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
6887 break;
6888 case "--activity-exclude-from-recents":
6889 intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
6890 break;
6891 case "--activity-launched-from-history":
6892 intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
6893 break;
6894 case "--activity-multiple-task":
6895 intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
6896 break;
6897 case "--activity-no-animation":
6898 intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
6899 break;
6900 case "--activity-no-history":
6901 intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
6902 break;
6903 case "--activity-no-user-action":
6904 intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
6905 break;
6906 case "--activity-previous-is-top":
6907 intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
6908 break;
6909 case "--activity-reorder-to-front":
6910 intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
6911 break;
6912 case "--activity-reset-task-if-needed":
6913 intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
6914 break;
6915 case "--activity-single-top":
6916 intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
6917 break;
6918 case "--activity-clear-task":
6919 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
6920 break;
6921 case "--activity-task-on-home":
6922 intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
6923 break;
Patrick Baumann229141f2018-04-06 13:53:25 -07006924 case "--activity-match-external":
6925 intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
6926 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006927 case "--receiver-registered-only":
6928 intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
6929 break;
6930 case "--receiver-replace-pending":
6931 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
6932 break;
Felipe Leme3cb48cd2016-01-27 08:39:09 -08006933 case "--receiver-foreground":
6934 intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
6935 break;
Dianne Hackborn797772b12017-02-08 16:33:43 -08006936 case "--receiver-no-abort":
6937 intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
6938 break;
6939 case "--receiver-include-background":
6940 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
6941 break;
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08006942 case "--selector":
6943 intent.setDataAndType(data, type);
6944 intent = new Intent();
6945 break;
6946 default:
6947 if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
6948 // Okay, caller handled this option.
6949 } else {
6950 throw new IllegalArgumentException("Unknown option: " + opt);
6951 }
6952 break;
6953 }
6954 }
6955 intent.setDataAndType(data, type);
6956
6957 final boolean hasSelector = intent != baseIntent;
6958 if (hasSelector) {
6959 // A selector was specified; fix up.
6960 baseIntent.setSelector(intent);
6961 intent = baseIntent;
6962 }
6963
6964 String arg = cmd.getNextArg();
6965 baseIntent = null;
6966 if (arg == null) {
6967 if (hasSelector) {
6968 // If a selector has been specified, and no arguments
6969 // have been supplied for the main Intent, then we can
6970 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
6971 // need to have a component name specified yet, the
6972 // selector will take care of that.
6973 baseIntent = new Intent(Intent.ACTION_MAIN);
6974 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6975 }
6976 } else if (arg.indexOf(':') >= 0) {
6977 // The argument is a URI. Fully parse it, and use that result
6978 // to fill in any data not specified so far.
6979 baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
6980 | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
6981 } else if (arg.indexOf('/') >= 0) {
6982 // The argument is a component name. Build an Intent to launch
6983 // it.
6984 baseIntent = new Intent(Intent.ACTION_MAIN);
6985 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6986 baseIntent.setComponent(ComponentName.unflattenFromString(arg));
6987 } else {
6988 // Assume the argument is a package name.
6989 baseIntent = new Intent(Intent.ACTION_MAIN);
6990 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
6991 baseIntent.setPackage(arg);
6992 }
6993 if (baseIntent != null) {
6994 Bundle extras = intent.getExtras();
6995 intent.replaceExtras((Bundle)null);
6996 Bundle uriExtras = baseIntent.getExtras();
6997 baseIntent.replaceExtras((Bundle)null);
6998 if (intent.getAction() != null && baseIntent.getCategories() != null) {
6999 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7000 for (String c : cats) {
7001 baseIntent.removeCategory(c);
7002 }
7003 }
7004 intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7005 if (extras == null) {
7006 extras = uriExtras;
7007 } else if (uriExtras != null) {
7008 uriExtras.putAll(extras);
7009 extras = uriExtras;
7010 }
7011 intent.replaceExtras(extras);
7012 hasIntentInfo = true;
7013 }
7014
7015 if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7016 return intent;
7017 }
7018
7019 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007020 @UnsupportedAppUsage
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007021 public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7022 final String[] lines = new String[] {
7023 "<INTENT> specifications include these flags and arguments:",
7024 " [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
7025 " [-c <CATEGORY> [-c <CATEGORY>] ...]",
Felipe Leme4e02e252018-04-20 11:25:59 -07007026 " [-n <COMPONENT_NAME>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007027 " [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7028 " [--esn <EXTRA_KEY> ...]",
7029 " [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7030 " [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7031 " [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7032 " [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7033 " [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7034 " [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7035 " [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7036 " (mutiple extras passed as Integer[])",
7037 " [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7038 " (mutiple extras passed as List<Integer>)",
7039 " [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7040 " (mutiple extras passed as Long[])",
7041 " [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7042 " (mutiple extras passed as List<Long>)",
7043 " [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7044 " (mutiple extras passed as Float[])",
7045 " [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7046 " (mutiple extras passed as List<Float>)",
7047 " [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7048 " (mutiple extras passed as String[]; to embed a comma into a string,",
7049 " escape it using \"\\,\")",
7050 " [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7051 " (mutiple extras passed as List<String>; to embed a comma into a string,",
7052 " escape it using \"\\,\")",
Felipe Leme545569d2016-01-11 16:27:58 -08007053 " [-f <FLAG>]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007054 " [--grant-read-uri-permission] [--grant-write-uri-permission]",
7055 " [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7056 " [--debug-log-resolution] [--exclude-stopped-packages]",
7057 " [--include-stopped-packages]",
7058 " [--activity-brought-to-front] [--activity-clear-top]",
7059 " [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7060 " [--activity-launched-from-history] [--activity-multiple-task]",
7061 " [--activity-no-animation] [--activity-no-history]",
7062 " [--activity-no-user-action] [--activity-previous-is-top]",
7063 " [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7064 " [--activity-single-top] [--activity-clear-task]",
Patrick Baumann229141f2018-04-06 13:53:25 -07007065 " [--activity-task-on-home] [--activity-match-external]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007066 " [--receiver-registered-only] [--receiver-replace-pending]",
Dianne Hackborn797772b12017-02-08 16:33:43 -08007067 " [--receiver-foreground] [--receiver-no-abort]",
7068 " [--receiver-include-background]",
Dianne Hackborn3cdb56e2015-11-11 12:45:44 -08007069 " [--selector]",
7070 " [<URI> | <PACKAGE> | <COMPONENT>]"
7071 };
7072 for (String line : lines) {
7073 pw.print(prefix);
7074 pw.println(line);
7075 }
7076 }
7077
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007078 /**
7079 * Retrieve the general action to be performed, such as
7080 * {@link #ACTION_VIEW}. The action describes the general way the rest of
7081 * the information in the intent should be interpreted -- most importantly,
7082 * what to do with the data returned by {@link #getData}.
7083 *
7084 * @return The action of this intent or null if none is specified.
7085 *
7086 * @see #setAction
7087 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007088 public @Nullable String getAction() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007089 return mAction;
7090 }
7091
7092 /**
7093 * Retrieve data this intent is operating on. This URI specifies the name
7094 * of the data; often it uses the content: scheme, specifying data in a
7095 * content provider. Other schemes may be handled by specific activities,
7096 * such as http: by the web browser.
7097 *
7098 * @return The URI of the data this intent is targeting or null.
7099 *
7100 * @see #getScheme
7101 * @see #setData
7102 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007103 public @Nullable Uri getData() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007104 return mData;
7105 }
7106
7107 /**
7108 * The same as {@link #getData()}, but returns the URI as an encoded
7109 * String.
7110 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007111 public @Nullable String getDataString() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007112 return mData != null ? mData.toString() : null;
7113 }
7114
7115 /**
7116 * Return the scheme portion of the intent's data. If the data is null or
7117 * does not include a scheme, null is returned. Otherwise, the scheme
7118 * prefix without the final ':' is returned, i.e. "http".
7119 *
7120 * <p>This is the same as calling getData().getScheme() (and checking for
7121 * null data).
7122 *
7123 * @return The scheme of this intent.
7124 *
7125 * @see #getData
7126 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007127 public @Nullable String getScheme() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007128 return mData != null ? mData.getScheme() : null;
7129 }
7130
7131 /**
7132 * Retrieve any explicit MIME type included in the intent. This is usually
7133 * null, as the type is determined by the intent data.
7134 *
7135 * @return If a type was manually set, it is returned; else null is
7136 * returned.
7137 *
7138 * @see #resolveType(ContentResolver)
7139 * @see #setType
7140 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007141 public @Nullable String getType() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007142 return mType;
7143 }
7144
7145 /**
7146 * Return the MIME data type of this intent. If the type field is
7147 * explicitly set, that is simply returned. Otherwise, if the data is set,
7148 * the type of that data is returned. If neither fields are set, a null is
7149 * returned.
7150 *
7151 * @return The MIME type of this intent.
7152 *
7153 * @see #getType
7154 * @see #resolveType(ContentResolver)
7155 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007156 public @Nullable String resolveType(@NonNull Context context) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007157 return resolveType(context.getContentResolver());
7158 }
7159
7160 /**
7161 * Return the MIME data type of this intent. If the type field is
7162 * explicitly set, that is simply returned. Otherwise, if the data is set,
7163 * the type of that data is returned. If neither fields are set, a null is
7164 * returned.
7165 *
7166 * @param resolver A ContentResolver that can be used to determine the MIME
7167 * type of the intent's data.
7168 *
7169 * @return The MIME type of this intent.
7170 *
7171 * @see #getType
7172 * @see #resolveType(Context)
7173 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007174 public @Nullable String resolveType(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007175 if (mType != null) {
7176 return mType;
7177 }
7178 if (mData != null) {
7179 if ("content".equals(mData.getScheme())) {
7180 return resolver.getType(mData);
7181 }
7182 }
7183 return null;
7184 }
7185
7186 /**
7187 * Return the MIME data type of this intent, only if it will be needed for
7188 * intent resolution. This is not generally useful for application code;
7189 * it is used by the frameworks for communicating with back-end system
7190 * services.
7191 *
7192 * @param resolver A ContentResolver that can be used to determine the MIME
7193 * type of the intent's data.
7194 *
7195 * @return The MIME type of this intent, or null if it is unknown or not
7196 * needed.
7197 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007198 public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007199 if (mComponent != null) {
7200 return mType;
7201 }
7202 return resolveType(resolver);
7203 }
7204
7205 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09007206 * Check if a category exists in the intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007207 *
7208 * @param category The category to check.
7209 *
7210 * @return boolean True if the intent contains the category, else false.
7211 *
7212 * @see #getCategories
7213 * @see #addCategory
7214 */
7215 public boolean hasCategory(String category) {
7216 return mCategories != null && mCategories.contains(category);
7217 }
7218
7219 /**
7220 * Return the set of all categories in the intent. If there are no categories,
7221 * returns NULL.
7222 *
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007223 * @return The set of categories you can examine. Do not modify!
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007224 *
7225 * @see #hasCategory
7226 * @see #addCategory
7227 */
7228 public Set<String> getCategories() {
7229 return mCategories;
7230 }
7231
7232 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007233 * Return the specific selector associated with this Intent. If there is
7234 * none, returns null. See {@link #setSelector} for more information.
7235 *
7236 * @see #setSelector
7237 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007238 public @Nullable Intent getSelector() {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08007239 return mSelector;
7240 }
7241
7242 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007243 * Return the {@link ClipData} associated with this Intent. If there is
7244 * none, returns null. See {@link #setClipData} for more information.
7245 *
John Spurlock125d1332013-11-25 11:58:37 -05007246 * @see #setClipData
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007247 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007248 public @Nullable ClipData getClipData() {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007249 return mClipData;
7250 }
7251
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01007252 /** @hide */
7253 public int getContentUserHint() {
7254 return mContentUserHint;
7255 }
7256
Todd Kennedyb3b431302017-03-20 16:05:48 -07007257 /** @hide */
7258 public String getLaunchToken() {
7259 return mLaunchToken;
7260 }
7261
7262 /** @hide */
7263 public void setLaunchToken(String launchToken) {
7264 mLaunchToken = launchToken;
7265 }
7266
Dianne Hackborn21c241e2012-03-08 13:57:23 -08007267 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007268 * Sets the ClassLoader that will be used when unmarshalling
7269 * any Parcelable values from the extras of this Intent.
7270 *
7271 * @param loader a ClassLoader, or null to use the default loader
7272 * at the time of unmarshalling.
7273 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007274 public void setExtrasClassLoader(@Nullable ClassLoader loader) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007275 if (mExtras != null) {
7276 mExtras.setClassLoader(loader);
7277 }
7278 }
7279
7280 /**
7281 * Returns true if an extra value is associated with the given name.
7282 * @param name the extra's name
7283 * @return true if the given extra is present.
7284 */
7285 public boolean hasExtra(String name) {
7286 return mExtras != null && mExtras.containsKey(name);
7287 }
7288
7289 /**
7290 * Returns true if the Intent's extras contain a parcelled file descriptor.
7291 * @return true if the Intent contains a parcelled file descriptor.
7292 */
7293 public boolean hasFileDescriptors() {
7294 return mExtras != null && mExtras.hasFileDescriptors();
7295 }
The Android Open Source Project10592532009-03-18 17:39:46 -07007296
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007297 /** {@hide} */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007298 @UnsupportedAppUsage
Dianne Hackborn9ecebbf2011-09-28 23:19:47 -04007299 public void setAllowFds(boolean allowFds) {
7300 if (mExtras != null) {
7301 mExtras.setAllowFds(allowFds);
7302 }
7303 }
7304
Jeff Sharkeyd136e512016-03-09 22:30:56 -07007305 /** {@hide} */
7306 public void setDefusable(boolean defusable) {
7307 if (mExtras != null) {
7308 mExtras.setDefusable(defusable);
7309 }
7310 }
7311
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007312 /**
7313 * Retrieve extended data from the intent.
7314 *
7315 * @param name The name of the desired item.
7316 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007317 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007318 * or null if none was found.
7319 *
7320 * @deprecated
7321 * @hide
7322 */
7323 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007324 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007325 public Object getExtra(String name) {
7326 return getExtra(name, null);
7327 }
7328
7329 /**
7330 * Retrieve extended data from the intent.
7331 *
7332 * @param name The name of the desired item.
7333 * @param defaultValue the value to be returned if no value of the desired
7334 * type is stored with the given name.
7335 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007336 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007337 * or the default value if none was found.
7338 *
7339 * @see #putExtra(String, boolean)
7340 */
7341 public boolean getBooleanExtra(String name, boolean defaultValue) {
7342 return mExtras == null ? defaultValue :
7343 mExtras.getBoolean(name, defaultValue);
7344 }
7345
7346 /**
7347 * Retrieve extended data from the intent.
7348 *
7349 * @param name The name of the desired item.
7350 * @param defaultValue the value to be returned if no value of the desired
7351 * type is stored with the given name.
7352 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007353 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007354 * or the default value if none was found.
7355 *
7356 * @see #putExtra(String, byte)
7357 */
7358 public byte getByteExtra(String name, byte defaultValue) {
7359 return mExtras == null ? defaultValue :
7360 mExtras.getByte(name, defaultValue);
7361 }
7362
7363 /**
7364 * Retrieve extended data from the intent.
7365 *
7366 * @param name The name of the desired item.
7367 * @param defaultValue the value to be returned if no value of the desired
7368 * type is stored with the given name.
7369 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007370 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007371 * or the default value if none was found.
7372 *
7373 * @see #putExtra(String, short)
7374 */
7375 public short getShortExtra(String name, short defaultValue) {
7376 return mExtras == null ? defaultValue :
7377 mExtras.getShort(name, defaultValue);
7378 }
7379
7380 /**
7381 * Retrieve extended data from the intent.
7382 *
7383 * @param name The name of the desired item.
7384 * @param defaultValue the value to be returned if no value of the desired
7385 * type is stored with the given name.
7386 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007387 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007388 * or the default value if none was found.
7389 *
7390 * @see #putExtra(String, char)
7391 */
7392 public char getCharExtra(String name, char defaultValue) {
7393 return mExtras == null ? defaultValue :
7394 mExtras.getChar(name, defaultValue);
7395 }
7396
7397 /**
7398 * Retrieve extended data from the intent.
7399 *
7400 * @param name The name of the desired item.
7401 * @param defaultValue the value to be returned if no value of the desired
7402 * type is stored with the given name.
7403 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007404 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007405 * or the default value if none was found.
7406 *
7407 * @see #putExtra(String, int)
7408 */
7409 public int getIntExtra(String name, int defaultValue) {
7410 return mExtras == null ? defaultValue :
7411 mExtras.getInt(name, defaultValue);
7412 }
7413
7414 /**
7415 * Retrieve extended data from the intent.
7416 *
7417 * @param name The name of the desired item.
7418 * @param defaultValue the value to be returned if no value of the desired
7419 * type is stored with the given name.
7420 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007421 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007422 * or the default value if none was found.
7423 *
7424 * @see #putExtra(String, long)
7425 */
7426 public long getLongExtra(String name, long defaultValue) {
7427 return mExtras == null ? defaultValue :
7428 mExtras.getLong(name, defaultValue);
7429 }
7430
7431 /**
7432 * Retrieve extended data from the intent.
7433 *
7434 * @param name The name of the desired item.
7435 * @param defaultValue the value to be returned if no value of the desired
7436 * type is stored with the given name.
7437 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007438 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007439 * or the default value if no such item is present
7440 *
7441 * @see #putExtra(String, float)
7442 */
7443 public float getFloatExtra(String name, float defaultValue) {
7444 return mExtras == null ? defaultValue :
7445 mExtras.getFloat(name, defaultValue);
7446 }
7447
7448 /**
7449 * Retrieve extended data from the intent.
7450 *
7451 * @param name The name of the desired item.
7452 * @param defaultValue the value to be returned if no value of the desired
7453 * type is stored with the given name.
7454 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007455 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007456 * or the default value if none was found.
7457 *
7458 * @see #putExtra(String, double)
7459 */
7460 public double getDoubleExtra(String name, double defaultValue) {
7461 return mExtras == null ? defaultValue :
7462 mExtras.getDouble(name, defaultValue);
7463 }
7464
7465 /**
7466 * Retrieve extended data from the intent.
7467 *
7468 * @param name The name of the desired item.
7469 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007470 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007471 * or null if no String value was found.
7472 *
7473 * @see #putExtra(String, String)
7474 */
7475 public String getStringExtra(String name) {
7476 return mExtras == null ? null : mExtras.getString(name);
7477 }
7478
7479 /**
7480 * Retrieve extended data from the intent.
7481 *
7482 * @param name The name of the desired item.
7483 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007484 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007485 * or null if no CharSequence value was found.
7486 *
7487 * @see #putExtra(String, CharSequence)
7488 */
7489 public CharSequence getCharSequenceExtra(String name) {
7490 return mExtras == null ? null : mExtras.getCharSequence(name);
7491 }
7492
7493 /**
7494 * Retrieve extended data from the intent.
7495 *
7496 * @param name The name of the desired item.
7497 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007498 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007499 * or null if no Parcelable value was found.
7500 *
7501 * @see #putExtra(String, Parcelable)
7502 */
7503 public <T extends Parcelable> T getParcelableExtra(String name) {
7504 return mExtras == null ? null : mExtras.<T>getParcelable(name);
7505 }
7506
7507 /**
7508 * Retrieve extended data from the intent.
7509 *
7510 * @param name The name of the desired item.
7511 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007512 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007513 * or null if no Parcelable[] value was found.
7514 *
7515 * @see #putExtra(String, Parcelable[])
7516 */
7517 public Parcelable[] getParcelableArrayExtra(String name) {
7518 return mExtras == null ? null : mExtras.getParcelableArray(name);
7519 }
7520
7521 /**
7522 * Retrieve extended data from the intent.
7523 *
7524 * @param name The name of the desired item.
7525 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007526 * @return the value of an item previously added with
7527 * putParcelableArrayListExtra(), or null if no
7528 * ArrayList<Parcelable> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007529 *
7530 * @see #putParcelableArrayListExtra(String, ArrayList)
7531 */
7532 public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7533 return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7534 }
7535
7536 /**
7537 * Retrieve extended data from the intent.
7538 *
7539 * @param name The name of the desired item.
7540 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007541 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007542 * or null if no Serializable value was found.
7543 *
7544 * @see #putExtra(String, Serializable)
7545 */
7546 public Serializable getSerializableExtra(String name) {
7547 return mExtras == null ? null : mExtras.getSerializable(name);
7548 }
7549
7550 /**
7551 * Retrieve extended data from the intent.
7552 *
7553 * @param name The name of the desired item.
7554 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007555 * @return the value of an item previously added with
7556 * putIntegerArrayListExtra(), or null if no
7557 * ArrayList<Integer> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007558 *
7559 * @see #putIntegerArrayListExtra(String, ArrayList)
7560 */
7561 public ArrayList<Integer> getIntegerArrayListExtra(String name) {
7562 return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7563 }
7564
7565 /**
7566 * Retrieve extended data from the intent.
7567 *
7568 * @param name The name of the desired item.
7569 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007570 * @return the value of an item previously added with
7571 * putStringArrayListExtra(), or null if no
7572 * ArrayList<String> value was found.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007573 *
7574 * @see #putStringArrayListExtra(String, ArrayList)
7575 */
7576 public ArrayList<String> getStringArrayListExtra(String name) {
7577 return mExtras == null ? null : mExtras.getStringArrayList(name);
7578 }
7579
7580 /**
7581 * Retrieve extended data from the intent.
7582 *
7583 * @param name The name of the desired item.
7584 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007585 * @return the value of an item previously added with
7586 * putCharSequenceArrayListExtra, or null if no
7587 * ArrayList<CharSequence> value was found.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007588 *
7589 * @see #putCharSequenceArrayListExtra(String, ArrayList)
7590 */
7591 public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
7592 return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
7593 }
7594
7595 /**
7596 * Retrieve extended data from the intent.
7597 *
7598 * @param name The name of the desired item.
7599 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007600 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007601 * or null if no boolean array value was found.
7602 *
7603 * @see #putExtra(String, boolean[])
7604 */
7605 public boolean[] getBooleanArrayExtra(String name) {
7606 return mExtras == null ? null : mExtras.getBooleanArray(name);
7607 }
7608
7609 /**
7610 * Retrieve extended data from the intent.
7611 *
7612 * @param name The name of the desired item.
7613 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007614 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007615 * or null if no byte array value was found.
7616 *
7617 * @see #putExtra(String, byte[])
7618 */
7619 public byte[] getByteArrayExtra(String name) {
7620 return mExtras == null ? null : mExtras.getByteArray(name);
7621 }
7622
7623 /**
7624 * Retrieve extended data from the intent.
7625 *
7626 * @param name The name of the desired item.
7627 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007628 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007629 * or null if no short array value was found.
7630 *
7631 * @see #putExtra(String, short[])
7632 */
7633 public short[] getShortArrayExtra(String name) {
7634 return mExtras == null ? null : mExtras.getShortArray(name);
7635 }
7636
7637 /**
7638 * Retrieve extended data from the intent.
7639 *
7640 * @param name The name of the desired item.
7641 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007642 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007643 * or null if no char array value was found.
7644 *
7645 * @see #putExtra(String, char[])
7646 */
7647 public char[] getCharArrayExtra(String name) {
7648 return mExtras == null ? null : mExtras.getCharArray(name);
7649 }
7650
7651 /**
7652 * Retrieve extended data from the intent.
7653 *
7654 * @param name The name of the desired item.
7655 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007656 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007657 * or null if no int array value was found.
7658 *
7659 * @see #putExtra(String, int[])
7660 */
7661 public int[] getIntArrayExtra(String name) {
7662 return mExtras == null ? null : mExtras.getIntArray(name);
7663 }
7664
7665 /**
7666 * Retrieve extended data from the intent.
7667 *
7668 * @param name The name of the desired item.
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 null if no long array value was found.
7672 *
7673 * @see #putExtra(String, long[])
7674 */
7675 public long[] getLongArrayExtra(String name) {
7676 return mExtras == null ? null : mExtras.getLongArray(name);
7677 }
7678
7679 /**
7680 * Retrieve extended data from the intent.
7681 *
7682 * @param name The name of the desired item.
7683 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007684 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007685 * or null if no float array value was found.
7686 *
7687 * @see #putExtra(String, float[])
7688 */
7689 public float[] getFloatArrayExtra(String name) {
7690 return mExtras == null ? null : mExtras.getFloatArray(name);
7691 }
7692
7693 /**
7694 * Retrieve extended data from the intent.
7695 *
7696 * @param name The name of the desired item.
7697 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007698 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007699 * or null if no double array value was found.
7700 *
7701 * @see #putExtra(String, double[])
7702 */
7703 public double[] getDoubleArrayExtra(String name) {
7704 return mExtras == null ? null : mExtras.getDoubleArray(name);
7705 }
7706
7707 /**
7708 * Retrieve extended data from the intent.
7709 *
7710 * @param name The name of the desired item.
7711 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007712 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007713 * or null if no String array value was found.
7714 *
7715 * @see #putExtra(String, String[])
7716 */
7717 public String[] getStringArrayExtra(String name) {
7718 return mExtras == null ? null : mExtras.getStringArray(name);
7719 }
7720
7721 /**
7722 * Retrieve extended data from the intent.
7723 *
7724 * @param name The name of the desired item.
7725 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007726 * @return the value of an item previously added with putExtra(),
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00007727 * or null if no CharSequence array value was found.
7728 *
7729 * @see #putExtra(String, CharSequence[])
7730 */
7731 public CharSequence[] getCharSequenceArrayExtra(String name) {
7732 return mExtras == null ? null : mExtras.getCharSequenceArray(name);
7733 }
7734
7735 /**
7736 * Retrieve extended data from the intent.
7737 *
7738 * @param name The name of the desired item.
7739 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007740 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007741 * or null if no Bundle value was found.
7742 *
7743 * @see #putExtra(String, Bundle)
7744 */
7745 public Bundle getBundleExtra(String name) {
7746 return mExtras == null ? null : mExtras.getBundle(name);
7747 }
7748
7749 /**
7750 * Retrieve extended data from the intent.
7751 *
7752 * @param name The name of the desired item.
7753 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007754 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007755 * or null if no IBinder value was found.
7756 *
7757 * @see #putExtra(String, IBinder)
7758 *
7759 * @deprecated
7760 * @hide
7761 */
7762 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007763 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007764 public IBinder getIBinderExtra(String name) {
7765 return mExtras == null ? null : mExtras.getIBinder(name);
7766 }
7767
7768 /**
7769 * Retrieve extended data from the intent.
7770 *
7771 * @param name The name of the desired item.
7772 * @param defaultValue The default value to return in case no item is
7773 * associated with the key 'name'
7774 *
Jonathan Dormodyd07017e2017-11-15 14:10:57 -07007775 * @return the value of an item previously added with putExtra(),
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007776 * or defaultValue if none was found.
7777 *
7778 * @see #putExtra
7779 *
7780 * @deprecated
7781 * @hide
7782 */
7783 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007784 @UnsupportedAppUsage
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007785 public Object getExtra(String name, Object defaultValue) {
7786 Object result = defaultValue;
7787 if (mExtras != null) {
7788 Object result2 = mExtras.get(name);
7789 if (result2 != null) {
7790 result = result2;
7791 }
7792 }
7793
7794 return result;
7795 }
7796
7797 /**
7798 * Retrieves a map of extended data from the intent.
7799 *
7800 * @return the map of all extras previously added with putExtra(),
7801 * or null if none have been added.
7802 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007803 public @Nullable Bundle getExtras() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007804 return (mExtras != null)
7805 ? new Bundle(mExtras)
7806 : null;
7807 }
7808
7809 /**
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007810 * Filter extras to only basic types.
7811 * @hide
7812 */
7813 public void removeUnsafeExtras() {
7814 if (mExtras != null) {
Dianne Hackborn851ec492016-10-12 17:20:07 -07007815 mExtras = mExtras.filterValues();
Dianne Hackborna83ce1d2015-03-11 15:16:13 -07007816 }
7817 }
7818
7819 /**
Makoto Onuki97f82f22017-05-31 16:20:21 -07007820 * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
7821 * return itself as-is.
7822 * @hide
7823 */
7824 public boolean canStripForHistory() {
7825 return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
7826 }
7827
7828 /**
7829 * Call it when the system needs to keep an intent for logging purposes to remove fields
7830 * that are not needed for logging.
7831 * @hide
7832 */
7833 public Intent maybeStripForHistory() {
7834 // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
7835
7836 if (!canStripForHistory()) {
7837 return this;
7838 }
7839 return new Intent(this, COPY_MODE_HISTORY);
7840 }
7841
7842 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007843 * Retrieve any special flags associated with this intent. You will
7844 * normally just set them with {@link #setFlags} and let the system
7845 * take the appropriate action with them.
7846 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007847 * @return The currently set flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007848 * @see #setFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007849 * @see #addFlags
7850 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007851 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007852 public @Flags int getFlags() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007853 return mFlags;
7854 }
7855
Dianne Hackborne7f97212011-02-24 14:40:20 -08007856 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01007857 @UnsupportedAppUsage
Dianne Hackborne7f97212011-02-24 14:40:20 -08007858 public boolean isExcludingStopped() {
7859 return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
7860 == FLAG_EXCLUDE_STOPPED_PACKAGES;
7861 }
7862
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007863 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007864 * Retrieve the application package name this Intent is limited to. When
7865 * resolving an Intent, if non-null this limits the resolution to only
7866 * components in the given application package.
7867 *
7868 * @return The name of the application package for the Intent.
7869 *
7870 * @see #resolveActivity
7871 * @see #setPackage
7872 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007873 public @Nullable String getPackage() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007874 return mPackage;
7875 }
7876
7877 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007878 * Retrieve the concrete component associated with the intent. When receiving
7879 * an intent, this is the component that was found to best handle it (that is,
7880 * yourself) and will always be non-null; in all other cases it will be
7881 * null unless explicitly set.
7882 *
7883 * @return The name of the application component to handle the intent.
7884 *
7885 * @see #resolveActivity
7886 * @see #setComponent
7887 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007888 public @Nullable ComponentName getComponent() {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007889 return mComponent;
7890 }
7891
7892 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007893 * Get the bounds of the sender of this intent, in screen coordinates. This can be
7894 * used as a hint to the receiver for animations and the like. Null means that there
7895 * is no source bounds.
7896 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007897 public @Nullable Rect getSourceBounds() {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08007898 return mSourceBounds;
7899 }
7900
7901 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007902 * Return the Activity component that should be used to handle this intent.
7903 * The appropriate component is determined based on the information in the
7904 * intent, evaluated as follows:
7905 *
7906 * <p>If {@link #getComponent} returns an explicit class, that is returned
7907 * without any further consideration.
7908 *
7909 * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
7910 * category to be considered.
7911 *
7912 * <p>If {@link #getAction} is non-NULL, the activity must handle this
7913 * action.
7914 *
7915 * <p>If {@link #resolveType} returns non-NULL, the activity must handle
7916 * this type.
7917 *
7918 * <p>If {@link #addCategory} has added any categories, the activity must
7919 * handle ALL of the categories specified.
7920 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07007921 * <p>If {@link #getPackage} is non-NULL, only activity components in
7922 * that application package will be considered.
7923 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007924 * <p>If there are no activities that satisfy all of these conditions, a
7925 * null string is returned.
7926 *
7927 * <p>If multiple activities are found to satisfy the intent, the one with
7928 * the highest priority will be used. If there are multiple activities
7929 * with the same priority, the system will either pick the best activity
7930 * based on user preference, or resolve to a system class that will allow
7931 * the user to pick an activity and forward from there.
7932 *
7933 * <p>This method is implemented simply by calling
7934 * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
7935 * true.</p>
7936 * <p> This API is called for you as part of starting an activity from an
7937 * intent. You do not normally need to call it yourself.</p>
7938 *
7939 * @param pm The package manager with which to resolve the Intent.
7940 *
7941 * @return Name of the component implementing an activity that can
7942 * display the intent.
7943 *
7944 * @see #setComponent
7945 * @see #getComponent
7946 * @see #resolveActivityInfo
7947 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007948 public ComponentName resolveActivity(@NonNull PackageManager pm) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007949 if (mComponent != null) {
7950 return mComponent;
7951 }
7952
7953 ResolveInfo info = pm.resolveActivity(
7954 this, PackageManager.MATCH_DEFAULT_ONLY);
7955 if (info != null) {
7956 return new ComponentName(
7957 info.activityInfo.applicationInfo.packageName,
7958 info.activityInfo.name);
7959 }
7960
7961 return null;
7962 }
7963
7964 /**
7965 * Resolve the Intent into an {@link ActivityInfo}
7966 * describing the activity that should execute the intent. Resolution
7967 * follows the same rules as described for {@link #resolveActivity}, but
7968 * you get back the completely information about the resolved activity
7969 * instead of just its class name.
7970 *
7971 * @param pm The package manager with which to resolve the Intent.
7972 * @param flags Addition information to retrieve as per
7973 * {@link PackageManager#getActivityInfo(ComponentName, int)
7974 * PackageManager.getActivityInfo()}.
7975 *
7976 * @return PackageManager.ActivityInfo
7977 *
7978 * @see #resolveActivity
7979 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06007980 public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
7981 @PackageManager.ComponentInfoFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007982 ActivityInfo ai = null;
7983 if (mComponent != null) {
7984 try {
7985 ai = pm.getActivityInfo(mComponent, flags);
7986 } catch (PackageManager.NameNotFoundException e) {
7987 // ignore
7988 }
7989 } else {
7990 ResolveInfo info = pm.resolveActivity(
Dianne Hackborn9bfb7072009-09-22 11:37:40 -07007991 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07007992 if (info != null) {
7993 ai = info.activityInfo;
7994 }
7995 }
7996
7997 return ai;
7998 }
7999
8000 /**
Dianne Hackborn221ea892013-08-04 16:50:16 -07008001 * Special function for use by the system to resolve service
8002 * intents to system apps. Throws an exception if there are
8003 * multiple potential matches to the Intent. Returns null if
8004 * there are no matches.
8005 * @hide
8006 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01008007 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008008 public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8009 @PackageManager.ComponentInfoFlags int flags) {
Dianne Hackborn221ea892013-08-04 16:50:16 -07008010 if (mComponent != null) {
8011 return mComponent;
8012 }
8013
8014 List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8015 if (results == null) {
8016 return null;
8017 }
8018 ComponentName comp = null;
8019 for (int i=0; i<results.size(); i++) {
8020 ResolveInfo ri = results.get(i);
8021 if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8022 continue;
8023 }
8024 ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8025 ri.serviceInfo.name);
8026 if (comp != null) {
8027 throw new IllegalStateException("Multiple system services handle " + this
8028 + ": " + comp + ", " + foundComp);
8029 }
8030 comp = foundComp;
8031 }
8032 return comp;
8033 }
8034
8035 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008036 * Set the general action to be performed.
8037 *
8038 * @param action An action name, such as ACTION_VIEW. Application-specific
8039 * actions should be prefixed with the vendor's package name.
8040 *
8041 * @return Returns the same Intent object, for chaining multiple calls
8042 * into a single statement.
8043 *
8044 * @see #getAction
8045 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008046 public @NonNull Intent setAction(@Nullable String action) {
Jeff Brown2c376fc2011-01-28 17:34:01 -08008047 mAction = action != null ? action.intern() : null;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008048 return this;
8049 }
8050
8051 /**
8052 * Set the data this intent is operating on. This method automatically
Nick Pellyccae4122012-01-09 14:12:58 -08008053 * clears any type that was previously set by {@link #setType} or
8054 * {@link #setTypeAndNormalize}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008055 *
Nick Pellyccae4122012-01-09 14:12:58 -08008056 * <p><em>Note: scheme matching in the Android framework is
8057 * case-sensitive, unlike the formal RFC. As a result,
8058 * you should always write your Uri with a lower case scheme,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008059 * or use {@link Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008060 * {@link #setDataAndNormalize}
8061 * to ensure that the scheme is converted to lower case.</em>
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008062 *
Nick Pellyccae4122012-01-09 14:12:58 -08008063 * @param data The Uri of the data this intent is now targeting.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008064 *
8065 * @return Returns the same Intent object, for chaining multiple calls
8066 * into a single statement.
8067 *
8068 * @see #getData
Nick Pellyccae4122012-01-09 14:12:58 -08008069 * @see #setDataAndNormalize
Dianne Hackborn221ea892013-08-04 16:50:16 -07008070 * @see android.net.Uri#normalizeScheme()
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008071 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008072 public @NonNull Intent setData(@Nullable Uri data) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008073 mData = data;
8074 mType = null;
8075 return this;
8076 }
8077
8078 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008079 * Normalize and set the data this intent is operating on.
8080 *
8081 * <p>This method automatically clears any type that was
8082 * previously set (for example, by {@link #setType}).
8083 *
8084 * <p>The data Uri is normalized using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008085 * {@link android.net.Uri#normalizeScheme} before it is set,
Nick Pellyccae4122012-01-09 14:12:58 -08008086 * so really this is just a convenience method for
8087 * <pre>
8088 * setData(data.normalize())
8089 * </pre>
8090 *
8091 * @param data The Uri of the data this intent is now targeting.
8092 *
8093 * @return Returns the same Intent object, for chaining multiple calls
8094 * into a single statement.
8095 *
8096 * @see #getData
8097 * @see #setType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008098 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008099 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008100 public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008101 return setData(data.normalizeScheme());
Nick Pellyccae4122012-01-09 14:12:58 -08008102 }
8103
8104 /**
8105 * Set an explicit MIME data type.
8106 *
8107 * <p>This is used to create intents that only specify a type and not data,
8108 * for example to indicate the type of data to return.
8109 *
8110 * <p>This method automatically clears any data that was
8111 * previously set (for example by {@link #setData}).
Romain Guy4969af72009-06-17 10:53:19 -07008112 *
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008113 * <p><em>Note: MIME type matching in the Android framework is
8114 * case-sensitive, unlike formal RFC MIME types. As a result,
8115 * you should always write your MIME types with lower case letters,
Nick Pellyccae4122012-01-09 14:12:58 -08008116 * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8117 * to ensure that it is converted to lower case.</em>
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008118 *
8119 * @param type The MIME type of the data being handled by this intent.
8120 *
8121 * @return Returns the same Intent object, for chaining multiple calls
8122 * into a single statement.
8123 *
8124 * @see #getType
Nick Pellyccae4122012-01-09 14:12:58 -08008125 * @see #setTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008126 * @see #setDataAndType
Nick Pellyccae4122012-01-09 14:12:58 -08008127 * @see #normalizeMimeType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008128 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008129 public @NonNull Intent setType(@Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008130 mData = null;
8131 mType = type;
8132 return this;
8133 }
8134
8135 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008136 * Normalize and set an explicit MIME data type.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008137 *
Nick Pellyccae4122012-01-09 14:12:58 -08008138 * <p>This is used to create intents that only specify a type and not data,
8139 * for example to indicate the type of data to return.
Dianne Hackbornb3cddae2009-04-13 16:54:00 -07008140 *
Nick Pellyccae4122012-01-09 14:12:58 -08008141 * <p>This method automatically clears any data that was
8142 * previously set (for example by {@link #setData}).
8143 *
8144 * <p>The MIME type is normalized using
8145 * {@link #normalizeMimeType} before it is set,
8146 * so really this is just a convenience method for
8147 * <pre>
8148 * setType(Intent.normalizeMimeType(type))
8149 * </pre>
8150 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008151 * @param type The MIME type of the data being handled by this intent.
8152 *
8153 * @return Returns the same Intent object, for chaining multiple calls
8154 * into a single statement.
8155 *
Nick Pellyccae4122012-01-09 14:12:58 -08008156 * @see #getType
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008157 * @see #setData
Nick Pellyccae4122012-01-09 14:12:58 -08008158 * @see #normalizeMimeType
8159 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008160 public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -08008161 return setType(normalizeMimeType(type));
8162 }
8163
8164 /**
8165 * (Usually optional) Set the data for the intent along with an explicit
8166 * MIME data type. This method should very rarely be used -- it allows you
8167 * to override the MIME type that would ordinarily be inferred from the
8168 * data with your own type given here.
8169 *
8170 * <p><em>Note: MIME type and Uri scheme matching in the
8171 * Android framework is case-sensitive, unlike the formal RFC definitions.
8172 * As a result, you should always write these elements with lower case letters,
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008173 * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
Nick Pellyccae4122012-01-09 14:12:58 -08008174 * {@link #setDataAndTypeAndNormalize}
8175 * to ensure that they are converted to lower case.</em>
8176 *
8177 * @param data The Uri of the data this intent is now targeting.
8178 * @param type The MIME type of the data being handled by this intent.
8179 *
8180 * @return Returns the same Intent object, for chaining multiple calls
8181 * into a single statement.
8182 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008183 * @see #setType
Nick Pellyccae4122012-01-09 14:12:58 -08008184 * @see #setData
8185 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008186 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008187 * @see #setDataAndTypeAndNormalize
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008188 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008189 public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008190 mData = data;
8191 mType = type;
8192 return this;
8193 }
8194
8195 /**
Nick Pellyccae4122012-01-09 14:12:58 -08008196 * (Usually optional) Normalize and set both the data Uri and an explicit
8197 * MIME data type. This method should very rarely be used -- it allows you
8198 * to override the MIME type that would ordinarily be inferred from the
8199 * data with your own type given here.
8200 *
8201 * <p>The data Uri and the MIME type are normalize using
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008202 * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
Nick Pellyccae4122012-01-09 14:12:58 -08008203 * before they are set, so really this is just a convenience method for
8204 * <pre>
8205 * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8206 * </pre>
8207 *
8208 * @param data The Uri of the data this intent is now targeting.
8209 * @param type The MIME type of the data being handled by this intent.
8210 *
8211 * @return Returns the same Intent object, for chaining multiple calls
8212 * into a single statement.
8213 *
8214 * @see #setType
8215 * @see #setData
8216 * @see #setDataAndType
8217 * @see #normalizeMimeType
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008218 * @see android.net.Uri#normalizeScheme
Nick Pellyccae4122012-01-09 14:12:58 -08008219 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008220 public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
Jesse Wilsonabc43dd2012-05-10 14:29:33 -04008221 return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
Nick Pellyccae4122012-01-09 14:12:58 -08008222 }
8223
8224 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008225 * Add a new category to the intent. Categories provide additional detail
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008226 * about the action the intent performs. When resolving an intent, only
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008227 * activities that provide <em>all</em> of the requested categories will be
8228 * used.
8229 *
8230 * @param category The desired category. This can be either one of the
8231 * predefined Intent categories, or a custom category in your own
8232 * namespace.
8233 *
8234 * @return Returns the same Intent object, for chaining multiple calls
8235 * into a single statement.
8236 *
8237 * @see #hasCategory
8238 * @see #removeCategory
8239 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008240 public @NonNull Intent addCategory(String category) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008241 if (mCategories == null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07008242 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008243 }
Jeff Brown2c376fc2011-01-28 17:34:01 -08008244 mCategories.add(category.intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008245 return this;
8246 }
8247
8248 /**
Ken Wakasaf76a50c2012-03-09 19:56:35 +09008249 * Remove a category from an intent.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008250 *
8251 * @param category The category to remove.
8252 *
8253 * @see #addCategory
8254 */
8255 public void removeCategory(String category) {
8256 if (mCategories != null) {
8257 mCategories.remove(category);
8258 if (mCategories.size() == 0) {
8259 mCategories = null;
8260 }
8261 }
8262 }
8263
8264 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008265 * Set a selector for this Intent. This is a modification to the kinds of
8266 * things the Intent will match. If the selector is set, it will be used
8267 * when trying to find entities that can handle the Intent, instead of the
8268 * main contents of the Intent. This allows you build an Intent containing
8269 * a generic protocol while targeting it more specifically.
8270 *
8271 * <p>An example of where this may be used is with things like
8272 * {@link #CATEGORY_APP_BROWSER}. This category allows you to build an
8273 * Intent that will launch the Browser application. However, the correct
8274 * main entry point of an application is actually {@link #ACTION_MAIN}
8275 * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8276 * used to specify the actual Activity to launch. If you launch the browser
8277 * with something different, undesired behavior may happen if the user has
8278 * previously or later launches it the normal way, since they do not match.
8279 * Instead, you can build an Intent with the MAIN action (but no ComponentName
8280 * yet specified) and set a selector with {@link #ACTION_MAIN} and
8281 * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8282 *
8283 * <p>Setting a selector does not impact the behavior of
8284 * {@link #filterEquals(Intent)} and {@link #filterHashCode()}. This is part of the
8285 * desired behavior of a selector -- it does not impact the base meaning
8286 * of the Intent, just what kinds of things will be matched against it
8287 * when determining who can handle it.</p>
8288 *
8289 * <p>You can not use both a selector and {@link #setPackage(String)} on
8290 * the same base Intent.</p>
8291 *
8292 * @param selector The desired selector Intent; set to null to not use
8293 * a special selector.
8294 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008295 public void setSelector(@Nullable Intent selector) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08008296 if (selector == this) {
8297 throw new IllegalArgumentException(
8298 "Intent being set as a selector of itself");
8299 }
8300 if (selector != null && mPackage != null) {
8301 throw new IllegalArgumentException(
8302 "Can't set selector when package name is already set");
8303 }
8304 mSelector = selector;
8305 }
8306
8307 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008308 * Set a {@link ClipData} associated with this Intent. This replaces any
8309 * previously set ClipData.
8310 *
8311 * <p>The ClipData in an intent is not used for Intent matching or other
8312 * such operations. Semantically it is like extras, used to transmit
8313 * additional data with the Intent. The main feature of using this over
8314 * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8315 * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8316 * items included in the clip data. This is useful, in particular, if
8317 * you want to transmit an Intent containing multiple <code>content:</code>
8318 * URIs for which the recipient may not have global permission to access the
8319 * content provider.
8320 *
8321 * <p>If the ClipData contains items that are themselves Intents, any
8322 * grant flags in those Intents will be ignored. Only the top-level flags
8323 * of the main Intent are respected, and will be applied to all Uri or
8324 * Intent items in the clip (or sub-items of the clip).
8325 *
8326 * <p>The MIME type, label, and icon in the ClipData object are not
8327 * directly used by Intent. Applications should generally rely on the
8328 * MIME type of the Intent itself, not what it may find in the ClipData.
8329 * A common practice is to construct a ClipData for use with an Intent
John Spurlock33900182014-01-02 11:04:18 -05008330 * with a MIME type of "*&#47;*".
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008331 *
8332 * @param clip The new clip to set. May be null to clear the current clip.
8333 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008334 public void setClipData(@Nullable ClipData clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08008335 mClipData = clip;
8336 }
8337
8338 /**
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008339 * This is NOT a secure mechanism to identify the user who sent the intent.
8340 * When the intent is sent to a different user, it is used to fix uris by adding the userId
8341 * who sent the intent.
8342 * @hide
8343 */
Nicolas Prevot107f7b72015-07-01 16:31:48 +01008344 public void prepareToLeaveUser(int userId) {
8345 // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8346 // We want mContentUserHint to refer to the original user, so don't do anything.
8347 if (mContentUserHint == UserHandle.USER_CURRENT) {
8348 mContentUserHint = userId;
8349 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01008350 }
8351
8352 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008353 * Add extended data to the intent. The name must include a package
8354 * prefix, for example the app com.android.contacts would use names
8355 * like "com.android.contacts.ShowAll".
8356 *
8357 * @param name The name of the extra data, with package prefix.
8358 * @param value The boolean data value.
8359 *
8360 * @return Returns the same Intent object, for chaining multiple calls
8361 * into a single statement.
8362 *
8363 * @see #putExtras
8364 * @see #removeExtra
8365 * @see #getBooleanExtra(String, boolean)
8366 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008367 public @NonNull Intent putExtra(String name, boolean value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008368 if (mExtras == null) {
8369 mExtras = new Bundle();
8370 }
8371 mExtras.putBoolean(name, value);
8372 return this;
8373 }
8374
8375 /**
8376 * Add extended data to the intent. The name must include a package
8377 * prefix, for example the app com.android.contacts would use names
8378 * like "com.android.contacts.ShowAll".
8379 *
8380 * @param name The name of the extra data, with package prefix.
8381 * @param value The byte data value.
8382 *
8383 * @return Returns the same Intent object, for chaining multiple calls
8384 * into a single statement.
8385 *
8386 * @see #putExtras
8387 * @see #removeExtra
8388 * @see #getByteExtra(String, byte)
8389 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008390 public @NonNull Intent putExtra(String name, byte value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008391 if (mExtras == null) {
8392 mExtras = new Bundle();
8393 }
8394 mExtras.putByte(name, value);
8395 return this;
8396 }
8397
8398 /**
8399 * Add extended data to the intent. The name must include a package
8400 * prefix, for example the app com.android.contacts would use names
8401 * like "com.android.contacts.ShowAll".
8402 *
8403 * @param name The name of the extra data, with package prefix.
8404 * @param value The char data value.
8405 *
8406 * @return Returns the same Intent object, for chaining multiple calls
8407 * into a single statement.
8408 *
8409 * @see #putExtras
8410 * @see #removeExtra
8411 * @see #getCharExtra(String, char)
8412 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008413 public @NonNull Intent putExtra(String name, char value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008414 if (mExtras == null) {
8415 mExtras = new Bundle();
8416 }
8417 mExtras.putChar(name, value);
8418 return this;
8419 }
8420
8421 /**
8422 * Add extended data to the intent. The name must include a package
8423 * prefix, for example the app com.android.contacts would use names
8424 * like "com.android.contacts.ShowAll".
8425 *
8426 * @param name The name of the extra data, with package prefix.
8427 * @param value The short data value.
8428 *
8429 * @return Returns the same Intent object, for chaining multiple calls
8430 * into a single statement.
8431 *
8432 * @see #putExtras
8433 * @see #removeExtra
8434 * @see #getShortExtra(String, short)
8435 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008436 public @NonNull Intent putExtra(String name, short value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008437 if (mExtras == null) {
8438 mExtras = new Bundle();
8439 }
8440 mExtras.putShort(name, value);
8441 return this;
8442 }
8443
8444 /**
8445 * Add extended data to the intent. The name must include a package
8446 * prefix, for example the app com.android.contacts would use names
8447 * like "com.android.contacts.ShowAll".
8448 *
8449 * @param name The name of the extra data, with package prefix.
8450 * @param value The integer data value.
8451 *
8452 * @return Returns the same Intent object, for chaining multiple calls
8453 * into a single statement.
8454 *
8455 * @see #putExtras
8456 * @see #removeExtra
8457 * @see #getIntExtra(String, int)
8458 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008459 public @NonNull Intent putExtra(String name, int value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008460 if (mExtras == null) {
8461 mExtras = new Bundle();
8462 }
8463 mExtras.putInt(name, value);
8464 return this;
8465 }
8466
8467 /**
8468 * Add extended data to the intent. The name must include a package
8469 * prefix, for example the app com.android.contacts would use names
8470 * like "com.android.contacts.ShowAll".
8471 *
8472 * @param name The name of the extra data, with package prefix.
8473 * @param value The long data value.
8474 *
8475 * @return Returns the same Intent object, for chaining multiple calls
8476 * into a single statement.
8477 *
8478 * @see #putExtras
8479 * @see #removeExtra
8480 * @see #getLongExtra(String, long)
8481 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008482 public @NonNull Intent putExtra(String name, long value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008483 if (mExtras == null) {
8484 mExtras = new Bundle();
8485 }
8486 mExtras.putLong(name, value);
8487 return this;
8488 }
8489
8490 /**
8491 * Add extended data to the intent. The name must include a package
8492 * prefix, for example the app com.android.contacts would use names
8493 * like "com.android.contacts.ShowAll".
8494 *
8495 * @param name The name of the extra data, with package prefix.
8496 * @param value The float data value.
8497 *
8498 * @return Returns the same Intent object, for chaining multiple calls
8499 * into a single statement.
8500 *
8501 * @see #putExtras
8502 * @see #removeExtra
8503 * @see #getFloatExtra(String, float)
8504 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008505 public @NonNull Intent putExtra(String name, float value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008506 if (mExtras == null) {
8507 mExtras = new Bundle();
8508 }
8509 mExtras.putFloat(name, value);
8510 return this;
8511 }
8512
8513 /**
8514 * Add extended data to the intent. The name must include a package
8515 * prefix, for example the app com.android.contacts would use names
8516 * like "com.android.contacts.ShowAll".
8517 *
8518 * @param name The name of the extra data, with package prefix.
8519 * @param value The double data value.
8520 *
8521 * @return Returns the same Intent object, for chaining multiple calls
8522 * into a single statement.
8523 *
8524 * @see #putExtras
8525 * @see #removeExtra
8526 * @see #getDoubleExtra(String, double)
8527 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008528 public @NonNull Intent putExtra(String name, double value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008529 if (mExtras == null) {
8530 mExtras = new Bundle();
8531 }
8532 mExtras.putDouble(name, value);
8533 return this;
8534 }
8535
8536 /**
8537 * Add extended data to the intent. The name must include a package
8538 * prefix, for example the app com.android.contacts would use names
8539 * like "com.android.contacts.ShowAll".
8540 *
8541 * @param name The name of the extra data, with package prefix.
8542 * @param value The String data value.
8543 *
8544 * @return Returns the same Intent object, for chaining multiple calls
8545 * into a single statement.
8546 *
8547 * @see #putExtras
8548 * @see #removeExtra
8549 * @see #getStringExtra(String)
8550 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008551 public @NonNull Intent putExtra(String name, String value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008552 if (mExtras == null) {
8553 mExtras = new Bundle();
8554 }
8555 mExtras.putString(name, value);
8556 return this;
8557 }
8558
8559 /**
8560 * Add extended data to the intent. The name must include a package
8561 * prefix, for example the app com.android.contacts would use names
8562 * like "com.android.contacts.ShowAll".
8563 *
8564 * @param name The name of the extra data, with package prefix.
8565 * @param value The CharSequence data value.
8566 *
8567 * @return Returns the same Intent object, for chaining multiple calls
8568 * into a single statement.
8569 *
8570 * @see #putExtras
8571 * @see #removeExtra
8572 * @see #getCharSequenceExtra(String)
8573 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008574 public @NonNull Intent putExtra(String name, CharSequence value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008575 if (mExtras == null) {
8576 mExtras = new Bundle();
8577 }
8578 mExtras.putCharSequence(name, value);
8579 return this;
8580 }
8581
8582 /**
8583 * Add extended data to the intent. The name must include a package
8584 * prefix, for example the app com.android.contacts would use names
8585 * like "com.android.contacts.ShowAll".
8586 *
8587 * @param name The name of the extra data, with package prefix.
8588 * @param value The Parcelable data value.
8589 *
8590 * @return Returns the same Intent object, for chaining multiple calls
8591 * into a single statement.
8592 *
8593 * @see #putExtras
8594 * @see #removeExtra
8595 * @see #getParcelableExtra(String)
8596 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008597 public @NonNull Intent putExtra(String name, Parcelable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008598 if (mExtras == null) {
8599 mExtras = new Bundle();
8600 }
8601 mExtras.putParcelable(name, value);
8602 return this;
8603 }
8604
8605 /**
8606 * Add extended data to the intent. The name must include a package
8607 * prefix, for example the app com.android.contacts would use names
8608 * like "com.android.contacts.ShowAll".
8609 *
8610 * @param name The name of the extra data, with package prefix.
8611 * @param value The Parcelable[] data value.
8612 *
8613 * @return Returns the same Intent object, for chaining multiple calls
8614 * into a single statement.
8615 *
8616 * @see #putExtras
8617 * @see #removeExtra
8618 * @see #getParcelableArrayExtra(String)
8619 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008620 public @NonNull Intent putExtra(String name, Parcelable[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008621 if (mExtras == null) {
8622 mExtras = new Bundle();
8623 }
8624 mExtras.putParcelableArray(name, value);
8625 return this;
8626 }
8627
8628 /**
8629 * Add extended data to the intent. The name must include a package
8630 * prefix, for example the app com.android.contacts would use names
8631 * like "com.android.contacts.ShowAll".
8632 *
8633 * @param name The name of the extra data, with package prefix.
8634 * @param value The ArrayList<Parcelable> data value.
8635 *
8636 * @return Returns the same Intent object, for chaining multiple calls
8637 * into a single statement.
8638 *
8639 * @see #putExtras
8640 * @see #removeExtra
8641 * @see #getParcelableArrayListExtra(String)
8642 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008643 public @NonNull Intent putParcelableArrayListExtra(String name,
8644 ArrayList<? extends Parcelable> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008645 if (mExtras == null) {
8646 mExtras = new Bundle();
8647 }
8648 mExtras.putParcelableArrayList(name, value);
8649 return this;
8650 }
8651
8652 /**
8653 * Add extended data to the intent. The name must include a package
8654 * prefix, for example the app com.android.contacts would use names
8655 * like "com.android.contacts.ShowAll".
8656 *
8657 * @param name The name of the extra data, with package prefix.
8658 * @param value The ArrayList<Integer> data value.
8659 *
8660 * @return Returns the same Intent object, for chaining multiple calls
8661 * into a single statement.
8662 *
8663 * @see #putExtras
8664 * @see #removeExtra
8665 * @see #getIntegerArrayListExtra(String)
8666 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008667 public @NonNull Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008668 if (mExtras == null) {
8669 mExtras = new Bundle();
8670 }
8671 mExtras.putIntegerArrayList(name, value);
8672 return this;
8673 }
8674
8675 /**
8676 * Add extended data to the intent. The name must include a package
8677 * prefix, for example the app com.android.contacts would use names
8678 * like "com.android.contacts.ShowAll".
8679 *
8680 * @param name The name of the extra data, with package prefix.
8681 * @param value The ArrayList<String> data value.
8682 *
8683 * @return Returns the same Intent object, for chaining multiple calls
8684 * into a single statement.
8685 *
8686 * @see #putExtras
8687 * @see #removeExtra
8688 * @see #getStringArrayListExtra(String)
8689 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008690 public @NonNull Intent putStringArrayListExtra(String name, ArrayList<String> value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008691 if (mExtras == null) {
8692 mExtras = new Bundle();
8693 }
8694 mExtras.putStringArrayList(name, value);
8695 return this;
8696 }
8697
8698 /**
8699 * Add extended data to the intent. The name must include a package
8700 * prefix, for example the app com.android.contacts would use names
8701 * like "com.android.contacts.ShowAll".
8702 *
8703 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008704 * @param value The ArrayList<CharSequence> data value.
8705 *
8706 * @return Returns the same Intent object, for chaining multiple calls
8707 * into a single statement.
8708 *
8709 * @see #putExtras
8710 * @see #removeExtra
8711 * @see #getCharSequenceArrayListExtra(String)
8712 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008713 public @NonNull Intent putCharSequenceArrayListExtra(String name,
8714 ArrayList<CharSequence> value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008715 if (mExtras == null) {
8716 mExtras = new Bundle();
8717 }
8718 mExtras.putCharSequenceArrayList(name, value);
8719 return this;
8720 }
8721
8722 /**
8723 * Add extended data to the intent. The name must include a package
8724 * prefix, for example the app com.android.contacts would use names
8725 * like "com.android.contacts.ShowAll".
8726 *
8727 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008728 * @param value The Serializable data value.
8729 *
8730 * @return Returns the same Intent object, for chaining multiple calls
8731 * into a single statement.
8732 *
8733 * @see #putExtras
8734 * @see #removeExtra
8735 * @see #getSerializableExtra(String)
8736 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008737 public @NonNull Intent putExtra(String name, Serializable value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008738 if (mExtras == null) {
8739 mExtras = new Bundle();
8740 }
8741 mExtras.putSerializable(name, value);
8742 return this;
8743 }
8744
8745 /**
8746 * Add extended data to the intent. The name must include a package
8747 * prefix, for example the app com.android.contacts would use names
8748 * like "com.android.contacts.ShowAll".
8749 *
8750 * @param name The name of the extra data, with package prefix.
8751 * @param value The boolean array data value.
8752 *
8753 * @return Returns the same Intent object, for chaining multiple calls
8754 * into a single statement.
8755 *
8756 * @see #putExtras
8757 * @see #removeExtra
8758 * @see #getBooleanArrayExtra(String)
8759 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008760 public @NonNull Intent putExtra(String name, boolean[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008761 if (mExtras == null) {
8762 mExtras = new Bundle();
8763 }
8764 mExtras.putBooleanArray(name, value);
8765 return this;
8766 }
8767
8768 /**
8769 * Add extended data to the intent. The name must include a package
8770 * prefix, for example the app com.android.contacts would use names
8771 * like "com.android.contacts.ShowAll".
8772 *
8773 * @param name The name of the extra data, with package prefix.
8774 * @param value The byte array data value.
8775 *
8776 * @return Returns the same Intent object, for chaining multiple calls
8777 * into a single statement.
8778 *
8779 * @see #putExtras
8780 * @see #removeExtra
8781 * @see #getByteArrayExtra(String)
8782 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008783 public @NonNull Intent putExtra(String name, byte[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008784 if (mExtras == null) {
8785 mExtras = new Bundle();
8786 }
8787 mExtras.putByteArray(name, value);
8788 return this;
8789 }
8790
8791 /**
8792 * Add extended data to the intent. The name must include a package
8793 * prefix, for example the app com.android.contacts would use names
8794 * like "com.android.contacts.ShowAll".
8795 *
8796 * @param name The name of the extra data, with package prefix.
8797 * @param value The short array data value.
8798 *
8799 * @return Returns the same Intent object, for chaining multiple calls
8800 * into a single statement.
8801 *
8802 * @see #putExtras
8803 * @see #removeExtra
8804 * @see #getShortArrayExtra(String)
8805 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008806 public @NonNull Intent putExtra(String name, short[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008807 if (mExtras == null) {
8808 mExtras = new Bundle();
8809 }
8810 mExtras.putShortArray(name, value);
8811 return this;
8812 }
8813
8814 /**
8815 * Add extended data to the intent. The name must include a package
8816 * prefix, for example the app com.android.contacts would use names
8817 * like "com.android.contacts.ShowAll".
8818 *
8819 * @param name The name of the extra data, with package prefix.
8820 * @param value The char array data value.
8821 *
8822 * @return Returns the same Intent object, for chaining multiple calls
8823 * into a single statement.
8824 *
8825 * @see #putExtras
8826 * @see #removeExtra
8827 * @see #getCharArrayExtra(String)
8828 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008829 public @NonNull Intent putExtra(String name, char[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008830 if (mExtras == null) {
8831 mExtras = new Bundle();
8832 }
8833 mExtras.putCharArray(name, value);
8834 return this;
8835 }
8836
8837 /**
8838 * Add extended data to the intent. The name must include a package
8839 * prefix, for example the app com.android.contacts would use names
8840 * like "com.android.contacts.ShowAll".
8841 *
8842 * @param name The name of the extra data, with package prefix.
8843 * @param value The int array data value.
8844 *
8845 * @return Returns the same Intent object, for chaining multiple calls
8846 * into a single statement.
8847 *
8848 * @see #putExtras
8849 * @see #removeExtra
8850 * @see #getIntArrayExtra(String)
8851 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008852 public @NonNull Intent putExtra(String name, int[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008853 if (mExtras == null) {
8854 mExtras = new Bundle();
8855 }
8856 mExtras.putIntArray(name, value);
8857 return this;
8858 }
8859
8860 /**
8861 * Add extended data to the intent. The name must include a package
8862 * prefix, for example the app com.android.contacts would use names
8863 * like "com.android.contacts.ShowAll".
8864 *
8865 * @param name The name of the extra data, with package prefix.
8866 * @param value The byte array data value.
8867 *
8868 * @return Returns the same Intent object, for chaining multiple calls
8869 * into a single statement.
8870 *
8871 * @see #putExtras
8872 * @see #removeExtra
8873 * @see #getLongArrayExtra(String)
8874 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008875 public @NonNull Intent putExtra(String name, long[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008876 if (mExtras == null) {
8877 mExtras = new Bundle();
8878 }
8879 mExtras.putLongArray(name, value);
8880 return this;
8881 }
8882
8883 /**
8884 * Add extended data to the intent. The name must include a package
8885 * prefix, for example the app com.android.contacts would use names
8886 * like "com.android.contacts.ShowAll".
8887 *
8888 * @param name The name of the extra data, with package prefix.
8889 * @param value The float array data value.
8890 *
8891 * @return Returns the same Intent object, for chaining multiple calls
8892 * into a single statement.
8893 *
8894 * @see #putExtras
8895 * @see #removeExtra
8896 * @see #getFloatArrayExtra(String)
8897 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008898 public @NonNull Intent putExtra(String name, float[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008899 if (mExtras == null) {
8900 mExtras = new Bundle();
8901 }
8902 mExtras.putFloatArray(name, value);
8903 return this;
8904 }
8905
8906 /**
8907 * Add extended data to the intent. The name must include a package
8908 * prefix, for example the app com.android.contacts would use names
8909 * like "com.android.contacts.ShowAll".
8910 *
8911 * @param name The name of the extra data, with package prefix.
8912 * @param value The double array data value.
8913 *
8914 * @return Returns the same Intent object, for chaining multiple calls
8915 * into a single statement.
8916 *
8917 * @see #putExtras
8918 * @see #removeExtra
8919 * @see #getDoubleArrayExtra(String)
8920 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008921 public @NonNull Intent putExtra(String name, double[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008922 if (mExtras == null) {
8923 mExtras = new Bundle();
8924 }
8925 mExtras.putDoubleArray(name, value);
8926 return this;
8927 }
8928
8929 /**
8930 * Add extended data to the intent. The name must include a package
8931 * prefix, for example the app com.android.contacts would use names
8932 * like "com.android.contacts.ShowAll".
8933 *
8934 * @param name The name of the extra data, with package prefix.
8935 * @param value The String array data value.
8936 *
8937 * @return Returns the same Intent object, for chaining multiple calls
8938 * into a single statement.
8939 *
8940 * @see #putExtras
8941 * @see #removeExtra
8942 * @see #getStringArrayExtra(String)
8943 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008944 public @NonNull Intent putExtra(String name, String[] value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008945 if (mExtras == null) {
8946 mExtras = new Bundle();
8947 }
8948 mExtras.putStringArray(name, value);
8949 return this;
8950 }
8951
8952 /**
8953 * Add extended data to the intent. The name must include a package
8954 * prefix, for example the app com.android.contacts would use names
8955 * like "com.android.contacts.ShowAll".
8956 *
8957 * @param name The name of the extra data, with package prefix.
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008958 * @param value The CharSequence array data value.
8959 *
8960 * @return Returns the same Intent object, for chaining multiple calls
8961 * into a single statement.
8962 *
8963 * @see #putExtras
8964 * @see #removeExtra
8965 * @see #getCharSequenceArrayExtra(String)
8966 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008967 public @NonNull Intent putExtra(String name, CharSequence[] value) {
Bjorn Bringert08bbffb2010-02-25 11:16:22 +00008968 if (mExtras == null) {
8969 mExtras = new Bundle();
8970 }
8971 mExtras.putCharSequenceArray(name, value);
8972 return this;
8973 }
8974
8975 /**
8976 * Add extended data to the intent. The name must include a package
8977 * prefix, for example the app com.android.contacts would use names
8978 * like "com.android.contacts.ShowAll".
8979 *
8980 * @param name The name of the extra data, with package prefix.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008981 * @param value The Bundle data value.
8982 *
8983 * @return Returns the same Intent object, for chaining multiple calls
8984 * into a single statement.
8985 *
8986 * @see #putExtras
8987 * @see #removeExtra
8988 * @see #getBundleExtra(String)
8989 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06008990 public @NonNull Intent putExtra(String name, Bundle value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07008991 if (mExtras == null) {
8992 mExtras = new Bundle();
8993 }
8994 mExtras.putBundle(name, value);
8995 return this;
8996 }
8997
8998 /**
8999 * Add extended data to the intent. The name must include a package
9000 * prefix, for example the app com.android.contacts would use names
9001 * like "com.android.contacts.ShowAll".
9002 *
9003 * @param name The name of the extra data, with package prefix.
9004 * @param value The IBinder data value.
9005 *
9006 * @return Returns the same Intent object, for chaining multiple calls
9007 * into a single statement.
9008 *
9009 * @see #putExtras
9010 * @see #removeExtra
9011 * @see #getIBinderExtra(String)
9012 *
9013 * @deprecated
9014 * @hide
9015 */
9016 @Deprecated
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009017 @UnsupportedAppUsage
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009018 public @NonNull Intent putExtra(String name, IBinder value) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009019 if (mExtras == null) {
9020 mExtras = new Bundle();
9021 }
9022 mExtras.putIBinder(name, value);
9023 return this;
9024 }
9025
9026 /**
9027 * Copy all extras in 'src' in to this intent.
9028 *
9029 * @param src Contains the extras to copy.
9030 *
9031 * @see #putExtra
9032 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009033 public @NonNull Intent putExtras(@NonNull Intent src) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009034 if (src.mExtras != null) {
9035 if (mExtras == null) {
9036 mExtras = new Bundle(src.mExtras);
9037 } else {
9038 mExtras.putAll(src.mExtras);
9039 }
9040 }
9041 return this;
9042 }
9043
9044 /**
9045 * Add a set of extended data to the intent. The keys must include a package
9046 * prefix, for example the app com.android.contacts would use names
9047 * like "com.android.contacts.ShowAll".
9048 *
9049 * @param extras The Bundle of extras to add to this intent.
9050 *
9051 * @see #putExtra
9052 * @see #removeExtra
9053 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009054 public @NonNull Intent putExtras(@NonNull Bundle extras) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009055 if (mExtras == null) {
9056 mExtras = new Bundle();
9057 }
9058 mExtras.putAll(extras);
9059 return this;
9060 }
9061
9062 /**
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009063 * Completely replace the extras in the Intent with the extras in the
9064 * given Intent.
The Android Open Source Project10592532009-03-18 17:39:46 -07009065 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009066 * @param src The exact extras contained in this Intent are copied
9067 * into the target intent, replacing any that were previously there.
9068 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009069 public @NonNull Intent replaceExtras(@NonNull Intent src) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009070 mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9071 return this;
9072 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009073
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009074 /**
9075 * Completely replace the extras in the Intent with the given Bundle of
9076 * extras.
The Android Open Source Project10592532009-03-18 17:39:46 -07009077 *
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009078 * @param extras The new set of extras in the Intent, or null to erase
9079 * all extras.
9080 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009081 public @NonNull Intent replaceExtras(@NonNull Bundle extras) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009082 mExtras = extras != null ? new Bundle(extras) : null;
9083 return this;
9084 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009085
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -08009086 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009087 * Remove extended data from the intent.
9088 *
9089 * @see #putExtra
9090 */
9091 public void removeExtra(String name) {
9092 if (mExtras != null) {
9093 mExtras.remove(name);
9094 if (mExtras.size() == 0) {
9095 mExtras = null;
9096 }
9097 }
9098 }
9099
9100 /**
9101 * Set special flags controlling how this intent is handled. Most values
9102 * here depend on the type of component being executed by the Intent,
9103 * specifically the FLAG_ACTIVITY_* flags are all for use with
9104 * {@link Context#startActivity Context.startActivity()} and the
9105 * FLAG_RECEIVER_* flags are all for use with
9106 * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9107 *
Scott Main7aee61f2011-02-08 11:25:01 -08009108 * <p>See the
9109 * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9110 * Stack</a> documentation for important information on how some of these options impact
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009111 * the behavior of your application.
9112 *
9113 * @param flags The desired flags.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009114 * @return Returns the same Intent object, for chaining multiple calls
9115 * into a single statement.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009116 * @see #getFlags
9117 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009118 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009119 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009120 public @NonNull Intent setFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009121 mFlags = flags;
9122 return this;
9123 }
9124
9125 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009126 * Add additional flags to the intent (or with existing flags value).
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009127 *
9128 * @param flags The new flags to set.
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009129 * @return Returns the same Intent object, for chaining multiple calls into
9130 * a single statement.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009131 * @see #setFlags
9132 * @see #getFlags
9133 * @see #removeFlags
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009134 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009135 public @NonNull Intent addFlags(@Flags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009136 mFlags |= flags;
9137 return this;
9138 }
9139
9140 /**
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009141 * Remove these flags from the intent.
9142 *
9143 * @param flags The flags to remove.
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009144 * @see #setFlags
9145 * @see #getFlags
9146 * @see #addFlags
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009147 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009148 public void removeFlags(@Flags int flags) {
Jeff Sharkey6a34e562016-12-21 09:56:00 -07009149 mFlags &= ~flags;
9150 }
9151
9152 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009153 * (Usually optional) Set an explicit application package name that limits
9154 * the components this Intent will resolve to. If left to the default
9155 * value of null, all components in all applications will considered.
9156 * If non-null, the Intent can only match the components in the given
9157 * application package.
9158 *
9159 * @param packageName The name of the application package to handle the
9160 * intent, or null to allow any application package.
9161 *
9162 * @return Returns the same Intent object, for chaining multiple calls
9163 * into a single statement.
9164 *
9165 * @see #getPackage
9166 * @see #resolveActivity
9167 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009168 public @NonNull Intent setPackage(@Nullable String packageName) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009169 if (packageName != null && mSelector != null) {
9170 throw new IllegalArgumentException(
9171 "Can't set package name when selector is already set");
9172 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009173 mPackage = packageName;
9174 return this;
9175 }
9176
9177 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009178 * (Usually optional) Explicitly set the component to handle the intent.
9179 * If left with the default value of null, the system will determine the
9180 * appropriate class to use based on the other fields (action, data,
9181 * type, categories) in the Intent. If this class is defined, the
9182 * specified class will always be used regardless of the other fields. You
9183 * should only set this value when you know you absolutely want a specific
9184 * class to be used; otherwise it is better to let the system find the
9185 * appropriate class so that you will respect the installed applications
9186 * and user preferences.
9187 *
9188 * @param component The name of the application component to handle the
9189 * intent, or null to let the system find one for you.
9190 *
9191 * @return Returns the same Intent object, for chaining multiple calls
9192 * into a single statement.
9193 *
9194 * @see #setClass
9195 * @see #setClassName(Context, String)
9196 * @see #setClassName(String, String)
9197 * @see #getComponent
9198 * @see #resolveActivity
9199 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009200 public @NonNull Intent setComponent(@Nullable ComponentName component) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009201 mComponent = component;
9202 return this;
9203 }
9204
9205 /**
9206 * Convenience for calling {@link #setComponent} with an
9207 * explicit class name.
9208 *
9209 * @param packageContext A Context of the application package implementing
9210 * this class.
9211 * @param className The name of a class inside of the application package
9212 * that will be used as the component for this Intent.
9213 *
9214 * @return Returns the same Intent object, for chaining multiple calls
9215 * into a single statement.
9216 *
9217 * @see #setComponent
9218 * @see #setClass
9219 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009220 public @NonNull Intent setClassName(@NonNull Context packageContext,
9221 @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009222 mComponent = new ComponentName(packageContext, className);
9223 return this;
9224 }
9225
9226 /**
9227 * Convenience for calling {@link #setComponent} with an
9228 * explicit application package name and class name.
9229 *
9230 * @param packageName The name of the package implementing the desired
9231 * component.
9232 * @param className The name of a class inside of the application package
9233 * that will be used as the component for this Intent.
9234 *
9235 * @return Returns the same Intent object, for chaining multiple calls
9236 * into a single statement.
9237 *
9238 * @see #setComponent
9239 * @see #setClass
9240 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009241 public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009242 mComponent = new ComponentName(packageName, className);
9243 return this;
9244 }
9245
9246 /**
9247 * Convenience for calling {@link #setComponent(ComponentName)} with the
9248 * name returned by a {@link Class} object.
9249 *
9250 * @param packageContext A Context of the application package implementing
9251 * this class.
9252 * @param cls The class name to set, equivalent to
9253 * <code>setClassName(context, cls.getName())</code>.
9254 *
9255 * @return Returns the same Intent object, for chaining multiple calls
9256 * into a single statement.
9257 *
9258 * @see #setComponent
9259 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009260 public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009261 mComponent = new ComponentName(packageContext, cls);
9262 return this;
9263 }
9264
9265 /**
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009266 * Set the bounds of the sender of this intent, in screen coordinates. This can be
9267 * used as a hint to the receiver for animations and the like. Null means that there
9268 * is no source bounds.
9269 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009270 public void setSourceBounds(@Nullable Rect r) {
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009271 if (r != null) {
9272 mSourceBounds = new Rect(r);
9273 } else {
Daniel Lehmanna5b58df2011-10-12 16:24:22 -07009274 mSourceBounds = null;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009275 }
9276 }
9277
Tor Norbyed9273d62013-05-30 15:59:53 -07009278 /** @hide */
Jeff Sharkeyce8db992017-12-13 20:05:05 -07009279 @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9280 FILL_IN_ACTION,
9281 FILL_IN_DATA,
9282 FILL_IN_CATEGORIES,
9283 FILL_IN_COMPONENT,
9284 FILL_IN_PACKAGE,
9285 FILL_IN_SOURCE_BOUNDS,
9286 FILL_IN_SELECTOR,
9287 FILL_IN_CLIP_DATA
9288 })
Tor Norbyed9273d62013-05-30 15:59:53 -07009289 @Retention(RetentionPolicy.SOURCE)
9290 public @interface FillInFlags {}
9291
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009292 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009293 * Use with {@link #fillIn} to allow the current action value to be
9294 * overwritten, even if it is already set.
9295 */
9296 public static final int FILL_IN_ACTION = 1<<0;
9297
9298 /**
9299 * Use with {@link #fillIn} to allow the current data or type value
9300 * overwritten, even if it is already set.
9301 */
9302 public static final int FILL_IN_DATA = 1<<1;
9303
9304 /**
9305 * Use with {@link #fillIn} to allow the current categories to be
9306 * overwritten, even if they are already set.
9307 */
9308 public static final int FILL_IN_CATEGORIES = 1<<2;
9309
9310 /**
9311 * Use with {@link #fillIn} to allow the current component value to be
9312 * overwritten, even if it is already set.
9313 */
9314 public static final int FILL_IN_COMPONENT = 1<<3;
9315
9316 /**
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009317 * Use with {@link #fillIn} to allow the current package value to be
9318 * overwritten, even if it is already set.
9319 */
9320 public static final int FILL_IN_PACKAGE = 1<<4;
9321
9322 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009323 * Use with {@link #fillIn} to allow the current bounds rectangle to be
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009324 * overwritten, even if it is already set.
9325 */
9326 public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9327
9328 /**
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009329 * Use with {@link #fillIn} to allow the current selector to be
9330 * overwritten, even if it is already set.
9331 */
9332 public static final int FILL_IN_SELECTOR = 1<<6;
9333
9334 /**
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009335 * Use with {@link #fillIn} to allow the current ClipData to be
9336 * overwritten, even if it is already set.
9337 */
9338 public static final int FILL_IN_CLIP_DATA = 1<<7;
9339
9340 /**
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009341 * Copy the contents of <var>other</var> in to this object, but only
9342 * where fields are not defined by this object. For purposes of a field
9343 * being defined, the following pieces of data in the Intent are
9344 * considered to be separate fields:
9345 *
9346 * <ul>
9347 * <li> action, as set by {@link #setAction}.
Nick Pellyccae4122012-01-09 14:12:58 -08009348 * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009349 * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9350 * <li> categories, as set by {@link #addCategory}.
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009351 * <li> package, as set by {@link #setPackage}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009352 * <li> component, as set by {@link #setComponent(ComponentName)} or
9353 * related methods.
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009354 * <li> source bounds, as set by {@link #setSourceBounds}.
9355 * <li> selector, as set by {@link #setSelector(Intent)}.
9356 * <li> clip data, as set by {@link #setClipData(ClipData)}.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009357 * <li> each top-level name in the associated extras.
9358 * </ul>
9359 *
9360 * <p>In addition, you can use the {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009361 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009362 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9363 * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9364 * the restriction where the corresponding field will not be replaced if
9365 * it is already set.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009366 *
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009367 * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9368 * is explicitly specified. The selector will only be copied if
9369 * {@link #FILL_IN_SELECTOR} is explicitly specified.
Brett Chabot3e391752009-07-21 16:07:23 -07009370 *
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009371 * <p>For example, consider Intent A with {data="foo", categories="bar"}
9372 * and Intent B with {action="gotit", data-type="some/thing",
9373 * categories="one","two"}.
9374 *
9375 * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9376 * containing: {action="gotit", data-type="some/thing",
9377 * categories="bar"}.
9378 *
9379 * @param other Another Intent whose values are to be used to fill in
9380 * the current one.
9381 * @param flags Options to control which fields can be filled in.
9382 *
9383 * @return Returns a bit mask of {@link #FILL_IN_ACTION},
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009384 * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
Tor Norbyed9273d62013-05-30 15:59:53 -07009385 * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
Elliot Waite54de7742017-01-11 15:30:35 -08009386 * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
Tor Norbyed9273d62013-05-30 15:59:53 -07009387 * changed.
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009388 */
Tor Norbyed9273d62013-05-30 15:59:53 -07009389 @FillInFlags
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009390 public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009391 int changes = 0;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009392 boolean mayHaveCopiedUris = false;
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009393 if (other.mAction != null
9394 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009395 mAction = other.mAction;
9396 changes |= FILL_IN_ACTION;
9397 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009398 if ((other.mData != null || other.mType != null)
9399 && ((mData == null && mType == null)
9400 || (flags&FILL_IN_DATA) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009401 mData = other.mData;
9402 mType = other.mType;
9403 changes |= FILL_IN_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009404 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009405 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009406 if (other.mCategories != null
9407 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009408 if (other.mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009409 mCategories = new ArraySet<String>(other.mCategories);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009410 }
9411 changes |= FILL_IN_CATEGORIES;
9412 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009413 if (other.mPackage != null
9414 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009415 // Only do this if mSelector is not set.
9416 if (mSelector == null) {
9417 mPackage = other.mPackage;
9418 changes |= FILL_IN_PACKAGE;
9419 }
9420 }
9421 // Selector is special: it can only be set if explicitly allowed,
9422 // for the same reason as the component name.
9423 if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9424 if (mPackage == null) {
9425 mSelector = new Intent(other.mSelector);
9426 mPackage = null;
9427 changes |= FILL_IN_SELECTOR;
9428 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009429 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009430 if (other.mClipData != null
9431 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9432 mClipData = other.mClipData;
9433 changes |= FILL_IN_CLIP_DATA;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009434 mayHaveCopiedUris = true;
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009435 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009436 // Component is special: it can -only- be set if explicitly allowed,
9437 // since otherwise the sender could force the intent somewhere the
9438 // originator didn't intend.
9439 if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009440 mComponent = other.mComponent;
9441 changes |= FILL_IN_COMPONENT;
9442 }
9443 mFlags |= other.mFlags;
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009444 if (other.mSourceBounds != null
9445 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9446 mSourceBounds = new Rect(other.mSourceBounds);
9447 changes |= FILL_IN_SOURCE_BOUNDS;
9448 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009449 if (mExtras == null) {
9450 if (other.mExtras != null) {
9451 mExtras = new Bundle(other.mExtras);
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009452 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009453 }
9454 } else if (other.mExtras != null) {
9455 try {
9456 Bundle newb = new Bundle(other.mExtras);
9457 newb.putAll(mExtras);
9458 mExtras = newb;
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009459 mayHaveCopiedUris = true;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009460 } catch (RuntimeException e) {
9461 // Modifying the extras can cause us to unparcel the contents
9462 // of the bundle, and if we do this in the system process that
9463 // may fail. We really should handle this (i.e., the Bundle
9464 // impl shouldn't be on top of a plain map), but for now just
9465 // ignore it and keep the original contents. :(
9466 Log.w("Intent", "Failure filling in extras", e);
9467 }
9468 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009469 if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9470 && other.mContentUserHint != UserHandle.USER_CURRENT) {
9471 mContentUserHint = other.mContentUserHint;
9472 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009473 return changes;
9474 }
9475
9476 /**
9477 * Wrapper class holding an Intent and implementing comparisons on it for
9478 * the purpose of filtering. The class implements its
9479 * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9480 * simple calls to {@link Intent#filterEquals(Intent)} filterEquals()} and
9481 * {@link android.content.Intent#filterHashCode()} filterHashCode()}
9482 * on the wrapped Intent.
9483 */
9484 public static final class FilterComparison {
9485 private final Intent mIntent;
9486 private final int mHashCode;
9487
9488 public FilterComparison(Intent intent) {
9489 mIntent = intent;
9490 mHashCode = intent.filterHashCode();
9491 }
9492
9493 /**
9494 * Return the Intent that this FilterComparison represents.
9495 * @return Returns the Intent held by the FilterComparison. Do
9496 * not modify!
9497 */
9498 public Intent getIntent() {
9499 return mIntent;
9500 }
9501
9502 @Override
9503 public boolean equals(Object obj) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009504 if (obj instanceof FilterComparison) {
9505 Intent other = ((FilterComparison)obj).mIntent;
9506 return mIntent.filterEquals(other);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009507 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08009508 return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009509 }
9510
9511 @Override
9512 public int hashCode() {
9513 return mHashCode;
9514 }
9515 }
9516
9517 /**
9518 * Determine if two intents are the same for the purposes of intent
9519 * resolution (filtering). That is, if their action, data, type,
9520 * class, and categories are the same. This does <em>not</em> compare
9521 * any extra data included in the intents.
9522 *
9523 * @param other The other Intent to compare against.
9524 *
9525 * @return Returns true if action, data, type, class, and categories
9526 * are the same.
9527 */
9528 public boolean filterEquals(Intent other) {
9529 if (other == null) {
9530 return false;
9531 }
Christopher Tate63d9ae12014-06-19 19:07:26 -07009532 if (!Objects.equals(this.mAction, other.mAction)) return false;
9533 if (!Objects.equals(this.mData, other.mData)) return false;
9534 if (!Objects.equals(this.mType, other.mType)) return false;
9535 if (!Objects.equals(this.mPackage, other.mPackage)) return false;
9536 if (!Objects.equals(this.mComponent, other.mComponent)) return false;
9537 if (!Objects.equals(this.mCategories, other.mCategories)) return false;
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009538
9539 return true;
9540 }
9541
9542 /**
9543 * Generate hash code that matches semantics of filterEquals().
9544 *
9545 * @return Returns the hash value of the action, data, type, class, and
9546 * categories.
9547 *
9548 * @see #filterEquals
9549 */
9550 public int filterHashCode() {
9551 int code = 0;
9552 if (mAction != null) {
9553 code += mAction.hashCode();
9554 }
9555 if (mData != null) {
9556 code += mData.hashCode();
9557 }
9558 if (mType != null) {
9559 code += mType.hashCode();
9560 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009561 if (mPackage != null) {
9562 code += mPackage.hashCode();
9563 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009564 if (mComponent != null) {
9565 code += mComponent.hashCode();
9566 }
9567 if (mCategories != null) {
9568 code += mCategories.hashCode();
9569 }
9570 return code;
9571 }
9572
9573 @Override
9574 public String toString() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009575 StringBuilder b = new StringBuilder(128);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009576
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009577 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009578 toShortString(b, true, true, true, false);
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009579 b.append(" }");
9580
9581 return b.toString();
9582 }
9583
9584 /** @hide */
Mathew Inwood5c0d3542018-08-14 13:54:31 +01009585 @UnsupportedAppUsage
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009586 public String toInsecureString() {
9587 StringBuilder b = new StringBuilder(128);
9588
9589 b.append("Intent { ");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009590 toShortString(b, false, true, true, false);
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009591 b.append(" }");
9592
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009593 return b.toString();
9594 }
Romain Guy4969af72009-06-17 10:53:19 -07009595
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009596 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009597 public String toInsecureStringWithClip() {
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009598 StringBuilder b = new StringBuilder(128);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009599
9600 b.append("Intent { ");
9601 toShortString(b, false, true, true, true);
9602 b.append(" }");
9603
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009604 return b.toString();
9605 }
9606
9607 /** @hide */
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009608 public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
9609 StringBuilder b = new StringBuilder(128);
9610 toShortString(b, secure, comp, extras, clip);
9611 return b.toString();
9612 }
9613
9614 /** @hide */
9615 public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
9616 boolean clip) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009617 boolean first = true;
9618 if (mAction != null) {
9619 b.append("act=").append(mAction);
9620 first = false;
9621 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009622 if (mCategories != null) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009623 if (!first) {
9624 b.append(' ');
9625 }
9626 first = false;
9627 b.append("cat=[");
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009628 for (int i=0; i<mCategories.size(); i++) {
9629 if (i > 0) b.append(',');
9630 b.append(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009631 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009632 b.append("]");
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009633 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009634 if (mData != null) {
9635 if (!first) {
9636 b.append(' ');
9637 }
9638 first = false;
Wink Savillea4288072010-10-12 12:36:38 -07009639 b.append("dat=");
Dianne Hackborn90c52de2011-09-23 12:57:44 -07009640 if (secure) {
9641 b.append(mData.toSafeString());
Wink Savillea4288072010-10-12 12:36:38 -07009642 } else {
9643 b.append(mData);
9644 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009645 }
9646 if (mType != null) {
9647 if (!first) {
9648 b.append(' ');
9649 }
9650 first = false;
9651 b.append("typ=").append(mType);
9652 }
9653 if (mFlags != 0) {
9654 if (!first) {
9655 b.append(' ');
9656 }
9657 first = false;
9658 b.append("flg=0x").append(Integer.toHexString(mFlags));
9659 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009660 if (mPackage != null) {
9661 if (!first) {
9662 b.append(' ');
9663 }
9664 first = false;
9665 b.append("pkg=").append(mPackage);
9666 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009667 if (comp && mComponent != null) {
9668 if (!first) {
9669 b.append(' ');
9670 }
9671 first = false;
9672 b.append("cmp=").append(mComponent.flattenToShortString());
9673 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009674 if (mSourceBounds != null) {
9675 if (!first) {
9676 b.append(' ');
9677 }
9678 first = false;
9679 b.append("bnds=").append(mSourceBounds.toShortString());
9680 }
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009681 if (mClipData != null) {
9682 if (!first) {
9683 b.append(' ');
9684 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009685 b.append("clip={");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009686 if (clip) {
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009687 mClipData.toShortString(b);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009688 } else {
Dianne Hackbornae498722015-08-14 13:29:47 -07009689 if (mClipData.getDescription() != null) {
9690 first = !mClipData.getDescription().toShortStringTypesOnly(b);
9691 } else {
9692 first = true;
9693 }
9694 mClipData.toShortStringShortItems(b, first);
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009695 }
Dianne Hackbornae498722015-08-14 13:29:47 -07009696 first = false;
9697 b.append('}');
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009698 }
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009699 if (extras && mExtras != null) {
9700 if (!first) {
9701 b.append(' ');
9702 }
9703 first = false;
9704 b.append("(has extras)");
9705 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009706 if (mContentUserHint != UserHandle.USER_CURRENT) {
9707 if (!first) {
9708 b.append(' ');
9709 }
9710 first = false;
9711 b.append("u=").append(mContentUserHint);
9712 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009713 if (mSelector != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009714 b.append(" sel=");
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009715 mSelector.toShortString(b, secure, comp, extras, clip);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009716 b.append("}");
9717 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009718 }
9719
Yi Jin129fc6c2017-09-28 15:48:38 -07009720 /** @hide */
Kweku Adams85f2fbc2017-12-18 12:04:12 -08009721 public void writeToProto(ProtoOutputStream proto, long fieldId) {
9722 // Same input parameters that toString() gives to toShortString().
9723 writeToProto(proto, fieldId, true, true, true, false);
9724 }
9725
9726 /** @hide */
Yi Jin129fc6c2017-09-28 15:48:38 -07009727 public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
9728 boolean extras, boolean clip) {
9729 long token = proto.start(fieldId);
9730 if (mAction != null) {
9731 proto.write(IntentProto.ACTION, mAction);
9732 }
9733 if (mCategories != null) {
9734 for (String category : mCategories) {
9735 proto.write(IntentProto.CATEGORIES, category);
9736 }
9737 }
9738 if (mData != null) {
9739 proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
9740 }
9741 if (mType != null) {
9742 proto.write(IntentProto.TYPE, mType);
9743 }
9744 if (mFlags != 0) {
9745 proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
9746 }
9747 if (mPackage != null) {
9748 proto.write(IntentProto.PACKAGE, mPackage);
9749 }
9750 if (comp && mComponent != null) {
Yi Jin676d1ac2018-01-25 15:40:28 -08009751 mComponent.writeToProto(proto, IntentProto.COMPONENT);
Yi Jin129fc6c2017-09-28 15:48:38 -07009752 }
9753 if (mSourceBounds != null) {
9754 proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
9755 }
9756 if (mClipData != null) {
9757 StringBuilder b = new StringBuilder();
9758 if (clip) {
9759 mClipData.toShortString(b);
9760 } else {
9761 mClipData.toShortStringShortItems(b, false);
9762 }
9763 proto.write(IntentProto.CLIP_DATA, b.toString());
9764 }
9765 if (extras && mExtras != null) {
9766 proto.write(IntentProto.EXTRAS, mExtras.toShortString());
9767 }
9768 if (mContentUserHint != 0) {
9769 proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
9770 }
9771 if (mSelector != null) {
9772 proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
9773 }
9774 proto.end(token);
9775 }
9776
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009777 /**
9778 * Call {@link #toUri} with 0 flags.
9779 * @deprecated Use {@link #toUri} instead.
9780 */
9781 @Deprecated
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009782 public String toURI() {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009783 return toUri(0);
9784 }
9785
9786 /**
9787 * Convert this Intent into a String holding a URI representation of it.
9788 * The returned URI string has been properly URI encoded, so it can be
9789 * used with {@link Uri#parse Uri.parse(String)}. The URI contains the
9790 * Intent's data as the base URI, with an additional fragment describing
9791 * the action, categories, type, flags, package, component, and extras.
Tom Taylord4a47292009-12-21 13:59:18 -08009792 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009793 * <p>You can convert the returned string back to an Intent with
9794 * {@link #getIntent}.
Tom Taylord4a47292009-12-21 13:59:18 -08009795 *
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009796 * @param flags Additional operating flags.
Tom Taylord4a47292009-12-21 13:59:18 -08009797 *
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009798 * @return Returns a URI encoding URI string describing the entire contents
9799 * of the Intent.
9800 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -06009801 public String toUri(@UriFlags int flags) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -07009802 StringBuilder uri = new StringBuilder(128);
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009803 if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
9804 if (mPackage == null) {
9805 throw new IllegalArgumentException(
9806 "Intent must include an explicit package name to build an android-app: "
9807 + this);
9808 }
9809 uri.append("android-app://");
9810 uri.append(mPackage);
9811 String scheme = null;
9812 if (mData != null) {
9813 scheme = mData.getScheme();
9814 if (scheme != null) {
9815 uri.append('/');
9816 uri.append(scheme);
9817 String authority = mData.getEncodedAuthority();
9818 if (authority != null) {
9819 uri.append('/');
9820 uri.append(authority);
9821 String path = mData.getEncodedPath();
9822 if (path != null) {
9823 uri.append(path);
9824 }
9825 String queryParams = mData.getEncodedQuery();
9826 if (queryParams != null) {
9827 uri.append('?');
9828 uri.append(queryParams);
9829 }
9830 String fragment = mData.getEncodedFragment();
9831 if (fragment != null) {
9832 uri.append('#');
9833 uri.append(fragment);
9834 }
9835 }
9836 }
9837 }
9838 toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
9839 mPackage, flags);
9840 return uri.toString();
9841 }
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009842 String scheme = null;
9843 if (mData != null) {
9844 String data = mData.toString();
9845 if ((flags&URI_INTENT_SCHEME) != 0) {
9846 final int N = data.length();
9847 for (int i=0; i<N; i++) {
9848 char c = data.charAt(i);
9849 if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
Christopher Schuster42c3a6e2017-07-21 14:53:52 -07009850 || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009851 continue;
9852 }
9853 if (c == ':' && i > 0) {
9854 // Valid scheme.
9855 scheme = data.substring(0, i);
9856 uri.append("intent:");
9857 data = data.substring(i+1);
9858 break;
9859 }
Tom Taylord4a47292009-12-21 13:59:18 -08009860
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009861 // No scheme.
9862 break;
9863 }
9864 }
9865 uri.append(data);
Tom Taylord4a47292009-12-21 13:59:18 -08009866
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009867 } else if ((flags&URI_INTENT_SCHEME) != 0) {
9868 uri.append("intent:");
9869 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009870
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009871 toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009872
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009873 return uri.toString();
9874 }
9875
9876 private void toUriFragment(StringBuilder uri, String scheme, String defAction,
9877 String defPackage, int flags) {
9878 StringBuilder frag = new StringBuilder(128);
9879
9880 toUriInner(frag, scheme, defAction, defPackage, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009881 if (mSelector != null) {
Dianne Hackborn80b1c562014-12-09 20:22:08 -08009882 frag.append("SEL;");
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009883 // Note that for now we are not going to try to handle the
9884 // data part; not clear how to represent this as a URI, and
9885 // not much utility in it.
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009886 mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
9887 null, null, flags);
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009888 }
9889
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009890 if (frag.length() > 0) {
9891 uri.append("#Intent;");
9892 uri.append(frag);
9893 uri.append("end");
9894 }
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009895 }
9896
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009897 private void toUriInner(StringBuilder uri, String scheme, String defAction,
9898 String defPackage, int flags) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009899 if (scheme != null) {
9900 uri.append("scheme=").append(scheme).append(';');
9901 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009902 if (mAction != null && !mAction.equals(defAction)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009903 uri.append("action=").append(Uri.encode(mAction)).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009904 }
9905 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009906 for (int i=0; i<mCategories.size(); i++) {
9907 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009908 }
9909 }
9910 if (mType != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009911 uri.append("type=").append(Uri.encode(mType, "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009912 }
9913 if (mFlags != 0) {
9914 uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
9915 }
Dianne Hackborn85d558c2014-11-04 10:31:54 -08009916 if (mPackage != null && !mPackage.equals(defPackage)) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009917 uri.append("package=").append(Uri.encode(mPackage)).append(';');
9918 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009919 if (mComponent != null) {
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009920 uri.append("component=").append(Uri.encode(
9921 mComponent.flattenToShortString(), "/")).append(';');
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009922 }
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009923 if (mSourceBounds != null) {
9924 uri.append("sourceBounds=")
9925 .append(Uri.encode(mSourceBounds.flattenToString()))
9926 .append(';');
9927 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009928 if (mExtras != null) {
9929 for (String key : mExtras.keySet()) {
9930 final Object value = mExtras.get(key);
9931 char entryType =
9932 value instanceof String ? 'S' :
9933 value instanceof Boolean ? 'B' :
9934 value instanceof Byte ? 'b' :
9935 value instanceof Character ? 'c' :
9936 value instanceof Double ? 'd' :
9937 value instanceof Float ? 'f' :
9938 value instanceof Integer ? 'i' :
9939 value instanceof Long ? 'l' :
9940 value instanceof Short ? 's' :
9941 '\0';
9942
9943 if (entryType != '\0') {
9944 uri.append(entryType);
9945 uri.append('.');
9946 uri.append(Uri.encode(key));
9947 uri.append('=');
9948 uri.append(Uri.encode(value.toString()));
9949 uri.append(';');
9950 }
9951 }
9952 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009953 }
The Android Open Source Project10592532009-03-18 17:39:46 -07009954
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009955 public int describeContents() {
9956 return (mExtras != null) ? mExtras.describeContents() : 0;
9957 }
9958
9959 public void writeToParcel(Parcel out, int flags) {
9960 out.writeString(mAction);
9961 Uri.writeToParcel(out, mData);
9962 out.writeString(mType);
9963 out.writeInt(mFlags);
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -07009964 out.writeString(mPackage);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009965 ComponentName.writeToParcel(mComponent, out);
9966
Joe Onoratoc7a63ee2009-12-02 21:13:17 -08009967 if (mSourceBounds != null) {
9968 out.writeInt(1);
9969 mSourceBounds.writeToParcel(out, flags);
9970 } else {
9971 out.writeInt(0);
9972 }
9973
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009974 if (mCategories != null) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -07009975 final int N = mCategories.size();
9976 out.writeInt(N);
9977 for (int i=0; i<N; i++) {
9978 out.writeString(mCategories.valueAt(i));
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009979 }
9980 } else {
9981 out.writeInt(0);
9982 }
9983
Dianne Hackbornf5b86712011-12-05 17:42:41 -08009984 if (mSelector != null) {
9985 out.writeInt(1);
9986 mSelector.writeToParcel(out, flags);
9987 } else {
9988 out.writeInt(0);
9989 }
9990
Dianne Hackborn21c241e2012-03-08 13:57:23 -08009991 if (mClipData != null) {
9992 out.writeInt(1);
9993 mClipData.writeToParcel(out, flags);
9994 } else {
9995 out.writeInt(0);
9996 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +01009997 out.writeInt(mContentUserHint);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -07009998 out.writeBundle(mExtras);
9999 }
10000
10001 public static final Parcelable.Creator<Intent> CREATOR
10002 = new Parcelable.Creator<Intent>() {
10003 public Intent createFromParcel(Parcel in) {
10004 return new Intent(in);
10005 }
10006 public Intent[] newArray(int size) {
10007 return new Intent[size];
10008 }
10009 };
10010
Dianne Hackborneb034652009-09-07 00:49:58 -070010011 /** @hide */
10012 protected Intent(Parcel in) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010013 readFromParcel(in);
10014 }
10015
10016 public void readFromParcel(Parcel in) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010017 setAction(in.readString());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010018 mData = Uri.CREATOR.createFromParcel(in);
10019 mType = in.readString();
10020 mFlags = in.readInt();
Dianne Hackbornc14b9cc2009-06-17 18:02:12 -070010021 mPackage = in.readString();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010022 mComponent = ComponentName.readFromParcel(in);
10023
Joe Onoratoc7a63ee2009-12-02 21:13:17 -080010024 if (in.readInt() != 0) {
10025 mSourceBounds = Rect.CREATOR.createFromParcel(in);
10026 }
10027
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010028 int N = in.readInt();
10029 if (N > 0) {
Dianne Hackbornadd005c2013-07-17 18:43:12 -070010030 mCategories = new ArraySet<String>();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010031 int i;
10032 for (i=0; i<N; i++) {
Jeff Brown2c376fc2011-01-28 17:34:01 -080010033 mCategories.add(in.readString().intern());
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010034 }
10035 } else {
10036 mCategories = null;
10037 }
10038
Dianne Hackbornf5b86712011-12-05 17:42:41 -080010039 if (in.readInt() != 0) {
10040 mSelector = new Intent(in);
10041 }
10042
Dianne Hackborn21c241e2012-03-08 13:57:23 -080010043 if (in.readInt() != 0) {
10044 mClipData = new ClipData(in);
10045 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010046 mContentUserHint = in.readInt();
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010047 mExtras = in.readBundle();
10048 }
10049
10050 /**
10051 * Parses the "intent" element (and its children) from XML and instantiates
10052 * an Intent object. The given XML parser should be located at the tag
10053 * where parsing should start (often named "intent"), from which the
10054 * basic action, data, type, and package and class name will be
10055 * retrieved. The function will then parse in to any child elements,
10056 * looking for <category android:name="xxx"> tags to add categories and
10057 * <extra android:name="xxx" android:value="yyy"> to attach extra data
10058 * to the intent.
10059 *
10060 * @param resources The Resources to use when inflating resources.
10061 * @param parser The XML parser pointing at an "intent" tag.
10062 * @param attrs The AttributeSet interface for retrieving extended
10063 * attribute data at the current <var>parser</var> location.
10064 * @return An Intent object matching the XML data.
10065 * @throws XmlPullParserException If there was an XML parsing error.
10066 * @throws IOException If there was an I/O error.
10067 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010068 public static @NonNull Intent parseIntent(@NonNull Resources resources,
10069 @NonNull XmlPullParser parser, AttributeSet attrs)
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010070 throws XmlPullParserException, IOException {
10071 Intent intent = new Intent();
10072
10073 TypedArray sa = resources.obtainAttributes(attrs,
10074 com.android.internal.R.styleable.Intent);
10075
10076 intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10077
10078 String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10079 String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10080 intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10081
10082 String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10083 String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10084 if (packageName != null && className != null) {
10085 intent.setComponent(new ComponentName(packageName, className));
10086 }
10087
10088 sa.recycle();
10089
10090 int outerDepth = parser.getDepth();
10091 int type;
10092 while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10093 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10094 if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10095 continue;
10096 }
10097
10098 String nodeName = parser.getName();
Craig Mautner21d24a22014-04-23 11:45:37 -070010099 if (nodeName.equals(TAG_CATEGORIES)) {
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010100 sa = resources.obtainAttributes(attrs,
10101 com.android.internal.R.styleable.IntentCategory);
10102 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10103 sa.recycle();
10104
10105 if (cat != null) {
10106 intent.addCategory(cat);
10107 }
10108 XmlUtils.skipCurrentTag(parser);
10109
Craig Mautner21d24a22014-04-23 11:45:37 -070010110 } else if (nodeName.equals(TAG_EXTRA)) {
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010111 if (intent.mExtras == null) {
10112 intent.mExtras = new Bundle();
10113 }
Craig Mautner21d24a22014-04-23 11:45:37 -070010114 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
The Android Open Source Projectf013e1a2008-12-17 18:05:43 -080010115 XmlUtils.skipCurrentTag(parser);
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010116
10117 } else {
10118 XmlUtils.skipCurrentTag(parser);
10119 }
10120 }
10121
10122 return intent;
10123 }
Nick Pellyccae4122012-01-09 14:12:58 -080010124
Craig Mautner21d24a22014-04-23 11:45:37 -070010125 /** @hide */
10126 public void saveToXml(XmlSerializer out) throws IOException {
10127 if (mAction != null) {
10128 out.attribute(null, ATTR_ACTION, mAction);
10129 }
10130 if (mData != null) {
10131 out.attribute(null, ATTR_DATA, mData.toString());
10132 }
10133 if (mType != null) {
10134 out.attribute(null, ATTR_TYPE, mType);
10135 }
10136 if (mComponent != null) {
10137 out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10138 }
10139 out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10140
10141 if (mCategories != null) {
10142 out.startTag(null, TAG_CATEGORIES);
10143 for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10144 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10145 }
Craig Mautner43e52ed2014-06-16 17:18:52 -070010146 out.endTag(null, TAG_CATEGORIES);
Craig Mautner21d24a22014-04-23 11:45:37 -070010147 }
10148 }
10149
10150 /** @hide */
10151 public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10152 XmlPullParserException {
10153 Intent intent = new Intent();
10154 final int outerDepth = in.getDepth();
10155
10156 int attrCount = in.getAttributeCount();
10157 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10158 final String attrName = in.getAttributeName(attrNdx);
10159 final String attrValue = in.getAttributeValue(attrNdx);
10160 if (ATTR_ACTION.equals(attrName)) {
10161 intent.setAction(attrValue);
10162 } else if (ATTR_DATA.equals(attrName)) {
10163 intent.setData(Uri.parse(attrValue));
10164 } else if (ATTR_TYPE.equals(attrName)) {
10165 intent.setType(attrValue);
10166 } else if (ATTR_COMPONENT.equals(attrName)) {
10167 intent.setComponent(ComponentName.unflattenFromString(attrValue));
10168 } else if (ATTR_FLAGS.equals(attrName)) {
Narayan Kamatha09b4d22016-04-15 18:32:45 +010010169 intent.setFlags(Integer.parseInt(attrValue, 16));
Craig Mautner21d24a22014-04-23 11:45:37 -070010170 } else {
10171 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
10172 }
10173 }
10174
10175 int event;
10176 String name;
10177 while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10178 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10179 if (event == XmlPullParser.START_TAG) {
10180 name = in.getName();
10181 if (TAG_CATEGORIES.equals(name)) {
10182 attrCount = in.getAttributeCount();
10183 for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10184 intent.addCategory(in.getAttributeValue(attrNdx));
10185 }
10186 } else {
10187 Log.w("Intent", "restoreFromXml: unknown name=" + name);
10188 XmlUtils.skipCurrentTag(in);
10189 }
10190 }
10191 }
10192
10193 return intent;
10194 }
10195
Nick Pellyccae4122012-01-09 14:12:58 -080010196 /**
10197 * Normalize a MIME data type.
10198 *
10199 * <p>A normalized MIME type has white-space trimmed,
10200 * content-type parameters removed, and is lower-case.
10201 * This aligns the type with Android best practices for
10202 * intent filtering.
10203 *
10204 * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10205 * "text/x-vCard" becomes "text/x-vcard".
10206 *
10207 * <p>All MIME types received from outside Android (such as user input,
10208 * or external sources like Bluetooth, NFC, or the Internet) should
10209 * be normalized before they are used to create an Intent.
10210 *
10211 * @param type MIME data type to normalize
10212 * @return normalized MIME data type, or null if the input was null
John Spurlock125d1332013-11-25 11:58:37 -050010213 * @see #setType
10214 * @see #setTypeAndNormalize
Nick Pellyccae4122012-01-09 14:12:58 -080010215 */
Jeff Sharkey30e06bb2017-04-24 11:18:03 -060010216 public static @Nullable String normalizeMimeType(@Nullable String type) {
Nick Pellyccae4122012-01-09 14:12:58 -080010217 if (type == null) {
10218 return null;
10219 }
10220
Elliott Hughescb64d432013-08-02 10:00:44 -070010221 type = type.trim().toLowerCase(Locale.ROOT);
Nick Pellyccae4122012-01-09 14:12:58 -080010222
10223 final int semicolonIndex = type.indexOf(';');
10224 if (semicolonIndex != -1) {
10225 type = type.substring(0, semicolonIndex);
10226 }
10227 return type;
10228 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010229
10230 /**
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010231 * Prepare this {@link Intent} to leave an app process.
10232 *
10233 * @hide
10234 */
Mathew Inwood5c0d3542018-08-14 13:54:31 +010010235 @UnsupportedAppUsage
Jeff Sharkey344744b2016-01-28 19:03:30 -070010236 public void prepareToLeaveProcess(Context context) {
10237 final boolean leavingPackage = (mComponent == null)
10238 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10239 prepareToLeaveProcess(leavingPackage);
10240 }
10241
10242 /**
10243 * Prepare this {@link Intent} to leave an app process.
10244 *
10245 * @hide
10246 */
10247 public void prepareToLeaveProcess(boolean leavingPackage) {
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010248 setAllowFds(false);
10249
10250 if (mSelector != null) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010251 mSelector.prepareToLeaveProcess(leavingPackage);
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010252 }
10253 if (mClipData != null) {
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010254 mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010255 }
10256
Jeff Sharkeyc6fe23d2017-02-24 09:39:58 -070010257 if (mExtras != null && !mExtras.isParcelled()) {
10258 final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10259 if (intent instanceof Intent) {
10260 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10261 }
10262 }
10263
Jeff Sharkeya8b42782016-01-30 17:58:09 -070010264 if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10265 && leavingPackage) {
Jeff Sharkey344744b2016-01-28 19:03:30 -070010266 switch (mAction) {
10267 case ACTION_MEDIA_REMOVED:
10268 case ACTION_MEDIA_UNMOUNTED:
10269 case ACTION_MEDIA_CHECKING:
10270 case ACTION_MEDIA_NOFS:
10271 case ACTION_MEDIA_MOUNTED:
10272 case ACTION_MEDIA_SHARED:
10273 case ACTION_MEDIA_UNSHARED:
10274 case ACTION_MEDIA_BAD_REMOVAL:
10275 case ACTION_MEDIA_UNMOUNTABLE:
10276 case ACTION_MEDIA_EJECT:
10277 case ACTION_MEDIA_SCANNER_STARTED:
10278 case ACTION_MEDIA_SCANNER_FINISHED:
10279 case ACTION_MEDIA_SCANNER_SCAN_FILE:
Jeff Sharkey37355a92016-02-05 16:19:10 -070010280 case ACTION_PACKAGE_NEEDS_VERIFICATION:
10281 case ACTION_PACKAGE_VERIFIED:
Jeff Sharkey344744b2016-01-28 19:03:30 -070010282 // Ignore legacy actions
10283 break;
10284 default:
10285 mData.checkFileUriExposed("Intent.getData()");
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010286 }
10287 }
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010288
10289 if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10290 && leavingPackage) {
10291 switch (mAction) {
10292 case ACTION_PROVIDER_CHANGED:
Makoto Onuki7d1911f2017-06-09 12:30:09 -070010293 case QuickContact.ACTION_QUICK_CONTACT:
Jeff Sharkeyfb833f32016-12-01 14:59:59 -070010294 // Ignore actions that don't need to grant
10295 break;
10296 default:
10297 mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10298 }
10299 }
Jeff Sharkeya14acd22013-04-02 18:27:45 -070010300 }
10301
10302 /**
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010303 * @hide
10304 */
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010305 public void prepareToEnterProcess() {
Jeff Sharkeyd136e512016-03-09 22:30:56 -070010306 // We just entered destination process, so we should be able to read all
10307 // parcelables inside.
10308 setDefusable(true);
10309
10310 if (mSelector != null) {
10311 mSelector.prepareToEnterProcess();
10312 }
10313 if (mClipData != null) {
10314 mClipData.prepareToEnterProcess();
10315 }
10316
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010317 if (mContentUserHint != UserHandle.USER_CURRENT) {
Nicolas Prevotc4fc00a2014-10-31 12:01:32 +000010318 if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10319 fixUris(mContentUserHint);
10320 mContentUserHint = UserHandle.USER_CURRENT;
10321 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010322 }
10323 }
10324
Patrick Baumann577d4022018-01-31 16:55:10 +000010325 /** @hide */
10326 public boolean hasWebURI() {
10327 if (getData() == null) {
10328 return false;
10329 }
10330 final String scheme = getScheme();
10331 if (TextUtils.isEmpty(scheme)) {
10332 return false;
10333 }
10334 return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10335 }
10336
10337 /** @hide */
Patrick Baumann0da85372018-02-02 16:07:35 -080010338 public boolean isWebIntent() {
Patrick Baumann577d4022018-01-31 16:55:10 +000010339 return ACTION_VIEW.equals(mAction)
Patrick Baumann577d4022018-01-31 16:55:10 +000010340 && hasWebURI();
10341 }
10342
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010343 /**
10344 * @hide
10345 */
10346 public void fixUris(int contentUserHint) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010347 Uri data = getData();
10348 if (data != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010349 mData = maybeAddUserId(data, contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010350 }
10351 if (mClipData != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010352 mClipData.fixUris(contentUserHint);
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010353 }
10354 String action = getAction();
10355 if (ACTION_SEND.equals(action)) {
10356 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10357 if (stream != null) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010358 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010359 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010360 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010361 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10362 if (streams != null) {
10363 ArrayList<Uri> newStreams = new ArrayList<Uri>();
10364 for (int i = 0; i < streams.size(); i++) {
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010365 newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010366 }
10367 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10368 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010369 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10370 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10371 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10372 final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10373 if (output != null) {
10374 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10375 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010376 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010377 }
Nicolas Prevotd85fc722014-04-16 19:52:08 +010010378
10379 /**
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010380 * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010381 * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10382 * intents in {@link #ACTION_CHOOSER}.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010383 *
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010384 * @return Whether any contents were migrated.
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010385 * @hide
10386 */
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010387 public boolean migrateExtraStreamToClipData() {
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010388 // Refuse to touch if extras already parcelled
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010389 if (mExtras != null && mExtras.isParcelled()) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010390
10391 // Bail when someone already gave us ClipData
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010392 if (getClipData() != null) return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010393
10394 final String action = getAction();
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010395 if (ACTION_CHOOSER.equals(action)) {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010396 // Inspect contained intents to see if we need to migrate extras. We
10397 // don't promote ClipData to the parent, since ChooserActivity will
10398 // already start the picked item as the caller, and we can't combine
10399 // the flags in a safe way.
10400
10401 boolean migrated = false;
Jeff Sharkey1c297002012-05-18 13:55:47 -070010402 try {
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010403 final Intent intent = getParcelableExtra(EXTRA_INTENT);
10404 if (intent != null) {
10405 migrated |= intent.migrateExtraStreamToClipData();
Jeff Sharkey1c297002012-05-18 13:55:47 -070010406 }
10407 } catch (ClassCastException e) {
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010408 }
Jeff Sharkeyc004eef2014-09-23 16:40:50 -070010409 try {
10410 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10411 if (intents != null) {
10412 for (int i = 0; i < intents.length; i++) {
10413 final Intent intent = (Intent) intents[i];
10414 if (intent != null) {
10415 migrated |= intent.migrateExtraStreamToClipData();
10416 }
10417 }
10418 }
10419 } catch (ClassCastException e) {
10420 }
10421 return migrated;
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010422
10423 } else if (ACTION_SEND.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010424 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010425 final Uri stream = getParcelableExtra(EXTRA_STREAM);
10426 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10427 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10428 if (stream != null || text != null || htmlText != null) {
10429 final ClipData clipData = new ClipData(
10430 null, new String[] { getType() },
10431 new ClipData.Item(text, htmlText, null, stream));
10432 setClipData(clipData);
10433 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010434 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010435 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010436 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010437 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010438
10439 } else if (ACTION_SEND_MULTIPLE.equals(action)) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010440 try {
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010441 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10442 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10443 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10444 int num = -1;
10445 if (streams != null) {
10446 num = streams.size();
10447 }
10448 if (texts != null) {
10449 if (num >= 0 && num != texts.size()) {
10450 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010451 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010452 }
10453 num = texts.size();
10454 }
10455 if (htmlTexts != null) {
10456 if (num >= 0 && num != htmlTexts.size()) {
10457 // Wha...! F- you.
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010458 return false;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010459 }
10460 num = htmlTexts.size();
10461 }
10462 if (num > 0) {
10463 final ClipData clipData = new ClipData(
10464 null, new String[] { getType() },
10465 makeClipItem(streams, texts, htmlTexts, 0));
10466
10467 for (int i = 1; i < num; i++) {
10468 clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10469 }
10470
10471 setClipData(clipData);
10472 addFlags(FLAG_GRANT_READ_URI_PERMISSION);
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010473 return true;
Jeff Sharkeydd471e62012-05-01 13:07:01 -070010474 }
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010475 } catch (ClassCastException e) {
Jeff Sharkeyf27ea662012-03-27 10:34:24 -070010476 }
Nicolas Prevotd1c99b12014-07-04 16:56:17 +010010477 } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10478 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10479 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10480 final Uri output;
10481 try {
10482 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10483 } catch (ClassCastException e) {
10484 return false;
10485 }
10486 if (output != null) {
10487 setClipData(ClipData.newRawUri("", output));
10488 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
10489 return true;
10490 }
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010491 }
Jeff Sharkey3b7d1ef2012-05-14 17:21:10 -070010492
10493 return false;
Jeff Sharkey678d04f2012-03-23 15:41:58 -070010494 }
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010495
Michael Wright19859762017-09-18 20:57:58 +010010496 /**
10497 * Convert the dock state to a human readable format.
10498 * @hide
10499 */
10500 public static String dockStateToString(int dock) {
10501 switch (dock) {
10502 case EXTRA_DOCK_STATE_HE_DESK:
10503 return "EXTRA_DOCK_STATE_HE_DESK";
10504 case EXTRA_DOCK_STATE_LE_DESK:
10505 return "EXTRA_DOCK_STATE_LE_DESK";
10506 case EXTRA_DOCK_STATE_CAR:
10507 return "EXTRA_DOCK_STATE_CAR";
10508 case EXTRA_DOCK_STATE_DESK:
10509 return "EXTRA_DOCK_STATE_DESK";
10510 case EXTRA_DOCK_STATE_UNDOCKED:
10511 return "EXTRA_DOCK_STATE_UNDOCKED";
10512 default:
10513 return Integer.toString(dock);
10514 }
10515 }
10516
Dianne Hackbornac4243f2012-04-13 17:32:18 -070010517 private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
10518 ArrayList<String> htmlTexts, int which) {
10519 Uri uri = streams != null ? streams.get(which) : null;
10520 CharSequence text = texts != null ? texts.get(which) : null;
10521 String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
10522 return new ClipData.Item(text, htmlText, null, uri);
10523 }
Craig Mautnerd00f4742014-03-12 14:17:26 -070010524
10525 /** @hide */
10526 public boolean isDocument() {
10527 return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
10528 }
The Android Open Source Project54b6cfa2008-10-21 07:00:00 -070010529}